41 #include <vtkSmartPointer.h>
42 #include <vtkPoints.h>
43 #include <vtkPolygon.h>
44 #include <vtkUnstructuredGrid.h>
50 namespace visualization
57 if (cloud->
points.empty ())
63 poly_points->SetNumberOfPoints (cloud->
size ());
64 polygon->GetPointIds ()->SetNumberOfIds (cloud->
size ());
66 for (std::size_t i = 0; i < cloud->
size (); ++i)
68 poly_points->SetPoint (i, (*cloud)[i].x, (*cloud)[i].y, (*cloud)[i].z);
69 polygon->GetPointIds ()->SetId (i, i);
73 poly_grid->Allocate (1, 1);
74 poly_grid->InsertNextCell (polygon->GetCellType (), polygon->GetPointIds ());
75 poly_grid->SetPoints (poly_points);
91 poly_points->SetNumberOfPoints (planar_polygon.
getContour ().size () + 1);
92 polygon->GetPointIds ()->SetNumberOfIds (planar_polygon.
getContour ().size () + 1);
94 for (std::size_t i = 0; i < planar_polygon.
getContour ().size (); ++i)
96 poly_points->SetPoint (i, planar_polygon.
getContour ()[i].x,
99 polygon->GetPointIds ()->SetId (i, i);
102 std::size_t closingContourId = planar_polygon.
getContour ().size ();
103 auto firstContour = planar_polygon.
getContour ()[0];
104 poly_points->SetPoint (closingContourId, firstContour.x,
107 polygon->GetPointIds ()->SetId (closingContourId, closingContourId);
110 poly_grid->Allocate (1, 1);
111 poly_grid->InsertNextCell (polygon->GetCellType (), polygon->GetPointIds ());
112 poly_grid->SetPoints (poly_points);
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
pcl::PointCloud< PointT >::VectorType & getContour()
Getter for the contour / boundary.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
shared_ptr< const PointCloud< PointT > > ConstPtr
vtkSmartPointer< vtkDataSet > createPolygon(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
Create a 3d poly line from a set of points.
PCL_EXPORTS void allocVtkUnstructuredGrid(vtkSmartPointer< vtkUnstructuredGrid > &polydata)
Allocate a new unstructured grid smartpointer.