<div dir="ltr"><div>I tried your suggestion but it gave the same error </div>
<div> </div>
<div><span lang="AR-EG">
<p dir="ltr"><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> shade = 0, compos = 0, interp = 0;</font></p>
<p dir="ltr"><font color="#008000" size="2"><font color="#008000" size="2">// renderer </font></font></p><font size="2">
<p dir="ltr">vtkRenderer ^ren1 = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkRenderer();
<p dir="ltr">ren1->SetBackground(1.0, 1.0, 1.0);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// render window
<p dir="ltr">// vtkRenderWindow renWin = new vtkRenderWindow();</p>
<p dir="ltr">// renWin.AddRenderer(ren1);</p>
<p dir="ltr">// renWin.SetSize(800, 600);</p></font></font><font size="2">
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">->vtkFormsWindowControl1->GetRenderWindow()->AddRenderer(ren1);
<p dir="ltr">vtkUnstructuredGrid ^grid = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkUnstructuredGrid();
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// interactor </font></font><font size="2">
<p dir="ltr">vtkRenderWindowInteractor ^iren1 = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkRenderWindowInteractor();
<p dir="ltr">iren1->SetRenderWindow(</p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">->vtkFormsWindowControl1->GetRenderWindow());
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// set up the input file for unstructured grid reader </font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//1.Create a volume data </font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// create sphere geometry </font></font><font size="2">
<p dir="ltr">vtkSphereSource ^sphere = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkSphereSource();
<p dir="ltr">sphere->SetRadius(1.0);</p>
<p dir="ltr">sphere->SetThetaResolution(18);</p>
<p dir="ltr">sphere->SetPhiResolution(18);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// grid.SetCells(new vtkTypeUInt16Array(), sphere.GetOutput().GetCellData());</font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//2.Apply the tetrahedral mish </font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// vtkPolyData vp = new vtkPolyData();
<p dir="ltr">// sphere.Update();</p>
<p dir="ltr">// grid.DeepCopy(sphere.GetOutputDataObject());</p></font></font><font size="2">
<p dir="ltr">vtkDelaunay3D ^unstructuredReader = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkDelaunay3D();
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// this.vtkFormsWindowControl1.GetRenderWindow().get</font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// set up opacity transfer function </font></font><font size="2">
<p dir="ltr">vtkPiecewiseFunction ^opacityTransferFunction = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkPiecewiseFunction();
<p dir="ltr">opacityTransferFunction->AddPoint(0, 0.02);</p>
<p dir="ltr">opacityTransferFunction->AddPoint(4095.0, 1.0);</p>
<p dir="ltr"> </p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// set up color transfer function </font></font><font size="2">
<p dir="ltr">vtkColorTransferFunction ^colorTransferFunction = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkColorTransferFunction();
<p dir="ltr">colorTransferFunction->AddRGBPoint(0.0, 0.1, 0.1, 0.1);</p>
<p dir="ltr">colorTransferFunction->AddRGBPoint(4095.0, 1.0, 0.0, 1.0);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// set up volume property </font></font><font size="2">
<p dir="ltr">vtkVolumeProperty ^volumeProperty = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkVolumeProperty();
<p dir="ltr">volumeProperty->SetColor(colorTransferFunction);</p>
<p dir="ltr">volumeProperty->SetScalarOpacity(opacityTransferFunction);</p>
<p dir="ltr">volumeProperty->SetInterpolationType(interp);</p>
<p dir="ltr">volumeProperty->SetShade(shade);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// Add scaler value </font></font><font size="2">
<p dir="ltr">vtkDoubleArray ^arr = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkDoubleArray();
<p dir="ltr">arr->SetNumberOfTuples(unstructuredReader->GetOutput()->GetNumberOfPoints());</p>
<p dir="ltr">arr->FillComponent(0, 1.0); </p></font><font color="#008000" size="2"><font color="#008000" size="2">// e.g. double value = 1.0;</font></font><font size="2">
<p dir="ltr">arr->SetName("myarray");</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// MessageBox.Show(arr.GetData( </font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//unstructuredReader.GetOutput().GetPointData().SetScalars(); </font></font><font size="2">
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">unstructuredReader->Update();</font></p>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid->DeepCopy(</font></p></font><font color="#0000ff" size="2"><font style="BACKGROUND-COLOR: #ffff00" color="#0000ff" size="2">safe_cast</font></font><font size="2"><font style="BACKGROUND-COLOR: #ffff00"><vtkDataObject^>(unstructuredReader->GetOutput()));</font>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid->GetPointData()->AddArray(arr);</font></p>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid->GetPointData()->SetScalars(arr);</font></p></font><font color="#008000" size="2"><font color="#008000" size="2">
<p dir="ltr">// unstructuredReader.GetOutput().GetPointData().AddArray();</p>
<p dir="ltr">// unstructuredReader.GetOutput().GetPointData().</p></font></font><font size="2">
<p dir="ltr"> </p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// composite function for strucured grid renderer </font></font><font size="2">
<p dir="ltr">vtkVolumeRayCastCompositeFunction ^compositeFunction = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkVolumeRayCastCompositeFunction();
<p dir="ltr">compositeFunction->SetCompositeMethod(compos);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//unstructuredGridRendering </font></font><font size="2">
<p dir="ltr">vtkUnstructuredGridVolumeRayCastMapper ^volumeUnstructedMapper = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkUnstructuredGridVolumeRayCastMapper();
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//vtkVolumeRayCastMapper volumeUnstructedMapper = new vtk.vtkVolumeRayCastMapper(); </font></font><font size="2">
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//volumeUnstructedMapper.set (compositeFunction); </font></font><font size="2">
<p dir="ltr">volumeUnstructedMapper->SetInput(grid);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">//volumeUnstructedMapper.SetScalarModeToUseCellData();</font></font><font size="2">
<p dir="ltr">vtkVolume ^volume = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">gcnew</font></font><font size="2"> vtkVolume();
<p dir="ltr">volume->SetMapper(volumeUnstructedMapper);</p>
<p dir="ltr">volume->SetProperty(volumeProperty);</p>
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// add volume to renderer </font></font><font size="2">
<p dir="ltr">ren1->AddVolume(volume);</p>
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">->vtkFormsWindowControl1->GetRenderWindow()->Render();
<p dir="ltr">iren1->Start();</p>
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> ren1;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">->vtkFormsWindowControl1->GetRenderWindow()->Dispose();
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> iren1;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> opacityTransferFunction;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> colorTransferFunction;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> volumeProperty;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> compositeFunction;
<p dir="ltr"></p></font><font color="#008000" size="2"><font color="#008000" size="2">// unstructured grid case </font></font><font size="2">
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> volumeUnstructedMapper;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> unstructuredReader;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> volume;
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">delete</font></font><font size="2"> grid;</font></span><br><br></div>
<div class="gmail_quote">On Mon, Oct 5, 2009 at 4:01 PM, Kevin H. Hobbs <span dir="ltr"><<a href="mailto:hobbsk@ohiou.edu">hobbsk@ohiou.edu</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im">On Tue, 2009-09-29 at 21:47 +0200, Ali Habib wrote:<br>> I wrote a code to make tetrahedral mesh on sphere , but it no give<br>> result except :<br>><br>> ERROR: In m:\dev\cur\vtkdotnet\branch\50\VolumeRendering<br>
> \vtkUnstructuredGridVolumeRayCastMapper.cxx, line 274<br>> vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can't use the ray<br>> cast mapper without scalars!<br>><br>><br><br><br></div>You are trying to add a scalar array to the output of the vtkDelaunay3D<br>
filter.<br><br>You cannot modify the output of a filter without disconnecting the<br>output from the pipeline.<br><br>I've never understood how to disconnect the output of a filter from the<br>filter so I always just do :<br>
<br>vtkUnstructuredGrid * my_grid = vtkUnstructuredGrid::New();<br>filter->Update();<br>my_grid->DeepCopy( filter->GetOutput() );<br></blockquote></div><br></div>