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);
相关推荐
Studying 开龙wu35 分钟前
Windos 10系统安装OpenPose的CPU版本过程说明和Release版本直接使用
c++·windows
温柔の敲代码1 小时前
从微观到宏观了解C++项目的编译
开发语言·c++
另寻沧海1 小时前
C++ Lambda表达式的隐式转换陷阱
java·c++·算法
好评1241 小时前
C++ 字符串:始于 char*,终于深拷贝
开发语言·c++·stl·字符串
小尧嵌入式1 小时前
QT软件开发知识点流程及记事本开发
服务器·开发语言·数据库·c++·qt
冷崖1 小时前
单例模式-创建型
c++·单例模式
明洞日记2 小时前
【VTK手册024】高效等值面提取:vtkFlyingEdges3D 详解与实战
c++·图像处理·vtk·图形渲染
遥望九龙湖2 小时前
3.析构函数
开发语言·c++
qq_479875432 小时前
systemd-resolved.service实验实战3
linux·服务器·c++
闻缺陷则喜何志丹2 小时前
【图论 组合数学】P10912 [蓝桥杯 2024 国 B] 数星星|普及+
c++·数学·蓝桥杯·图论