Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions include/geode/io/model/internal/msh_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
#include <geode/model/representation/builder/brep_builder.hpp>
#include <geode/model/representation/core/brep.hpp>

namespace geode

Check warning on line 60 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:60:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace internal
{
struct GmshElementID

Check warning on line 64 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:64:16 [cppcoreguidelines-pro-type-member-init]

constructor does not initialize these fields: id
{
GmshElementID() = default;
GmshElementID(
Expand Down Expand Up @@ -94,7 +94,7 @@
};
} // namespace std

namespace geode

Check warning on line 97 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:97:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace internal
{
Expand All @@ -104,14 +104,14 @@
{
GmshId2Uuids() = default;

bool contains_elementary_id(

Check warning on line 107 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:107:13 [modernize-use-nodiscard]

function 'contains_elementary_id' should be marked [[nodiscard]]
const GmshElementID& elementary_id ) const
{
return elementary_ids.find( elementary_id )
!= elementary_ids.end();
}

bool contains_physical_id( const GmshElementID& physical_id ) const

Check warning on line 114 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:114:13 [modernize-use-nodiscard]

function 'contains_physical_id' should be marked [[nodiscard]]
{
return physical_ids.find( physical_id ) != physical_ids.end();
}
Expand All @@ -119,19 +119,19 @@
absl::flat_hash_map< GmshElementID, uuid > physical_ids;
};

class GMSHElement

Check warning on line 122 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:122:15 [cppcoreguidelines-special-member-functions]

class 'GMSHElement' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
{
public:
GMSHElement( geode::index_t physical_entity_id,
geode::index_t elementary_entity_id,

Check warning on line 126 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:126:17 [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'GMSHElement' of similar type ('geode::index_t') are easily swapped by mistake
geode::index_t nb_vertices,
absl::Span< const std::string_view > vertex_ids )
: physical_entity_id_( std::move( physical_entity_id ) ),

Check warning on line 129 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:129:40 [hicpp-move-const-arg]

std::move of the variable 'physical_entity_id' of the trivially-copyable type 'geode::index_t' (aka 'unsigned int') has no effect; remove std::move()
elementary_entity_id_( std::move( elementary_entity_id ) ),

Check warning on line 130 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:130:42 [hicpp-move-const-arg]

std::move of the variable 'elementary_entity_id' of the trivially-copyable type 'geode::index_t' (aka 'unsigned int') has no effect; remove std::move()
nb_vertices_( nb_vertices ),
vertex_ids_str_( vertex_ids )
{
OpenGeodeIOModelException::check_exception(

Check failure on line 134 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:134:17 [clang-diagnostic-error]

use of undeclared identifier 'OpenGeodeIOModelException'; did you mean 'OpenGeodeModelException'?
elementary_entity_id > 0, nullptr,
OpenGeodeException::TYPE::data,
"[GMSHElement] GMSH tag for elementary entity "
Expand All @@ -152,7 +152,7 @@
virtual void add_element(
geode::BRep& brep, GmshId2Uuids& id_map ) = 0;

geode::index_t physical_entity_id()

Check warning on line 155 in include/geode/io/model/internal/msh_common.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/model/internal/msh_common.hpp:155:28 [readability-make-member-function-const]

method 'physical_entity_id' can be made const
{
return physical_entity_id_;
}
Expand Down Expand Up @@ -229,7 +229,8 @@
}

const auto v_id =
builder.corner_mesh_builder( corner_uuid )->create_vertex();
builder.corner_mesh_builder( brep.corner( corner_uuid ) )
->create_vertex();
builder.set_unique_vertex(
{ brep.corner( corner_uuid ).component_id(), v_id },
vertex_ids()[0] - GMSH_OFFSET_START );
Expand Down Expand Up @@ -265,14 +266,13 @@
line_uuid = builder.add_line();
id_map.elementary_ids.insert( { cur_gmsh_id, line_uuid } );
}
const auto& line = brep.line( line_uuid );
const auto first_v_id =
builder.line_mesh_builder( line_uuid )
->create_vertices( vertex_ids().size() );
builder.line_mesh_builder( line )->create_vertices(
vertex_ids().size() );
const auto edge_id =
builder.line_mesh_builder( line_uuid )
->create_edge( first_v_id, first_v_id + 1 );

const auto& line = brep.line( line_uuid );
builder.line_mesh_builder( line )->create_edge(
first_v_id, first_v_id + 1 );
for( const auto v_id : geode::LIndices{ vertex_ids() } )
{
builder.set_unique_vertex(
Expand Down Expand Up @@ -314,16 +314,16 @@
id_map.elementary_ids.insert(
{ cur_gmsh_id, surface_uuid } );
}
const auto& surface = brep.surface( surface_uuid );
const auto first_v_id =
builder.surface_mesh_builder( surface_uuid )
->create_vertices( vertex_ids().size() );
builder.surface_mesh_builder( surface )->create_vertices(
vertex_ids().size() );
std::vector< geode::index_t > v_ids( vertex_ids().size() );
std::iota( v_ids.begin(), v_ids.end(), first_v_id );
const auto polygon_id =
builder.surface_mesh_builder( surface_uuid )
->create_polygon( v_ids );
builder.surface_mesh_builder( surface )->create_polygon(
v_ids );

const auto& surface = brep.surface( surface_uuid );
for( const auto v_id : geode::LIndices{ vertex_ids() } )
{
builder.set_unique_vertex(
Expand Down Expand Up @@ -372,7 +372,7 @@

virtual geode::index_t create_gmsh_polyhedron(
geode::BRepBuilder& builder,
const uuid& block_uuid,
const Block3D& block,
const std::vector< geode::index_t >& v_ids ) = 0;

void add_element( geode::BRep& brep, GmshId2Uuids& id_map ) final
Expand All @@ -395,16 +395,16 @@
geode::HybridSolid3D::type_name_static() ) );
id_map.elementary_ids.insert( { cur_gmsh_id, block_uuid } );
}
const auto& block = brep.block( block_uuid );

const auto first_v_id =
builder.block_mesh_builder( block_uuid )
->create_vertices( vertex_ids().size() );
builder.block_mesh_builder( block )->create_vertices(
vertex_ids().size() );
std::vector< geode::index_t > v_ids( vertex_ids().size() );
std::iota( v_ids.begin(), v_ids.end(), first_v_id );
const auto polyhedron_id =
create_gmsh_polyhedron( builder, block_uuid, v_ids );
create_gmsh_polyhedron( builder, block, v_ids );

const auto& block = brep.block( block_uuid );
for( const auto v_id : geode::LIndices{ vertex_ids() } )
{
builder.set_unique_vertex(
Expand All @@ -427,15 +427,15 @@
}

geode::index_t create_gmsh_polyhedron( geode::BRepBuilder& builder,
const uuid& block_uuid,
const Block3D& block,
const std::vector< geode::index_t >& v_ids ) override final
{
static const std::array< std::vector< geode::local_index_t >,
4 >
gmsh_tetrahedron_faces{ { { 0, 1, 2 }, { 0, 2, 3 },
{ 1, 3, 2 }, { 0, 3, 1 } } };
return builder.block_mesh_builder( block_uuid )
->create_polyhedron( v_ids, gmsh_tetrahedron_faces );
return builder.block_mesh_builder( block )->create_polyhedron(
v_ids, gmsh_tetrahedron_faces );
}
};

Expand All @@ -451,16 +451,16 @@
}

geode::index_t create_gmsh_polyhedron( geode::BRepBuilder& builder,
const uuid& block_uuid,
const Block3D& block,
const std::vector< geode::index_t >& v_ids ) override final
{
static const std::array< std::vector< geode::local_index_t >,
6 >
gmsh_hexahedron_faces{ { { 0, 1, 2, 3 }, { 7, 6, 5, 4 },
{ 0, 3, 7, 4 }, { 1, 5, 6, 2 }, { 2, 6, 7, 3 },
{ 0, 4, 5, 1 } } };
return builder.block_mesh_builder( block_uuid )
->create_polyhedron( v_ids, gmsh_hexahedron_faces );
return builder.block_mesh_builder( block )->create_polyhedron(
v_ids, gmsh_hexahedron_faces );
}
};

Expand All @@ -476,15 +476,15 @@
}

geode::index_t create_gmsh_polyhedron( geode::BRepBuilder& builder,
const uuid& block_uuid,
const Block3D& block,
const std::vector< geode::index_t >& v_ids ) override final
{
static const std::array< std::vector< geode::local_index_t >,
5 >
gmsh_prism_faces{ { { 0, 1, 2 }, { 5, 4, 3 },
{ 0, 2, 5, 3 }, { 0, 3, 4, 1 }, { 1, 4, 5, 2 } } };
return builder.block_mesh_builder( block_uuid )
->create_polyhedron( v_ids, gmsh_prism_faces );
return builder.block_mesh_builder( block )->create_polyhedron(
v_ids, gmsh_prism_faces );
}
};

Expand All @@ -500,15 +500,15 @@
}

geode::index_t create_gmsh_polyhedron( geode::BRepBuilder& builder,
const uuid& block_uuid,
const Block3D& block,
const std::vector< geode::index_t >& v_ids ) override final
{
static const std::array< std::vector< geode::local_index_t >,
5 >
gmsh_pyramid_faces{ { { 0, 3, 4 }, { 0, 4, 1 }, { 4, 3, 2 },
{ 1, 4, 2 }, { 0, 1, 2, 3 } } };
return builder.block_mesh_builder( block_uuid )
->create_polyhedron( v_ids, gmsh_pyramid_faces );
return builder.block_mesh_builder( block )->create_polyhedron(
v_ids, gmsh_pyramid_faces );
}
};

Expand Down
16 changes: 7 additions & 9 deletions src/geode/io/model/msh_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ namespace
{
for( const auto& c : brep_.corners() )
{
builder_.corner_mesh_builder( c.id() )->set_point(
builder_.corner_mesh_builder( c )->set_point(
0, nodes_[brep_.unique_vertex( { c.component_id(), 0 } )] );
}
}
Expand All @@ -613,7 +613,7 @@ namespace
for( const auto& l : brep_.lines() )
{
filter_duplicated_line_vertices( l, brep_ );
auto line_builder = builder_.line_mesh_builder( l.id() );
auto line_builder = builder_.line_mesh_builder( l );
for( const auto v : geode::Range{ l.mesh().nb_vertices() } )
{
line_builder->set_point(
Expand All @@ -628,8 +628,7 @@ namespace
for( const auto& surface : brep_.surfaces() )
{
filter_duplicated_surface_vertices( surface, brep_ );
auto surface_builder =
builder_.surface_mesh_builder( surface.id() );
auto surface_builder = builder_.surface_mesh_builder( surface );
const auto& mesh = surface.mesh();
for( const auto v : geode::Range{ mesh.nb_vertices() } )
{
Expand Down Expand Up @@ -692,7 +691,7 @@ namespace
for( const auto& b : brep_.blocks() )
{
filter_duplicated_block_vertices( b, brep_ );
auto block_builder = builder_.block_mesh_builder( b.id() );
auto block_builder = builder_.block_mesh_builder( b );
for( const auto v : geode::Range{ b.mesh().nb_vertices() } )
{
block_builder->set_point(
Expand Down Expand Up @@ -780,24 +779,23 @@ namespace
void filter_duplicated_line_vertices(
const geode::Line3D& line, geode::BRep& brep )
{
auto builder =
geode::BRepBuilder{ brep }.line_mesh_builder( line.id() );
auto builder = geode::BRepBuilder{ brep }.line_mesh_builder( line );
filter_duplicated_vertices( line, brep, *builder );
}

void filter_duplicated_surface_vertices(
const geode::Surface3D& surface, geode::BRep& brep )
{
auto builder =
geode::BRepBuilder{ brep }.surface_mesh_builder( surface.id() );
geode::BRepBuilder{ brep }.surface_mesh_builder( surface );
filter_duplicated_vertices( surface, brep, *builder );
}

void filter_duplicated_block_vertices(
const geode::Block3D& block, geode::BRep& brep )
{
auto builder =
geode::BRepBuilder{ brep }.block_mesh_builder( block.id() );
geode::BRepBuilder{ brep }.block_mesh_builder( block );
filter_duplicated_vertices( block, brep, *builder );
}

Expand Down
5 changes: 3 additions & 2 deletions src/geode/io/model/svg_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ namespace
return;
}
const auto& line_id = builder_.add_line();
const auto line_builder = builder_.line_mesh_builder( line_id );
const auto line_builder =
builder_.line_mesh_builder( section_.line( line_id ) );
line_builder->create_point( vertices.front() );
for( const auto v : geode::Range{ 1, vertices.size() } )
{
Expand All @@ -377,7 +378,7 @@ namespace
for( const auto& unique_point : colocated_info.unique_points )
{
const auto corner_id = builder_.add_corner();
builder_.corner_mesh_builder( corner_id )
builder_.corner_mesh_builder( section_.corner( corner_id ) )
->create_point( unique_point );
const auto uv_id = builder_.create_unique_vertex();
builder_.set_unique_vertex(
Expand Down
Loading