本文整理汇总了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];
}
}
示例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]);
}
}
}