MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / geomesh_to_mesh

Method geomesh_to_mesh

tools/Geogram/GeogramMeshUtils.cpp:107–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107Mesh::Ptr GeogramMeshUtils::geomesh_to_mesh(const GeoMeshPtr geo_mesh) {
108 constexpr size_t dim = 3;
109 const size_t num_vertices = geo_mesh->vertices.nb();
110 const size_t num_faces = geo_mesh->facets.nb();
111 const size_t num_voxels = geo_mesh->cells.nb();
112
113 const size_t vertex_per_face =
114 num_faces > 0 ? geo_mesh->facets.nb_vertices(0) : 3;
115 const size_t vertex_per_voxel =
116 num_voxels > 0 ? geo_mesh->cells.nb_vertices(0) : 4;
117
118 VectorF vertices(num_vertices * dim);
119 VectorI faces(num_faces * vertex_per_face);
120 VectorI voxels(num_voxels * vertex_per_voxel);
121
122 for (size_t i=0; i<num_vertices; i++) {
123 const auto& v = geo_mesh->vertices.point(i);
124 vertices[i*3] = v[0];
125 vertices[i*3+1] = v[1];
126 vertices[i*3+2] = v[2];
127 }
128 for (size_t i=0; i<num_faces; i++) {
129 if (geo_mesh->facets.nb_vertices(i) != vertex_per_face) {
130 throw NotImplementedError("Mixed faces detected in Geogram."
131 " It is not supported by Pymesh");
132 }
133 for (size_t j=0; j<vertex_per_face; j++) {
134 faces[i*vertex_per_face+j] = geo_mesh->facets.vertex(i, j);
135 }
136 }
137 for (size_t i=0; i<num_voxels; i++) {
138 if (geo_mesh->cells.nb_vertices(i) != vertex_per_voxel) {
139 throw NotImplementedError("Mixed cells detected in Geogram."
140 " It is not supported by Pymesh");
141 }
142 for (size_t j=0; j<vertex_per_voxel; j++) {
143 voxels[i*vertex_per_voxel+j] = geo_mesh->cells.vertex(i, j);
144 }
145 }
146
147 return MeshFactory().load_data(vertices, faces, voxels,
148 dim, vertex_per_face, vertex_per_voxel).create();
149}
150
151#endif

Callers

nothing calls this directly

Calls 4

NotImplementedErrorClass · 0.85
MeshFactoryClass · 0.50
createMethod · 0.45
load_dataMethod · 0.45

Tested by

no test coverage detected