<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-&gt;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">-&gt;vtkFormsWindowControl1-&gt;GetRenderWindow()-&gt;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-&gt;SetRenderWindow(</p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">-&gt;vtkFormsWindowControl1-&gt;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-&gt;SetRadius(1.0);</p>
<p dir="ltr">sphere-&gt;SetThetaResolution(18);</p>
<p dir="ltr">sphere-&gt;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-&gt;AddPoint(0, 0.02);</p>
<p dir="ltr">opacityTransferFunction-&gt;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-&gt;AddRGBPoint(0.0, 0.1, 0.1, 0.1);</p>
<p dir="ltr">colorTransferFunction-&gt;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-&gt;SetColor(colorTransferFunction);</p>
<p dir="ltr">volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction);</p>
<p dir="ltr">volumeProperty-&gt;SetInterpolationType(interp);</p>
<p dir="ltr">volumeProperty-&gt;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-&gt;SetNumberOfTuples(unstructuredReader-&gt;GetOutput()-&gt;GetNumberOfPoints());</p>
<p dir="ltr">arr-&gt;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-&gt;SetName(&quot;myarray&quot;);</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-&gt;Update();</font></p>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid-&gt;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">&lt;vtkDataObject^&gt;(unstructuredReader-&gt;GetOutput()));</font>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid-&gt;GetPointData()-&gt;AddArray(arr);</font></p>
<p dir="ltr"><font style="BACKGROUND-COLOR: #ffff00">grid-&gt;GetPointData()-&gt;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-&gt;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-&gt;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-&gt;SetMapper(volumeUnstructedMapper);</p>
<p dir="ltr">volume-&gt;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-&gt;AddVolume(volume);</p>
<p dir="ltr"></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">this</font></font><font size="2">-&gt;vtkFormsWindowControl1-&gt;GetRenderWindow()-&gt;Render();
<p dir="ltr">iren1-&gt;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">-&gt;vtkFormsWindowControl1-&gt;GetRenderWindow()-&gt;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">&lt;<a href="mailto:hobbsk@ohiou.edu">hobbsk@ohiou.edu</a>&gt;</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>&gt; I wrote a code to make tetrahedral mesh on sphere , but it no give<br>&gt; result except :<br>&gt;<br>&gt; ERROR: In m:\dev\cur\vtkdotnet\branch\50\VolumeRendering<br>
&gt; \vtkUnstructuredGridVolumeRayCastMapper.cxx, line 274<br>&gt; vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can&#39;t use the ray<br>&gt; cast mapper without scalars!<br>&gt;<br>&gt;<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&#39;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-&gt;Update();<br>my_grid-&gt;DeepCopy( filter-&gt;GetOutput() );<br></blockquote></div><br></div>