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

在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);
				}
相关推荐
白太岁2 分钟前
Muduo:(0) 架构与接口总览
c++·架构·tcp
闻缺陷则喜何志丹4 分钟前
微分中值定理与导数的应用
c++·高等数学·微分·中值定理·导数应用
tankeven5 分钟前
HJ94 记票统计
c++·算法
逆境不可逃9 分钟前
LeetCode 热题 100 之 76.最小覆盖子串
java·算法·leetcode·职场和发展·滑动窗口
I_LPL15 分钟前
day35 代码随想录算法训练营 动态规划专题3
java·算法·动态规划·hot100·求职面试
DeepModel19 分钟前
【回归算法】多项式回归详解
算法·回归
Frostnova丶36 分钟前
LeetCode 761. 特殊的二进制字符串
算法·leetcode
mjhcsp1 小时前
C++ 树形 DP解析
开发语言·c++·动态规划·代理模式
犽戾武1 小时前
RK3588 上 ROS2 Humble + 串口机械臂驱动(ROS2安装流程 + V1版本Serial驱动)
c++
dgaf1 小时前
DX12 快速教程(15) —— 多实例渲染
c++·microsoft·图形渲染·visual studio·d3d12