[vtkusers] Multiple vtkPolygons in a vtkPolyData
DLRdave at aol.com
Wed Oct 29 08:56:03 EDT 2014
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.
See this example:
And the documentation for the append and clean polydata filters:
The vtkAppendPolyData filter produces a single polydata output from many
input polydata objects.
On Wed, Oct 29, 2014 at 7:11 AM, Nick Patterson <pattersonnp at gmail.com>
> Dear VTK Users,
> I have been having some trouble with handling polygons in VTK and hoped
> that someone can offer some guidance.
> I wish to do the following:-
> 1) Read some contours (structures) from a DICOM file - these are
> essentially polygons drawn on 2D slices. *( I have completed this task
> and have the ability to extract the x,y,z point of each vertex from a DICOM
> RTStruct)* There are approximately 250 polygons.
> 2) I want to add these coordinate positions to create a vtkPolygon
> 3) I want add each vtkPolygon object to a vtkPolyData
> 4) Render the polygons. ( I can probably deal with this ).
> Up until now I have been using the
> http://www.itk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Polygon example
> and trying to adapt it.
> 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.
> vtkSmartPointer<vtkPoints> points =
> points->InsertNextPoint(0.0, 0.0, 0.0);
> points->InsertNextPoint(1.0, 0.0, 0.0);
> points->InsertNextPoint(1.0, 1.0, 0.0);
> points->InsertNextPoint(0.0, 1.0, 0.0);
> // Create the polygon
> vtkSmartPointer<vtkPolygon> polygon =
> polygon->GetPointIds()->SetNumberOfIds(4); //make a quad
> polygon->GetPointIds()->SetId(0, 0);
> polygon->GetPointIds()->SetId(1, 1);
> polygon->GetPointIds()->SetId(2, 2);
> polygon->GetPointIds()->SetId(3, 3);
> // Add the polygon to a list of polygons
> vtkSmartPointer<vtkCellArray> polygons =
> // Create a PolyData
> vtkSmartPointer<vtkPolyData> polygonPolyData =
> 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.
> Regards, Nick.
> Powered by www.kitware.com
> Visit other Kitware open-source projects at
> Please keep messages on-topic and check the VTK FAQ at:
> Follow this link to subscribe/unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers