Hi ali,<br><br>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.<br>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<br>
- sphere source does not produce scalar<br>- delaunay does not produce scalar<br>- so the mapper input has no scalars<br><br>You have to use a source/filter that has scalars in its output (elevation filter, threshold,...)<br>
<br>HTH<br>Jerome<br><br><div class="gmail_quote">2009/10/5 <span dir="ltr"><<a href="mailto:ali.mahmoud.habib@gmail.com">ali.mahmoud.habib@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I wrote a code to make tetrahedral mesh on sphere , but it no give result except :<br>
<br>
ERROR: In m:\dev\cur\vtkdotnet\branch\50\VolumeRendering\vtkUnstructuredGridVolumeRayCastMapper.cxx, line 274<br>
vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can't use the ray cast mapper without scalars!<br>
<br>
every time I run the code<br>
<br>
I want to fix the proplem because I want to apply the same concept on 3D Skull be reconstructed<br>
<br>
The code is :<br>
// volume property<br>
int shade = 0, compos = 0, interp = 0;<br>
<br>
// renderer<br>
vtkRenderer *ren1 = gcnew vtkRenderer();<br>
ren1->SetBackground(1.0, 1.0, 1.0);<br>
<br>
// render window<br>
vtkRenderWindow *renWin = gcnew vtkRenderWindow();<br>
renWin->AddRenderer(ren1);<br>
renWin->SetSize(800, 600);<br>
<br>
// interactor<br>
vtkRenderWindowInteractor *iren1 = gcnew vtkRenderWindowInteractor();<br>
iren1->SetRenderWindow(renWin);<br>
<br>
// set up the input file for unstructured grid reader<br>
//1.Create a volume data<br>
// create sphere geometry<br>
vtkSphereSource *sphere = gcnew vtkSphereSource();<br>
sphere->SetRadius(1.0);<br>
sphere->SetThetaResolution(18);<br>
sphere->SetPhiResolution(18);<br>
//2.Apply the tetrahedral mish<br>
vtkPolyData *vp = gcnew vtkPolyData();<br>
<br>
vtkDelaunay3D *unstructuredReader = gcnew vtkDelaunay3D();<br>
unstructuredReader->SetInput(sphere->GetOutput());<br>
<br>
<br>
// set up opacity transfer function<br>
vtkPiecewiseFunction *opacityTransferFunction = gcnew vtkPiecewiseFunction();<br>
opacityTransferFunction->AddPoint(0, 0.02);<br>
opacityTransferFunction->AddPoint(4095.0, 1.0);<br>
<br>
// set up color transfer function<br>
vtkColorTransferFunction *colorTransferFunction = gcnew vtkColorTransferFunction();<br>
colorTransferFunction->AddRGBPoint(0.0, 0.1, 0.1, 0.1);<br>
colorTransferFunction->AddRGBPoint(4095.0, 1.0, 0.0, 1.0);<br>
<br>
// set up volume property<br>
vtkVolumeProperty *volumeProperty = gcnew vtkVolumeProperty();<br>
volumeProperty->SetColor(colorTransferFunction);<br>
volumeProperty->SetScalarOpacity(opacityTransferFunction);<br>
volumeProperty->SetInterpolationType(interp);<br>
volumeProperty->SetShade(shade);<br>
// Add scaler value<br>
vtkDoubleArray *arr = gcnew vtkDoubleArray();<br>
arr->SetNumberOfTuples(unstructuredReader->GetOutput()->GetNumberOfPoints());<br>
arr->FillComponent(0, 1.0); // e.g. double value = 1.0;<br>
arr->SetName("myarray");<br>
// MessageBox.Show(arr.GetData(<br>
//unstructuredReader.GetOutput().GetPointData().SetScalars();<br>
unstructuredReader->GetOutput()->GetPointData()->AddArray(arr);<br>
unstructuredReader->GetOutput()->GetPointData()->SetActiveScalars("myarray");<br>
<br>
<br>
// composite function for strucured grid renderer<br>
vtkVolumeRayCastCompositeFunction *compositeFunction = gcnew vtkVolumeRayCastCompositeFunction();<br>
compositeFunction->SetCompositeMethod(compos);<br>
<br>
//unstructuredGridRendering<br>
vtkUnstructuredGridVolumeRayCastMapper *volumeUnstructedMapper = gcnew vtkUnstructuredGridVolumeRayCastMapper();<br>
//vtkVolumeRayCastMapper volumeUnstructedMapper = new vtk.vtkVolumeRayCastMapper();<br>
//volumeUnstructedMapper.set (compositeFunction);<br>
volumeUnstructedMapper->SetInput(unstructuredReader->GetOutput());<br>
<br>
volumeUnstructedMapper->SetScalarModeToUseCellData();<br>
<br>
vtkVolume *volume = gcnew vtkVolume();<br>
<br>
volume->SetMapper(volumeUnstructedMapper);<br>
<br>
volume->SetProperty(volumeProperty);<br>
<br>
// add volume to renderer<br>
ren1->AddVolume(volume);<br>
<br>
renWin->Render();<br>
<br>
iren1->Start();<br>
</blockquote></div><br>