三维图形学知识分享---求平面与模型相交线

在CGAL(Computational Geometry Algorithms Library)中,Polygon_mesh_processing模块提供了用于处理多边形网格数据结构的功能。其中,surface_intersection函数是用来计算模型的表面相交线的工具。

cpp 复制代码
				CGAL_Mesh mesh_orcl;
				std::vector<CGAL_Mesh::Vertex_index> vertexmap;
				for (int j = 0; j < sample; j++)
				{
					Point_3 p(ins_dir[j].x, ins_dir[j].y, ins_dir[j].z);
					CGAL_Mesh::Vertex_index vi = mesh_orcl.add_vertex(p);
					vertexmap.push_back(vi);
				}

				{
					Point_3 p(org.x, org.y, org.z);
					CGAL_Mesh::Vertex_index vi = mesh_orcl.add_vertex(p);
					vertexmap.push_back(vi);
				}

				for (int j = 0; j < sample - 1; j++)
				{
					std::vector<CGAL_Mesh::Vertex_index> vr;
					vr.push_back(vertexmap[j]);
					vr.push_back(vertexmap[j + 1]);
					vr.push_back(vertexmap[vertexmap.size() - 1]);
					CGAL_Mesh::Face_index fi = mesh_orcl.add_face(vr);
				}

				std::vector< std::vector<Point_3> > polyline;

				PMP::surface_intersection(mesh_T, mesh_orcl, std::back_inserter(polyline));

				std::vector<Point_3> line = polyline.at(0);

				std::vector<Point3f> tooth_orc_inter;
				for (int i = 0; i < line.size(); i++)
				{
					Point3f p(line.at(i).x(), line.at(i).y(), line.at(i).z());
					tooth_orc_inter.push_back(p);
				}
相关推荐
GoCoding4 分钟前
YOLO-Master 与 YOLO26 开始
算法
VALENIAN瓦伦尼安教学设备7 分钟前
设备对中不良的危害
数据库·嵌入式硬件·算法
不熬夜的熬润之30 分钟前
APCE-平均峰值相关能量
人工智能·算法·计算机视觉
yzx99101332 分钟前
实时数据流处理实战:从滑动窗口算法到Docker部署
算法·docker·容器
-许平安-36 分钟前
MCP项目笔记六(PluginsLoader)
c++·笔记·raii·plugin system
呜喵王阿尔萨斯38 分钟前
argc & argv
c语言·c++
Vect__1 小时前
std::bind和lambda的使用
c++
她叫我大水龙1 小时前
MSYS2的C/C++,python2,python3编译环境安装脚本
c语言·c++
佩奇大王1 小时前
P674 三羊献瑞
算法·深度优先·图论
发疯幼稚鬼2 小时前
大整数乘法运算
c语言·算法