40 #include <geogram/basic/command_line.h> 42 #include <geogram/mesh/mesh_preprocessing.h> 44 #include <geogram/voronoi/CVT.h> 51 #define COMMON_GEOGRAM_MESH_BUILDER_IMPLEMENTATION( Class ) \ 53 void do_copy( const MeshBase< DIMENSION >& rhs, bool copy_attributes ) \ 56 const auto& geogrammesh = \ 57 dynamic_cast< const Class< DIMENSION >& >( rhs ); \ 59 *geogrammesh.mesh_, copy_attributes, GEO::MESH_ALL_ELEMENTS ); \ 61 void load_mesh( const std::string& filename ) override \ 63 GEO::MeshIOFlags ioflags; \ 64 ioflags.set_attribute( GEO::MESH_ALL_ATTRIBUTES ); \ 65 GEO::mesh_load( filename, *mesh_.mesh_, ioflags ); \ 67 void do_clear( bool keep_attributes, bool keep_memory ) override \ 69 mesh_.mesh_->clear( keep_attributes, keep_memory ); \ 71 void do_repair( GEO::MeshRepairMode mode, double colocate_epsilon ) \ 74 GEO::mesh_repair( *mesh_.mesh_, mode, colocate_epsilon ); \ 76 void do_set_vertex( index_t v_id, const vecn< DIMENSION >& vertex ) \ 79 mesh_.ref_vertex( v_id ) = vertex; \ 81 index_t do_create_vertex() override \ 83 return mesh_.mesh_->vertices.create_vertex(); \ 85 index_t do_create_vertices( index_t nb ) override \ 87 return mesh_.mesh_->vertices.create_vertices( nb ); \ 89 void do_assign_vertices( const std::vector< double >& point_coordinates ) \ 92 GEO::vector< double > point_coordinates_cp = \ 93 copy_std_vector_to_geo_vector( point_coordinates ); \ 94 mesh_.mesh_->vertices.assign_points( \ 95 point_coordinates_cp, DIMENSION, false ); \ 97 void do_delete_vertices( const std::vector< bool >& to_delete ) override \ 99 GEO::vector< index_t > vertices_to_delete = \ 100 copy_std_vector_to_geo_vector< bool, index_t >( to_delete ); \ 101 mesh_.mesh_->vertices.delete_elements( vertices_to_delete, false ); \ 103 void do_clear_vertices( bool keep_attributes, bool keep_memory ) override \ 105 mesh_.mesh_->vertices.clear( keep_attributes, keep_memory ); \ 107 void do_permute_vertices( const std::vector< index_t >& permutation ) \ 110 GEO::vector< index_t > geo_vector_permutation = \ 111 copy_std_vector_to_geo_vector( permutation ); \ 112 mesh_.mesh_->vertices.permute_elements( geo_vector_permutation ); \ 116 Class< DIMENSION >& mesh_ 118 template < index_t DIMENSION >
134 template < index_t DIMENSION >
149 mesh_.mesh_->edges.create_edge( v1_id, v2_id );
154 return mesh_.mesh_->edges.create_edges( nb_edges );
158 index_t vertex_id )
override 160 mesh_.mesh_->edges.set_vertex( edge_local_vertex.
edge_id_,
166 GEO::vector< index_t > edges_to_delete =
167 copy_std_vector_to_geo_vector< bool, index_t >( to_delete );
168 mesh_.mesh_->edges.delete_elements( edges_to_delete,
false );
173 mesh_.mesh_->edges.clear( keep_attributes, keep_memory );
177 const std::vector< index_t >& permutation )
override 179 GEO::vector< index_t > geo_vector_permutation =
181 mesh_.mesh_->edges.permute_elements( geo_vector_permutation );
187 template < index_t DIMENSION >
201 double min_area, index_t min_polygons )
override 203 GEO::remove_small_connected_components(
204 *mesh_.mesh_, min_area, min_polygons );
211 const auto& geogram_surf_in =
214 GEO::CentroidalVoronoiTesselation CVT( geogram_surf_in.mesh_.get(),
215 3, GEO::CmdLine::get_arg(
"algo:delaunay" ) );
217 mesh_.nb_vertices(), mesh_.mesh_->vertices.point_ptr( 0 ) );
218 CVT.compute_surface( mesh_.mesh_.get(), false );
223 const std::vector< index_t >& polygon_ptr )
override 225 for(
auto p :
range( polygon_ptr.size() - 1 ) )
227 index_t start = polygon_ptr[p];
228 index_t end = polygon_ptr[p + 1];
229 GEO::vector< index_t > polygon_vertices =
231 mesh_.mesh_->facets.create_polygon( polygon_vertices );
236 const std::vector< index_t >& vertices )
override 238 GEO::vector< index_t > polygon_vertices =
240 return mesh_.mesh_->facets.create_polygon( polygon_vertices );
245 return mesh_.mesh_->facets.create_triangles( nb_triangles );
250 return mesh_.mesh_->facets.create_quads( nb_quads );
255 index_t vertex_id )
override 257 mesh_.mesh_->facets.set_vertex( polygon_local_edge.
polygon_id_,
263 index_t specifies )
override 265 mesh_.mesh_->facets.set_adjacent( polygon_local_edge.
polygon_id_,
270 bool keep_attributes,
bool keep_memory )
override 272 mesh_.mesh_->facets.clear( keep_attributes, keep_memory );
276 const std::vector< index_t >& permutation )
override 278 GEO::vector< index_t > geo_vector_permutation =
280 mesh_.mesh_->facets.permute_elements( geo_vector_permutation );
285 GEO::vector< index_t > polygons_to_delete =
286 copy_std_vector_to_geo_vector< bool, index_t >( to_delete );
287 mesh_.mesh_->facets.delete_elements( polygons_to_delete,
false );
293 template < index_t DIMENSION >
308 return mesh_.mesh_->cells.create_cells(
309 nb_cells, static_cast< GEO::MeshCellType >( type ) );
313 const std::vector< index_t >& tets )
override 316 mesh_.mesh_->cells.assign_tet_mesh( copy,
false );
320 index_t vertex_id )
override 322 mesh_.mesh_->cells.set_vertex( cell_local_vertex.
element_id_,
327 index_t corner_index, index_t vertex_index )
override 329 mesh_.mesh_->cell_corners.set_vertex( corner_index, vertex_index );
333 index_t cell_adjacent )
override 335 mesh_.mesh_->cells.set_adjacent( cell_local_facet.
cell_id_,
341 mesh_.mesh_->cells.connect();
346 mesh_.mesh_->cells.clear( keep_attributes, keep_memory );
350 const std::vector< index_t >& permutation )
override 352 GEO::vector< index_t > geo_vector_permutation =
354 mesh_.mesh_->cells.permute_elements( geo_vector_permutation );
359 GEO::vector< index_t > geo_to_delete =
360 copy_std_vector_to_geo_vector< bool, index_t >( to_delete );
361 mesh_.mesh_->cells.delete_elements( geo_to_delete,
false );
void do_permute_polygons(const std::vector< index_t > &permutation) override
void do_permute_cells(const std::vector< index_t > &permutation) override
Applies a permutation to the entities and their attributes. On exit, permutation is modified (used fo...
void do_clear_cells(bool keep_attributes, bool keep_memory) override
Removes all the cells and attributes.
void do_delete_edges(const std::vector< bool > &to_delete) override
Deletes a set of edges.
index_t do_create_triangles(index_t nb_triangles) override
Creates a contiguous chunk of triangles.
void do_permute_edges(const std::vector< index_t > &permutation) override
void do_set_edge_vertex(const EdgeLocalVertex &edge_local_vertex, index_t vertex_id) override
Sets a vertex of a edge by local vertex index.
void do_create_edge(index_t v1_id, index_t v2_id) override
Create a new edge.
index_t do_create_edges(index_t nb_edges) override
Creates a contiguous chunk of edges.
#define ringmesh_template_assert_3d(type)
void do_set_cell_vertex(const ElementLocalVertex &cell_local_vertex, index_t vertex_id) override
Sets a vertex of a cell by local vertex index.
void copy(const MeshBase< DIMENSION > &rhs, bool copy_attributes)
Copy a mesh into this one.
void remove_small_connected_components(double min_area, index_t min_polygons) override
Removes the connected components that have an area smaller than a given threshold.
void do_assign_cell_tet_mesh(const std::vector< index_t > &tets) override
COMMON_GEOGRAM_MESH_BUILDER_IMPLEMENTATION(GeogramPointSetMesh)
ringmesh_template_assert_2d_or_3d(DIMENSION)
void do_create_polygons(const std::vector< index_t > &polygons, const std::vector< index_t > &polygon_ptr) override
static GEO::Logger * instance()
void triangulate(const SurfaceMeshBase< DIMENSION > &surface_in) override
index_t do_create_cells(index_t nb_cells, CellType type) override
Creates a contiguous chunk of cells of the same type.
void do_clear_edges(bool keep_attributes, bool keep_memory) override
Removes all the edges and attributes.
void do_delete_cells(const std::vector< bool > &to_delete) override
Deletes a set of cells.
void do_set_cell_corner_vertex_index(index_t corner_index, index_t vertex_index) override
Sets the vertex that a corner is incident to.
void do_delete_polygons(const std::vector< bool > &to_delete) override
Deletes a set of polygons.
void do_set_cell_adjacent(const CellLocalFacet &cell_local_facet, index_t cell_adjacent) override
Sets the cell adjacent.
void do_set_polygon_vertex(const RINGMesh::PolygonLocalEdge &polygon_local_edge, index_t vertex_id) override
Sets a vertex of a polygon by local vertex index.
GEO::vector< U > copy_std_vector_to_geo_vector(const std::vector< T > &in, index_t from, index_t to)
GeogramLineMeshBuilder(LineMesh< DIMENSION > &mesh)
void do_clear_polygons(bool keep_attributes, bool keep_memory) override
Removes all the polygons and attributes.
GeogramSurfaceMeshBuilder(SurfaceMesh< DIMENSION > &mesh)
Classes to build GeoModel from various inputs.
GeogramPointSetMeshBuilder(PointSetMesh< DIMENSION > &mesh)
void do_set_polygon_adjacent(const RINGMesh::PolygonLocalEdge &polygon_local_edge, index_t specifies) override
Sets an adjacent polygon by both its polygon.
index_t do_create_quads(index_t nb_quads) override
Creates a contiguous chunk of quads.
void connect_cells() override
Retrieve the adjacencies.
index_t do_create_polygon(const std::vector< index_t > &vertices) override
Creates a polygon.
GeogramVolumeMeshBuilder(VolumeMesh< DIMENSION > &mesh)