[vtkusers] Volume Rendering Problem

nikhil navkar nikhilnavkar at gmail.com
Thu Jun 11 18:27:02 EDT 2009


Hi,

I am using the following code for volume rendering (VTK 5.4). But it is
giving me the some errors. Could anyone please tell me where I am making the
mistake or sent me a correct volume rendering code.

Thanks,
Nikhil Navkar

ERRORS :
========================================================================

error LNK2019: unresolved external symbol "__declspec(dllimport) public:
static class vtkVolumeRayCastMapper * __cdecl
vtkVolumeRayCastMapper::New(void)" (__imp_?New at vtkVolumeRayCastMapper
@@SAPAV1 at XZ) referenced in function _main

error LNK2019: unresolved external symbol "__declspec(dllimport) public:
static class vtkVolumeRayCastCompositeFunction * __cdecl
vtkVolumeRayCastCompositeFunction::New(void)"
(__imp_?New at vtkVolumeRayCastCompositeFunction@@SAPAV1 at XZ) referenced in
function _main


CODE :
========================================================================
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStructuredPointsReader.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolume.h"
#include "vtkRenderer.h"

int main( int argc, char **argv)
{
    //
    vtkStructuredPointsReader *reader1 = vtkStructuredPointsReader::New();
    reader1->SetFileName("c:\\t1.vtk");

    //
    vtkPiecewiseFunction *opacityTranferFunction =
vtkPiecewiseFunction::New();
    opacityTranferFunction->AddPoint( 20, 0.0);
    opacityTranferFunction->AddPoint(255, 0.2);

    //
    vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();
    colorTransferFunction->AddRGBPoint(   0.0, 0.0, 0.0, 0.0);
    colorTransferFunction->AddRGBPoint(  64.0, 0.0, 0.0, 0.0);
    colorTransferFunction->AddRGBPoint( 128.0, 0.0, 0.0, 0.0);
    colorTransferFunction->AddRGBPoint( 192.0, 0.0, 0.0, 0.0);
    colorTransferFunction->AddRGBPoint( 255.0, 0.0, 0.0, 0.0);

    //
    vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
    volumeProperty->SetColor(colorTransferFunction);
    volumeProperty->SetScalarOpacity(opacityTranferFunction);
    volumeProperty->ShadeOn();
    volumeProperty->SetInterpolationTypeToLinear();

    //
    vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
    vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
    volumeMapper->SetVolumeRayCastFunction(compositeFunction);
    volumeMapper->SetInputConnection(reader1->GetOutputPort());

    //
    vtkVolume *volume = vtkVolume::New();
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volumeProperty);

    vtkRenderer *ren1 = vtkRenderer::New();
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor ::New();
    renderWindowInteractor->SetRenderWindow(renWin);

    ren1->AddVolume(volume);
    ren1->Render();
    renderWindowInteractor->Start();

    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090611/b54704ab/attachment.htm>


More information about the vtkusers mailing list