使用Meshlab对CAD模型采样点云,并在PCL中显示

使用的版本为solidworks 2016+meshlab 2016.12+PCL 1.8.0

solidworks部分
绘制想要渲染成点云数据的模型

另存为的时候选择STL文件

mashlab部分
2.1 File->import mesh->保存的stl文件

选择ok

点击就可以看到模型的坐标系
2.2修改坐标系
Filters->normal, curvatures and orientation->transform:rotation(旋转)//translate, center, set origin(平移)
根据包围盒的坐标修改自己想要的坐标系
2.3蒙特卡诺滤波
Filters->sampling-> montecarlo sampling

保存的时候选择ply的点云格式 就可以使用PCL打开了

pcl::PointCloud<pcl::PointXYZ>::Ptr chip(new pcl::PointCloud<pcl::PointXYZ>);
	if (pcl::io::loadPLYFile<pcl::PointXYZ>("1.ply", *chip) == -1) //* load the file
	{
		PCL_ERROR("Couldn't read file test_pcd.pcd \n");
		return (-1);
	}
	else {
		cout << "chip's size is" << chip->size() << endl;
	}