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


C++ vtkSmartPointer::BuildCells方法代码示例

本文整理汇总了C++中vtkSmartPointer::BuildCells方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::BuildCells方法的具体用法?C++ vtkSmartPointer::BuildCells怎么用?C++ vtkSmartPointer::BuildCells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtkSmartPointer的用法示例。


在下文中一共展示了vtkSmartPointer::BuildCells方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cumulativeAreas

void
uniform_sampling (vtkSmartPointer<vtkPolyData> polydata, size_t n_samples, pcl::PointCloud<pcl::PointXYZ> & cloud_out)
{
  polydata->BuildCells ();
  vtkSmartPointer<vtkCellArray> cells = polydata->GetPolys ();

  double p1[3], p2[3], p3[3], totalArea = 0;
  std::vector<double> cumulativeAreas (cells->GetNumberOfCells (), 0);
  size_t i = 0;
  vtkIdType npts = 0, *ptIds = NULL;
  for (cells->InitTraversal (); cells->GetNextCell (npts, ptIds); i++)
  {
    polydata->GetPoint (ptIds[0], p1);
    polydata->GetPoint (ptIds[1], p2);
    polydata->GetPoint (ptIds[2], p3);
    totalArea += vtkTriangle::TriangleArea (p1, p2, p3);
    cumulativeAreas[i] = totalArea;
  }

  cloud_out.points.resize (n_samples);
  cloud_out.width = static_cast<uint32_t> (n_samples);
  cloud_out.height = 1;

  for (i = 0; i < n_samples; i++)
  {
    Eigen::Vector4f p;
    randPSurface (polydata, &cumulativeAreas, totalArea, p);
    cloud_out.points[i].x = p[0];
    cloud_out.points[i].y = p[1];
    cloud_out.points[i].z = p[2];
  }
}
开发者ID:diegodgs,项目名称:PCL,代码行数:32,代码来源:mesh_sampling.cpp

示例2: cumulativeAreas

void
uniform_sampling (vtkSmartPointer<vtkPolyData> polydata, size_t n_samples, bool calc_normal, bool calc_color, pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud_out)
{
  polydata->BuildCells ();
  vtkSmartPointer<vtkCellArray> cells = polydata->GetPolys ();

  double p1[3], p2[3], p3[3], totalArea = 0;
  std::vector<double> cumulativeAreas (cells->GetNumberOfCells (), 0);
  vtkIdType npts = 0, *ptIds = NULL;
  size_t cellId = 0;
  for (cells->InitTraversal (); cells->GetNextCell (npts, ptIds); cellId++)
  {
    polydata->GetPoint (ptIds[0], p1);
    polydata->GetPoint (ptIds[1], p2);
    polydata->GetPoint (ptIds[2], p3);
    totalArea += vtkTriangle::TriangleArea (p1, p2, p3);
    cumulativeAreas[cellId] = totalArea;
  }

  cloud_out.points.resize (n_samples);
  cloud_out.width = static_cast<pcl::uint32_t> (n_samples);
  cloud_out.height = 1;

  for (size_t i = 0; i < n_samples; i++)
  {
    Eigen::Vector3f p;
    Eigen::Vector3f n (0, 0, 0);
    Eigen::Vector3f c (0, 0, 0);
    randPSurface (polydata, &cumulativeAreas, totalArea, p, calc_normal, n, calc_color, c);
    cloud_out.points[i].x = p[0];
    cloud_out.points[i].y = p[1];
    cloud_out.points[i].z = p[2];
    if (calc_normal)
    {
      cloud_out.points[i].normal_x = n[0];
      cloud_out.points[i].normal_y = n[1];
      cloud_out.points[i].normal_z = n[2];
    }
    if (calc_color)
    {
      cloud_out.points[i].r = static_cast<uint8_t>(c[0]);
      cloud_out.points[i].g = static_cast<uint8_t>(c[1]);
      cloud_out.points[i].b = static_cast<uint8_t>(c[2]);
    }
  }
}
开发者ID:VictorLamoine,项目名称:pcl,代码行数:46,代码来源:mesh_sampling.cpp


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