[vtkusers] Volume Rendering Problem
John Drescher
drescherjm at gmail.com
Thu Jun 11 18:40:59 EDT 2009
On Thu, Jun 11, 2009 at 6:27 PM, nikhil navkar<nikhilnavkar at gmail.com> wrote:
> 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;
> }
>
Add the folloing to your TARGET_LINK_LIBRARIES
vtkRendering vtkVolumeRendering
John
More information about the vtkusers
mailing list