CGAL生成简单形状

三角形

四边形

立方体

六面体

棱柱

锥体

二十面体

网格

cpp 复制代码
	Polyhedron _mesh;

	/**************三角形************/
	CGAL::make_triangle(K::Point_3(100, 0, 0), K::Point_3(0, 100, 0), K::Point_3(0, 0, 0), _mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/triangle.stl", _mesh);
	_mesh.clear();

	/**************四边形************/
	CGAL::make_quad(K::Point_3(0, 0, 0), K::Point_3(100, 0, 0), K::Point_3(100, 100, 0), K::Point_3(0, 100, 0), _mesh);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/quad.stl", _mesh);	
	_mesh.clear();

	/**************立方体************/
	K::Iso_cuboid_3 cubte(K::Point_3(0, 0, 0), K::Point_3(100, 100, 100));
	CGAL::make_hexahedron(cubte, _mesh);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/cubte.stl", _mesh);	
	_mesh.clear();

	/**************六面体(下面的点顺时针,上面的点逆时针,与下面的一一对应)************/
	CGAL::make_hexahedron(
		K::Point_3(0, 0, 0), K::Point_3(100, 0, 0), K::Point_3(120, 120, 0), K::Point_3(0, 90, 0),
		K::Point_3(0, 0, 100), K::Point_3(110, 0,100), K::Point_3(100, 100, 130), K::Point_3(0, 100, 100),
		_mesh);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/hexahedron.stl", _mesh);
	_mesh.clear();

	/**************正棱柱************/
	CGAL::make_regular_prism(36, _mesh, K::Point_3(0, 0, 0),100, 20);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/regular_prism.stl", _mesh);
	_mesh.clear();

	/**************锥体(金字塔)************/
	CGAL::make_pyramid(36, _mesh, K::Point_3(0, 0, 0),100, 20);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/pyramid.stl", _mesh);
	_mesh.clear();

	/**************二十面体************/
	CGAL::make_icosahedron(_mesh, K::Point_3(0, 0, 0),5);
	CGAL::Polygon_mesh_processing::triangulate_faces(_mesh);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/icosahedron.stl", _mesh);
	_mesh.clear();

	/**************网格************/
	CGAL::make_grid(10, 20, _mesh, true);
	CGAL::IO::write_polygon_mesh("F:/WORK/STL/grid.stl", _mesh);
相关推荐
Tri_Function1 小时前
动态规划DP1(c++)
c++
清水迎朝阳4 小时前
客户端软件 — 用户统计方案
服务器·c++·客户端·用户统计
再卷也是菜5 小时前
C++17(下)
c++
alexwang2115 小时前
HDU 4348 详细题解
c++·算法·题解·hdu·主席树·可持久化数据结构·可持久化线段树
程序员zgh5 小时前
C++ 拷贝赋值运算符 详解
c语言·开发语言·c++
皓月斯语7 小时前
B2132 素数对
c++·算法·题解
星轨初途8 小时前
LeetCode 热题 100——day2 字母异位词分组
c++·算法·leetcode
笨鸟先飞的橘猫8 小时前
c++面向对象编程
开发语言·c++
啦啦啦啦啦zzzz9 小时前
设计模式:桥接模式和组合模式
c++·设计模式·组合模式·桥接模式
-森屿安年-9 小时前
647. 回文子串
c++·算法·动态规划