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

在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);
				}
相关推荐
_殊途1 小时前
《Java HashMap底层原理全解析(源码+性能+面试)》
java·数据结构·算法
还债大湿兄1 小时前
《C++内存泄漏8大战场:Qt/MFC实战详解 + 面试高频陷阱破解》
c++·qt·mfc
珊瑚里的鱼4 小时前
LeetCode 692题解 | 前K个高频单词
开发语言·c++·算法·leetcode·职场和发展·学习方法
AI+程序员在路上4 小时前
QTextCodec的功能及其在Qt5及Qt6中的演变
开发语言·c++·qt
Risehuxyc5 小时前
C++卸载了会影响电脑正常使用吗?解析C++运行库的作用与卸载后果
开发语言·c++
秋说5 小时前
【PTA数据结构 | C语言版】顺序队列的3个操作
c语言·数据结构·算法
lifallen6 小时前
Kafka 时间轮深度解析:如何O(1)处理定时任务
java·数据结构·分布式·后端·算法·kafka
liupenglove6 小时前
自动驾驶数据仓库:时间片合并算法。
大数据·数据仓库·算法·elasticsearch·自动驾驶
python_tty7 小时前
排序算法(二):插入排序
算法·排序算法
然我7 小时前
面试官:如何判断元素是否出现过?我:三种哈希方法任你选
前端·javascript·算法