[vtkusers] How to solve this problem when compiling this program about volumerendering?(Albert, Yan)

Simon Drouin drouin.simon at gmail.com
Mon Mar 16 21:49:31 EDT 2009


I think you forgot to link against vtkVolumeRendering library.

s.

2009/3/16 YanAlbert <bluewolf3557 at hotmail.com>

>
> Hello, everyone.
>
>        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.
>
>        This is the error when compiling(on Fedora 9).
>
> [albert at localhost Cxxbin]$ make
> Linking CXX executable VolumeExample
> CMakeFiles/VolumeExample.dir/VolumeExample.cxx.o: In function `main':
> VolumeExample.cxx:(.text+0x309): undefined reference to
> `vtkVolumeRayCastCompositeFunction::New()'
> VolumeExample.cxx:(.text+0x311): undefined reference to
> `vtkVolumeRayCastMapper::New()'
> collect2: ld returned 1 exit status
> make[2]: *** [VolumeExample] Error 1
> make[1]: *** [CMakeFiles/VolumeExample.dir/all] Error 2
> make: *** [all] Error 2
>
>
> And here is the related code!!
>
>
> #include "vtkActor.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkRe nderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkProperty.h"
>
> #include "vtkImageData.h"
> #include "vtkVolume16Reader.h"
> #include "vtkPiecewiseFunction.h"
> #include "vtkColorTransferFunction.h"
> #include "vtkVolumeRayCastCompositeFunction.h"
> #include "vtkVolumeRayCastMapper.h"
> #include "vtkVolumeProperty.h"
> #include "vtkVolume.h"
> #include "vtkOutlineFilter.h"
> #include "vtkPlanes.h"
>
>
> int main(){
>     vtkVolume16Reader *v16 = vtkVolume16Reader::New();
>         v16->SetDataDimensions(64, 64);
>         v16->GetOutput()->SetOrigin(0.0, 0.0, 0.0);
>         v16->SetDataByteOrderToLittleEndian();
>         v16->SetFilePrefix("./quarter/");
>         v16->SetImageRange(1, 93);
> & nbsp;       v16->SetDataSpacing(3.2, 3.2, 1.5);
>
>     vtkPiecewiseFunction *tfun = vtkPiecewiseFunction::New();
>         tfun->AddPoint(70.0, 0.0);
>         tfun->AddPoint(599.0, 0.0);
>         tfun->AddPoint(600.0, 0.0);
>         tfun->AddPoint(1195.0, 0.0);
>         tfun->AddPoint(1200.0, 0.2);
>         tfun->AddPoint(2000.0, 0.3);
>         tfun->AddPoint(4095.0, 1.0);
>
>     vtkColorTransferFunction *ctfun = vtkColorTransferFunction::New();
>         ctfun->AddRGBPoint(0.0, 0.5, 0.0, 0.0);
>         ctfun->AddRGBPoint(600.0, 1.0, 0.5, 0.5);
>          ctfun->AddRGBPoint(1280.0, 0.9, 0.2, 0.3);
>         ctfun->AddRGBPoint(1960.0, 0.81, 0.27, 0.1);
>         ctfun->AddRGBPoint(4095.0, 0.5, 0.5, 0.5);
>
>     vtkVolumeRayCastCompositeFunction *compositeFunction =
> vtkVolumeRayCastCompositeFunction::New();
>
>     vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
>         volumeMapper->SetInputConnection(v16->GetOutputPort());
>         volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
>     vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
>         volumeProperty->SetColor(ctfun);
> & nbsp;       volumeProperty->SetScalarOpacity(tfun);
>         //volumeProperty->SetInterPolationTypeToLinear();
>         volumeProperty->ShadeOn();
>
>     vtkVolume *newvol = vtkVolume::New();
>         newvol->SetMapper(volumeMapper);
>         newvol->SetProperty(volumeProperty);
>
>     vtkOutlineFilter *outline = vtkOutlineFilter::New();
>         outline->SetInputConnection(v16->GetOutputPort());
>
>     vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
>         outlineMapper->SetInputConnection(outline->GetOutputPort());
>
>     vtkActor *outlineActor = vtkActor::New();
>      & nbsp;  outlineActor->SetMapper(outlineMapper);
>
>     vtkRenderer *ren1 = vtkRenderer::New();
>
>     vtkRenderWindow *renWin = vtkRenderWindow::New();
>         renWin->AddRenderer(ren1);
>
>     vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>         iren->SetRenderWindow(renWin);
>
>     //vtkBoxWidget *boxWidget = vtkBoxWidget::New();
>         //boxWidget->SetInteractor(iren);
>         //boxWidget->SetPlaceFactor(1.0);
>
>     ren1->AddActor(outlineActor);
>     ren1->AddVolume(newvol);
>
>
>     //boxWidget->SetInput(v16->GetOutput());
>     //boxWidget->PlaceWidget();
>     //b oxWidget->InsideOutOn();
>     iren->Initialize();
>     iren->Start();
>
> }
>
>
>
> Hope anyone can help me! Thanks in advance!
>
>
> ------------------------------
> 更多热辣资讯尽在新版MSN首页! 立刻访问! <http://cn.msn.com/>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090316/89fdbbae/attachment.htm>


More information about the vtkusers mailing list