<div dir="ltr"><div>You should be able to put all of the points and all of the polygons into your existing "points" and "polygons" variables, and have just one polydata that refers to all of them at once.</div><div><br></div><div>Or:</div><div><br></div>See this example:<div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/CombinePolyData">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/CombinePolyData</a><br></div><div><br></div><div>And the documentation for the append and clean polydata filters:</div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkAppendPolyData.html">http://www.vtk.org/doc/nightly/html/classvtkAppendPolyData.html</a><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html">http://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html</a><br></div><div><br></div><div>The vtkAppendPolyData filter produces a single polydata output from many input polydata objects.</div><div><br></div><div><br></div><div>HTH,</div><div>David C.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 29, 2014 at 7:11 AM, Nick Patterson <span dir="ltr"><<a href="mailto:pattersonnp@gmail.com" target="_blank">pattersonnp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Dear VTK Users,<div> </div><div>I have been having some trouble with handling polygons in VTK and hoped that someone can offer some guidance. </div><div><br></div><div>I wish to do the following:-</div><div>1) Read some contours (structures) from a DICOM file - these are essentially polygons drawn on 2D slices. <b><i>( I have completed this task and have the ability to extract the x,y,z point of each vertex from a DICOM RTStruct)</i></b> There are approximately 250 polygons.</div><div><br></div><div>2) I want to add these coordinate positions to create a vtkPolygon</div><div><br></div><div>3) I want add each vtkPolygon object to a vtkPolyData </div><div><br></div><div>4) Render the polygons. ( I can probably deal with this ).</div><div><br></div><div>Up until now I have been using the <a href="http://www.itk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Polygon" target="_blank">http://www.itk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Polygon</a> example and trying to adapt it. </div><div><br></div><div>Can anyone advise how I would modify this segment of code (taken straight from the code in the link above) so that it would be generic that I can add multiple independent polygons (in the example I am working with there are approximately 250 polygons) to the vtkPolyData.</div><div><br></div><div><pre style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPoints<span style="color:rgb(0,0,128)">></span> points <span style="color:rgb(0,0,128)">=</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPoints<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">New</span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
points<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>InsertNextPoint<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(128,0,128)">0.0</span>, <span style="color:rgb(128,0,128)">0.0</span>, <span style="color:rgb(128,0,128)">0.0</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
points<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>InsertNextPoint<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(128,0,128)">1.0</span>, <span style="color:rgb(128,0,128)">0.0</span>, <span style="color:rgb(128,0,128)">0.0</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
points<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>InsertNextPoint<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(128,0,128)">1.0</span>, <span style="color:rgb(128,0,128)">1.0</span>, <span style="color:rgb(128,0,128)">0.0</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
points<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>InsertNextPoint<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(128,0,128)">0.0</span>, <span style="color:rgb(128,0,128)">1.0</span>, <span style="color:rgb(128,0,128)">0.0</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
<span style="color:rgb(102,102,102)">// Create the polygon</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPolygon<span style="color:rgb(0,0,128)">></span> polygon <span style="color:rgb(0,0,128)">=</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPolygon<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">New</span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygon<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>GetPointIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetNumberOfIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,221)">4</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span> <span style="color:rgb(102,102,102)">//make a quad</span>
polygon<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>GetPointIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetId<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,221)">0</span>, <span style="color:rgb(0,0,221)">0</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygon<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>GetPointIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetId<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,221)">1</span>, <span style="color:rgb(0,0,221)">1</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygon<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>GetPointIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetId<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,221)">2</span>, <span style="color:rgb(0,0,221)">2</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygon<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>GetPointIds<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetId<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,221)">3</span>, <span style="color:rgb(0,0,221)">3</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
<span style="color:rgb(102,102,102)">// Add the polygon to a list of polygons</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkCellArray<span style="color:rgb(0,0,128)">></span> polygons <span style="color:rgb(0,0,128)">=</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkCellArray<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">New</span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygons<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>InsertNextCell<span style="color:rgb(0,128,0)">(</span>polygon<span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
<span style="color:rgb(102,102,102)">// Create a PolyData</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPolyData<span style="color:rgb(0,0,128)">></span> polygonPolyData <span style="color:rgb(0,0,128)">=</span>
vtkSmartPointer<span style="color:rgb(0,0,128)"><</span>vtkPolyData<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,128)">::</span><span style="color:rgb(0,119,136)">New</span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygonPolyData<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetPoints<span style="color:rgb(0,128,0)">(</span>points<span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
polygonPolyData<span style="color:rgb(0,0,64)">-</span><span style="color:rgb(0,0,128)">></span>SetPolys<span style="color:rgb(0,128,0)">(</span>polygons<span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span></pre><div><br></div></div><div><br></div><div>I hope my problem is clear, but am happy to clarify if you think you are able to offer guidance which would be much appreciated.</div><div><br></div><div>Regards, Nick.</div></div></div></div><br>_______________________________________________<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://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>