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">&lt;<a href="mailto:bluewolf3557@hotmail.com">bluewolf3557@hotmail.com</a>&gt;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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&#39;:<br>VolumeExample.cxx:(.text+0x309): undefined reference to `vtkVolumeRayCastCompositeFunction::New()&#39;<br>
VolumeExample.cxx:(.text+0x311): undefined reference to `vtkVolumeRayCastMapper::New()&#39;<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 &quot;vtkActor.h&quot;<br>#include &quot;vtkPolyDataMapper.h&quot;<br>#include &quot;vtkRe
 nderer.h&quot;<br>#include &quot;vtkRenderWindow.h&quot;<br>#include &quot;vtkRenderWindowInteractor.h&quot;<br>#include &quot;vtkProperty.h&quot;<br><br>#include &quot;vtkImageData.h&quot;<br>#include &quot;vtkVolume16Reader.h&quot;<br>
#include &quot;vtkPiecewiseFunction.h&quot;<br>#include &quot;vtkColorTransferFunction.h&quot;<br>#include &quot;vtkVolumeRayCastCompositeFunction.h&quot;<br>#include &quot;vtkVolumeRayCastMapper.h&quot;<br>#include &quot;vtkVolumeProperty.h&quot;<br>
#include &quot;vtkVolume.h&quot;<br>#include &quot;vtkOutlineFilter.h&quot;<br>#include &quot;vtkPlanes.h&quot;<br><br><br>int main(){<br>&nbsp;&nbsp;&nbsp; vtkVolume16Reader *v16 = vtkVolume16Reader::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;SetDataDimensions(64, 64);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;GetOutput()-&gt;SetOrigin(0.0, 0.0, 0.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;SetDataByteOrderToLittleEndian();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;SetFilePrefix(&quot;./quarter/&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;SetImageRange(1, 93);<br>&amp;
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v16-&gt;SetDataSpacing(3.2, 3.2, 1.5);<br><br>&nbsp;&nbsp;&nbsp; vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(70.0, 0.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(599.0, 0.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(600.0, 0.0);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(1195.0, 0.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(1200.0, 0.2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(2000.0, 0.3);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tfun-&gt;AddPoint(4095.0, 1.0);<br><br>&nbsp;&nbsp;&nbsp; vtkColorTransferFunction *ctfun = vtkColorTransferFunction::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctfun-&gt;AddRGBPoint(0.0, 0.5, 0.0, 0.0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctfun-&gt;AddRGBPoint(600.0, 1.0, 0.5, 0.5);<br>&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctfun-&gt;AddRGBPoint(1280.0, 0.9, 0.2, 0.3);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctfun-&gt;AddRGBPoint(1960.0, 0.81, 0.27, 0.1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctfun-&gt;AddRGBPoint(4095.0, 0.5, 0.5, 0.5);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeMapper-&gt;SetInputConnection(v16-&gt;GetOutputPort());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeMapper-&gt;SetVolumeRayCastFunction(compositeFunction);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>
<br>&nbsp;&nbsp;&nbsp; vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty-&gt;SetColor(ctfun);<br>&amp;
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty-&gt;SetScalarOpacity(tfun);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //volumeProperty-&gt;SetInterPolationTypeToLinear();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty-&gt;ShadeOn();<br><br>&nbsp;&nbsp;&nbsp; vtkVolume *newvol = vtkVolume::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newvol-&gt;SetMapper(volumeMapper);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newvol-&gt;SetProperty(volumeProperty);<br>&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; vtkOutlineFilter *outline = vtkOutlineFilter::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outline-&gt;SetInputConnection(v16-&gt;GetOutputPort());<br><br>&nbsp;&nbsp;&nbsp; vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outlineMapper-&gt;SetInputConnection(outline-&gt;GetOutputPort());<br><br>&nbsp;&nbsp;&nbsp; vtkActor *outlineActor = vtkActor::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;
 nbsp;&nbsp; outlineActor-&gt;SetMapper(outlineMapper);<br><br>&nbsp;&nbsp;&nbsp; vtkRenderer *ren1 = vtkRenderer::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; vtkRenderWindow *renWin = vtkRenderWindow::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin-&gt;AddRenderer(ren1);<br><br>&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iren-&gt;SetRenderWindow(renWin);<br><br>&nbsp;&nbsp;&nbsp; //vtkBoxWidget *boxWidget = vtkBoxWidget::New();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //boxWidget-&gt;SetInteractor(iren);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //boxWidget-&gt;SetPlaceFactor(1.0);<br><br>&nbsp;&nbsp;&nbsp; ren1-&gt;AddActor(outlineActor);<br>
&nbsp;&nbsp;&nbsp; ren1-&gt;AddVolume(newvol);<br><br><br>&nbsp;&nbsp;&nbsp; //boxWidget-&gt;SetInput(v16-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; //boxWidget-&gt;PlaceWidget();<br>&nbsp;&nbsp;&nbsp; //b
 oxWidget-&gt;InsideOutOn();<br>&nbsp;&nbsp;&nbsp; iren-&gt;Initialize();<br>&nbsp;&nbsp;&nbsp; iren-&gt;Start();<br>&nbsp; &nbsp;<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>