#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/common/transforms.h>
#include <vtkVersion.h>
#include <vtkPLYReader.h>
#include <vtkOBJReader.h>
#include <vtkTriangle.h>
#include <vtkTriangleFilter.h>
#include <vtkPolyDataMapper.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/console/print.h>
#include <pcl/console/parse.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <string> // std::string, std::to_string
inline double uniform_deviate (int seed)
{
double ran = seed * (1.0 / (RAND_MAX + 1.0));
return ran;
}
inline void randomPointTriangle (float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3, Eigen::Vector4f& p)
{
float r1 = static_cast<float> (uniform_deviate (rand ()));
float r2 = static_cast<float> (uniform_deviate (rand ()));
float r1sqr = std::sqrt (r1);
float OneMinR1Sqr = (1 - r1sqr);
float OneMinR2 = (1 - r2);
a1 *= OneMinR1Sqr;
a2 *= OneMinR1Sqr;
a3 *= OneMinR1Sqr;
b1 *= OneMinR2;
b2 *= OneMinR2;
b3 *= OneMinR2;
c1 = r1sqr * (r2 * c1 + b1) + a1;
c2 = r1sqr * (r2 * c2 + b2) + a2;
c3 = r1sqr * (r2 * c3 + b3) + a3;
p[0] = c1;
p[1] = c2;
p[2] = c3;
p[3] = 0;
}
inline void randPSurface (vtkPolyData * polydata, std::vector<double> * cumulativeAreas, double totalArea, Eigen::Vector4f& p, bool calcNormal, Eigen::Vector3f& n)
{
float r = static_cast<float> (uniform_deviate (rand ()) * totalArea);
std::vector<double>::iterator low = std::lower_bound (cumulativeAreas->begin (), cumulativeAreas->end (), r);
vtkIdType el = vtkIdType (low - cumulativeAreas->begin ());
double A[3], B[3], C[3];
vtkIdType npts = 0;
vtkIdType *ptIds = NULL;
polydata->GetCellPoints (el, npts, ptIds);
polydata->GetPoint (ptIds[0], A);
polydata->GetPoint (ptIds[1], B);
polydata->GetPoint (ptIds[2], C);
if (
PCL批量将mesh对象采样生成点云数据
最新推荐文章于 2024-05-22 09:45:46 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)