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
7 changes: 2 additions & 5 deletions bindings/python/src/model/mixin/core/component_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ namespace geode
pybind11::class_< ComponentID >( module, "ComponentID" )
.def( pybind11::init<>() )
.def( pybind11::init< ComponentType, uuid >() )
.def( "id", static_cast< const uuid& (ComponentID::*) () const& >(
&ComponentID::id ) )
.def( "type",
static_cast< const ComponentType& (ComponentID::*) () const& >(
&ComponentID::type ) )
.def( "string", &ComponentID::string )
.def_readwrite( "type", &ComponentID::type )
.def_readwrite( "id", &ComponentID::id )
.def( pybind11::self == pybind11::self )
.def( pybind11::self != pybind11::self );
}
Expand Down
12 changes: 6 additions & 6 deletions bindings/python/tests/model/test-py-brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def add_surfaces_in_model_boundaries(brep, builder, surface_uuids, boundary_uuid
if brep.nb_collections(surface_id) != 1:
raise ValueError("[Test] All Surfaces should be in 1 collection")
for collection in brep.collections(surface_id):
if not collection.type().matches(
if not collection.type.matches(
model.ModelBoundary3D.component_type_static()
):
raise ValueError(
Expand All @@ -368,7 +368,7 @@ def add_corners_in_corner_collections(brep, builder, corner_uuids, collection_uu
if brep.nb_collections(corner_id) != 1:
raise ValueError("[Test] All Corners should be in 1 collection")
for collection in brep.collections(corner_id):
if not collection.type().matches(
if not collection.type.matches(
model.CornerCollection3D.component_type_static()
):
raise ValueError(
Expand All @@ -390,7 +390,7 @@ def add_lines_in_line_collections(brep, builder, line_uuids, collection_uuids):
if brep.nb_collections(line_id) != 1:
raise ValueError("[Test] All Lines should be in 1 collection")
for collection in brep.collections(line_id):
if not collection.type().matches(
if not collection.type.matches(
model.LineCollection3D.component_type_static()
):
raise ValueError(
Expand All @@ -412,9 +412,9 @@ def add_surfaces_in_surface_collections(brep, builder, surface_uuids, collection
if brep.nb_collections(surface_id) != 2:
raise ValueError("[Test] All Surfaces should be in 2 collections")
for collection in brep.collections(surface_id):
if not collection.type().matches(
if not collection.type.matches(
model.SurfaceCollection3D.component_type_static()
) and not collection.type().matches(
) and not collection.type.matches(
model.ModelBoundary3D.component_type_static()
):
raise ValueError(
Expand All @@ -430,7 +430,7 @@ def add_blocks_in_block_collections(brep, builder, block_uuid, collection_uuid):
if brep.nb_collections(block_uuid) != 1:
raise ValueError("[Test] All Blocks should be in 1 collection")
for collection in brep.collections(block_uuid):
if not collection.type().matches(
if not collection.type.matches(
model.BlockCollection3D.component_type_static()
):
raise ValueError(
Expand Down
10 changes: 5 additions & 5 deletions bindings/python/tests/model/test-py-section.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def add_lines_in_model_boundaries(section, builder, line_uuids, boundary_uuids):
if section.nb_collections(line_uuids[i]) != 1:
raise ValueError("[Test] This Line should be in 1 collection")
for collection in section.collections(line_uuids[i]):
if not collection.type().matches(model.ModelBoundary2D.component_type_static()):
if not collection.type.matches(model.ModelBoundary2D.component_type_static()):
raise ValueError(
"[Test] This Line should be in 1 collection of type Boundary")
if section.nb_collections(line_uuids[4]) != 0:
Expand All @@ -237,7 +237,7 @@ def add_corners_in_corner_collections(section, builder, corner_uuids, collection
if section.nb_collections(corner_id) != 1:
raise ValueError("[Test] All Corners should be in 1 collection")
for collection in section.collections(corner_id):
if not collection.type().matches(model.CornerCollection2D.component_type_static()):
if not collection.type.matches(model.CornerCollection2D.component_type_static()):
raise ValueError(
"[Test] This corner should be in 1 collection of type CornerCollection")

Expand All @@ -253,15 +253,15 @@ def add_lines_in_line_collections(section, builder, line_uuids, collection_uuids
if section.nb_collections(line_uuids[i]) != 2:
raise ValueError("[Test] This Line should be in 2 collections")
for collection in section.collections(line_uuids[i]):
if not collection.type().matches(model.LineCollection2D.component_type_static()) and not collection.type().matches(model.ModelBoundary2D.component_type_static()):
if not collection.type.matches(model.LineCollection2D.component_type_static()) and not collection.type.matches(model.ModelBoundary2D.component_type_static()):
raise ValueError(
"[Test] This line should be in 2 collection of type LineCollection and ModelBoundary")
for i in range(3,5):
if section.nb_collections(line_uuids[i]) != 1:
raise ValueError(
"[Test] Last Lines should be in 1 collection (of type LineCollection)")
for collection in section.collections(line_uuids[i]):
if not collection.type().matches(model.LineCollection2D.component_type_static()):
if not collection.type.matches(model.LineCollection2D.component_type_static()):
raise ValueError(
"[Test] This line should be in 1 collection of type LineCollection")

Expand All @@ -274,7 +274,7 @@ def add_surfaces_in_surface_collections(section, builder, surface_uuids, collect
if section.nb_collections(surface_id) != 1:
raise ValueError("[Test] All Surfaces should be in 1 collections")
for collection in section.collections(surface_id):
if not collection.type().matches(model.SurfaceCollection2D.component_type_static()):
if not collection.type.matches(model.SurfaceCollection2D.component_type_static()):
raise ValueError(
"[Test] This surface should be in 2 collections of type SurfaceCollection")

Expand Down
4 changes: 2 additions & 2 deletions examples/layer_cake.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"def _corner_from_surface_vertex(brep, surface, vertex):\n",
" vertex_id = brep.unique_vertex(opengeode.ComponentMeshVertex(surface.component_id(), vertex))\n",
" unique_vertices = brep.filtered_component_mesh_vertices_by_type(vertex_id, opengeode.Corner3D.component_type_static())\n",
" return unique_vertices[0].component_id.id()\n",
" return unique_vertices[0].component_id.id\n",
"\n",
"def _brep_mapping(brep0, brep1):\n",
" corner_mapping = _corner_mapping(brep0, brep1)\n",
Expand Down Expand Up @@ -312,4 +312,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
2 changes: 1 addition & 1 deletion include/geode/model/helpers/model_component_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace geode
{
class BRep;
class Section;
class ComponentID;
struct ComponentID;
} // namespace geode

namespace geode
Expand Down
2 changes: 1 addition & 1 deletion include/geode/model/mixin/core/component_mesh_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace geode

[[nodiscard]] MeshElement mesh_element() const
{
return { component_id.id(), element_id };
return { component_id.id, element_id };
}

[[nodiscard]] bool operator==( const ComponentMeshElement& other ) const
Expand Down
53 changes: 15 additions & 38 deletions include/geode/model/mixin/core/component_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,13 @@
/*!
* Identify a component by its type and a unique index
*/
class ComponentID
struct ComponentID
{
public:
ComponentID() : ComponentID( ComponentType{ "undefined" }, uuid{} ) {}

ComponentID( ComponentType component_type, uuid id )
: type_( std::move( component_type ) ), id_( std::move( id ) )
{
}

[[nodiscard]] const uuid& id() const&
{
return id_;
}

[[nodiscard]] uuid&& id() &&
{
return std::move( id_ );
}

[[nodiscard]] const ComponentType& type() const&
{
return type_;
}

[[nodiscard]] ComponentType&& type() &&
{
return std::move( type_ );
}
ComponentID( ComponentType component_type, uuid input_id )
: type{ std::move( component_type ) },
id{ std::move( input_id ) } {};

Check warning on line 53 in include/geode/model/mixin/core/component_type.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/mixin/core/component_type.hpp:53:19 [hicpp-move-const-arg]

std::move of the variable 'input_id' of the trivially-copyable type 'uuid' has no effect; remove std::move()

[[nodiscard]] bool operator!=( const ComponentID& other ) const
{
Expand All @@ -81,29 +59,32 @@

[[nodiscard]] bool operator==( const ComponentID& other ) const
{
return type_.get() == other.type_.get() && id_ == other.id_;
return type.get() == other.type.get() && id == other.id;
}

[[nodiscard]] bool operator<( const ComponentID& other ) const
{
if( type_.get() != other.type_.get() )
if( type.get() != other.type.get() )
{
return type_.get() < other.type_.get();
return type.get() < other.type.get();
}
return id_ < other.id_;
return id < other.id;
}

[[nodiscard]] std::string string() const
{
return absl::StrCat( type_.get(), " ", id_.string() );
return absl::StrCat( type.get(), " ", id.string() );
}

template < typename H >
friend H AbslHashValue( H h, const ComponentID& value )

Check warning on line 80 in include/geode/model/mixin/core/component_type.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/mixin/core/component_type.hpp:80:35 [readability-identifier-length]

parameter name 'h' is too short, expected at least 3 characters

Check warning on line 80 in include/geode/model/mixin/core/component_type.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/mixin/core/component_type.hpp:80:18 [readability-identifier-naming]

invalid case style for global function 'AbslHashValue'
{
return H::combine( std::move( h ), value.type_, value.id_ );
return H::combine( std::move( h ), value.type, value.id );
}

ComponentType type;
uuid id;

private:
friend class bitsery::Access;
template < typename Archive >
Expand All @@ -112,14 +93,10 @@
serializer.ext(
*this, Growable< Archive, ComponentID >{
{ []( Archive& archive, ComponentID& component_id ) {
archive.object( component_id.type_ );
archive.object( component_id.id_ );
archive.object( component_id.type );
archive.object( component_id.id );
} } } );
}

private:
ComponentType type_;
uuid id_;
};

} // namespace geode
Expand All @@ -135,5 +112,5 @@
template <>
struct opengeode_model_api hash< geode::ComponentID >
{
size_t operator()( const geode::ComponentID& id ) const;

Check warning on line 115 in include/geode/model/mixin/core/component_type.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/mixin/core/component_type.hpp:115:54 [readability-identifier-length]

parameter name 'id' is too short, expected at least 3 characters
};
Expand Down
4 changes: 2 additions & 2 deletions include/geode/model/representation/builder/detail/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
#include <geode/model/mixin/core/surface_collection.hpp>
#include <geode/model/representation/core/mapping.hpp>

namespace geode

Check warning on line 48 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:48:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace detail
{
using Mapping = ModelCopyMapping::Mapping;

template < typename ModelFrom, typename ModelTo >
void copy_corner_components( const ModelFrom& from,

Check warning on line 55 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:55:14 [readability-function-cognitive-complexity]

function 'copy_corner_components' has cognitive complexity of 12 (threshold 10)
const ModelTo& model_to,
typename ModelTo::Builder& builder_to,
Mapping& mapping )
Expand All @@ -61,20 +61,20 @@
{
if( mapping.has_mapping_input( corner.id() ) )
{
const auto& id = mapping.in2out( corner.id() );

Check warning on line 64 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:64:33 [readability-identifier-length]

variable name 'id' is too short, expected at least 3 characters
ModelFrom::dim == ModelTo::dim
? builder_to.add_corner( id, corner.mesh().impl_name() )
: builder_to.add_corner( id );
}
else
{
const auto& id =

Check warning on line 71 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:71:33 [readability-identifier-length]

variable name 'id' is too short, expected at least 3 characters
ModelFrom::dim == ModelTo::dim
? builder_to.add_corner( corner.mesh().impl_name() )
: builder_to.add_corner();
mapping.map( corner.id(), id );
}
const auto& id = mapping.in2out( corner.id() );

Check warning on line 77 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:77:29 [readability-identifier-length]

variable name 'id' is too short, expected at least 3 characters
if( const auto name = corner.name() )
{
builder_to.set_corner_name(
Expand All @@ -86,7 +86,7 @@
}

template < typename ModelFrom, typename ModelTo >
void copy_line_components( const ModelFrom& from,

Check warning on line 89 in include/geode/model/representation/builder/detail/copy.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/model/representation/builder/detail/copy.hpp:89:14 [readability-function-cognitive-complexity]

function 'copy_line_components' has cognitive complexity of 12 (threshold 10)
const ModelTo& model_to,
typename ModelTo::Builder& builder_to,
Mapping& mapping )
Expand Down Expand Up @@ -433,10 +433,10 @@
for( const auto& mesh_vertex :
from.component_mesh_vertices( v ) )
{
const auto& type = mesh_vertex.component_id.type();
const auto& type = mesh_vertex.component_id.type;
builder_to.set_unique_vertex(
{ { type, mapping.at( type ).in2out(
mesh_vertex.component_id.id() ) },
mesh_vertex.component_id.id ) },
mesh_vertex.vertex },
first_new_unique_vertex_id + v );
}
Expand Down
4 changes: 2 additions & 2 deletions include/geode/model/representation/builder/detail/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ namespace geode
{
const auto& component_id =
model.component_with_relation( vertex );
if( !checker.apply( component_id.type() ) )
if( !checker.apply( component_id.type ) )
{
components_to_remove.push_back( component_id.id() );
components_to_remove.push_back( component_id.id );
}
}
for( const auto& component : components_to_remove )
Expand Down
4 changes: 2 additions & 2 deletions include/geode/model/representation/core/internal/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace geode
{
while( iterator.operator!=( iterator )
&& iterator.Relationships::InternalRangeIterator::operator*()
.type()
.type
!= Filter::component_type_static() )
{
iterator.Relationships::InternalRangeIterator::operator++();
Expand All @@ -49,7 +49,7 @@ namespace geode
while(
iterator.operator!=( iterator )
&& iterator.Relationships::EmbeddingRangeIterator::operator*()
.type()
.type
!= Filter::component_type_static() )
{
iterator.Relationships::EmbeddingRangeIterator::operator++();
Expand Down
6 changes: 3 additions & 3 deletions src/geode/model/helpers/component_mesh_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace geode
edges.reserve( line_pairs.size() );
for( const auto& line_pair : line_pairs )
{
const auto& line = model.line( line_pair.first.id() );
const auto& line = model.line( line_pair.first.id );
const auto& mesh = line.mesh();
for( const auto& pair : line_pair.second )
{
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace geode
edges.reserve( surface_pairs.size() );
for( const auto& [surface_id, edge_pairs] : surface_pairs )
{
const auto& surface = model.surface( surface_id.id() );
const auto& surface = model.surface( surface_id.id );
const auto& mesh = surface.mesh();
for( const auto& pair : edge_pairs )
{
Expand Down Expand Up @@ -300,7 +300,7 @@ namespace geode
edges.reserve( block_pairs.size() );
for( const auto& block_pair : block_pairs )
{
const auto& block = model.block( block_pair.first.id() );
const auto& block = model.block( block_pair.first.id );
const auto& mesh = block.mesh();
for( const auto& pair : block_pair.second )
{
Expand Down
8 changes: 4 additions & 4 deletions src/geode/model/helpers/component_mesh_polygons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace
for( const auto& cmv : model.component_mesh_vertices(
facet_unique_vertices[polygon_vertex_id] ) )
{
if( cmv.component_id.id() == block.id() )
if( cmv.component_id.id == block.id() )
{
block_facet_from_unique_vertices[polygon_vertex_id]
.emplace_back( cmv.vertex );
Expand Down Expand Up @@ -311,7 +311,7 @@ namespace
for( const auto& cmv : model.component_mesh_vertices(
edge_unique_vertices[edge_vertex_id] ) )
{
if( cmv.component_id.id() == surface.id() )
if( cmv.component_id.id == surface.id() )
{
surface_edge_from_unique_vertices[edge_vertex_id]
.emplace_back( cmv.vertex );
Expand Down Expand Up @@ -643,7 +643,7 @@ namespace geode
polygons.reserve( surface_pairs.size() );
for( auto& surface_pair : surface_pairs )
{
const auto& surface = model.surface( surface_pair.first.id() );
const auto& surface = model.surface( surface_pair.first.id );
const auto& mesh = surface.mesh();
for( auto& pair : surface_pair.second )
{
Expand Down Expand Up @@ -680,7 +680,7 @@ namespace geode
polygons.reserve( block_pairs.size() );
for( const auto& block_pair : block_pairs )
{
const auto& block = model.block( block_pair.first.id() );
const auto& block = model.block( block_pair.first.id );
const auto& mesh = block.mesh();
for( const auto& pair : block_pair.second )
{
Expand Down
8 changes: 4 additions & 4 deletions src/geode/model/helpers/component_mesh_polyhedra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace
common_block_vertices_list_.clear();
for( const auto& first_cmv : unique_vertices_cmvs_[0].get() )
{
if( first_cmv.component_id.type()
if( first_cmv.component_id.type
!= geode::Block3D::component_type_static() )
{
continue;
Expand All @@ -80,7 +80,7 @@ namespace
continue;
}
fill_polyhedron_vertices_possibilities(
first_cmv.component_id.id(), mesh_vertices, 1,
first_cmv.component_id.id, mesh_vertices, 1,
{ first_cmv.vertex } );
}
return std::move( common_block_vertices_list_ );
Expand All @@ -90,7 +90,7 @@ namespace
absl::FixedArray< std::vector< geode::index_t > > block_mesh_vertices(
const geode::ComponentMeshVertex& first_cmv )
{
const auto& first_cmv_block_id = first_cmv.component_id.id();
const auto& first_cmv_block_id = first_cmv.component_id.id;
absl::FixedArray< std::vector< geode::index_t > > mesh_vertices(
nb_unique_vertices_ );
mesh_vertices[0].push_back( first_cmv.vertex );
Expand All @@ -100,7 +100,7 @@ namespace
for( const auto& other_cmv :
unique_vertices_cmvs_[other_cmv_list_id].get() )
{
if( first_cmv_block_id == other_cmv.component_id.id() )
if( first_cmv_block_id == other_cmv.component_id.id )
{
mesh_vertices[other_cmv_list_id].push_back(
other_cmv.vertex );
Expand Down
Loading
Loading