[vtkusers] Help me in VTK PLEASE

Jérôme jerome.velut at gmail.com
Wed Oct 14 03:04:14 EDT 2009


Hi ali,

Sorry for late answer, I didn't see your mail. In the future, please send
your question to the vtkusers list, not only to me.
For your problem -but maybe it's too late?-, the VTK error message is clear.
Your data has no scalar attributes and it seems normal because
- sphere source does not produce scalar
- delaunay does not produce scalar
- so the mapper input has no scalars

You have to use a source/filter that has scalars in its output (elevation
filter, threshold,...)

HTH
Jerome

2009/10/5 <ali.mahmoud.habib at gmail.com>

> I wrote a code to make tetrahedral mesh on sphere , but it no give result
> except :
>
> ERROR: In
> m:\dev\cur\vtkdotnet\branch\50\VolumeRendering\vtkUnstructuredGridVolumeRayCastMapper.cxx,
> line 274
> vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can't use the ray cast
> mapper without scalars!
>
> every time I  run the code
>
> I want to fix the proplem because I want to apply the same concept on 3D
> Skull be reconstructed
>
> The code is :
> // volume property
> int shade = 0, compos = 0, interp = 0;
>
> // renderer
> vtkRenderer *ren1 = gcnew vtkRenderer();
> ren1->SetBackground(1.0, 1.0, 1.0);
>
> // render window
> vtkRenderWindow *renWin = gcnew vtkRenderWindow();
> renWin->AddRenderer(ren1);
> renWin->SetSize(800, 600);
>
> // interactor
> vtkRenderWindowInteractor *iren1 = gcnew vtkRenderWindowInteractor();
> iren1->SetRenderWindow(renWin);
>
> // set up the input file for unstructured grid reader
> //1.Create a volume data
> // create sphere geometry
> vtkSphereSource *sphere = gcnew vtkSphereSource();
> sphere->SetRadius(1.0);
> sphere->SetThetaResolution(18);
> sphere->SetPhiResolution(18);
> //2.Apply the tetrahedral mish
> vtkPolyData *vp = gcnew vtkPolyData();
>
> vtkDelaunay3D *unstructuredReader = gcnew vtkDelaunay3D();
> unstructuredReader->SetInput(sphere->GetOutput());
>
>
> // set up opacity transfer function
> vtkPiecewiseFunction *opacityTransferFunction = gcnew
> vtkPiecewiseFunction();
> opacityTransferFunction->AddPoint(0, 0.02);
> opacityTransferFunction->AddPoint(4095.0, 1.0);
>
> // set up color transfer function
> vtkColorTransferFunction *colorTransferFunction = gcnew
> 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 = gcnew vtkVolumeProperty();
> volumeProperty->SetColor(colorTransferFunction);
> volumeProperty->SetScalarOpacity(opacityTransferFunction);
> volumeProperty->SetInterpolationType(interp);
> volumeProperty->SetShade(shade);
> // Add scaler value
> vtkDoubleArray *arr = gcnew vtkDoubleArray();
>
> arr->SetNumberOfTuples(unstructuredReader->GetOutput()->GetNumberOfPoints());
> arr->FillComponent(0, 1.0); // e.g. double value = 1.0;
> arr->SetName("myarray");
> // MessageBox.Show(arr.GetData(
> //unstructuredReader.GetOutput().GetPointData().SetScalars();
> unstructuredReader->GetOutput()->GetPointData()->AddArray(arr);
>
> unstructuredReader->GetOutput()->GetPointData()->SetActiveScalars("myarray");
>
>
> // composite function for strucured grid renderer
>           vtkVolumeRayCastCompositeFunction *compositeFunction = gcnew
> vtkVolumeRayCastCompositeFunction();
> compositeFunction->SetCompositeMethod(compos);
>
> //unstructuredGridRendering
>           vtkUnstructuredGridVolumeRayCastMapper *volumeUnstructedMapper =
> gcnew vtkUnstructuredGridVolumeRayCastMapper();
> //vtkVolumeRayCastMapper volumeUnstructedMapper = new
> vtk.vtkVolumeRayCastMapper();
> //volumeUnstructedMapper.set  (compositeFunction);
> volumeUnstructedMapper->SetInput(unstructuredReader->GetOutput());
>
> volumeUnstructedMapper->SetScalarModeToUseCellData();
>
> vtkVolume *volume = gcnew vtkVolume();
>
> volume->SetMapper(volumeUnstructedMapper);
>
> volume->SetProperty(volumeProperty);
>
> // add volume to renderer
> ren1->AddVolume(volume);
>
> renWin->Render();
>
> iren1->Start();
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091014/5420686b/attachment.htm>


More information about the vtkusers mailing list