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

在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);
				}
相关推荐
pusue_the_sun37 分钟前
数据结构——栈和队列oj练习
c语言·数据结构·算法··队列
大锦终38 分钟前
【算法】模拟专题
c++·算法
方传旺1 小时前
C++17 std::optional 深拷贝 vs 引用:unordered_map 查询大对象性能对比
c++
Dontla1 小时前
Makefile介绍(Makefile教程)(C/C++编译构建、自动化构建工具)
c语言·c++·自动化
Xの哲學1 小时前
Perf使用详解
linux·网络·网络协议·算法·架构
想不明白的过度思考者1 小时前
数据结构(排序篇)——七大排序算法奇幻之旅:从扑克牌到百亿数据的魔法整理术
数据结构·算法·排序算法
小七rrrrr2 小时前
动态规划法 - 53. 最大子数组和
java·算法·动态规划
code小毛孩2 小时前
leetcodehot100 矩阵置零
算法
何妨重温wdys2 小时前
矩阵链相乘的最少乘法次数(动态规划解法)
c++·算法·矩阵·动态规划
重启的码农2 小时前
ggml 介绍 (6) 后端 (ggml_backend)
c++·人工智能·神经网络