[vtkusers] Can not execute SIMIMAGE.CXX example
Leonid Dulman
leonid_dulman at yahoo.co.uk
Wed Jan 26 06:57:15 EST 2011
Hi all
I tried to compile and execute simimage.cxx example on Windows with VC 2010
/*
This is a simple volume rendering example that
uses a vtkVolumeRayCast mapper
This example is based on VTK example SimpleRayCast.tcl
*/
#include "vtkDataArray.h"
#include "vtkPointData.h"
#include "vtkUnsignedCharArray.h"
#include "vtkFieldData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStructuredPoints.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkVolume.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(stderr, "\n\nUsage: %s vtkfile\n\n", argv[0]);
exit(1);
}
/*-----------------------------------------------------------------------*/
/* DATA READER */
/*-----------------------------------------------------------------------*/
int mx=63;
int extent[6] = {0, mx, 0, mx, 0, mx};
double spacing[3] = {1.0, 1.0, 1.0};
int ts = (mx+1)*(mx+1)*(mx+1);
vtkStructuredPoints *sp;
sp = vtkStructuredPoints::New();
sp->SetExtent(extent);
sp->SetWholeExtent(extent);
sp->SetSpacing(spacing);
sp->SetScalarTypeToUnsignedChar();
sp->AllocateScalars();
vtkPointData *p;
p = sp->GetPointData();
vtkDataArray *da = p->GetScalars();
FILE *fp;
fp = fopen(argv[1], "r");
for (int i=0; i<ts; i++)
{
unsigned char a;
fread(&a, sizeof(a), 1, fp);
da->SetTuple1(i,a);
}
/*-----------------------------------------------------------------------*/
/* RAYCASTING VISUALIZATION */
/*-----------------------------------------------------------------------*/
// Create transfer mapping scalar value to opacity
vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint(20, 0.0);
opacityTransferFunction->AddPoint(255, 0.2);
// Create transfer mapping scalar value to color
vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();
colorTransferFunction->AddRGBPoint( 0.0, 0.0, 0.0, 0.0);
colorTransferFunction->AddRGBPoint( 64.0, 1.0, 0.0, 0.0);
colorTransferFunction->AddRGBPoint(128.0, 0.0, 0.0, 1.0);
colorTransferFunction->AddRGBPoint(192.0, 0.0, 1.0, 0.0);
colorTransferFunction->AddRGBPoint(255.0, 0.0, 0.2, 0.0);
// The property describes how the data will look
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetColor(colorTransferFunction);
volumeProperty->SetScalarOpacity(opacityTransferFunction);
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationTypeToLinear();
// The mapper / ray cast function know how to render the data
vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
volumeMapper->SetInput(sp);
/* The volume holds the mapper and the property and
can be used to position/orient the volume */
vtkVolume *volume = vtkVolume::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
/*-----------------------------------------------------------------------*/
/* RENDERERS + RENDERING WINDOW + INTERACTOR */
/*-----------------------------------------------------------------------*/
// create a rendering window and renderers
vtkRenderWindow *renWindow = vtkRenderWindow::New();
vtkRenderer *ren1 = vtkRenderer::New();
renWindow->AddRenderer(ren1);
renWindow->SetSize(600, 600);
// set the viewports and background of the renderers
ren1->SetViewport(0, 0, 1.0, 1.0); // xmin,ymin,xmax,ymax between 0 and 1
ren1->SetBackground(1.0, 1.0, 1.0);
/* Add actors and volumen to renderers */
/* */
/* Renderer 1 */
ren1->AddVolume(volume);
/* */
/* Interactror */
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWindow);
/* Start rendering process */
renWindow->Render();
iren->Start();
return 0;
}
but have got link error messages
Microsoft (R) Incremental Linker Version 10.00.20506.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:simimage.exe
/out:simimage.exe
simimage.obj
d:\vtk\lib\vtkRendering.lib
d:\vtk\lib\vtkCommon.lib
d:\vtk\lib\vtkFiltering.lib
d:\vtk\lib\vtkIO.lib
d:\vtk\lib\vtkImaging.lib
d:\vtk\lib\vtkGraphics.lib
d:\vtk\lib\vtkWidgets.lib
d:\vtk\lib\vtkInfovis.lib
simimage.obj : 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
simimage.obj : 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
simimage.exe : fatal error LNK1120: 2 unresolved externals
Thank you for any help. Leonid
More information about the vtkusers
mailing list