当前位置: 首页>>代码示例>>C++>>正文


C++ PCLVisualizer::addModelFromPolyData方法代码示例

本文整理汇总了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);
  }
开发者ID:yazdani,项目名称:robosherlock,代码行数:44,代码来源:SuperVoxelAnnotator.cpp


注:本文中的pcl::visualization::PCLVisualizer::addModelFromPolyData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。