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

在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);
				}
相关推荐
H_z___12 分钟前
Codeforces Round 1070 (Div. 2) A~D F
数据结构·算法
晨尘光28 分钟前
【Windows 下FlatBuffers 编译.fbs文件并应用】
c++·windows
自学小白菜34 分钟前
每周刷题 - 第三周 - 双指针专题 - 02
python·算法·leetcode
杜子不疼.1 小时前
【LeetCode76_滑动窗口】最小覆盖子串问题
算法·哈希算法
煤球王子1 小时前
学而时习之:C++中的文件处理2
c++
ComputerInBook1 小时前
代数基本概念理解——特征向量和特征值
人工智能·算法·机器学习·线性变换·特征值·特征向量
不能只会打代码1 小时前
力扣--3433. 统计用户被提及情况
java·算法·leetcode·力扣
fakerth1 小时前
【OpenHarmony】设计模式模块详解
c++·单例模式·设计模式·openharmony
biter down2 小时前
C++ 解决海量数据 TopK 问题:小根堆高效解法
c++·算法
用户6600676685392 小时前
斐波那契数列:从递归到缓存优化的极致拆解
前端·javascript·算法