<div><br></div><div><br><div class="gmail_quote">On Mon, Mar 19, 2012 at 7:35 AM, Jothybasu Selvaraj <span dir="ltr">&lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">What is your polydata made of? <br><br>Is it from 2D contours?<br></div></blockquote><div><br></div><div>My polydata has 3D triangles. Here is the DumpXML output for it.</div><div><div>------------------------</div>

<div>out_p_w.vtk</div><div> contains a </div><div>vtkPolyData that has 1310888 cells and 1772275 points.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Cell type vtkTriangle occurs 1310888 times.</div>

<div> contains point data with 2 arrays.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Array 0 is named scalars</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Array 1 is named Normals</div>

<div> contains cell data with 0 arrays.</div><div> contains field data with 0 arrays.</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><br>You may post your code, that would make people to help you better.<br></div></blockquote><div><br></div>Sorry, I should have done that. </div><div class="gmail_quote"><br></div><div class="gmail_quote">

<div class="gmail_quote">int main(int, char *[])</div><div class="gmail_quote">{</div><div class="gmail_quote">    vtkSmartPointer&lt;vtkPolyDataReader&gt; pdR =</div><div class="gmail_quote">        vtkSmartPointer&lt;vtkPolyDataReader&gt;::New();</div>

<div class="gmail_quote">  vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource =</div><div class="gmail_quote">    vtkSmartPointer&lt;vtkSphereSource&gt;::New();</div><div class="gmail_quote">  vtkSmartPointer&lt;vtkWarpScalar&gt; warp=</div>

<div class="gmail_quote">    vtkSmartPointer&lt;vtkWarpScalar&gt;::New();</div><div class="gmail_quote">  sphereSource-&gt;SetRadius(20);</div><div class="gmail_quote">  sphereSource-&gt;SetPhiResolution(30);</div><div class="gmail_quote">

  sphereSource-&gt;SetThetaResolution(30);</div><div class="gmail_quote">  pdR-&gt;SetFileName(&quot;../../data/vtk/out_p_w.vtk&quot;);</div><div class="gmail_quote">  //pdR-&gt;SetFileName(&quot;../../data/vtk/out_poly_append_one.vtk&quot;);</div>

<div class="gmail_quote">  //pdR-&gt;SetFileName(&quot;../../vis/out_poly.vtk&quot;);</div><div class="gmail_quote">  //vtkSmartPointer&lt;vtkPolyData&gt; pd = sphereSource-&gt;GetOutput();</div><div class="gmail_quote">
  pdR-&gt;Update();</div>
<div class="gmail_quote">  vtkSmartPointer&lt;vtkPolyData&gt; pd = pdR-&gt;GetOutput();</div><div class="gmail_quote">  //warp-&gt;SetInput(pd);</div><div class="gmail_quote">  //warp-&gt;SetScaleFactor(10);</div><div class="gmail_quote">

  //warp-&gt;Update();</div><div class="gmail_quote">  //vtkSmartPointer&lt;vtkPolyData&gt; pd =</div><div class="gmail_quote">  //pd = warp-&gt;GetOutput();</div><div class="gmail_quote">  //sphereSource-&gt;Update();</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">  vtkSmartPointer&lt;vtkImageData&gt; whiteImage =</div><div class="gmail_quote">    vtkSmartPointer&lt;vtkImageData&gt;::New();</div><div class="gmail_quote">  double bounds[6];</div>

<div class="gmail_quote">  pd-&gt;GetBounds(bounds);</div><div class="gmail_quote">  double spacing[3]; // desired volume spacing</div><div class="gmail_quote">  spacing[0] = 0.31;</div><div class="gmail_quote">  spacing[1] = 0.31;</div>

<div class="gmail_quote">  spacing[2] = 0.31;</div><div class="gmail_quote">  whiteImage-&gt;SetSpacing(spacing);</div><div class="gmail_quote"><br></div><div class="gmail_quote">  // compute dimensions</div><div class="gmail_quote">

  int dim[3];</div><div class="gmail_quote">  for (int i = 0; i &lt; 3; i++)</div><div class="gmail_quote">    {</div><div class="gmail_quote">    dim[i] = static_cast&lt;int&gt;(ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i]));</div>

<div class="gmail_quote">    }</div><div class="gmail_quote">  whiteImage-&gt;SetDimensions(dim);</div><div class="gmail_quote">  whiteImage-&gt;SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);</div><div class="gmail_quote">

<br></div><div class="gmail_quote">  double origin[3];</div><div class="gmail_quote">  origin[0] = bounds[0] + spacing[0] / 2;</div><div class="gmail_quote">  origin[1] = bounds[2] + spacing[1] / 2;</div><div class="gmail_quote">

  origin[2] = bounds[4] + spacing[2] / 2;</div><div class="gmail_quote">  whiteImage-&gt;SetOrigin(origin);</div><div class="gmail_quote"><br></div><div class="gmail_quote">#if VTK_MAJOR_VERSION &lt;= 5</div><div class="gmail_quote">

  whiteImage-&gt;SetScalarTypeToUnsignedChar();</div><div class="gmail_quote">  whiteImage-&gt;AllocateScalars();</div><div class="gmail_quote">#else</div><div class="gmail_quote">  whiteImage-&gt;AllocateScalars(VTK_UNSIGNED_SHORT,1);</div>

<div class="gmail_quote">#endif</div><div class="gmail_quote">  // fill the image with foreground voxels:</div><div class="gmail_quote">  unsigned char inval = 255; unsigned char outval = 0;</div><div class="gmail_quote">

  vtkIdType count = whiteImage-&gt;GetNumberOfPoints();</div><div class="gmail_quote">  for (vtkIdType i = 0; i &lt; count; ++i)</div><div class="gmail_quote">    {</div><div class="gmail_quote">    whiteImage-&gt;GetPointData()-&gt;GetScalars()-&gt;SetTuple1(i, inval);</div>

<div class="gmail_quote">    }</div><div class="gmail_quote"><br></div><div class="gmail_quote">  // polygonal data --&gt; image stencil:</div><div class="gmail_quote">  vtkSmartPointer&lt;vtkPolyDataToImageStencil&gt; pol2stenc =</div>

<div class="gmail_quote">    vtkSmartPointer&lt;vtkPolyDataToImageStencil&gt;::New();</div><div class="gmail_quote">#if VTK_MAJOR_VERSION &lt;= 5</div><div class="gmail_quote">  pol2stenc-&gt;SetInput(pd);</div><div class="gmail_quote">

#else</div><div class="gmail_quote">  pol2stenc-&gt;SetInputData(pd);</div><div class="gmail_quote">#endif</div><div class="gmail_quote">  pol2stenc-&gt;SetOutputOrigin(origin);</div><div class="gmail_quote">  pol2stenc-&gt;SetOutputSpacing(spacing);</div>

<div class="gmail_quote">  pol2stenc-&gt;SetOutputWholeExtent(whiteImage-&gt;GetExtent());</div><div class="gmail_quote">  pol2stenc-&gt;Update();</div><div class="gmail_quote"><br></div><div class="gmail_quote">  vtkSmartPointer&lt;vtkImplicitFunctionToImageStencil&gt; func2stenc =</div>

<div class="gmail_quote">  vtkImplicitFunctionToImageStencil::New();</div><div class="gmail_quote">  //vtkSmartPointer&lt;vtkElevationFilter&gt; elev = vtkElevationFilter::New();</div><div class="gmail_quote">  //elev-&gt;SetInput(pd);</div>

<div class="gmail_quote">  //vtkSmartPointer&lt;vtkImplicitDataSet&gt; imp = vtkImplicitDataSet::New();</div><div class="gmail_quote">  //imp-&gt;SetDataSet(elev-&gt;GetOutput());</div><div class="gmail_quote"><br></div>
<div class="gmail_quote">
  //func2stenc-&gt;SetThreshold(0.1);</div><div class="gmail_quote">  //func2stenc-&gt;SetInput(imp);</div><div class="gmail_quote">  //func2stenc-&gt;SetOutputOrigin(origin);</div><div class="gmail_quote">  //func2stenc-&gt;SetOutputSpacing(spacing);</div>

<div class="gmail_quote">  //func2stenc-&gt;SetOutputWholeExtent(whiteImage-&gt;GetExtent());</div><div class="gmail_quote">  //func2stenc-&gt;Update();</div><div class="gmail_quote"><br></div><div class="gmail_quote">  // cut the corresponding white image and set the background:</div>

<div class="gmail_quote">  vtkSmartPointer&lt;vtkImageStencil&gt; imgstenc =</div><div class="gmail_quote">    vtkSmartPointer&lt;vtkImageStencil&gt;::New();</div><div class="gmail_quote">#if VTK_MAJOR_VERSION &lt;= 5</div>

<div class="gmail_quote">  imgstenc-&gt;SetInput(whiteImage);</div><div class="gmail_quote">  imgstenc-&gt;SetStencil(pol2stenc-&gt;GetOutput());</div><div class="gmail_quote">  //imgstenc-&gt;SetStencil(func2stenc-&gt;GetOutput());</div>

<div class="gmail_quote">#else</div><div class="gmail_quote">  imgstenc-&gt;SetInputData(whiteImage);</div><div class="gmail_quote">  imgstenc-&gt;SetStencilConnection(pol2stenc-&gt;GetOutputPort());</div><div class="gmail_quote">

  //imgstenc-&gt;SetStencilConnection(func2stenc-&gt;GetOutputPort());</div><div class="gmail_quote">#endif</div><div class="gmail_quote">  //imgstenc-&gt;ReverseStencilOff();</div><div class="gmail_quote">  imgstenc-&gt;SetBackgroundValue(outval);</div>

<div class="gmail_quote">  imgstenc-&gt;Update();</div><div class="gmail_quote"><br></div><div class="gmail_quote">  vtkSmartPointer&lt;vtkMetaImageWriter&gt; writer =</div><div class="gmail_quote">    vtkSmartPointer&lt;vtkMetaImageWriter&gt;::New();</div>

<div class="gmail_quote">  writer-&gt;SetFileName(&quot;SphereVolume_p_w.mhd&quot;);</div><div class="gmail_quote">#if VTK_MAJOR_VERSION &lt;= 5</div><div class="gmail_quote">  writer-&gt;SetInput(imgstenc-&gt;GetOutput());</div>

<div class="gmail_quote">#else</div><div class="gmail_quote">  writer-&gt;SetInputData(imgstenc-&gt;GetOutput());</div><div class="gmail_quote">#endif</div><div class="gmail_quote">  writer-&gt;Write();</div><div class="gmail_quote">

<br></div><div class="gmail_quote">  return EXIT_SUCCESS;</div><div class="gmail_quote">}</div><div><br></div><div><br></div><div> </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><br>Jothy<br><br><div class="gmail_quote"><div><div class="h5">On Mon, Mar 19, 2012 at 2:51 AM, Raghuram.O.S. <span dir="ltr">&lt;<a href="mailto:raghuramos1987@gmail.com" target="_blank">raghuramos1987@gmail.com</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">Hi,<div><br></div><div><div>I have been trying to convert polydata to imagedata using the image stencil filter. I seem to be running into an issue of noise in the converted image. I get random triangles in the image which are pretty huge in the middle of actual data. I saw this post <a href="http://www.vtk.org/pipermail/vtkusers/2011-October/119302.html" target="_blank">http://www.vtk.org/pipermail/vtkusers/2011-October/119302.html</a> and tried using the implicit function. But, the post doesnt have a full example and there doesnt seem to be an example of <span style>vtkImplicitFunctionToImageStencil. </span></div>





<div><span style><br></span></div><div><span style>My polydata doesnt seem to have any issues when I render it using polydatamapper. I have been using the example on the site at </span><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData</a> (as indicated in the previous post also).</div>





-- <br><font color="#888888">Regards,<br>Onti<br>
</font></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Onti<br>
</div>