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

在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);
				}
相关推荐
FirstFrost --sy1 小时前
仿mudou库one thread one loop式并发服务器实现
运维·服务器·开发语言·c++
x_xbx1 小时前
LeetCode:27. 移除元素
数据结构·算法·leetcode
云泽8081 小时前
C++ map 底层探秘:从结构设计到 operator [] 实现的全解析
数据结构·c++·算法
小O的算法实验室2 小时前
2026年EAAI SCI1区TOP,基于LLM驱动的多群粒子群算法动态通信策略生成方法,深度解析+性能实测
算法·论文复现·智能算法·智能算法改进
午彦琳2 小时前
leetcode hot 100_49,128
算法·leetcode·职场和发展
..过云雨2 小时前
【负载均衡oj项目】01. 项目概述及准备工作
linux·c++·html·json·负载均衡
郝学胜-神的一滴2 小时前
深度解析:Python元类手撸ORM框架,解锁底层编程魔法
数据结构·数据库·python·算法·职场和发展
yuuki2332332 小时前
【C++ 智能指针全解析】从内存泄漏痛点到 RAII + unique/shared/weak_ptr 手撕实现
开发语言·c++
big_rabbit05022 小时前
[算法][力扣219]存在重复元素2
数据结构·算法·leetcode
闻缺陷则喜何志丹2 小时前
【构造 前缀和】P8902 [USACO22DEC] Range Reconstruction S|普及+
c++·算法·前缀和·洛谷·构造