本文整理汇总了C++中pcl::visualization::PCLVisualizer::addModelFromPolyData方法的典型用法代码示例。如果您正苦于以下问题:C++ PCLVisualizer::addModelFromPolyData方法的具体用法?C++ PCLVisualizer::addModelFromPolyData怎么用?C++ PCLVisualizer::addModelFromPolyData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pcl::visualization::PCLVisualizer
的用法示例。
在下文中一共展示了PCLVisualizer::addModelFromPolyData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSupervoxelConnectionsToViewer
void addSupervoxelConnectionsToViewer(pcl::PointXYZRGBA &supervoxel_center,
pcl::PointCloud< pcl::PointXYZRGBA> &adjacent_supervoxel_centers,
std::string supervoxel_name,
pcl::visualization::PCLVisualizer &viewer)
{
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPolyLine> polyLine = vtkSmartPointer<vtkPolyLine>::New();
// Setup colors
unsigned char red[3] = {255, 0, 0};
unsigned char green[3] = {0, 255, 0};
unsigned char blue[3] = {0, 0, 255};
vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New();
colors->SetNumberOfComponents(3);
colors->SetName("Colors");
colors->InsertNextTupleValue(red);
colors->InsertNextTupleValue(green);
colors->InsertNextTupleValue(blue);
//Iterate through all adjacent points, and add a center point to adjacent point pair
pcl::PointCloud< pcl::PointXYZRGBA>::iterator adjacent_itr = adjacent_supervoxel_centers.begin();
for(; adjacent_itr != adjacent_supervoxel_centers.end(); ++adjacent_itr)
{
points->InsertNextPoint(supervoxel_center.data);
points->InsertNextPoint(adjacent_itr->data);
}
// Create a polydata to store everything in
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
// Add the points to the dataset
polyData->SetPoints(points);
polyLine->GetPointIds()->SetNumberOfIds(points->GetNumberOfPoints());
for(unsigned int i = 0; i < points->GetNumberOfPoints(); i++)
{
polyLine->GetPointIds()->SetId(i, i);
}
cells->InsertNextCell(polyLine);
// Add the lines to the dataset
polyData->SetLines(cells);
// polyData->GetPointData()->SetScalars(colors);
viewer.addModelFromPolyData(polyData, supervoxel_name);
}