[vtkusers] using vtkPolyhedron and clipping.

Billy Araujo billyaraujo at gmail.com
Thu Aug 30 12:00:18 EDT 2012


Also, how do I define the faces of a vtkPolyhedron?

I am following:

http://www.cmake.org/Wiki/VTK/Examples/Broken/Cxx/GeometricObjects/Cell3DDemo

example.


On Thu, Aug 30, 2012 at 4:52 PM, Billy Araujo <billyaraujo at gmail.com> wrote:

> I am trying to display to create and display a polyhedron and a clipped
> polyhedron by a plane. Does anyone know of a simple example?
>
> Also, I don't understand why I have to add the vtkPolyhedron to
> a vtkUnstructuredGrid to display the polyhedron.
>
> Is this the best way to display a polyhedron?
>
>   // Geometry
>
>   VTK_CREATE(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);
>   points->InsertNextPoint(0.0, 0.0, 1.0);
>   points->InsertNextPoint(1.0, 0.0, 1.0);
>   points->InsertNextPoint(1.0, 1.0, 1.0);
>   points->InsertNextPoint(0.0, 1.0, 1.0);
>
>   /*
>   VTK_CREATE(vtkPolyhedron, polyhedron);
>   polyhedron->GetPointIds()->SetNumberOfIds(8);
>   polyhedron->GetPointIds()->SetId(0,0);
>   polyhedron->GetPointIds()->SetId(1,1);
>   polyhedron->GetPointIds()->SetId(2,2);
>   polyhedron->GetPointIds()->SetId(3,3);
>   polyhedron->GetPointIds()->SetId(4,4);
>   polyhedron->GetPointIds()->SetId(5,5);
>   polyhedron->GetPointIds()->SetId(6,6);
>   polyhedron->GetPointIds()->SetId(7,7);
>   */
>
>   vtkIdType polyhedronPointsIds[8] = {0, 1, 2, 3, 4, 5, 6, 7};
>
>   vtkIdType polyhedronFace[6][4] = {{0, 3, 2, 1}, {4, 5, 6, 7},
>  {1, 2, 6, 5}, {0, 4, 7, 3},
>         {0, 1, 5, 4}, {2, 3, 7, 6}};
>
>   VTK_CREATE(vtkCellArray, polyhedronFaces);
>   for (int i = 0; i < 6; i++)
>   {
>     polyhedronFaces->InsertNextCell(4, polyhedronFace[i]);
>   }
>
>   VTK_CREATE(vtkUnstructuredGrid, uGrid);
>   uGrid->SetPoints(points);
>   uGrid->InsertNextCell(VTK_POLYHEDRON, 8, polyhedronPointsIds, 6,
> polyhedronFaces->GetPointer());
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120830/cca88aa1/attachment.htm>


More information about the vtkusers mailing list