I think you forgot to link against vtkVolumeRendering library.<br><br>s.<br><br><div class="gmail_quote">2009/3/16 YanAlbert <span dir="ltr"><<a href="mailto:bluewolf3557@hotmail.com">bluewolf3557@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<br>Hello, everyone.<br><br> I am recently studying volume rendering in VTK, but when compiling a program I met some curious problems, and I have tried to solve it but failed at last. hope someone can tell me how to solve it.<br>
<br> This is the error when compiling(on Fedora 9).<br><br>[albert@localhost Cxxbin]$ make<br>Linking CXX executable VolumeExample<br>CMakeFiles/VolumeExample.dir/VolumeExample.cxx.o: In function `main':<br>VolumeExample.cxx:(.text+0x309): undefined reference to `vtkVolumeRayCastCompositeFunction::New()'<br>
VolumeExample.cxx:(.text+0x311): undefined reference to `vtkVolumeRayCastMapper::New()'<br>collect2: ld returned 1 exit status<br>make[2]: *** [VolumeExample] Error 1<br>make[1]: *** [CMakeFiles/VolumeExample.dir/all] Error 2<br>
make: *** [all] Error 2<br><br><br>And here is the related code!!<br><br><br>#include "vtkActor.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkRe
nderer.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkProperty.h"<br><br>#include "vtkImageData.h"<br>#include "vtkVolume16Reader.h"<br>
#include "vtkPiecewiseFunction.h"<br>#include "vtkColorTransferFunction.h"<br>#include "vtkVolumeRayCastCompositeFunction.h"<br>#include "vtkVolumeRayCastMapper.h"<br>#include "vtkVolumeProperty.h"<br>
#include "vtkVolume.h"<br>#include "vtkOutlineFilter.h"<br>#include "vtkPlanes.h"<br><br><br>int main(){<br> vtkVolume16Reader *v16 = vtkVolume16Reader::New();<br> v16->SetDataDimensions(64, 64);<br>
v16->GetOutput()->SetOrigin(0.0, 0.0, 0.0);<br> v16->SetDataByteOrderToLittleEndian();<br> v16->SetFilePrefix("./quarter/");<br> v16->SetImageRange(1, 93);<br>&
nbsp; v16->SetDataSpacing(3.2, 3.2, 1.5);<br><br> vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();<br> tfun->AddPoint(70.0, 0.0);<br> tfun->AddPoint(599.0, 0.0);<br> tfun->AddPoint(600.0, 0.0);<br>
tfun->AddPoint(1195.0, 0.0);<br> tfun->AddPoint(1200.0, 0.2);<br> tfun->AddPoint(2000.0, 0.3);<br> tfun->AddPoint(4095.0, 1.0);<br><br> vtkColorTransferFunction *ctfun = vtkColorTransferFunction::New();<br>
ctfun->AddRGBPoint(0.0, 0.5, 0.0, 0.0);<br> ctfun->AddRGBPoint(600.0, 1.0, 0.5, 0.5);<br>
ctfun->AddRGBPoint(1280.0, 0.9, 0.2, 0.3);<br> ctfun->AddRGBPoint(1960.0, 0.81, 0.27, 0.1);<br> ctfun->AddRGBPoint(4095.0, 0.5, 0.5, 0.5);<br> <br> vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New();<br>
<br> vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();<br> volumeMapper->SetInputConnection(v16->GetOutputPort());<br> volumeMapper->SetVolumeRayCastFunction(compositeFunction); <br>
<br> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();<br> volumeProperty->SetColor(ctfun);<br>&
nbsp; volumeProperty->SetScalarOpacity(tfun);<br> //volumeProperty->SetInterPolationTypeToLinear();<br> volumeProperty->ShadeOn();<br><br> vtkVolume *newvol = vtkVolume::New();<br> newvol->SetMapper(volumeMapper);<br>
newvol->SetProperty(volumeProperty);<br> <br> vtkOutlineFilter *outline = vtkOutlineFilter::New();<br> outline->SetInputConnection(v16->GetOutputPort());<br><br> vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();<br>
outlineMapper->SetInputConnection(outline->GetOutputPort());<br><br> vtkActor *outlineActor = vtkActor::New();<br> &
nbsp; outlineActor->SetMapper(outlineMapper);<br><br> vtkRenderer *ren1 = vtkRenderer::New();<br> <br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(ren1);<br><br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br><br> //vtkBoxWidget *boxWidget = vtkBoxWidget::New();<br> //boxWidget->SetInteractor(iren);<br> //boxWidget->SetPlaceFactor(1.0);<br><br> ren1->AddActor(outlineActor);<br>
ren1->AddVolume(newvol);<br><br><br> //boxWidget->SetInput(v16->GetOutput());<br> //boxWidget->PlaceWidget();<br> //b
oxWidget->InsideOutOn();<br> iren->Initialize();<br> iren->Start();<br> <br>}<br><br><br><br>Hope anyone can help me! Thanks in advance!<br><br><br><hr>更多热辣资讯尽在新版MSN首页! <a href="http://cn.msn.com/" target="_blank">立刻访问!</a></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>