Skip to content
Open
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
24 changes: 14 additions & 10 deletions include/geode/basic/mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

#pragma once

#include <absl/container/flat_hash_map.h>
#include <absl/algorithm/container.h>
#include <absl/container/btree_map.h>
#include <absl/container/inlined_vector.h>

#include <geode/basic/common.hpp>
Expand All @@ -33,16 +34,15 @@
template < typename T1,
typename T2,
template < typename > class StorageType >
class MappingBase

Check warning on line 37 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:37:11 [cppcoreguidelines-special-member-functions]

class 'MappingBase' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
public:
template < typename T >
using Storage = typename StorageType< T >::Type;

void reserve( index_t capacity )
[[deprecated]] void reserve( index_t capacity )
{
in2out_.reserve( capacity );
out2in_.reserve( capacity );
geode_unused( capacity );
}

void clear()
Expand All @@ -61,7 +61,7 @@
return out2in_.contains( value );
}

[[nodiscard]] const Storage< T2 >& in2out( const T1& in ) const

Check warning on line 64 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:64:62 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
return in2out_.at( in );
}
Expand All @@ -71,13 +71,13 @@
return out2in_.at( out );
}

[[nodiscard]] const absl::flat_hash_map< T1, Storage< T2 > >&
[[nodiscard]] const absl::btree_map< T1, Storage< T2 > >&
in2out_map() const
{
return in2out_;
}

[[nodiscard]] const absl::flat_hash_map< T2, Storage< T1 > >&
[[nodiscard]] const absl::btree_map< T2, Storage< T1 > >&
out2in_map() const
{
return out2in_;
Expand All @@ -100,19 +100,19 @@
return static_cast< index_t >( out2in_.size() );
}

[[nodiscard]] absl::flat_hash_map< T1, Storage< T2 > >& in2out_mapping()
[[nodiscard]] absl::btree_map< T1, Storage< T2 > >& in2out_mapping()
{
return in2out_;
}

[[nodiscard]] absl::flat_hash_map< T2, Storage< T1 > >& out2in_mapping()
[[nodiscard]] absl::btree_map< T2, Storage< T1 > >& out2in_mapping()
{
return out2in_;
}

private:
absl::flat_hash_map< T1, Storage< T2 > > in2out_;
absl::flat_hash_map< T2, Storage< T1 > > out2in_;
absl::btree_map< T1, Storage< T2 > > in2out_;
absl::btree_map< T2, Storage< T1 > > out2in_;
};

template < typename T >
Expand All @@ -122,7 +122,7 @@
};

template < typename T1, typename T2 = T1 >
class BijectiveMapping : public MappingBase< T1, T2, OneValueStorage >

Check warning on line 125 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:125:11 [cppcoreguidelines-special-member-functions]

class 'BijectiveMapping' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
public:
BijectiveMapping() = default;
Expand All @@ -131,7 +131,7 @@
BijectiveMapping( BijectiveMapping&& ) noexcept = default;
BijectiveMapping& operator=( BijectiveMapping&& ) noexcept = default;

void map( const T1& in, const T2& out )

Check warning on line 134 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:134:29 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
auto [in_itr, in_is_new] =
this->in2out_mapping().emplace( in, out );
Expand All @@ -149,7 +149,7 @@
}
}

void erase_in( const T1& in )

Check warning on line 152 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:152:34 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
auto in_itr = this->in2out_mapping().find( in );
if( in_itr == this->in2out_mapping().end() )
Expand Down Expand Up @@ -184,7 +184,7 @@
};

template < typename T1, typename T2 = T1 >
class GenericMapping : public MappingBase< T1, T2, MultipleValueStorage >

Check warning on line 187 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:187:11 [cppcoreguidelines-special-member-functions]

class 'GenericMapping' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
public:
GenericMapping() = default;
Expand All @@ -193,7 +193,7 @@
GenericMapping( GenericMapping&& ) noexcept = default;
GenericMapping& operator=( GenericMapping&& ) noexcept = default;

void map( const T1& in, const T2& out )

Check warning on line 196 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:196:29 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
if( this->has_mapping_input( in ) )
{
Expand All @@ -206,7 +206,7 @@
this->out2in_mapping()[out].push_back( in );
}

void unmap( const T1& in, const T2& out )

Check warning on line 209 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:209:31 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
if( !this->has_mapping_input( in ) )
{
Expand All @@ -225,6 +225,10 @@
}
auto& out_map = this->out2in_mapping().at( out );
const auto itr2 = absl::c_find( out_map, in );
if( itr2 == out_map.end() )
{
return;
}
out_map.erase( itr2 );
if( this->out2in( out ).empty() )
{
Expand All @@ -232,7 +236,7 @@
}
}

void erase_in( const T1& in )

Check warning on line 239 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:239:34 [readability-identifier-length]

parameter name 'in' is too short, expected at least 3 characters
{
if( !this->has_mapping_input( in ) )
{
Expand All @@ -257,7 +261,7 @@
{
return;
}
for( const auto& in : this->out2in( out ) )

Check warning on line 264 in include/geode/basic/mapping.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/mapping.hpp:264:30 [readability-identifier-length]

variable name 'in' is too short, expected at least 3 characters
{
auto& in_map = this->in2out_mapping().at( in );
const auto itr = absl::c_find( in_map, out );
Expand Down
9 changes: 9 additions & 0 deletions include/geode/model/mixin/core/component_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ namespace geode
return type_.get() == other.type_.get() && id_ == other.id_;
}

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

[[nodiscard]] std::string string() const
{
return absl::StrCat( type_.get(), " ", id_.string() );
Expand Down
2 changes: 2 additions & 0 deletions include/geode/model/mixin/core/vertex_identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace geode

[[nodiscard]] bool operator==( const ComponentMeshVertex& other ) const;

[[nodiscard]] bool operator<( const ComponentMeshVertex& other ) const;

template < typename Archive >
void serialize( Archive& archive );

Expand Down
2 changes: 2 additions & 0 deletions src/geode/mesh/helpers/convert_surface_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/mesh/helpers/convert_surface_mesh.hpp>

#include <absl/container/flat_hash_map.h>

#include <geode/basic/attribute_manager.hpp>
#include <geode/basic/logger.hpp>

Expand Down
1 change: 0 additions & 1 deletion src/geode/mesh/helpers/detail/split_along_solid_facets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ namespace geode
ElementsMapping duplicate_points( const SolidInfo& solid_info )
{
ElementsMapping vertices_mapping;
vertices_mapping.reserve( solid_.nb_vertices() );
for( const auto vertex_id : Range{ solid_.nb_vertices() } )
{
vertices_mapping.map( vertex_id, vertex_id );
Expand Down
10 changes: 10 additions & 0 deletions src/geode/model/mixin/core/vertex_identifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
return component_id == other.component_id && vertex == other.vertex;
}

bool ComponentMeshVertex::operator<(
const ComponentMeshVertex& other ) const
{
if( component_id != other.component_id )
{
return component_id < other.component_id;
}
return vertex < other.vertex;
}

template < typename Archive >
void ComponentMeshVertex::serialize( Archive& archive )
{
Expand Down Expand Up @@ -398,7 +408,7 @@
a.ext( impl.component_vertices_,
bitsery::ext::StdSmartPtr{} );
a.ext( impl.vertex2unique_vertex_,
bitsery::ext::StdMap{

Check failure on line 411 in src/geode/model/mixin/core/vertex_identifier.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/mixin/core/vertex_identifier.cpp:411:44 [clang-diagnostic-error]

no member named 'StdMap' in namespace 'bitsery::ext'
impl.vertex2unique_vertex_.max_size() },
[]( Archive& a2, uuid& id,
std::shared_ptr< VariableAttribute<
Expand All @@ -419,7 +429,7 @@
a.ext( impl.component_vertices_,
bitsery::ext::StdSmartPtr{} );
a.ext( impl.vertex2unique_vertex_,
bitsery::ext::StdMap{

Check failure on line 432 in src/geode/model/mixin/core/vertex_identifier.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/mixin/core/vertex_identifier.cpp:432:47 [clang-diagnostic-error]

no member named 'StdMap' in namespace 'bitsery::ext'
impl.vertex2unique_vertex_.max_size() },
[]( Archive& a2, uuid& id,
std::shared_ptr< VariableAttribute<
Expand Down
Loading