<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div apple-content-edited="true"><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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 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">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 class="de1" 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; position: static; z-index: auto;">vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPoints<span class="sy1" style="color: rgb(0, 0, 128);">></span> points <span class="sy1" style="color: rgb(0, 0, 128);">=</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPoints<span class="sy1" style="color: rgb(0, 0, 128);">></span><span class="sy4" style="color: rgb(0, 128, 128);">::</span><span class="me2" style="color: rgb(0, 119, 136);">New</span><span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
points<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>InsertNextPoint<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu16" style="color: rgb(128, 0, 128);">0.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
points<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>InsertNextPoint<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu16" style="color: rgb(128, 0, 128);">1.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
points<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>InsertNextPoint<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu16" style="color: rgb(128, 0, 128);">1.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">1.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
points<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>InsertNextPoint<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu16" style="color: rgb(128, 0, 128);">0.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">1.0</span>, <span class="nu16" style="color: rgb(128, 0, 128);">0.0</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
<span class="co1" style="color: rgb(102, 102, 102);">// Create the polygon</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPolygon<span class="sy1" style="color: rgb(0, 0, 128);">></span> polygon <span class="sy1" style="color: rgb(0, 0, 128);">=</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPolygon<span class="sy1" style="color: rgb(0, 0, 128);">></span><span class="sy4" style="color: rgb(0, 128, 128);">::</span><span class="me2" style="color: rgb(0, 119, 136);">New</span><span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygon<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>GetPointIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetNumberOfIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu0" style="color: rgb(0, 0, 221);">4</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span> <span class="co1" style="color: rgb(102, 102, 102);">//make a quad</span>
polygon<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>GetPointIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetId<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu0" style="color: rgb(0, 0, 221);">0</span>, <span class="nu0" style="color: rgb(0, 0, 221);">0</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygon<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>GetPointIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetId<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu0" style="color: rgb(0, 0, 221);">1</span>, <span class="nu0" style="color: rgb(0, 0, 221);">1</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygon<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>GetPointIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetId<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu0" style="color: rgb(0, 0, 221);">2</span>, <span class="nu0" style="color: rgb(0, 0, 221);">2</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygon<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>GetPointIds<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetId<span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="nu0" style="color: rgb(0, 0, 221);">3</span>, <span class="nu0" style="color: rgb(0, 0, 221);">3</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
<span class="co1" style="color: rgb(102, 102, 102);">// Add the polygon to a list of polygons</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkCellArray<span class="sy1" style="color: rgb(0, 0, 128);">></span> polygons <span class="sy1" style="color: rgb(0, 0, 128);">=</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkCellArray<span class="sy1" style="color: rgb(0, 0, 128);">></span><span class="sy4" style="color: rgb(0, 128, 128);">::</span><span class="me2" style="color: rgb(0, 119, 136);">New</span><span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygons<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>InsertNextCell<span class="br0" style="color: rgb(0, 128, 0);">(</span>polygon<span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
<span class="co1" style="color: rgb(102, 102, 102);">// Create a PolyData</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPolyData<span class="sy1" style="color: rgb(0, 0, 128);">></span> polygonPolyData <span class="sy1" style="color: rgb(0, 0, 128);">=</span>
vtkSmartPointer<span class="sy1" style="color: rgb(0, 0, 128);"><</span>vtkPolyData<span class="sy1" style="color: rgb(0, 0, 128);">></span><span class="sy4" style="color: rgb(0, 128, 128);">::</span><span class="me2" style="color: rgb(0, 119, 136);">New</span><span class="br0" style="color: rgb(0, 128, 0);">(</span><span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygonPolyData<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetPoints<span class="br0" style="color: rgb(0, 128, 0);">(</span>points<span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" style="color: rgb(0, 128, 128);">;</span>
polygonPolyData<span class="sy2" style="color: rgb(0, 0, 64);">-</span><span class="sy1" style="color: rgb(0, 0, 128);">></span>SetPolys<span class="br0" style="color: rgb(0, 128, 0);">(</span>polygons<span class="br0" style="color: rgb(0, 128, 0);">)</span><span class="sy4" 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></body></html>