创建了基于8.3示例:约束Delaunay三角剖分的简单程序。并且只想将其导出到一些常见的网格文件格式,如vtk、msh等,以便能够在GMesh或ParaView中打开它。为此,我发现最简单的方法是使用write_VTU。在示例代码的开头和结尾,我接下来添加了以下内容:
#include <CGAL/IO/write_VTU.h>
#include <fstream>
...
//example 8.3
...
std::ofstream mesh_file("mesh.VTU");
CGAL::write_vtu(mesh_file, cdt);
mesh_file.close();
...因此,得到这样的编译时错误:
[build] In file included from /home/oleg/Документи/riversim/source/../include/RiverSim.hpp:5,
[build] from /home/oleg/Документи/riversim/source/main.cpp:1:
[build] /usr/local/include/CGAL/IO/write_VTU.h: In instantiation of ‘void CGAL::IO::internal::write_VTU_with_attributes(std::ostream&, const CDT&, std::vector<std::pair<const char*, const std::vector<double>*> >&, CGAL::IO::Mode) [with CDT = CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Default, CGAL::Exact_predicates_tag>; std::ostream = std::basic_ostream<char>]’:
[build] /usr/local/include/CGAL/IO/write_VTU.h:395:38: required from ‘void CGAL::IO::write_VTU(std::ostream&, const CDT&, CGAL::IO::Mode) [with CDT = CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Default, CGAL::Exact_predicates_tag>; std::ostream = std::basic_ostream<char>]’
[build] /usr/local/include/CGAL/IO/write_VTU.h:406:16: required from ‘void CGAL::write_vtu(std::ostream&, const CDT&, CGAL::IO::Mode) [with CDT = CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Default, CGAL::Exact_predicates_tag>; std::ostream = std::basic_ostream<char>]’
[build] /home/oleg/Документи/riversim/source/../include/RiverSim.hpp:44:47: required from here
[build] /usr/local/include/CGAL/IO/write_VTU.h:358:13: error: ‘class CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<void> > > > > > >’ has no member named ‘is_in_domain’
[build] 358 | if(fit->is_in_domain()) ++number_of_triangles;
[build] | ~~~~~^~~~~~~~~~~~
[build] make[2]: *** [source/CMakeFiles/river.dir/build.make:63: source/CMakeFiles/river.dir/main.cpp.o] Помилка 1
[build] make[1]: *** [CMakeFiles/Makefile2:96: source/CMakeFiles/river.dir/all] Помилка 2
[build] make: *** [Makefile:84: all] Помилка 2
[build] Build finished with exit code 2我使用write_vtu或更一般的方法有什么问题:如何将网格对象(约束)导出到文件(msh、vtk、vtu等)。
UPD:示例8.4提供了相同的错误。
发布于 2021-12-17 08:16:45
正如记录的这里一样,三角剖分的人脸类型必须是DelaunayMeshFaceBase_2的模型。例如,您可以像在Delaunay_mesh_face_base_2中一样使用这个例子。
发布于 2021-12-18 23:15:25
请注意,有一个Python接口,吡咯烷酮 (由我编写),让我们很容易地做到这一点:
import numpy as np
import pygalmesh
points = np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]])
constraints = [[0, 1], [1, 2], [2, 3], [3, 0]]
mesh = pygalmesh.generate_2d(
points,
constraints,
max_edge_size=1.0e-1,
num_lloyd_steps=10,
)
# save in whatever format is supported by meshio
# https://github.com/nschloe/meshio
mesh.write("out.vtk") https://stackoverflow.com/questions/70383755
复制相似问题