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

YanAlbert bluewolf3557 at hotmail.com
Mon Mar 16 21:08:10 EDT 2009



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 "vtkRenderer.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);
        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);
        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();
        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();
    //boxWidget->InsideOutOn();
    iren->Initialize();
    iren->Start();
   
}



Hope anyone can help me! Thanks in advance!


_________________________________________________________________
Live Search视频搜索,快速检索视频的利器!
http://www.live.com/?scope=video
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090317/8cfcebe2/attachment.htm>


More information about the vtkusers mailing list