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

在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);
				}
相关推荐
KMDxiaozuanfeng11 小时前
卡梅德生物技术快报|SPR 技术应用|基于 SPR 亲和力的中药活性成分筛选系统实现与数据分析
科技·算法·面试·考试
水饺编程12 小时前
第5章,[标签 Win32] :获取设备环境的信息
c语言·c++·windows·visual studio
lhbian12 小时前
C++、C与易语言:编程语言对比解析
c语言·开发语言·c++
꧁细听勿语情꧂12 小时前
数据结构概念和算法、时间复杂度、空间复杂度引入
c语言·开发语言·数据结构·算法
hehelm12 小时前
二叉搜索树
c++
Felven12 小时前
B. The 67th 6-7 Integer Problem
数据结构·算法
玉树临风ives12 小时前
atcoder ABC 454 题解
算法·深度优先·图论
钮钴禄·爱因斯晨12 小时前
聚焦操作系统中的PV操作
数据库·算法·系统架构·c#
云泽80812 小时前
笔试算法 - 双指针篇(一):移动零、复写零、快乐数与盛水容器
c++·算法
小堃学编程12 小时前
【项目实战】基于protobuf的发布订阅式消息队列(4)—— 服务端
c语言·c++·vscode·消息队列·gtest·protobuf·muduo