[vtkusers] the code always give erorr : Can't use the ray cast mapper without scalars!
InfoSeekerr
ali.mahmoud.habib at gmail.com
Wed Sep 2 06:19:01 EDT 2009
Dear All,
I wanted to apply traingular mish on sphere , but the code always give
erorr : Can't use the ray cast mapper without scalars! , how to fix this
error please,I used the following code (written in c#) :
// volume property
int shade = 0,compos = 0, //Classify First or Interpolate
First
interp = 0;
// renderer
vtkRenderer ren1= new vtkRenderer();
ren1.SetBackground( 1.0, 1.0, 1.0 );
// render window
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer( ren1 );
renWin.SetSize( 800, 600 );
// interactor
vtkRenderWindowInteractor iren1 = new
vtkRenderWindowInteractor();
iren1.SetRenderWindow(renWin);
// set up the input file for unstructured grid reader
//1.Create a volume data
// create sphere geometry
vtkSphereSource sphere = new vtkSphereSource();
sphere.SetRadius(1.0);
sphere.SetThetaResolution(18);
sphere.SetPhiResolution(18);
//2.Apply the tetrahedral mish
vtkPolyData vp = new vtkPolyData();
vtkDelaunay3D unstructuredReader = new vtkDelaunay3D();
unstructuredReader.SetInput(sphere.GetOutput());
// set up opacity transfer function
vtkPiecewiseFunction opacityTransferFunction = new
vtkPiecewiseFunction();
opacityTransferFunction.AddPoint(0, 0.02);
opacityTransferFunction.AddPoint(4095.0, 1.0);
// set up color transfer function
vtkColorTransferFunction colorTransferFunction = new
vtkColorTransferFunction();
colorTransferFunction.AddRGBPoint( 0.0, 0.1, 0.1, 0.1);
colorTransferFunction.AddRGBPoint( 4095.0, 1.0, 0.0, 1.0);
// set up volume property
vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
volumeProperty.SetColor(colorTransferFunction);
volumeProperty.SetScalarOpacity(opacityTransferFunction);
volumeProperty.SetInterpolationType(interp);
volumeProperty.SetShade(shade);
// composite function for strucured grid renderer
vtkVolumeRayCastCompositeFunction compositeFunction = new
vtkVolumeRayCastCompositeFunction();
compositeFunction.SetCompositeMethod(compos);
//unstructuredGridRendering
vtkUnstructuredGridVolumeRayCastMapper volumeUnstructedMapper = new
vtkUnstructuredGridVolumeRayCastMapper();
// vtkVolumeRayCastMapper volumeUnstructedMapper = new
vtk.vtkVolumeRayCastMapper();
//volumeUnstructedMapper.set (compositeFunction);
volumeUnstructedMapper.SetInputConnection(unstructuredReader.GetOutputPort());
vtkVolume volume = new vtkVolume();
volume.SetMapper(volumeUnstructedMapper);
volume.SetProperty(volumeProperty);
// add volume to renderer
ren1.AddVolume(volume);
renWin.Render();
iren1.Start();
ren1.Dispose();
renWin.Dispose();
iren1.Dispose();
opacityTransferFunction.Dispose();
colorTransferFunction.Dispose();
volumeProperty.Dispose();
compositeFunction.Dispose();
// unstructured grid case
volumeUnstructedMapper.Dispose();
unstructuredReader.Dispose();
volume.Dispose();
///////////////////////////////////////////////
--
View this message in context: http://www.nabble.com/the--code-always-give-erorr-%3A-Can%27t-use-the-ray-cast-mapper-without-scalars%21-tp25254954p25254954.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list