[vtkusers] Multiple vtkPolygons in a vtkPolyData
David Cole
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.
Or:
See this example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/CombinePolyData
And the documentation for the append and clean polydata filters:
http://www.vtk.org/doc/nightly/html/classvtkAppendPolyData.html
http://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html
The vtkAppendPolyData filter produces a single polydata output from many
input polydata objects.
HTH,
David C.
On Wed, Oct 29, 2014 at 7:11 AM, Nick Patterson <pattersonnp at gmail.com>
wrote:
> 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 =
> vtkSmartPointer<vtkPoints>::New();
> 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 =
> vtkSmartPointer<vtkPolygon>::New();
> 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 =
> vtkSmartPointer<vtkCellArray>::New();
> polygons->InsertNextCell(polygon);
>
> // Create a PolyData
> vtkSmartPointer<vtkPolyData> polygonPolyData =
> vtkSmartPointer<vtkPolyData>::New();
> polygonPolyData->SetPoints(points);
> polygonPolyData->SetPolys(polygons);
>
>
>
> 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
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141029/dd89976b/attachment.html>
More information about the vtkusers
mailing list