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);
相关推荐
CoderCodingNo1 分钟前
【GESP】C++四级真题 luogu-B4068 [GESP202412 四级] Recamán
开发语言·c++·算法
一个不知名程序员www3 分钟前
算法学习入门---双指针(C++)
c++·算法
Maple_land17 分钟前
常见Linux环境变量深度解析
linux·运维·服务器·c++·centos
Larry_Yanan25 分钟前
QML学习笔记(四十四)QML与C++交互:对QML对象设置objectName
开发语言·c++·笔记·qt·学习·ui·交互
Want5951 小时前
C/C++大雪纷飞①
c语言·开发语言·c++
Mr_WangAndy1 小时前
C++设计模式_行为型模式_策略模式Strategy
c++·设计模式·策略模式·依赖倒置原则
LoveXming1 小时前
Chapter11—适配器模式
c++·设计模式·适配器模式·开闭原则
Benny_Tang2 小时前
题解:P7989 [USACO21DEC] Bracelet Crossings G
c++·算法
小白杨树树2 小时前
【C++】力扣hot100错误总结
c++·leetcode·c#
ajassi20002 小时前
开源 C++ QT QML 开发(二十三)程序发布
c++·qt·mfc