From 39756d1aba3445fab3ed9c46068b9a1b2213792f Mon Sep 17 00:00:00 2001 From: BenPinet Date: Mon, 8 Jun 2026 16:19:49 +0200 Subject: [PATCH 01/19] wip --- include/geode/basic/attribute.hpp | 14 +-- include/geode/basic/attribute_manager.hpp | 99 ++++----------- src/geode/basic/attribute_manager.cpp | 146 +++++++++------------- 3 files changed, 87 insertions(+), 172 deletions(-) diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index 64e240a43..07f9db278 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,7 @@ namespace geode /*! * Base class defining the virtual API used by the AttributeManager. */ - class AttributeBase + class AttributeBase : public Identifier { OPENGEODE_DISABLE_COPY( AttributeBase ); friend class bitsery::Access; @@ -69,11 +70,6 @@ namespace geode [[nodiscard]] virtual std::string_view type() = 0; - [[nodiscard]] std::string_view name() const - { - return name_; - } - [[nodiscard]] const AttributeProperties& properties() const { return properties_; @@ -85,11 +81,6 @@ namespace geode } public: - void set_name( std::string_view name, AttributeKey /*key*/ ) - { - name_ = to_string( name ); - } - [[nodiscard]] virtual std::shared_ptr< AttributeBase > clone( AttributeKey /*key*/ ) const = 0; @@ -160,7 +151,6 @@ namespace geode private: AttributeProperties properties_; - std::string name_; }; /*! diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 28c1eb444..77626c8ca 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace geode { @@ -59,10 +60,10 @@ namespace geode * @return nullptr if no attribute matches the given name. */ [[nodiscard]] std::shared_ptr< AttributeBase > find_generic_attribute( - std::string_view name ) const + const geode::uuid& attribute_id ) const { absl::ReaderMutexLock lock{ mutex() }; - return find_attribute_base( name ); + return find_attribute_base( attribute_id ); } /*! @@ -73,81 +74,31 @@ namespace geode */ template < typename T > [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > find_attribute( - std::string_view name ) const + const geode::uuid& attribute_id ) const { absl::ReaderMutexLock lock{ mutex() }; auto attribute = std::dynamic_pointer_cast< ReadOnlyAttribute< T > >( - find_attribute_base( name ) ); + find_attribute_base( attribute_id ) ); OpenGeodeBasicException::check_exception( attribute.get(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::find_attribute] Could not find attribute '", name, "'. You have to create an attribute before using it. See " - "find_or_create_attribute method and derived classes of " + "create_attribute method and derived classes of " "ReadOnlyAttribute." ); return attribute; } - /*! - * Recover or create the attribute from the manager - * and the attribute name. - * If the recovered Attribute is not a of the same type than the - * attribute, it replaces it by the Attribute corresponding to the - * attribute. - * @param[in] name The associated attribute name to look for - * @param[in] default_value The default value to use when new attribute - * element are created - * @param[in] properties The AttributeProperties to set the attribute - * flags for future modifications - * @tparam Attribute The attribute type to look for, - * such as ConstantAttribute - * @tparam T The type of the Attribute element - * @exception OpenGeodeException if the Attribute replacement failed - */ - template < template < typename > class Attribute, typename T > - std::shared_ptr< Attribute< T > > find_or_create_attribute( - std::string_view name, - T default_value, - AttributeProperties properties ) - { - { - absl::ReaderMutexLock lock{ mutex() }; - auto attribute = find_attribute_base( name ); - auto typed_attribute = - std::dynamic_pointer_cast< Attribute< T > >( attribute ); - if( typed_attribute.get() ) - { - return typed_attribute; - } - } - absl::MutexLock lock{ mutex() }; - auto attribute = find_attribute_base( name ); - auto typed_attribute = - std::dynamic_pointer_cast< Attribute< T > >( attribute ); - if( typed_attribute.get() ) - { - return typed_attribute; - } - OpenGeodeBasicException::check_exception( attribute.use_count() < 2, - nullptr, OpenGeodeException::TYPE::internal, - "[AttributeManager::find_or_create_attribute] Do not " - "instantiate an attribute " - "if an instantiated attribute of the same name " - "with different storage already exists." ); - - typed_attribute.reset( new Attribute< T >{ - std::move( default_value ), std::move( properties ), {} } ); - register_attribute( typed_attribute, name ); - return typed_attribute; - } - - template < template < typename > class Attribute, typename T > - std::shared_ptr< Attribute< T > > find_or_create_attribute( - std::string_view name, T default_value ) + template < typename T > + [[nodiscard]] geode::uuid create_attribute( + T default_value, AttributeProperties properties ) { - return find_or_create_attribute< Attribute, T >( - name, std::move( default_value ), AttributeProperties{} ); + geode::uuid attribute_id; + auto typed_attribute = std::make_shared< TypedAttribute< T > >( + std::move( default_value ), std::move( properties ), {} ); + register_attribute( attribute_id, typed_attribute ); + return attribute_id; } /*! @@ -196,33 +147,29 @@ namespace geode /*! * Get all the associated attribute names */ - [[nodiscard]] absl::FixedArray< std::string_view > - attribute_names() const; + [[nodiscard]] absl::FixedArray< geode::uuid > attribute_ids() const; /*! * Return true if an attribute matching the given name. * @param[in] name The attribute name to use */ - [[nodiscard]] bool attribute_exists( std::string_view name ) const; + [[nodiscard]] bool attribute_exists( const geode::uuid& ) const; /*! * Delete the attribute matching the given name. * Do nothing if the name does not exist. * @param[in] name The attribute name to delete */ - void delete_attribute( std::string_view name ); + void delete_attribute( const geode::uuid& ); /*! * Get the typeid name of the attribute type * @param[in] name The attribute name to use */ [[nodiscard]] std::string_view attribute_type( - std::string_view name ) const; - - void rename_attribute( - std::string_view old_name, std::string_view new_name ); + const geode::uuid& ) const; - void set_attribute_properties( std::string_view attribute_name, + void set_attribute_properties( geode::uuid attribute_id, const AttributeProperties& new_properties ); /*! @@ -262,14 +209,14 @@ namespace geode void import( const AttributeManager& attribute_manager, absl::Span< const index_t > old2new, - std::string_view attribute_name ); + geode::uuid attribute_id ); void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping ); void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping, - std::string_view attribute_name ); + uuid attribute_id ); private: friend class bitsery::Access; @@ -286,7 +233,7 @@ namespace geode * the shared pointer is empty. */ [[nodiscard]] std::shared_ptr< AttributeBase > find_attribute_base( - std::string_view name ) const; + const geode::uuid& ) const; /*! * Register an Attribute to the given name. @@ -296,7 +243,7 @@ namespace geode * @param[in] name The associated name to the store */ void register_attribute( - std::shared_ptr< AttributeBase > attribute, std::string_view name ); + std::shared_ptr< AttributeBase > attribute, const geode::uuid& ); private: IMPLEMENTATION_MEMBER( impl_ ); diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index e596ea6b2..2138b52be 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -38,16 +39,16 @@ namespace geode { class AttributeManager::Impl { - using AttributesMap = absl::flat_hash_map< std::string, - std::shared_ptr< AttributeBase > >; + using AttributesMap = + absl::linked_hash_map< uuid, std::shared_ptr< AttributeBase > >; using AttributesMapElement = std::pair< const AttributesMap::key_type, AttributesMap::mapped_type >; public: std::shared_ptr< AttributeBase > find_attribute_base( - std::string_view name ) const + const uuid &attribute_id ) const { - const auto attribute_it = attributes_.find( name ); + const auto attribute_it = attributes_.find( attribute_id ); if( attribute_it == attributes_.end() ) { return nullptr; @@ -56,12 +57,11 @@ namespace geode } void register_attribute( std::shared_ptr< AttributeBase > &attribute, - std::string_view name, + const uuid &attribute_id, const AttributeBase::AttributeKey &key ) { attribute->resize( nb_elements_, key ); - attribute->set_name( name, key ); - attributes_.emplace( name, attribute ); + attributes_.emplace( attribute_id, attribute ); } void resize( index_t size, const AttributeBase::AttributeKey &key ) @@ -145,35 +145,35 @@ namespace geode } ); } - absl::FixedArray< std::string_view > attribute_names() const + absl::FixedArray< uuid > attribute_ids() const { - absl::FixedArray< std::string_view > names( attributes_.size() ); + absl::FixedArray< uuid > ids( attributes_.size() ); index_t count{ 0 }; - for( const auto &[attribute_name, _] : attributes_ ) + for( const auto &[attribute_id, _] : attributes_ ) { - names[count++] = attribute_name; + ids[count++] = attribute_id; } - return names; + return ids; } - bool attribute_exists( std::string_view name ) const + bool attribute_exists( const uuid &attribute_id ) const { - return attributes_.find( name ) != attributes_.end(); + return absl::c_contains( attributes_, attribute_id ); } - void delete_attribute( std::string_view name ) + void delete_attribute( const uuid &attribute_id ) { absl::MutexLock lock{ mutex_ }; - const auto attribute_it = attributes_.find( name ); + const auto attribute_it = attributes_.find( attribute_id ); if( attribute_it != attributes_.end() ) { attributes_.erase( attribute_it ); } } - std::string_view attribute_type( std::string_view name ) const + std::string_view attribute_type( const uuid &attribute_id ) const { - const auto attribute_it = attributes_.find( name ); + const auto attribute_it = attributes_.find( attribute_id ); if( attribute_it == attributes_.end() ) { static constexpr auto UNDEFINED = "undefined"; @@ -256,28 +256,28 @@ namespace geode const T &old2new_mapping, const AttributeBase::AttributeKey &key ) { - for( const auto &[attribute_name, attribute_from] : + for( const auto &[attribute_id, attribute_from] : attribute_manager.attributes_ ) { if( !attribute_from->properties().transferable ) { continue; } - if( attribute_exists( attribute_name ) ) + if( attribute_exists( attribute_id ) ) { if( attribute_from->type() - != this->attributes_.at( attribute_name )->type() ) + != this->attributes_.at( attribute_id )->type() ) { continue; } - this->attributes_.at( attribute_name ) + this->attributes_.at( attribute_id ) ->import( old2new_mapping, attribute_from, key ); } else { - attributes_.emplace( attribute_name, - attribute_from->extract( - old2new_mapping, nb_elements_, key ) ); + attributes_.emplace( + attribute_id, attribute_from->extract( old2new_mapping, + nb_elements_, key ) ); } } } @@ -285,10 +285,10 @@ namespace geode template < typename T > void import( const AttributeManager::Impl &attribute_manager, const T &old2new_mapping, - std::string_view attribute_name, + geode::uuid attribute_id, const AttributeBase::AttributeKey &key ) { - auto it = attribute_manager.attributes_.find( attribute_name ); + auto it = attribute_manager.attributes_.find( attribute_id ); OpenGeodeBasicException::check_exception( it != attribute_manager.attributes_.end(), nullptr, OpenGeodeException::TYPE::data, @@ -301,60 +301,44 @@ namespace geode OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", attribute_name, "'. The attribute is not transferable." ); - if( attribute_exists( attribute_name ) ) + if( attribute_exists( attribute_id ) ) { OpenGeodeBasicException::check_exception( it->second->type() - == this->attributes_.at( attribute_name )->type(), + == this->attributes_.at( attribute_id )->type(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", attribute_name, "'. An attribute with the same name but a different type " "already exists in the destination AttributeManager." ); - this->attributes_.at( attribute_name ) + this->attributes_.at( attribute_id ) ->import( old2new_mapping, it->second, key ); } else { - attributes_.emplace( attribute_name, + attributes_.emplace( attribute_id, it->second->extract( old2new_mapping, nb_elements_, key ) ); } } - void initialize_attribute_names( - const AttributeBase::AttributeKey &key ) - { - for( auto &[attribute_name, attribute] : attributes_ ) - { - attribute->set_name( attribute_name, key ); - } - } - - void rename_attribute( std::string_view old_name, - std::string_view new_name, - const AttributeBase::AttributeKey &key ) - { - const auto attribute_it = attributes_.find( old_name ); - OpenGeodeBasicException::check_exception( - attribute_it != attributes_.end(), nullptr, - OpenGeodeException::TYPE::data, - "[AttributeManager::rename_attribute] Attribute ", old_name, - "does not exist" ); - auto attribute = attribute_it->second; - attributes_.erase( attribute_it ); - attribute->set_name( new_name, key ); - attributes_.emplace( new_name, attribute ); - } + // void initialize_attribute_ids( const AttributeBase::AttributeKey &key + // ) + // { + // for( auto &[attribute_id, attribute] : attributes_ ) + // { + // attribute->set_id( attribute_id, key ); + // } + // } - void set_attribute_properties( std::string_view attribute_name, + void set_attribute_properties( geode::uuid attribute_id, const AttributeProperties &new_properties ) { - const auto attribute_it = attributes_.find( attribute_name ); + const auto attribute_it = attributes_.find( attribute_id ); OpenGeodeBasicException::check_exception( attribute_it != attributes_.end(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::rename_attribute] Attribute ", - attribute_name, "does not exist" ); + attribute_id.string(), "does not exist" ); attribute_it->second->set_properties( new_properties ); } @@ -406,15 +390,16 @@ namespace geode AttributeManager::~AttributeManager() = default; std::shared_ptr< AttributeBase > AttributeManager::find_attribute_base( - std::string_view name ) const + const geode::uuid &attribute_id ) const { - return impl_->find_attribute_base( name ); + return impl_->find_attribute_base( attribute_id ); } void AttributeManager::register_attribute( - std::shared_ptr< AttributeBase > attribute, std::string_view name ) + std::shared_ptr< AttributeBase > attribute, + const geode::uuid &attribute_id ) { - return impl_->register_attribute( attribute, name, {} ); + return impl_->register_attribute( attribute, attribute_id, {} ); } void AttributeManager::resize( index_t size ) @@ -455,26 +440,26 @@ namespace geode impl_->interpolate_attribute_value( interpolation, to_element, {} ); } - absl::FixedArray< std::string_view > - AttributeManager::attribute_names() const + absl::FixedArray< geode::uuid > AttributeManager::attribute_ids() const { - return impl_->attribute_names(); + return impl_->attribute_ids(); } - bool AttributeManager::attribute_exists( std::string_view name ) const + bool AttributeManager::attribute_exists( + const geode::uuid &attribute_id ) const { - return impl_->attribute_exists( name ); + return impl_->attribute_exists( attribute_id ); } - void AttributeManager::delete_attribute( std::string_view name ) + void AttributeManager::delete_attribute( const geode::uuid &attribute_id ) { - impl_->delete_attribute( name ); + impl_->delete_attribute( attribute_id ); } std::string_view AttributeManager::attribute_type( - std::string_view name ) const + const geode::uuid &attribute_id ) const { - return impl_->attribute_type( name ); + return impl_->attribute_type( attribute_id ); } void AttributeManager::clear() @@ -524,9 +509,9 @@ namespace geode void AttributeManager::import( const AttributeManager &attribute_manager, absl::Span< const index_t > old2new, - std::string_view attribute_name ) + geode::uuid attribute_id ) { - impl_->import( *attribute_manager.impl_, old2new, attribute_name, {} ); + impl_->import( *attribute_manager.impl_, old2new, attribute_id, {} ); } void AttributeManager::import( const AttributeManager &attribute_manager, @@ -537,23 +522,16 @@ namespace geode void AttributeManager::import( const AttributeManager &attribute_manager, const GenericMapping< index_t > &old2new_mapping, - std::string_view attribute_name ) + geode::uuid attribute_id ) { impl_->import( - *attribute_manager.impl_, old2new_mapping, attribute_name, {} ); - } - - void AttributeManager::rename_attribute( - std::string_view old_name, std::string_view new_name ) - { - impl_->rename_attribute( old_name, new_name, {} ); + *attribute_manager.impl_, old2new_mapping, attribute_id, {} ); } void AttributeManager::set_attribute_properties( - std::string_view attribute_name, - const AttributeProperties &new_properties ) + geode::uuid attribute_id, const AttributeProperties &new_properties ) { - impl_->set_attribute_properties( attribute_name, new_properties ); + impl_->set_attribute_properties( attribute_id, new_properties ); } absl::Mutex &AttributeManager::mutex() const From 1b183850d18d7f1eb723bfb2fd74667e82b08acf Mon Sep 17 00:00:00 2001 From: BenPinet Date: Tue, 9 Jun 2026 11:19:21 +0200 Subject: [PATCH 02/19] wip --- include/geode/basic/attribute_manager.hpp | 14 +++++------ .../geode/mesh/core/detail/facet_storage.hpp | 24 ++++++------------- src/geode/basic/attribute_manager.cpp | 2 +- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 77626c8ca..7ee92afd8 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -83,7 +83,7 @@ namespace geode OpenGeodeBasicException::check_exception( attribute.get(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::find_attribute] Could not find attribute '", - name, + attribute_id, "'. You have to create an attribute before using it. See " "create_attribute method and derived classes of " "ReadOnlyAttribute." ); @@ -226,21 +226,21 @@ namespace geode [[nodiscard]] absl::Mutex& mutex() const; /*! - * Find the Attribute associated with the given name + * Find the Attribute associated with the given id * regardless the content type - * @param[in] name The attribute name to search for - * @return The associated store. If the name was not found, + * @param[in] id The attribute id to search for + * @return The associated store. If the id was not found, * the shared pointer is empty. */ [[nodiscard]] std::shared_ptr< AttributeBase > find_attribute_base( const geode::uuid& ) const; /*! - * Register an Attribute to the given name. - * If the given name already exists in the manager, the new attribute + * Register an Attribute to the given id. + * If the given id already exists in the manager, the new attribute * will override the old one. * @param[in] attribute The attribute to register - * @param[in] name The associated name to the store + * @param[in] id The associated id to the store */ void register_attribute( std::shared_ptr< AttributeBase > attribute, const geode::uuid& ); diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index 16d7e68e3..cdbcf284f 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -44,7 +44,6 @@ namespace geode class FacetStorage { using TypedVertexCycle = VertexCycle< VertexContainer >; - static constexpr auto ATTRIBUTE_NAME = "facet_vertices"; friend class bitsery::Access; public: @@ -60,14 +59,12 @@ namespace geode protected: FacetStorage() : counter_( facet_attribute_manager_ - .template find_or_create_attribute< VariableAttribute, - index_t >( - "counter", 1u, { false, false, false } ) ), + .template create_attribute< VariableAttribute, + index_t >( 1u, { false, false, false } ) ), vertices_( facet_attribute_manager_ - .template find_or_create_attribute< VariableAttribute, - VertexContainer >( attribute_name(), - VertexContainer(), - { false, false, false } ) ) + .template create_attribute< VariableAttribute, + VertexContainer >( + VertexContainer(), { false, false, false } ) ) { } @@ -221,17 +218,10 @@ namespace geode } protected: - static constexpr std::string_view attribute_name() - { - return ATTRIBUTE_NAME; - } - void update_attribute() { - vertices_ = - facet_attribute_manager_.template find_or_create_attribute< - VariableAttribute, VertexContainer >( attribute_name(), - VertexContainer{}, { false, false, false } ); + vertices_ = facet_attribute_manager_.template find_attribute< + VariableAttribute, VertexContainer >( vertices_->id() ); } [[nodiscard]] index_t get_counter( index_t facet_id ) const diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 2138b52be..77e52b0b4 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -293,7 +293,7 @@ namespace geode it != attribute_manager.attributes_.end(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", - attribute_name, + attribute_id, "'. No attribute with this name exists in the source " "AttributeManager." ); OpenGeodeBasicException::check_exception( From df8dc99defd4e62b93de747204104c070a01adc4 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 12 Jun 2026 09:49:10 +0200 Subject: [PATCH 03/19] wip --- include/geode/basic/attribute.hpp | 10 ++- include/geode/basic/attribute_manager.hpp | 72 +++++++++++++++++-- .../geode/mesh/core/detail/facet_storage.hpp | 42 +++++++---- .../geode/mesh/core/internal/edges_impl.hpp | 17 +++-- .../geode/mesh/core/internal/points_impl.hpp | 21 ++++-- include/geode/mesh/core/texture1d.hpp | 2 + include/geode/mesh/core/texture2d.hpp | 2 + include/geode/mesh/core/texture3d.hpp | 2 + 8 files changed, 135 insertions(+), 33 deletions(-) diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index 07f9db278..f6ced2f6f 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -138,8 +139,13 @@ namespace geode }, []( Archive& archive, AttributeBase& attribute ) { archive.object( attribute.properties_ ); - archive.text1b( - attribute.name_, attribute.name_.max_size() ); + std::string old_name; + archive.text1b( old_name, old_name.max_size() ); + IdentifierBuilder builder{ attribute }; + builder.set_name( old_name ); + }, + []( Archive& archive, AttributeBase& attribute ) { + archive.object( attribute.properties_ ); } } } ); } diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 7ee92afd8..2ff0b7f8d 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -73,7 +73,7 @@ namespace geode * @exception OpenGeodeException if no Attribute found */ template < typename T > - [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > find_attribute( + [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > read_attribute( const geode::uuid& attribute_id ) const { absl::ReaderMutexLock lock{ mutex() }; @@ -83,24 +83,82 @@ namespace geode OpenGeodeBasicException::check_exception( attribute.get(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::find_attribute] Could not find attribute '", - attribute_id, + attribute_id.string(), "'. You have to create an attribute before using it. See " "create_attribute method and derived classes of " "ReadOnlyAttribute." ); return attribute; } - template < typename T > + template < template < typename > class Attribute, typename T > + [[nodiscard]] std::shared_ptr< Attribute< T > > find_attribute( + const geode::uuid& attribute_id ) + { + absl::ReaderMutexLock lock{ mutex() }; + auto attribute = std::dynamic_pointer_cast< Attribute< T > >( + find_attribute_base( attribute_id ) ); + OpenGeodeBasicException::check_exception( attribute.get(), nullptr, + OpenGeodeException::TYPE::data, + "[AttributeManager::find_attribute] Could not find attribute '", + attribute_id.string(), + "'. You have to create an attribute before using it. See " + "create_attribute method and derived classes of " + "ReadOnlyAttribute." ); + return attribute; + } + + template < template < typename > class Attribute, typename T > + void create_attribute( std::string_view attribute_name, + const geode::uuid& attribute_id, + T default_value, + AttributeProperties properties ) + { + absl::MutexLock lock{ mutex() }; + auto attribute = find_attribute_base( attribute_id ); + auto typed_attribute = + std::dynamic_pointer_cast< Attribute< T > >( attribute ); + OpenGeodeBasicException::check_exception( + typed_attribute.get() == nullptr, nullptr, + OpenGeodeException::TYPE::data, + "[AttributeManager::create_attribute] Attribute '", + attribute_id.string(), "' already exists." ); + typed_attribute.reset( new Attribute< T >{ + std::move( default_value ), std::move( properties ), {} } ); + IdentifierBuilder builder{ *typed_attribute }; + builder.set_name( attribute_name ); + register_attribute( typed_attribute, attribute_id ); + } + + template < template < typename > class Attribute, typename T > + void create_attribute( std::string_view attribute_name, + const geode::uuid& attribute_id, + T default_value ) + { + return create_attribute< Attribute, T >( attribute_name, + attribute_id, std::move( default_value ), + AttributeProperties{} ); + } + + template < template < typename > class Attribute, typename T > [[nodiscard]] geode::uuid create_attribute( - T default_value, AttributeProperties properties ) + std::string_view attribute_name, + T default_value, + AttributeProperties properties ) { geode::uuid attribute_id; - auto typed_attribute = std::make_shared< TypedAttribute< T > >( - std::move( default_value ), std::move( properties ), {} ); - register_attribute( attribute_id, typed_attribute ); + create_attribute< Attribute, T >( attribute_name, attribute_id, + std::move( default_value ), std::move( properties ) ); return attribute_id; } + template < template < typename > class Attribute, typename T > + [[nodiscard]] geode::uuid create_attribute( + std::string_view attribute_name, T default_value ) + { + return create_attribute< Attribute, T >( attribute_name, + std::move( default_value ), AttributeProperties{} ); + } + /*! * Resize all the attributes to the given size * @param[in] size The new attribute size diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index cdbcf284f..b01cb0d73 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -58,14 +58,23 @@ namespace geode protected: FacetStorage() - : counter_( facet_attribute_manager_ - .template create_attribute< VariableAttribute, - index_t >( 1u, { false, false, false } ) ), - vertices_( facet_attribute_manager_ - .template create_attribute< VariableAttribute, - VertexContainer >( - VertexContainer(), { false, false, false } ) ) { + const auto counter_attribute_id = + facet_attribute_manager_ + .create_attribute< VariableAttribute, index_t >( + "counter", 1u, { false, false, false } ); + counter_ = facet_attribute_manager_ + .find_attribute< VariableAttribute, index_t >( + counter_attribute_id ); + const auto vertices_attribute_id = + facet_attribute_manager_ + .create_attribute< VariableAttribute, VertexContainer >( + "vertices", VertexContainer{}, + { false, false, false } ); + vertices_ = + facet_attribute_manager_ + .find_attribute< VariableAttribute, VertexContainer >( + vertices_attribute_id ); } [[nodiscard]] AttributeManager& facet_attribute_manager() const @@ -233,13 +242,22 @@ namespace geode { facet_attribute_manager_.copy( from.facet_attribute_manager() ); facet_indices_ = from.facet_indices_; - counter_ = + const auto counter_attribute_id = facet_attribute_manager_ - .find_or_create_attribute< VariableAttribute, index_t >( + .create_attribute< VariableAttribute, index_t >( "counter", 1u, { false, false, false } ); - vertices_ = facet_attribute_manager_.find_or_create_attribute< - VariableAttribute, VertexContainer >( attribute_name(), - VertexContainer{}, { false, false, false } ); + counter_ = facet_attribute_manager_ + .find_attribute< VariableAttribute, index_t >( + counter_attribute_id ); + const auto vertices_attribute_id = + facet_attribute_manager_ + .create_attribute< VariableAttribute, VertexContainer >( + "vertices", VertexContainer{}, + { false, false, false } ); + vertices_ = + facet_attribute_manager_ + .find_attribute< VariableAttribute, VertexContainer >( + vertices_attribute_id ); } private: diff --git a/include/geode/mesh/core/internal/edges_impl.hpp b/include/geode/mesh/core/internal/edges_impl.hpp index be63fe690..d588b4831 100644 --- a/include/geode/mesh/core/internal/edges_impl.hpp +++ b/include/geode/mesh/core/internal/edges_impl.hpp @@ -37,13 +37,18 @@ namespace geode class EdgesImpl { public: - explicit EdgesImpl( Graph& graph ) - : edges_( graph.edge_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - std::array< index_t, 2 > >( "edges", - std::array< index_t, 2 >{ NO_ID, NO_ID }, - { false, false, false } ) ) + explicit EdgesImpl( Graph& graph ) : edges_() { + const auto edge_attribute_id = + graph.edge_attribute_manager() + .template create_attribute< VariableAttribute, + std::array< index_t, 2 > >( "edges", + std::array< index_t, 2 >{ NO_ID, NO_ID }, + { false, false, false } ); + edges_ = + graph.edge_attribute_manager() + .template find_attribute< VariableAttribute, + std::array< index_t, 2 > >( edge_attribute_id ); } [[nodiscard]] index_t get_edge_vertex( diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index 0c09c9610..645a1ec9f 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -55,12 +55,18 @@ namespace geode [[nodiscard]] const Point< dimension >& get_point( index_t vertex_id ) const { + DEBUG( "get_point" ); + SDEBUG( points_->id() ); return points_->value( vertex_id ); } void set_point( index_t vertex_id, Point< dimension > point ) { + DEBUG( "set_point" ); + SDEBUG( point ); points_->set_value( vertex_id, std::move( point ) ); + SDEBUG( points_->id() ); + SDEBUG( points_->value( vertex_id ) ); } [[nodiscard]] index_t nb_points() const @@ -70,7 +76,7 @@ namespace geode [[nodiscard]] std::string_view attribute_name() const { - return points_->name(); + return points_->name().value(); } template < typename Mesh > @@ -135,6 +141,8 @@ namespace geode explicit PointsImpl( Mesh& mesh ) : PointsImpl( mesh.vertex_attribute_manager() ) { + DEBUG( "PointsImpl::PointsImpl" ); + DEBUG( "register_as_active_crs" ); register_as_active_crs( mesh ); } @@ -145,12 +153,13 @@ namespace geode PointsImpl( AttributeManager& manager, std::string_view attribute_name ) - : points_{ manager - .template find_or_create_attribute< VariableAttribute, - Point< dimension > >( attribute_name, - Point< dimension >{}, - { false, false, false } ) } { + const auto attribute_id = + manager.template create_attribute< VariableAttribute, + Point< dimension > >( attribute_name, + Point< dimension >{}, { false, false, false } ); + points_ = manager.template find_attribute< VariableAttribute, + Point< dimension > >( attribute_id ); } private: diff --git a/include/geode/mesh/core/texture1d.hpp b/include/geode/mesh/core/texture1d.hpp index b6565f05c..58b1dd941 100644 --- a/include/geode/mesh/core/texture1d.hpp +++ b/include/geode/mesh/core/texture1d.hpp @@ -61,6 +61,8 @@ namespace geode void set_texture_coordinates( const EdgeVertex& vertex, const Point1D& coordinates ) const; + [[nodiscard]] uuid texture_id() const; + private: Texture(); diff --git a/include/geode/mesh/core/texture2d.hpp b/include/geode/mesh/core/texture2d.hpp index 1f7e2545c..a3c13bdee 100644 --- a/include/geode/mesh/core/texture2d.hpp +++ b/include/geode/mesh/core/texture2d.hpp @@ -61,6 +61,8 @@ namespace geode void set_texture_coordinates( const PolygonVertex& vertex, const Point2D& coordinates ) const; + [[nodiscard]] uuid texture_id() const; + private: Texture(); diff --git a/include/geode/mesh/core/texture3d.hpp b/include/geode/mesh/core/texture3d.hpp index dc8cbee84..5ff9eafc9 100644 --- a/include/geode/mesh/core/texture3d.hpp +++ b/include/geode/mesh/core/texture3d.hpp @@ -61,6 +61,8 @@ namespace geode void set_texture_coordinates( const PolyhedronVertex& vertex, const Point3D& coordinates ) const; + [[nodiscard]] uuid texture_id() const; + private: Texture(); From cc237e7b272f8511543376fc9f27bf6f80e665c7 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 12 Jun 2026 10:12:06 +0200 Subject: [PATCH 04/19] wip --- .../geode/mesh/core/internal/texture_impl.hpp | 31 +- .../mesh/helpers/gradient_computation.hpp | 19 +- src/geode/basic/attribute_manager.cpp | 141 +++--- .../mesh/builder/edged_curve_builder.cpp | 15 +- src/geode/mesh/builder/graph_builder.cpp | 23 +- src/geode/mesh/builder/point_set_builder.cpp | 15 +- src/geode/mesh/builder/solid_mesh_builder.cpp | 17 +- .../mesh/builder/surface_mesh_builder.cpp | 17 +- .../coordinate_reference_system_manager.cpp | 2 + .../core/geode/geode_tetrahedral_solid.cpp | 34 +- .../core/geode/geode_triangulated_surface.cpp | 32 +- src/geode/mesh/core/graph.cpp | 14 +- src/geode/mesh/core/solid_mesh.cpp | 23 +- src/geode/mesh/core/surface_mesh.cpp | 22 +- src/geode/mesh/core/texture1d.cpp | 5 + src/geode/mesh/core/texture2d.cpp | 5 + src/geode/mesh/core/texture3d.cpp | 5 + src/geode/mesh/core/texture_manager.cpp | 4 +- src/geode/mesh/core/triangulated_surface.cpp | 6 + src/geode/mesh/helpers/convert_grid.cpp | 11 +- .../helpers/euclidean_distance_transform.cpp | 16 +- .../mesh/helpers/gradient_computation.cpp | 89 ++-- .../mesh/helpers/grid_point_function.cpp | 32 +- .../mesh/helpers/grid_scalar_function.cpp | 28 +- .../tetrahedral_solid_point_function.cpp | 30 +- .../tetrahedral_solid_scalar_function.cpp | 30 +- .../triangulated_surface_point_function.cpp | 30 +- .../triangulated_surface_scalar_function.cpp | 30 +- .../mixin/core/detail/relationships_impl.cpp | 7 +- src/geode/model/mixin/core/relationships.cpp | 11 +- .../model/mixin/core/vertex_identifier.cpp | 40 +- tests/basic/test-attribute.cpp | 400 ++++++++++-------- tests/common.hpp.in | 17 +- tests/geometry/test-point.cpp | 9 +- tests/image/test-colors.cpp | 15 +- tests/mesh/test-convert-surface.cpp | 19 +- tests/mesh/test-edged-curve.cpp | 10 +- .../test-euclidean-distance-transform.cpp | 1 + tests/mesh/test-generic-mesh-accessor.cpp | 60 ++- .../test-geometrical-operations-on-mesh.cpp | 18 + tests/mesh/test-gradient-computation.cpp | 49 ++- tests/mesh/test-light-regular-grid.cpp | 6 +- tests/mesh/test-point-set.cpp | 21 +- tests/mesh/test-polygonal-surface.cpp | 72 ++-- tests/mesh/test-polyhedral-solid.cpp | 86 ++-- tests/mesh/test-regular-grid.cpp | 30 +- tests/mesh/test-tetrahedral-solid.cpp | 27 +- tests/mesh/test-triangulated-surface.cpp | 16 +- tests/model/test-relationships.cpp | 8 +- 49 files changed, 948 insertions(+), 700 deletions(-) diff --git a/include/geode/mesh/core/internal/texture_impl.hpp b/include/geode/mesh/core/internal/texture_impl.hpp index 17992db03..321d3f74a 100644 --- a/include/geode/mesh/core/internal/texture_impl.hpp +++ b/include/geode/mesh/core/internal/texture_impl.hpp @@ -52,6 +52,11 @@ namespace geode return image_; } + [[nodiscard]] geode::uuid texture_id() const + { + return texture_id_; + } + void set_image( RasterImage< dimension >&& image ) { image_ = std::move( image ); @@ -86,11 +91,11 @@ namespace geode } TextureImpl( AttributeManager& manager, std::string_view name ) - : coordinates_{ - manager.find_or_create_attribute< VariableAttribute, - ElementTextureCoordinates >( name, {} ) - } { + texture_id_ = manager.create_attribute< VariableAttribute, + ElementTextureCoordinates >( name, {} ); + coordinates_ = manager.find_attribute< VariableAttribute, + ElementTextureCoordinates >( texture_id_ ); } TextureImpl() = default; @@ -102,14 +107,24 @@ namespace geode serializer.ext( *this, Growable< Archive, TextureImpl >{ { []( Archive& archive, TextureImpl& impl ) { - archive.object( impl.image_ ); - archive.ext( impl.coordinates_, - bitsery::ext::StdSmartPtr{} ); - } } } ); + archive.object( impl.image_ ); + geode::uuid texture_id; + archive.object( texture_id ); + impl.texture_id_ = texture_id; + archive.ext( impl.coordinates_, + bitsery::ext::StdSmartPtr{} ); + }, + []( Archive& archive, TextureImpl& impl ) { + archive.object( impl.image_ ); + archive.object( impl.texture_id_ ); + archive.ext( impl.coordinates_, + bitsery::ext::StdSmartPtr{} ); + } } } ); } private: RasterImage< dimension > image_; + geode::uuid texture_id_; std::shared_ptr< VariableAttribute< ElementTextureCoordinates > > coordinates_; }; diff --git a/include/geode/mesh/helpers/gradient_computation.hpp b/include/geode/mesh/helpers/gradient_computation.hpp index 0bb78cc84..9258236ac 100644 --- a/include/geode/mesh/helpers/gradient_computation.hpp +++ b/include/geode/mesh/helpers/gradient_computation.hpp @@ -25,6 +25,8 @@ #include +#include + namespace geode { FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh ); @@ -36,27 +38,26 @@ namespace geode namespace geode { template < index_t dimension > - [[nodiscard]] std::string compute_surface_scalar_function_gradient( - const SurfaceMesh< dimension >& mesh, - std::string_view scalar_function_name ); + [[nodiscard]] geode::uuid compute_surface_scalar_function_gradient( + const SurfaceMesh< dimension >& mesh, const uuid& scalar_function_id ); - [[nodiscard]] std::string opengeode_mesh_api + [[nodiscard]] geode::uuid opengeode_mesh_api compute_solid_scalar_function_gradient( - const SolidMesh3D& mesh, std::string_view scalar_function_name ); + const SolidMesh3D& mesh, const uuid& scalar_function_id ); namespace internal { template < index_t dimension > - [[nodiscard]] std::tuple< std::string, std::vector< index_t > > + [[nodiscard]] std::tuple< geode::uuid, std::vector< index_t > > compute_surface_scalar_function_gradient( const SurfaceMesh< dimension >& mesh, - std::string_view scalar_function_name, + const uuid& scalar_function_id, absl::Span< const index_t > no_value_vertices ); - [[nodiscard]] std::tuple< std::string, std::vector< index_t > > + [[nodiscard]] std::tuple< geode::uuid, std::vector< index_t > > opengeode_mesh_api compute_solid_scalar_function_gradient( const SolidMesh3D& mesh, - std::string_view scalar_function_name, + const uuid& scalar_function_id, absl::Span< const index_t > no_value_vertices ); } // namespace internal } // namespace geode \ No newline at end of file diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 77e52b0b4..ae0e8c992 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -158,7 +158,7 @@ namespace geode bool attribute_exists( const uuid &attribute_id ) const { - return absl::c_contains( attributes_, attribute_id ); + return attributes_.find( attribute_id ) != attributes_.end(); } void delete_attribute( const uuid &attribute_id ) @@ -226,10 +226,10 @@ namespace geode const AttributeBase::AttributeKey &key ) { nb_elements_ = attribute_manager.nb_elements_; - for( const auto &[attribute_name, attribute] : + for( const auto &[attribute_id, attribute] : attribute_manager.attributes_ ) { - const auto attribute_it = attributes_.find( attribute_name ); + const auto attribute_it = attributes_.find( attribute_id ); if( attribute_it != attributes_.end() ) { try @@ -239,14 +239,14 @@ namespace geode } catch( const std::bad_cast &e ) { - Logger::error( "Attribute \"", attribute_name, + Logger::error( "Attribute \"", attribute_id.string(), "\" cannot be copied: ", e.what() ); } } else { attributes_.emplace( - attribute_name, attribute->clone( key ) ); + attribute_id, attribute->clone( key ) ); } } } @@ -293,14 +293,15 @@ namespace geode it != attribute_manager.attributes_.end(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", - attribute_id, - "'. No attribute with this name exists in the source " + attribute_id.string(), + "'. No attribute with this id exists in the source " "AttributeManager." ); OpenGeodeBasicException::check_exception( it->second->properties().transferable, nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", - attribute_name, "'. The attribute is not transferable." ); + attribute_id.string(), + "'. The attribute is not transferable." ); if( attribute_exists( attribute_id ) ) { OpenGeodeBasicException::check_exception( @@ -308,8 +309,8 @@ namespace geode == this->attributes_.at( attribute_id )->type(), nullptr, OpenGeodeException::TYPE::data, "[AttributeManager::import] Could not import attribute '", - attribute_name, - "'. An attribute with the same name but a different type " + attribute_id.string(), + "'. An attribute with the same id but a different type " "already exists in the destination AttributeManager." ); this->attributes_.at( attribute_id ) ->import( old2new_mapping, it->second, key ); @@ -321,15 +322,6 @@ namespace geode } } - // void initialize_attribute_ids( const AttributeBase::AttributeKey &key - // ) - // { - // for( auto &[attribute_id, attribute] : attributes_ ) - // { - // attribute->set_id( attribute_id, key ); - // } - // } - void set_attribute_properties( geode::uuid attribute_id, const AttributeProperties &new_properties ) { @@ -337,7 +329,7 @@ namespace geode OpenGeodeBasicException::check_exception( attribute_it != attributes_.end(), nullptr, OpenGeodeException::TYPE::data, - "[AttributeManager::rename_attribute] Attribute ", + "[AttributeManager::set_attribute_properties] Attribute ", attribute_id.string(), "does not exist" ); attribute_it->second->set_properties( new_properties ); } @@ -345,30 +337,69 @@ namespace geode template < typename Archive > void serialize( Archive &serializer ) { - serializer.ext( - *this, Growable< Archive, Impl >{ { []( Archive &local_archive, - Impl &impl ) { - local_archive.value4b( impl.nb_elements_ ); - local_archive.ext( impl.attributes_, - bitsery::ext::StdMap{ impl.attributes_.max_size() }, - []( Archive &local_archive2, std::string &name, - std::shared_ptr< AttributeBase > &attribute ) { - local_archive2.text1b( name, name.max_size() ); - try - { - local_archive2.ext( - attribute, bitsery::ext::StdSmartPtr{} ); - } - catch( ... ) - { - throw OpenGeodeBasicException{ nullptr, - OpenGeodeException::TYPE::internal, - "[AttributeManager::serialize] Cannot " - "serialize attribute ", - name, " holding type ", attribute->type() }; - } - } ); - } } } ); + serializer.ext( *this, + Growable< Archive, Impl >{ + { []( Archive &local_archive, Impl &impl ) { + local_archive.value4b( impl.nb_elements_ ); + absl::linked_hash_map< std::string, + std::shared_ptr< AttributeBase > > + old_map; + local_archive.ext( old_map, + bitsery::ext::StdMap{ old_map.max_size() }, + []( Archive &local_archive2, std::string &name, + std::shared_ptr< AttributeBase > &attribute ) { + local_archive2.text1b( name, name.max_size() ); + try + { + local_archive2.ext( attribute, + bitsery::ext::StdSmartPtr{} ); + } + catch( ... ) + { + throw OpenGeodeBasicException{ nullptr, + OpenGeodeException::TYPE::internal, + "[AttributeManager::serialize] Cannot " + "serialize attribute ", + name, " holding type ", + attribute->type() }; + } + } ); + for( auto &[attribute_name, attribute] : old_map ) + { + IdentifierBuilder builder{ *attribute }; + builder.set_name( attribute_name ); + impl.attributes_.emplace( + attribute->id(), std::move( attribute ) ); + } + }, + []( Archive &local_archive, Impl &impl ) { + local_archive.value4b( impl.nb_elements_ ); + local_archive.ext( impl.attributes_, + bitsery::ext::StdMap{ + impl.attributes_.max_size() }, + []( Archive &local_archive2, + geode::uuid &attribute_id, + std::shared_ptr< AttributeBase > + &attribute ) { + local_archive2.object( attribute_id ); + try + { + local_archive2.ext( attribute, + bitsery::ext::StdSmartPtr{} ); + } + catch( ... ) + { + throw OpenGeodeBasicException{ nullptr, + OpenGeodeException::TYPE::internal, + "[AttributeManager::serialize] " + "Cannot " + "serialize attribute with id ", + attribute_id.string(), + " holding type ", + attribute->type() }; + } + } ); + } } } ); } absl::Mutex &mutex() const @@ -542,18 +573,16 @@ namespace geode template < typename Archive > void AttributeManager::serialize( Archive &serializer ) { - serializer.ext( *this, - Growable< Archive, AttributeManager >{ - { []( Archive &local_archive, - AttributeManager &attribute_manager ) { - local_archive.object( attribute_manager.impl_ ); - const AttributeBase::AttributeKey key; - attribute_manager.impl_->initialize_attribute_names( key ); - }, - []( Archive &local_archive, - AttributeManager &attribute_manager ) { - local_archive.object( attribute_manager.impl_ ); - } } } ); + serializer.ext( + *this, Growable< Archive, AttributeManager >{ + { []( Archive &local_archive, + AttributeManager &attribute_manager ) { + local_archive.object( attribute_manager.impl_ ); + }, + []( Archive &local_archive, + AttributeManager &attribute_manager ) { + local_archive.object( attribute_manager.impl_ ); + } } } ); } SERIALIZE_BITSERY_ARCHIVE( opengeode_basic_api, AttributeManager ); diff --git a/src/geode/mesh/builder/edged_curve_builder.cpp b/src/geode/mesh/builder/edged_curve_builder.cpp index c07842aef..89a1e5639 100644 --- a/src/geode/mesh/builder/edged_curve_builder.cpp +++ b/src/geode/mesh/builder/edged_curve_builder.cpp @@ -67,16 +67,13 @@ namespace geode "[EdgedCurveBuilder::copy] Cannot copy a mesh into an already " "initialized mesh." ); GraphBuilder::copy( edged_curve ); - if( edged_curve_.impl_name() == edged_curve.impl_name() ) + // if( edged_curve_.impl_name() == edged_curve.impl_name() ) + // { + // do_copy_points( edged_curve ); + // } + for( const auto p : Range{ edged_curve.nb_vertices() } ) { - do_copy_points( edged_curve ); - } - else - { - for( const auto p : Range{ edged_curve.nb_vertices() } ) - { - this->set_point( p, edged_curve.point( p ) ); - } + this->set_point( p, edged_curve.point( p ) ); } } diff --git a/src/geode/mesh/builder/graph_builder.cpp b/src/geode/mesh/builder/graph_builder.cpp index f629501ab..7beb04af0 100644 --- a/src/geode/mesh/builder/graph_builder.cpp +++ b/src/geode/mesh/builder/graph_builder.cpp @@ -245,22 +245,19 @@ namespace geode VertexSetBuilder::copy( graph ); create_edges( graph.nb_edges() ); graph_.edge_attribute_manager().copy( graph.edge_attribute_manager() ); - if( graph_.impl_name() == graph.impl_name() ) + // if( graph_.impl_name() == graph.impl_name() ) + // { + // do_copy_edges( graph ); + // } + for( const auto e : Range{ graph.nb_edges() } ) { - do_copy_edges( graph ); - } - else - { - for( const auto e : Range{ graph.nb_edges() } ) + for( const auto v : LRange{ 2 } ) { - for( const auto v : LRange{ 2 } ) + const EdgeVertex id{ e, v }; + const auto vertex = graph.edge_vertex( id ); + if( vertex != NO_ID ) { - const EdgeVertex id{ e, v }; - const auto vertex = graph.edge_vertex( id ); - if( vertex != NO_ID ) - { - set_edge_vertex( id, vertex ); - } + set_edge_vertex( id, vertex ); } } } diff --git a/src/geode/mesh/builder/point_set_builder.cpp b/src/geode/mesh/builder/point_set_builder.cpp index 6aafe4757..59da047d8 100644 --- a/src/geode/mesh/builder/point_set_builder.cpp +++ b/src/geode/mesh/builder/point_set_builder.cpp @@ -65,16 +65,13 @@ namespace geode "[PointSetBuilder::copy] Cannot copy a mesh into an already " "initialized mesh." ); VertexSetBuilder::copy( point_set ); - if( point_set_.impl_name() == point_set.impl_name() ) + // if( point_set_.impl_name() == point_set.impl_name() ) + // { + // do_copy_points( point_set ); + // } + for( const auto p : Range{ point_set.nb_vertices() } ) { - do_copy_points( point_set ); - } - else - { - for( const auto p : Range{ point_set.nb_vertices() } ) - { - this->set_point( p, point_set.point( p ) ); - } + this->set_point( p, point_set.point( p ) ); } } diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index 1b7b307f4..53a60a861 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -958,16 +958,6 @@ namespace geode solid_mesh_.disable_facets(); } VertexSetBuilder::copy( solid_mesh ); - if( solid_mesh.impl_name() == solid_mesh_.impl_name() ) - { - do_copy_points( solid_mesh ); - do_copy_polyhedra( solid_mesh ); - } - else - { - copy_points( solid_mesh, *this ); - copy_polyhedra( solid_mesh, *this ); - } solid_mesh_.polyhedron_attribute_manager().copy( solid_mesh.polyhedron_attribute_manager() ); if( solid_mesh.are_edges_enabled() ) @@ -978,6 +968,13 @@ namespace geode { solid_mesh_.copy_facets( solid_mesh, {} ); } + // if( solid_mesh.impl_name() == solid_mesh_.impl_name() ) + // { + // do_copy_points( solid_mesh ); + // do_copy_polyhedra( solid_mesh ); + // } + copy_points( solid_mesh, *this ); + copy_polyhedra( solid_mesh, *this ); } template class opengeode_mesh_api SolidMeshBuilder< 3 >; diff --git a/src/geode/mesh/builder/surface_mesh_builder.cpp b/src/geode/mesh/builder/surface_mesh_builder.cpp index 778ce2f2f..e30bcfafc 100644 --- a/src/geode/mesh/builder/surface_mesh_builder.cpp +++ b/src/geode/mesh/builder/surface_mesh_builder.cpp @@ -832,18 +832,15 @@ namespace geode surface_mesh_.disable_edges(); } VertexSetBuilder::copy( surface_mesh ); - if( surface_mesh.impl_name() == surface_mesh_.impl_name() ) - { - do_copy_points( surface_mesh ); - do_copy_polygons( surface_mesh ); - } - else - { - copy_points( surface_mesh, *this ); - copy_polygons( surface_mesh, *this ); - } + // if( surface_mesh.impl_name() == surface_mesh_.impl_name() ) + // { + // do_copy_points( surface_mesh ); + // do_copy_polygons( surface_mesh ); + // } surface_mesh_.polygon_attribute_manager().copy( surface_mesh.polygon_attribute_manager() ); + copy_points( surface_mesh, *this ); + copy_polygons( surface_mesh, *this ); if( surface_mesh.are_edges_enabled() ) { surface_mesh_.copy_edges( surface_mesh, {} ); diff --git a/src/geode/mesh/core/coordinate_reference_system_manager.cpp b/src/geode/mesh/core/coordinate_reference_system_manager.cpp index 846b216f5..28cca6492 100644 --- a/src/geode/mesh/core/coordinate_reference_system_manager.cpp +++ b/src/geode/mesh/core/coordinate_reference_system_manager.cpp @@ -91,6 +91,8 @@ namespace geode void register_coordinate_reference_system( std::string_view name, std::shared_ptr< CoordinateReferenceSystem< dimension > >&& crs ) { + DEBUG( "register_coordinate_reference_system" ); + DEBUG( name ); const auto status = crss_.emplace( to_string( name ), std::move( crs ) ); OpenGeodeMeshException::check_exception( status.second, nullptr, diff --git a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp index 9195fa167..f4cf760a0 100644 --- a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp @@ -48,20 +48,28 @@ namespace geode public: explicit Impl( OpenGeodeTetrahedralSolid< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ), - tetrahedron_vertices_( mesh.polyhedron_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - std::array< index_t, 4 > >( "tetrahedron_vertices", - std::array< index_t, 4 >{ - NO_ID, NO_ID, NO_ID, NO_ID }, - { false, false, false } ) ), - tetrahedron_adjacents_( mesh.polyhedron_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - std::array< index_t, 4 > >( "tetrahedron_adjacents", - std::array< index_t, 4 >{ - NO_ID, NO_ID, NO_ID, NO_ID }, - { false, false, false } ) ) + : internal::PointsImpl< dimension >( mesh ) { + const auto tetrahedron_vertices_id = + mesh.polyhedron_attribute_manager() + .template create_attribute< VariableAttribute, + std::array< index_t, 4 > >( "tetrahedron_vertices", + std::array< index_t, 4 >{ NO_ID, NO_ID, NO_ID, NO_ID }, + { false, false, false } ); + tetrahedron_vertices_ = + mesh.polyhedron_attribute_manager() + .template find_attribute< VariableAttribute, + std::array< index_t, 4 > >( tetrahedron_vertices_id ); + const auto tetrahedron_adjacents_id = + mesh.polyhedron_attribute_manager() + .template create_attribute< VariableAttribute, + std::array< index_t, 4 > >( "tetrahedron_adjacents", + std::array< index_t, 4 >{ NO_ID, NO_ID, NO_ID, NO_ID }, + { false, false, false } ); + tetrahedron_adjacents_ = + mesh.polyhedron_attribute_manager() + .template find_attribute< VariableAttribute, + std::array< index_t, 4 > >( tetrahedron_adjacents_id ); } index_t get_polyhedron_vertex( diff --git a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp index e0aa6c26e..f2e1c6890 100644 --- a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp +++ b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp @@ -46,18 +46,28 @@ namespace geode public: explicit Impl( OpenGeodeTriangulatedSurface< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ), - triangle_vertices_( mesh.polygon_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - std::array< index_t, 3 > >( "triangle_vertices", - std::array< index_t, 3 >{ NO_ID, NO_ID, NO_ID }, - { false, false, false } ) ), - triangle_adjacents_( mesh.polygon_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - std::array< index_t, 3 > >( "triangle_adjacents", - std::array< index_t, 3 >{ NO_ID, NO_ID, NO_ID }, - { false, false, false } ) ) + : internal::PointsImpl< dimension >( mesh ) { + const auto triangle_vertices_id = + mesh.polygon_attribute_manager() + .template create_attribute< VariableAttribute, + std::array< index_t, 3 > >( "triangle_vertices", + std::array< index_t, 3 >{ NO_ID, NO_ID, NO_ID }, + { false, false, false } ); + triangle_vertices_ = + mesh.polygon_attribute_manager() + .template find_attribute< VariableAttribute, + std::array< index_t, 3 > >( triangle_vertices_id ); + const auto triangle_adjacents_id = + mesh.polygon_attribute_manager() + .template create_attribute< VariableAttribute, + std::array< index_t, 3 > >( "triangle_adjacents", + std::array< index_t, 3 >{ NO_ID, NO_ID, NO_ID }, + { false, false, false } ); + triangle_adjacents_ = + mesh.polygon_attribute_manager() + .template find_attribute< VariableAttribute, + std::array< index_t, 3 > >( triangle_adjacents_id ); } index_t get_polygon_vertex( const PolygonVertex& polygon_vertex ) const diff --git a/src/geode/mesh/core/graph.cpp b/src/geode/mesh/core/graph.cpp index 4cb4eefa5..9eb185190 100644 --- a/src/geode/mesh/core/graph.cpp +++ b/src/geode/mesh/core/graph.cpp @@ -47,12 +47,16 @@ namespace geode public: explicit Impl( Graph& graph ) - : edges_around_vertex_( graph.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - EdgesAroundVertex >( ATTRIBUTE_NAME, - EdgesAroundVertex{}, - { false, false, false } ) ) { + const auto attribute_id = + graph.vertex_attribute_manager() + .template create_attribute< VariableAttribute, + EdgesAroundVertex >( ATTRIBUTE_NAME, + EdgesAroundVertex{}, { false, false, false } ); + edges_around_vertex_ = + graph.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + EdgesAroundVertex >( attribute_id ); } AttributeManager& edge_attribute_manager() const diff --git a/src/geode/mesh/core/solid_mesh.cpp b/src/geode/mesh/core/solid_mesh.cpp index c5a06d876..427a9414a 100644 --- a/src/geode/mesh/core/solid_mesh.cpp +++ b/src/geode/mesh/core/solid_mesh.cpp @@ -435,17 +435,20 @@ namespace geode using CachedPolyhedra = CachedValue< internal::PolyhedraAroundVertexImpl >; static constexpr auto POLYHEDRA_AROUND_VERTEX_NAME = - "polyhedra_around_vertex"; public: explicit Impl( SolidMesh& solid ) - : polyhedron_around_vertex_( solid.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - PolyhedronVertex >( "polyhedron_around_vertex", - PolyhedronVertex{}, - { false, false, false } ) ) { + const auto attribute_id = + solid.vertex_attribute_manager() + .template create_attribute< VariableAttribute, + PolyhedronVertex >( "polyhedron_around_vertex", + PolyhedronVertex{}, { false, false, false } ); + polyhedron_around_vertex_ = + solid.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + PolyhedronVertex >( attribute_id ); initialize_polyhedra_around_vertex( solid ); } @@ -678,11 +681,15 @@ namespace geode void initialize_polyhedra_around_vertex( const SolidMesh< dimension >& solid ) { - polyhedra_around_vertex_ = + const auto attribute_id = solid.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, CachedPolyhedra >( POLYHEDRA_AROUND_VERTEX_NAME, CachedPolyhedra{}, { false, false, false } ); + polyhedra_around_vertex_ = + solid.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + CachedPolyhedra >( attribute_id ); } const internal::PolyhedraAroundVertexImpl& diff --git a/src/geode/mesh/core/surface_mesh.cpp b/src/geode/mesh/core/surface_mesh.cpp index 465292ae0..ec1d82bde 100644 --- a/src/geode/mesh/core/surface_mesh.cpp +++ b/src/geode/mesh/core/surface_mesh.cpp @@ -283,12 +283,16 @@ namespace geode public: Impl( SurfaceMesh& surface ) - : polygon_around_vertex_( surface.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - PolygonVertex >( "polygon_around_vertex", - PolygonVertex{}, - { false, false, false } ) ) { + const auto attribute_id = + surface.vertex_attribute_manager() + .template create_attribute< VariableAttribute, + PolygonVertex >( "polygon_around_vertex", + PolygonVertex{}, { false, false, false } ); + polygon_around_vertex_ = + surface.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + PolygonVertex >( attribute_id ); initialize_polygons_around_vertex( surface ); } @@ -431,11 +435,15 @@ namespace geode void initialize_polygons_around_vertex( const SurfaceMesh< dimension >& surface ) { - polygons_around_vertex_ = + const auto attribute_id = surface.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, CachedPolygons >( POLYGONS_AROUND_VERTEX_NAME, CachedPolygons{}, { false, false, false } ); + polygons_around_vertex_ = + surface.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + CachedPolygons >( attribute_id ); } private: diff --git a/src/geode/mesh/core/texture1d.cpp b/src/geode/mesh/core/texture1d.cpp index 8a292f5e0..005c2fb2a 100644 --- a/src/geode/mesh/core/texture1d.cpp +++ b/src/geode/mesh/core/texture1d.cpp @@ -103,6 +103,11 @@ namespace geode impl_->set_texture_coordinates( vertex, coordinates ); } + geode::uuid Texture< 1 >::texture_id() const + { + return impl_->texture_id(); + } + template < typename Archive > void Texture< 1 >::serialize( Archive& serializer ) { diff --git a/src/geode/mesh/core/texture2d.cpp b/src/geode/mesh/core/texture2d.cpp index f2f3aa1f6..7888d657c 100644 --- a/src/geode/mesh/core/texture2d.cpp +++ b/src/geode/mesh/core/texture2d.cpp @@ -104,6 +104,11 @@ namespace geode impl_->set_texture_coordinates( vertex, coordinates ); } + geode::uuid Texture< 2 >::texture_id() const + { + return impl_->texture_id(); + } + template < typename Archive > void Texture< 2 >::serialize( Archive& serializer ) { diff --git a/src/geode/mesh/core/texture3d.cpp b/src/geode/mesh/core/texture3d.cpp index 912bc1411..c32d7aaa3 100644 --- a/src/geode/mesh/core/texture3d.cpp +++ b/src/geode/mesh/core/texture3d.cpp @@ -105,6 +105,11 @@ namespace geode impl_->set_texture_coordinates( vertex, coordinates ); } + geode::uuid Texture< 3 >::texture_id() const + { + return impl_->texture_id(); + } + template < typename Archive > void Texture< 3 >::serialize( Archive& serializer ) { diff --git a/src/geode/mesh/core/texture_manager.cpp b/src/geode/mesh/core/texture_manager.cpp index c1f426621..f77b155c9 100644 --- a/src/geode/mesh/core/texture_manager.cpp +++ b/src/geode/mesh/core/texture_manager.cpp @@ -73,8 +73,10 @@ namespace geode void delete_texture( std::string_view name ) { + const auto& texture = textures_.find_texture( name, {} ); + const auto texture_id = texture.texture_id(); textures_.delete_texture( name, {} ); - manager_.delete_attribute( name ); + manager_.delete_attribute( texture_id ); } private: diff --git a/src/geode/mesh/core/triangulated_surface.cpp b/src/geode/mesh/core/triangulated_surface.cpp index 99d3f59bd..3d2d7bda4 100644 --- a/src/geode/mesh/core/triangulated_surface.cpp +++ b/src/geode/mesh/core/triangulated_surface.cpp @@ -60,7 +60,13 @@ namespace geode std::unique_ptr< TriangulatedSurface< dimension > > TriangulatedSurface< dimension >::clone() const { + DEBUG( "CLONE" ); auto clone = create( this->impl_name() ); + DEBUG( "clone" ); + for( const auto vertex : geode::Range{ clone->nb_vertices() } ) + { + SDEBUG( clone->point( vertex ) ); + } auto builder = TriangulatedSurfaceBuilder< dimension >::create( *clone ); builder->copy_identifier( *this ); diff --git a/src/geode/mesh/helpers/convert_grid.cpp b/src/geode/mesh/helpers/convert_grid.cpp index ff8df0b11..4efbb43a3 100644 --- a/src/geode/mesh/helpers/convert_grid.cpp +++ b/src/geode/mesh/helpers/convert_grid.cpp @@ -51,9 +51,14 @@ namespace geode cells_number, cells_directions }; IdentifierBuilder builder{ grid }; internal::copy_meta_info( raster, builder ); - auto color = grid.cell_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - RGBColor >( "RGB_data", {} ); + auto color_attribute_id = + grid.cell_attribute_manager() + .template create_attribute< VariableAttribute, RGBColor >( + "RGB_data", {} ); + auto color = + grid.cell_attribute_manager() + .template find_attribute< VariableAttribute, RGBColor >( + color_attribute_id ); for( const auto cell_id : geode::Range{ raster.nb_cells() } ) { color->set_value( cell_id, raster.color( cell_id ) ); diff --git a/src/geode/mesh/helpers/euclidean_distance_transform.cpp b/src/geode/mesh/helpers/euclidean_distance_transform.cpp index 940e86cb4..395b98e21 100644 --- a/src/geode/mesh/helpers/euclidean_distance_transform.cpp +++ b/src/geode/mesh/helpers/euclidean_distance_transform.cpp @@ -41,13 +41,17 @@ namespace geode EuclideanDistanceTransform( const Grid< dimension >& grid, absl::Span< const Index > grid_cell_id, std::string_view distance_map_name ) - : grid_( grid ), - squared_cell_length_{}, - distance_map_{ grid.cell_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( distance_map_name, - std::numeric_limits< double >::max() ) } + : grid_( grid ), squared_cell_length_{} { + const auto distance_map_id = + grid.cell_attribute_manager() + .template create_attribute< VariableAttribute, double >( + distance_map_name, + std::numeric_limits< double >::max() ); + distance_map_ = + grid.cell_attribute_manager() + .template find_attribute< VariableAttribute, double >( + distance_map_id ); for( const auto d : LRange( dimension ) ) { squared_cell_length_[d] = grid_.cell_length_in_direction( d ) diff --git a/src/geode/mesh/helpers/gradient_computation.cpp b/src/geode/mesh/helpers/gradient_computation.cpp index 10a347ab7..1b9357931 100644 --- a/src/geode/mesh/helpers/gradient_computation.cpp +++ b/src/geode/mesh/helpers/gradient_computation.cpp @@ -34,7 +34,6 @@ #include #include #include - namespace { template < typename Mesh > @@ -42,10 +41,10 @@ namespace { public: ScalarGradientComputer( - const Mesh& mesh, std::string_view scalar_function_name ) + const Mesh& mesh, const geode::uuid& scalar_function_id ) : mesh_( mesh ), vertex_has_value_( mesh.nb_vertices(), true ) { - initialize_attribute_and_name( scalar_function_name ); + initialize_attribute_and_id( scalar_function_id ); for( const auto vertex_id : geode::Range{ mesh_.nb_vertices() } ) { if( std::isnan( scalar_function_->value( vertex_id ) ) ) @@ -56,26 +55,31 @@ namespace } ScalarGradientComputer( const Mesh& mesh, - std::string_view scalar_function_name, + const geode::uuid& scalar_function_id, absl::Span< const geode::index_t > no_value_vertices ) : mesh_( mesh ), vertex_has_value_( mesh.nb_vertices(), true ) { - initialize_attribute_and_name( scalar_function_name ); + initialize_attribute_and_id( scalar_function_id ); for( const auto vertex_id : no_value_vertices ) { vertex_has_value_[vertex_id] = false; } } - std::tuple< std::string, std::vector< geode::index_t > > + std::tuple< geode::uuid, std::vector< geode::index_t > > compute_scalar_function_gradient() const { + const auto gradient_function_name = + absl::StrCat( scalar_function_->name().value(), "_gradient" ); + auto gradient_function_id = + mesh_.vertex_attribute_manager() + .template create_attribute< geode::VariableAttribute, + geode::Vector< Mesh::dim > >( + gradient_function_name, geode::Vector< Mesh::dim >{} ); auto gradient_function = mesh_.vertex_attribute_manager() - .template find_or_create_attribute< - geode::VariableAttribute, geode::Vector< Mesh::dim > >( - output_gradient_attribute_name_, - geode::Vector< Mesh::dim >{} ); + .template find_attribute< geode::VariableAttribute, + geode::Vector< Mesh::dim > >( gradient_function_id ); std::vector< geode::index_t > no_gradient_value_vertices; for( const auto vertex_id : geode::Range{ mesh_.nb_vertices() } ) { @@ -84,39 +88,30 @@ namespace no_gradient_value_vertices.push_back( vertex_id ); } } - return std::make_tuple( output_gradient_attribute_name_, - std::move( no_gradient_value_vertices ) ); + return std::make_tuple( + gradient_function_id, std::move( no_gradient_value_vertices ) ); } private: - void initialize_attribute_and_name( - std::string_view scalar_function_name ) + void initialize_attribute_and_id( + const geode::uuid& scalar_function_id ) { geode::OpenGeodeMeshException::check_exception( mesh_.vertex_attribute_manager().attribute_exists( - scalar_function_name ), + scalar_function_id ), nullptr, geode::OpenGeodeException::TYPE::data, "[compute_scalar_function_gradient] No attribute exists with " "given name." ); geode::OpenGeodeMeshException::check_exception( mesh_.vertex_attribute_manager().attribute_type( - scalar_function_name ) + scalar_function_id ) == typeid( double ).name(), nullptr, geode::OpenGeodeException::TYPE::data, "[compute_scalar_function_gradient] The attribute linked to " "given name is not scalar." ); scalar_function_ = mesh_.vertex_attribute_manager() - .template find_attribute< double >( scalar_function_name ); - output_gradient_attribute_name_ = - absl::StrCat( scalar_function_name, "_gradient" ); - geode::index_t counter{ 0 }; - while( mesh_.vertex_attribute_manager().attribute_exists( - absl::StrCat( output_gradient_attribute_name_, counter ) ) ) - { - counter++; - } - absl::StrAppend( &output_gradient_attribute_name_, counter ); + .template read_attribute< double >( scalar_function_id ); } bool compute_gradient( @@ -197,7 +192,6 @@ namespace private: const Mesh& mesh_; std::shared_ptr< geode::ReadOnlyAttribute< double > > scalar_function_; - std::string output_gradient_attribute_name_; std::vector< bool > vertex_has_value_; }; } // namespace @@ -205,61 +199,60 @@ namespace namespace geode { template < index_t dimension > - std::string compute_surface_scalar_function_gradient( - const SurfaceMesh< dimension >& mesh, - std::string_view scalar_function_name ) + geode::uuid compute_surface_scalar_function_gradient( + const SurfaceMesh< dimension >& mesh, const uuid& scalar_function_id ) { - ::ScalarGradientComputer computer{ mesh, scalar_function_name }; + ::ScalarGradientComputer computer{ mesh, scalar_function_id }; return std::get< 0 >( computer.compute_scalar_function_gradient() ); } - std::string compute_solid_scalar_function_gradient( - const SolidMesh3D& mesh, std::string_view scalar_function_name ) + geode::uuid compute_solid_scalar_function_gradient( + const SolidMesh3D& mesh, const uuid& scalar_function_id ) { - ::ScalarGradientComputer computer{ mesh, scalar_function_name }; + ::ScalarGradientComputer computer{ mesh, scalar_function_id }; return std::get< 0 >( computer.compute_scalar_function_gradient() ); } - template std::string opengeode_mesh_api + template geode::uuid opengeode_mesh_api compute_surface_scalar_function_gradient( - const SurfaceMesh2D&, std::string_view ); - template std::string opengeode_mesh_api + const SurfaceMesh2D&, const uuid& ); + template geode::uuid opengeode_mesh_api compute_surface_scalar_function_gradient( - const SurfaceMesh3D&, std::string_view ); + const SurfaceMesh3D&, const uuid& ); namespace internal { template < index_t dimension > - std::tuple< std::string, std::vector< index_t > > + std::tuple< geode::uuid, std::vector< index_t > > compute_surface_scalar_function_gradient( const SurfaceMesh< dimension >& mesh, - std::string_view scalar_function_name, + const uuid& scalar_function_id, absl::Span< const index_t > no_value_vertices ) { - ::ScalarGradientComputer computer{ mesh, scalar_function_name, + ::ScalarGradientComputer computer{ mesh, scalar_function_id, no_value_vertices }; return computer.compute_scalar_function_gradient(); } - std::tuple< std::string, std::vector< index_t > > + std::tuple< geode::uuid, std::vector< index_t > > compute_solid_scalar_function_gradient( const SolidMesh3D& mesh, - std::string_view scalar_function_name, + const uuid& scalar_function_id, absl::Span< const index_t > no_value_vertices ) { - ::ScalarGradientComputer computer{ mesh, scalar_function_name, + ::ScalarGradientComputer computer{ mesh, scalar_function_id, no_value_vertices }; return computer.compute_scalar_function_gradient(); } - template std::tuple< std::string, std::vector< index_t > > + template std::tuple< geode::uuid, std::vector< index_t > > opengeode_mesh_api compute_surface_scalar_function_gradient( const SurfaceMesh2D&, - std::string_view, + const uuid&, absl::Span< const index_t > ); - template std::tuple< std::string, std::vector< index_t > > + template std::tuple< geode::uuid, std::vector< index_t > > opengeode_mesh_api compute_surface_scalar_function_gradient( const SurfaceMesh3D&, - std::string_view, + const uuid&, absl::Span< const index_t > ); } // namespace internal } // namespace geode \ No newline at end of file diff --git a/src/geode/mesh/helpers/grid_point_function.cpp b/src/geode/mesh/helpers/grid_point_function.cpp index aa573460f..79b3fc20f 100644 --- a/src/geode/mesh/helpers/grid_point_function.cpp +++ b/src/geode/mesh/helpers/grid_point_function.cpp @@ -44,33 +44,29 @@ namespace geode Point< point_dimension > value ) : grid_( grid ) { - OpenGeodeMeshException::check_exception( - !grid_.grid_vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create GridPointFunction: attribute with name ", - function_name, " already exists." ); - function_attribute_ = + const auto function_id = grid_.grid_vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, Point< point_dimension > >( function_name, std::move( value ), { false, true } ); + function_attribute_ = + grid_.grid_vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( function_id ); } - Impl( const Grid< dimension >& grid, std::string_view function_name ) + Impl( const Grid< dimension >& grid, std::string_view attribute_name ) : grid_( grid ) { - OpenGeodeMeshException::check_exception( - grid_.grid_vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create GridPointFunction: attribute with name", - function_name, " does not exist." ); - function_attribute_ = + const auto attribute_id = grid_.grid_vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - Point< point_dimension > >( function_name, + .template create_attribute< VariableAttribute, + Point< point_dimension > >( attribute_name, Point< point_dimension >(), { false, true } ); + function_attribute_ = + grid_.grid_vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( attribute_id ); } void set_value( diff --git a/src/geode/mesh/helpers/grid_scalar_function.cpp b/src/geode/mesh/helpers/grid_scalar_function.cpp index 9c19d3618..6e9bed147 100644 --- a/src/geode/mesh/helpers/grid_scalar_function.cpp +++ b/src/geode/mesh/helpers/grid_scalar_function.cpp @@ -44,31 +44,27 @@ namespace geode double value ) : grid_( grid ) { - OpenGeodeMeshException::check_exception( - !grid_.grid_vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create GridScalarFunction: attribute with name ", - function_name, " already exists." ); + const auto function_id = + grid_.grid_vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, value, { false, true } ); function_attribute_ = grid_.grid_vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, value, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } Impl( const Grid< dimension >& grid, std::string_view function_name ) : grid_( grid ) { - OpenGeodeMeshException::check_exception( - grid_.grid_vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create GridScalarFunction: attribute with name", - function_name, " does not exist." ); + const auto function_id = + grid_.grid_vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, 0, { false, true } ); function_attribute_ = grid_.grid_vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, 0, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } void set_value( diff --git a/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp b/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp index 00e1f07ee..74f140763 100644 --- a/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp +++ b/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp @@ -44,36 +44,30 @@ namespace geode Point< point_dimension > value ) : solid_( solid ) { - OpenGeodeMeshException::check_exception( - !solid_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TetrahedralSolidPointFunction: attribute with " - "name '", - function_name, "' already exists." ); - function_attribute_ = + const auto function_id = solid_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, Point< point_dimension > >( function_name, std::move( value ), { false, true } ); + function_attribute_ = + solid_.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( function_id ); } Impl( const TetrahedralSolid< dimension >& solid, std::string_view function_name ) : solid_( solid ) { - OpenGeodeMeshException::check_exception( - solid_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TetrahedralSolidPointFunction: attribute with " - "name '", - function_name, "' does not exist." ); - function_attribute_ = + const auto function_id = solid_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, Point< point_dimension > >( function_name, Point< point_dimension >(), { false, true } ); + function_attribute_ = + solid_.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( function_id ); } void set_value( index_t vertex_id, Point< point_dimension > value ) diff --git a/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp b/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp index c8700d330..cb8ef104c 100644 --- a/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp +++ b/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp @@ -43,34 +43,28 @@ namespace geode double value ) : solid_( solid ) { - OpenGeodeMeshException::check_exception( - !solid_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TetrahedralSolidScalarFunction: attribute with " - "name '", - function_name, "' already exists." ); + const auto function_id = + solid_.vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, value, { false, true } ); function_attribute_ = solid_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, value, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } Impl( const TetrahedralSolid< dimension >& solid, std::string_view function_name ) : solid_( solid ) { - OpenGeodeMeshException::check_exception( - solid_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TetrahedralSolidScalarFunction: attribute with " - "name '", - function_name, "' does not exist." ); + const auto function_id = + solid_.vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, 0, { false, true } ); function_attribute_ = solid_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, 0, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } void set_value( index_t vertex_id, double value ) diff --git a/src/geode/mesh/helpers/triangulated_surface_point_function.cpp b/src/geode/mesh/helpers/triangulated_surface_point_function.cpp index 56d9e6395..deb85f94e 100644 --- a/src/geode/mesh/helpers/triangulated_surface_point_function.cpp +++ b/src/geode/mesh/helpers/triangulated_surface_point_function.cpp @@ -44,36 +44,30 @@ namespace geode Point< point_dimension > value ) : surface_( surface ) { - OpenGeodeMeshException::check_exception( - !surface_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TriangulatedSurfacePointFunction: attribute " - "with name '", - function_name, "' already exists." ); - function_attribute_ = + const auto function_id = surface_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, Point< point_dimension > >( function_name, std::move( value ), { false, true } ); + function_attribute_ = + surface_.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( function_id ); } Impl( const TriangulatedSurface< dimension >& surface, std::string_view function_name ) : surface_( surface ) { - OpenGeodeMeshException::check_exception( - surface_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TriangulatedSurfacePointFunction: attribute " - "with name '", - function_name, "' does not exist." ); - function_attribute_ = + const auto function_id = surface_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, Point< point_dimension > >( function_name, Point< point_dimension >(), { false, true } ); + function_attribute_ = + surface_.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + Point< point_dimension > >( function_id ); } void set_value( index_t vertex_id, Point< point_dimension > value ) diff --git a/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp b/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp index da24e3e03..87089b36b 100644 --- a/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp +++ b/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp @@ -44,34 +44,28 @@ namespace geode double value ) : surface_( surface ) { - OpenGeodeMeshException::check_exception( - !surface_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TriangulatedSurfaceScalarFunction: attribute " - "with name '", - function_name, "' already exists." ); + const auto function_id = + surface_.vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, value, { false, true } ); function_attribute_ = surface_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, value, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } Impl( const TriangulatedSurface< dimension >& surface, std::string_view function_name ) : surface_( surface ) { - OpenGeodeMeshException::check_exception( - surface_.vertex_attribute_manager().attribute_exists( - function_name ), - nullptr, OpenGeodeException::TYPE::data, - "Cannot create TriangulatedSurfaceScalarFunction: attribute " - "with name '", - function_name, "' does not exist." ); + const auto function_id = + surface_.vertex_attribute_manager() + .template create_attribute< VariableAttribute, double >( + function_name, 0, { false, true } ); function_attribute_ = surface_.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - double >( function_name, 0, { false, true } ); + .template find_attribute< VariableAttribute, double >( + function_id ); } void set_value( index_t vertex_id, double value ) diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index 0f6cf5c6f..8b8195d2a 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -232,10 +232,13 @@ namespace geode void RelationshipsImpl::initialize_attributes() { - ids_ = + const auto ids_attribute_id = graph_->vertex_attribute_manager() - .find_or_create_attribute< VariableAttribute, ComponentID >( + .create_attribute< VariableAttribute, ComponentID >( "id", ComponentID{} ); + ids_ = graph_->vertex_attribute_manager() + .find_attribute< VariableAttribute, ComponentID >( + ids_attribute_id ); } std::optional< index_t > RelationshipsImpl::vertex_id( diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index 68a2e1e70..43e559bd7 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -236,9 +236,14 @@ namespace geode void initialize_relation_attribute() { - relation_type_ = relation_attribute_manager() - .find_or_create_attribute< VariableAttribute, - RelationType >( "relation_type", NO_ID ); + const auto relation_type_attribute_id = + relation_attribute_manager() + .create_attribute< VariableAttribute, RelationType >( + "relation_type", NO_ID ); + relation_type_ = + relation_attribute_manager() + .find_attribute< VariableAttribute, RelationType >( + relation_type_attribute_id ); } std::string relation_to_string( index_t relation_type ) const diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 3b8878233..697019916 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -106,13 +106,18 @@ namespace geode public: Impl() - : component_vertices_( unique_vertices_.vertex_attribute_manager() - .find_or_create_attribute< VariableAttribute, - std::vector< ComponentMeshVertex > >( - "component vertices", - std::vector< ComponentMeshVertex >{}, - { false, false, false } ) ) { + const auto unique_vertices_attribute_id = + unique_vertices_.vertex_attribute_manager() + .create_attribute< VariableAttribute, + std::vector< ComponentMeshVertex > >( + "component vertices", + std::vector< ComponentMeshVertex >{}, + { false, false, false } ); + component_vertices_ = unique_vertices_.vertex_attribute_manager() + .find_attribute< VariableAttribute, + std::vector< ComponentMeshVertex > >( + unique_vertices_attribute_id ); } index_t nb_unique_vertices() const @@ -178,21 +183,19 @@ namespace geode const auto& mesh = component.mesh(); if( it == vertex2unique_vertex_.end() ) { - mesh.vertex_attribute_manager().delete_attribute( - unique_vertices_name ); - vertex2unique_vertex_.emplace( component.id(), + const auto unique_vertices_attribute_id = mesh.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, + .template create_attribute< VariableAttribute, index_t >( unique_vertices_name, NO_ID, - { false, false, false } ) ); + { false, false, false } ); + vertex2unique_vertex_.emplace( component.id(), + mesh.vertex_attribute_manager() + .template find_attribute< VariableAttribute, index_t >( + unique_vertices_attribute_id ) ); } else { - auto attribute = - mesh.vertex_attribute_manager() - .template find_or_create_attribute< VariableAttribute, - index_t >( unique_vertices_name, NO_ID, - { false, false, false } ); + auto attribute = vertex2unique_vertex_.at( component.id() ); attribute->set_properties( { false, false, false } ); try { @@ -215,8 +218,9 @@ namespace geode void unregister_component( const MeshComponent& component ) { const auto& mesh = component.mesh(); - mesh.vertex_attribute_manager().delete_attribute( - unique_vertices_name ); + auto attribute = vertex2unique_vertex_.at( component.id() ); + const auto attribute_id = attribute->id(); + mesh.vertex_attribute_manager().delete_attribute( attribute_id ); vertex2unique_vertex_.erase( component.id() ); filter_component_vertices( component.id() ); } diff --git a/tests/basic/test-attribute.cpp b/tests/basic/test-attribute.cpp index a3f1d07cb..0c592860e 100644 --- a/tests/basic/test-attribute.cpp +++ b/tests/basic/test-attribute.cpp @@ -106,17 +106,20 @@ namespace geode }; } // namespace geode -void test_constant_attribute( geode::AttributeManager& manager ) +void test_constant_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::ConstantAttribute, bool >( + "bool", attribute_id, true, { true, true } ); auto constant_attribute = - manager.find_or_create_attribute< geode::ConstantAttribute, bool >( - "bool", true, { true, true } ); + manager.find_attribute< geode::ConstantAttribute, bool >( + attribute_id ); geode::OpenGeodeBasicException::test( constant_attribute->name() == "bool", "Wrong attribute name" ); geode::OpenGeodeBasicException::test( constant_attribute->default_value() == true, "Wrong default value" ); - auto attribute = manager.find_attribute< bool >( "bool" ); + auto attribute = manager.read_attribute< bool >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 0 ), "Should be equal to true" ); geode::OpenGeodeBasicException::test( @@ -128,11 +131,13 @@ void test_constant_attribute( geode::AttributeManager& manager ) !attribute->value( 12 ), "Should be equal to false" ); } -void test_foo_constant_attribute( geode::AttributeManager& manager ) +void test_foo_constant_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::ConstantAttribute, Foo >( + "foo", attribute_id, Foo{} ); auto constant_attribute = - manager.find_or_create_attribute< geode::ConstantAttribute, Foo >( - "foo_cst", Foo{} ); + manager.find_attribute< geode::ConstantAttribute, Foo >( attribute_id ); constant_attribute->modify_value( []( Foo& foo ) { foo.double_ = 12.4; } ); @@ -141,12 +146,14 @@ void test_foo_constant_attribute( geode::AttributeManager& manager ) "Should be equal to 12.4" ); } -void test_foo_variable_attribute( geode::AttributeManager& manager ) +void test_foo_variable_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::VariableAttribute, Foo >( + "foo2", attribute_id, Foo{}, { false, false, false } ); auto variable_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, Foo >( - "foo_var", Foo{}, { false, false, false } ); - manager.set_attribute_properties( "foo_var", { true, false, true } ); + manager.find_attribute< geode::VariableAttribute, Foo >( attribute_id ); + manager.set_attribute_properties( attribute_id, { true, false, true } ); geode::OpenGeodeBasicException::test( variable_attribute->properties().assignable && !variable_attribute->properties().interpolable @@ -170,16 +177,18 @@ void test_foo_variable_attribute( geode::AttributeManager& manager ) "Should be equal to 12.4" ); } -void test_int_variable_attribute( geode::AttributeManager& manager ) +void test_int_variable_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::VariableAttribute, int >( + "int", attribute_id, 12, { true, true } ); auto variable_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, int >( - "int", 12, { true, true } ); + manager.find_attribute< geode::VariableAttribute, int >( attribute_id ); geode::OpenGeodeBasicException::test( variable_attribute->default_value() == 12, "Wrong default value" ); variable_attribute->set_value( 3, 3 ); - const auto attribute = manager.find_attribute< int >( "int" ); + const auto attribute = manager.read_attribute< int >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 3 ) == 3, "Int variable value 3 should be equal to 3" ); geode::OpenGeodeBasicException::test( attribute->value( 6 ) == 12, @@ -190,11 +199,13 @@ void test_int_variable_attribute( geode::AttributeManager& manager ) "Int variable value 3 should be equal to 5" ); } -void test_foo_sparse_attribute( geode::AttributeManager& manager ) +void test_foo_sparse_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::SparseAttribute, Foo >( + "foo", attribute_id, Foo{} ); auto sparse_attribute = - manager.find_or_create_attribute< geode::SparseAttribute, Foo >( - "foo_spr", Foo{} ); + manager.find_attribute< geode::SparseAttribute, Foo >( attribute_id ); sparse_attribute->modify_value( 3, []( Foo& foo ) { foo.double_ = 12.4; } ); @@ -211,11 +222,14 @@ void test_foo_sparse_attribute( geode::AttributeManager& manager ) "Foo sparse value should be equal to 3" ); } -void test_double_sparse_attribute( geode::AttributeManager& manager ) +void test_double_sparse_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::SparseAttribute, double >( + "double", attribute_id, 12., { true, true } ); auto sparse_attribute = - manager.find_or_create_attribute< geode::SparseAttribute, double >( - "double", 12., { true, true } ); + manager.find_attribute< geode::SparseAttribute, double >( + attribute_id ); geode::OpenGeodeBasicException::test( sparse_attribute->default_value() == 12, "Wrong default value" ); sparse_attribute->set_value( 3, 3 ); @@ -223,7 +237,7 @@ void test_double_sparse_attribute( geode::AttributeManager& manager ) manager.assign_attribute_value( 3, 2 ); manager.interpolate_attribute_value( { { 1, 7 }, { 0.5, 0.3 } }, 4 ); - auto attribute = manager.find_attribute< double >( "double" ); + auto attribute = manager.read_attribute< double >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 2 ) == 3, "Double sparse value 2 should be equal to 3" ); geode::OpenGeodeBasicException::test( attribute->value( 3 ) == 3, @@ -242,10 +256,12 @@ void test_double_sparse_attribute( geode::AttributeManager& manager ) void test_double_array_attribute( geode::AttributeManager& manager ) { - auto array_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, + const auto attribute_id = + manager.create_attribute< geode::VariableAttribute, std::array< double, 3 > >( - "array_double_3", { { 10., 11., 12. } }, { true, true } ); + "double_array", { { 10., 11., 12. } }, { true, true } ); + auto array_attribute = manager.find_attribute< geode::VariableAttribute, + std::array< double, 3 > >( attribute_id ); geode::OpenGeodeBasicException::test( array_attribute->default_value()[0] == 10., "Wrong default value" ); geode::OpenGeodeBasicException::test( @@ -258,7 +274,7 @@ void test_double_array_attribute( geode::AttributeManager& manager ) manager.interpolate_attribute_value( { { 1, 7 }, { 0.5, 0.3 } }, 4 ); auto attribute = - manager.find_attribute< std::array< double, 3 > >( "array_double_3" ); + manager.read_attribute< std::array< double, 3 > >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 2 )[0] == 1., "Value [2,0] Should be equal to 1., not ", attribute->value( 2 )[0] ); geode::OpenGeodeBasicException::test( attribute->value( 2 )[1] == 2., @@ -299,16 +315,20 @@ void test_double_array_attribute( geode::AttributeManager& manager ) attribute->value( 3 )[2] == 5., "Should be equal to 5." ); } -void test_bool_variable_attribute( geode::AttributeManager& manager ) +void test_bool_variable_attribute( + geode::AttributeManager& manager, const geode::uuid& attribute_id ) { + manager.create_attribute< geode::VariableAttribute, bool >( + "bool", attribute_id, false, { true, true } ); + auto variable_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, bool >( - "bool_var", false, { true, true } ); + manager.find_attribute< geode::VariableAttribute, bool >( + attribute_id ); geode::OpenGeodeBasicException::test( variable_attribute->default_value() == false, "Wrong default value" ); variable_attribute->set_value( 3, true ); - const auto attribute = manager.find_attribute< bool >( "bool_var" ); + const auto attribute = manager.read_attribute< bool >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 3 ), "Should be equal to true" ); @@ -320,23 +340,23 @@ void test_bool_variable_attribute( geode::AttributeManager& manager ) bool managers_have_same_attributes( const geode::AttributeManager& manager, const geode::AttributeManager& reloaded_manager ) { - const auto& attribute_names = manager.attribute_names(); - const auto& reloaded_attribute_names = reloaded_manager.attribute_names(); - if( attribute_names.size() != reloaded_attribute_names.size() ) + const auto& attribute_ids = manager.attribute_ids(); + const auto& reloaded_attribute_ids = reloaded_manager.attribute_ids(); + if( attribute_ids.size() != reloaded_attribute_ids.size() ) { return false; } - for( const auto& att : attribute_names ) + for( const auto& att : attribute_ids ) { - if( absl::c_find( reloaded_attribute_names, att ) - == reloaded_attribute_names.end() ) + if( absl::c_find( reloaded_attribute_ids, att ) + == reloaded_attribute_ids.end() ) { return false; } } - for( const auto& att : reloaded_attribute_names ) + for( const auto& att : reloaded_attribute_ids ) { - if( absl::c_find( attribute_names, att ) == attribute_names.end() ) + if( absl::c_find( attribute_ids, att ) == attribute_ids.end() ) { return false; } @@ -347,106 +367,98 @@ bool managers_have_same_attributes( const geode::AttributeManager& manager, template < typename T > void check_one_attribute_values( geode::AttributeManager& manager, geode::AttributeManager& reloaded_manager, - std::string_view name ) + const geode::uuid& attribute_id ) { - const auto in_att = manager.find_attribute< T >( name ); - const auto out_att = reloaded_manager.find_attribute< T >( name ); + const auto in_att = manager.read_attribute< T >( attribute_id ); + const auto out_att = reloaded_manager.read_attribute< T >( attribute_id ); for( auto i : geode::Range{ manager.nb_elements() } ) { geode::OpenGeodeBasicException::test( in_att->value( i ) == out_att->value( i ), - "At least one value of Attribute ", name, + "At least one value of Attribute ", attribute_id, " is not correct after reloading" ); } } -void check_attribute_values( geode::AttributeManager& manager, - geode::AttributeManager& reloaded_manager ) -{ - check_one_attribute_values< bool >( manager, reloaded_manager, "bool" ); - check_one_attribute_values< int >( manager, reloaded_manager, "int" ); - check_one_attribute_values< double >( manager, reloaded_manager, "double" ); - check_one_attribute_values< bool >( manager, reloaded_manager, "bool_var" ); - check_one_attribute_values< Foo >( manager, reloaded_manager, "foo_cst" ); - check_one_attribute_values< Foo >( manager, reloaded_manager, "foo_var" ); - check_one_attribute_values< Foo >( manager, reloaded_manager, "foo_spr" ); -} - -void test_serialize_manager( geode::AttributeManager& manager ) -{ - const auto filename = "manager.out"; - std::ofstream file{ filename, std::ofstream::binary }; - geode::TContext context{}; - geode::register_attribute_type< Foo, geode::Serializer >( - std::get< 0 >( context ), "Foo" ); - geode::register_basic_serialize_pcontext( std::get< 0 >( context ) ); - geode::register_attribute_type< std::array< double, 2 >, - geode::Serializer >( std::get< 0 >( context ), "array_double_2" ); - geode::Serializer archive{ context, file }; - archive.object( manager ); - archive.adapter().flush(); - geode::OpenGeodeBasicException::test( std::get< 1 >( context ).isValid(), - "Error while writing file: ", filename ); - - std::ifstream infile{ filename, std::ifstream::binary }; - geode::AttributeManager reloaded_manager; - geode::TContext reload_context{}; - geode::register_attribute_type< std::array< double, 30 >, - geode::Serializer >( std::get< 0 >( context ), "array_double_30" ); - geode::register_basic_deserialize_pcontext( - std::get< 0 >( reload_context ) ); - geode::register_attribute_type< Foo, geode::Deserializer >( - std::get< 0 >( reload_context ), "Foo" ); - geode::register_attribute_type< std::array< double, 2 >, - geode::Deserializer >( - std::get< 0 >( reload_context ), "array_double_2" ); - geode::Deserializer unarchive{ reload_context, infile }; - unarchive.object( reloaded_manager ); - const auto& adapter = unarchive.adapter(); - geode::OpenGeodeBasicException::test( - adapter.error() == bitsery::ReaderError::NoError - && adapter.isCompletedSuccessfully() - && std::get< 1 >( context ).isValid(), - "Error while reading file: ", filename ); - - geode::OpenGeodeBasicException::test( - reloaded_manager.nb_elements() == manager.nb_elements(), - "Number of elements in reloaded AttributeManager is not " - "correct" ); - geode::OpenGeodeBasicException::test( - managers_have_same_attributes( manager, reloaded_manager ), - "Number and names of attributes in reloaded AttributeManager " - "are not correct" ); - check_attribute_values( manager, reloaded_manager ); -} - -void test_attribute_types( geode::AttributeManager& manager ) +// void check_attribute_values( geode::AttributeManager& manager, +// geode::AttributeManager& reloaded_manager ) +// { +// check_one_attribute_values< bool >( manager, reloaded_manager, "bool" ); +// check_one_attribute_values< int >( manager, reloaded_manager, "int" ); +// check_one_attribute_values< double >( manager, reloaded_manager, "double" +// ); check_one_attribute_values< bool >( manager, reloaded_manager, +// "bool_var" ); check_one_attribute_values< Foo >( manager, +// reloaded_manager, "foo_cst" ); check_one_attribute_values< Foo >( +// manager, reloaded_manager, "foo_var" ); check_one_attribute_values< Foo +// >( manager, reloaded_manager, "foo_spr" ); +// } + +// void test_serialize_manager( geode::AttributeManager& manager ) +// { +// const auto filename = "manager.out"; +// std::ofstream file{ filename, std::ofstream::binary }; +// geode::TContext context{}; +// geode::register_attribute_type< Foo, geode::Serializer >( +// std::get< 0 >( context ), "Foo" ); +// geode::register_basic_serialize_pcontext( std::get< 0 >( context ) ); +// geode::register_attribute_type< std::array< double, 2 >, +// geode::Serializer >( std::get< 0 >( context ), "array_double_2" ); +// geode::Serializer archive{ context, file }; +// archive.object( manager ); +// archive.adapter().flush(); +// geode::OpenGeodeBasicException::test( std::get< 1 >( context ).isValid(), +// "Error while writing file: ", filename ); + +// std::ifstream infile{ filename, std::ifstream::binary }; +// geode::AttributeManager reloaded_manager; +// geode::TContext reload_context{}; +// geode::register_attribute_type< std::array< double, 30 >, +// geode::Serializer >( std::get< 0 >( context ), "array_double_30" ); +// geode::register_basic_deserialize_pcontext( +// std::get< 0 >( reload_context ) ); +// geode::register_attribute_type< Foo, geode::Deserializer >( +// std::get< 0 >( reload_context ), "Foo" ); +// geode::register_attribute_type< std::array< double, 2 >, +// geode::Deserializer >( +// std::get< 0 >( reload_context ), "array_double_2" ); +// geode::Deserializer unarchive{ reload_context, infile }; +// unarchive.object( reloaded_manager ); +// const auto& adapter = unarchive.adapter(); +// geode::OpenGeodeBasicException::test( +// adapter.error() == bitsery::ReaderError::NoError +// && adapter.isCompletedSuccessfully() +// && std::get< 1 >( context ).isValid(), +// "Error while reading file: ", filename ); + +// geode::OpenGeodeBasicException::test( +// reloaded_manager.nb_elements() == manager.nb_elements(), +// "Number of elements in reloaded AttributeManager is not " +// "correct" ); +// geode::OpenGeodeBasicException::test( +// managers_have_same_attributes( manager, reloaded_manager ), +// "Number and names of attributes in reloaded AttributeManager " +// "are not correct" ); +// check_attribute_values( manager, reloaded_manager ); +// } + +void test_attribute_types( geode::AttributeManager& manager, + const geode::uuid& bool_variable_attribute_id ) { geode::OpenGeodeBasicException::test( - manager.attribute_type( "bool_var" ) == typeid( bool ).name(), + manager.attribute_type( bool_variable_attribute_id ) + == typeid( bool ).name(), "Returned attribute type is not correct (should be bool)" ); + geode::uuid not_registered_attribute_id; geode::OpenGeodeBasicException::test( - manager.attribute_type( "unknown_name" ) == "undefined", + manager.attribute_type( not_registered_attribute_id ) == "undefined", "Returned attribute type is not correct (should be undefined)" ); } -void test_attribute_rename( geode::AttributeManager& manager ) -{ - manager.rename_attribute( "foo_cst", "foo_constant" ); - auto constant_attribute = - manager.find_or_create_attribute< geode::ConstantAttribute, Foo >( - "foo_constant", Foo{} ); - geode::OpenGeodeBasicException::test( - constant_attribute->value().double_ == 12.4, - "Should be equal to 12.4" ); -} - void test_number_of_attributes( geode::AttributeManager& manager, geode::index_t nb ) { - geode::OpenGeodeBasicException::test( - manager.attribute_names().size() == nb, "Should have ", nb, - " attributes in the manager" ); + geode::OpenGeodeBasicException::test( manager.attribute_ids().size() == nb, + "Should have ", nb, " attributes in the manager" ); } void test_delete_attribute_elements( geode::AttributeManager& manager ) @@ -461,9 +473,10 @@ void test_delete_attribute_elements( geode::AttributeManager& manager ) } void test_sparse_attribute_after_element_deletion( - geode::AttributeManager& manager ) + geode::AttributeManager& manager, const geode::uuid& double_attribute_id ) { - const auto sparse_attribute = manager.find_attribute< double >( "double" ); + const auto sparse_attribute = + manager.read_attribute< double >( double_attribute_id ); geode::OpenGeodeBasicException::test( sparse_attribute->value( 0 ) == 12, "Element 0 of sparse attribute should be 12 " ); geode::OpenGeodeBasicException::test( sparse_attribute->value( 3 ) == 3, @@ -474,23 +487,27 @@ void test_sparse_attribute_after_element_deletion( "Element 7 of sparse attribute should be 7 " ); } -void test_generic_value( geode::AttributeManager& manager ) +geode::uuid test_generic_value( geode::AttributeManager& manager, + const geode::uuid& foo_sparse_id, + const geode::uuid& double_attribute_id ) { - const auto& foo_attr = manager.find_attribute< Foo >( "foo_spr" ); + const auto& foo_attr = manager.read_attribute< Foo >( foo_sparse_id ); geode::OpenGeodeBasicException::test( foo_attr->is_genericable(), "Foo attribute should be genericable" ); geode::OpenGeodeBasicException::test( foo_attr->generic_value( 3 ) == 15.4f, "Generic value for element 3 of foo sparse attribute should be " "15.4" ); - const auto& double_attr = manager.find_attribute< double >( "double" ); + const auto& double_attr = + manager.read_attribute< double >( double_attribute_id ); geode::OpenGeodeBasicException::test( double_attr->generic_value( 7 ) == 7, "Generic value for element 7 of double attribute should be 7" ); - auto array_attr = - manager.find_or_create_attribute< geode::VariableAttribute, - std::array< double, 2 > >( - "array_double", std::array< double, 2 >() ); + auto array_attr_id = manager.create_attribute< geode::VariableAttribute, + std::array< double, 2 > >( + "array_double_2", std::array< double, 2 >() ); + auto array_attr = manager.find_attribute< geode::VariableAttribute, + std::array< double, 2 > >( array_attr_id ); array_attr->set_value( 2, { 3.1, 1.3 } ); geode::OpenGeodeBasicException::test( array_attr->is_genericable(), "Foo attribute is genericable" ); @@ -505,25 +522,30 @@ void test_generic_value( geode::AttributeManager& manager ) array_attr->generic_item_value( 2, 1 ) == 1.3f, "Generic value for element 2,1 of array attribute should be " "1.3" ); + return array_attr_id; } -void test_copy_manager( geode::AttributeManager& manager ) +void test_copy_manager( geode::AttributeManager& manager, + const geode::uuid& bool_variable_attribute_id ) { geode::AttributeManager manager2; manager2.copy( manager ); manager2.reserve( 15 ); - test_attribute_types( manager2 ); + test_attribute_types( manager2, bool_variable_attribute_id ); test_number_of_attributes( manager2, 8 ); } -void test_import_manager( geode::AttributeManager& manager ) +void test_import_manager( geode::AttributeManager& manager, + const geode::uuid& bool_variable_attribute_id, + const geode::uuid& array_double_attribute_id, + const geode::uuid& double_attribute_id ) { const auto nb_elements = manager.nb_elements(); geode::AttributeManager manager2; std::vector< geode::index_t > old2new( nb_elements, geode::NO_ID ); manager2.resize( 0 ); manager2.import( manager, old2new ); - test_attribute_types( manager2 ); + test_attribute_types( manager2, bool_variable_attribute_id ); test_number_of_attributes( manager2, 8 ); geode::AttributeManager manager3; @@ -533,12 +555,12 @@ void test_import_manager( geode::AttributeManager& manager ) } manager3.resize( nb_elements - 2 ); manager3.import( manager, old2new ); - test_attribute_types( manager3 ); + test_attribute_types( manager3, bool_variable_attribute_id ); test_number_of_attributes( manager3, 8 ); - auto array_attr = - manager.find_attribute< std::array< double, 2 > >( "array_double" ); - auto array_attr2 = - manager3.find_attribute< std::array< double, 2 > >( "array_double" ); + auto array_attr = manager.read_attribute< std::array< double, 2 > >( + array_double_attribute_id ); + auto array_attr2 = manager3.read_attribute< std::array< double, 2 > >( + array_double_attribute_id ); geode::OpenGeodeBasicException::test( array_attr->value( 2 ) == array_attr2->value( 4 ), "Error in attribute import value." ); @@ -550,43 +572,59 @@ void test_import_manager( geode::AttributeManager& manager ) } manager4.resize( nb_elements ); manager4.import( manager, old2new ); - test_attribute_types( manager4 ); + test_attribute_types( manager4, bool_variable_attribute_id ); test_number_of_attributes( manager4, 8 ); - test_sparse_attribute_after_element_deletion( manager4 ); + test_sparse_attribute_after_element_deletion( + manager4, double_attribute_id ); } void test_multi_import_manager() { geode::AttributeManager from1; from1.resize( 10 ); - auto attr1_from1 = from1.find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "variable", 42 ); + auto attr1_from1_id = + from1.create_attribute< geode::VariableAttribute, geode::index_t >( + " variable", 42 ); + auto attr1_from1 = + from1.find_attribute< geode::VariableAttribute, geode::index_t >( + attr1_from1_id ); for( const auto i : geode::LRange( from1.nb_elements() ) ) { attr1_from1->set_value( i, i ); } - auto attr2_from1 = - from1.find_or_create_attribute< geode::ConstantAttribute, double >( + auto attr2_from1_id = + from1.create_attribute< geode::ConstantAttribute, double >( "constant", 1.0 ); - auto attr3_from1 = - from1.find_or_create_attribute< geode::SparseAttribute, std::string >( + auto attr2_from1 = from1.find_attribute< geode::ConstantAttribute, double >( + attr2_from1_id ); + auto attr3_from1_id = + from1.create_attribute< geode::SparseAttribute, std::string >( "sparse", "default" ); + auto attr3_from1 = + from1.find_attribute< geode::SparseAttribute, std::string >( + attr3_from1_id ); attr3_from1->set_value( 1, "one" ); geode::AttributeManager from2; from2.resize( 10 ); - auto attr1_from2 = from2.find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "variable", 42 ); + from2.create_attribute< geode::VariableAttribute, geode::index_t >( + " variable", attr1_from1_id, 42 ); + auto attr1_from2 = + from2.find_attribute< geode::VariableAttribute, geode::index_t >( + attr1_from1_id ); for( const auto i : geode::LRange( from2.nb_elements() ) ) { attr1_from2->set_value( i, from2.nb_elements() - i ); } - auto attr2_from2 = - from2.find_or_create_attribute< geode::ConstantAttribute, double >( - "constant", 2.0 ); + from2.create_attribute< geode::ConstantAttribute, double >( + "constant", attr2_from1_id, 2.0 ); + auto attr2_from2 = from2.find_attribute< geode::ConstantAttribute, double >( + attr2_from1_id ); + from2.create_attribute< geode::SparseAttribute, std::string >( + "sparse", attr3_from1_id, "another_default" ); auto attr3_from2 = - from2.find_or_create_attribute< geode::SparseAttribute, std::string >( - "sparse", "another_default" ); + from2.find_attribute< geode::SparseAttribute, std::string >( + attr3_from1_id ); attr3_from2->set_value( 2, "two" ); geode::GenericMapping< geode::index_t > from1_to; @@ -618,9 +656,10 @@ void test_multi_import_manager() "default", "default", "another_default", "two", "another_default", "another_default", "another_default" }; const auto result_variable = - to.find_attribute< geode::index_t >( "variable" ); - const auto result_constant = to.find_attribute< double >( "constant" ); - const auto result_sparse = to.find_attribute< std::string >( "sparse" ); + to.read_attribute< geode::index_t >( attr1_from1_id ); + const auto result_constant = to.read_attribute< double >( attr2_from1_id ); + const auto result_sparse = + to.read_attribute< std::string >( attr3_from1_id ); for( const auto i : geode::LRange( from2.nb_elements() ) ) { @@ -636,12 +675,14 @@ void test_multi_import_manager() } } -void test_permutation( geode::AttributeManager& manager ) +void test_permutation( geode::AttributeManager& manager, + const geode::uuid& int_att_id, + const geode::uuid& double_att_id ) { std::vector< geode::index_t > permutation{ 2, 1, 4, 6, 7, 8, 5, 9, 3, 0 }; manager.permute_elements( permutation ); - const auto int_attribute = manager.find_attribute< int >( "int" ); + const auto int_attribute = manager.read_attribute< int >( int_att_id ); geode::OpenGeodeBasicException::test( int_attribute->value( 3 ) == 12, "Attribute value 3 should be equal to 12" ); geode::OpenGeodeBasicException::test( int_attribute->value( 0 ) == 5, @@ -649,7 +690,7 @@ void test_permutation( geode::AttributeManager& manager ) geode::OpenGeodeBasicException::test( int_attribute->value( 8 ) == 5, "Attribute value 8 should be equal to 5" ); - auto double_attribute = manager.find_attribute< double >( "double" ); + auto double_attribute = manager.read_attribute< double >( double_att_id ); geode::OpenGeodeBasicException::test( double_attribute->value( 2 ) == 12, "Attribute value 2 should be equal to 3, not ", double_attribute->value( 2 ) ); @@ -667,27 +708,36 @@ void test() manager.resize( 10 ); geode::OpenGeodeBasicException::test( manager.nb_elements() == 10, "Manager should have 10 elements" ); - test_constant_attribute( manager ); - test_foo_constant_attribute( manager ); - test_int_variable_attribute( manager ); - test_bool_variable_attribute( manager ); - test_foo_variable_attribute( manager ); - test_double_sparse_attribute( manager ); - test_foo_sparse_attribute( manager ); - test_generic_value( manager ); - test_permutation( manager ); + geode::uuid constant_attribute_id; + test_constant_attribute( manager, constant_attribute_id ); + geode::uuid foo_constant_attribute_id; + test_foo_constant_attribute( manager, foo_constant_attribute_id ); + geode::uuid int_variable_attribute_id; + test_int_variable_attribute( manager, int_variable_attribute_id ); + geode::uuid bool_variable_attribute_id; + test_bool_variable_attribute( manager, bool_variable_attribute_id ); + geode::uuid foo_variable_attribute_id; + test_foo_variable_attribute( manager, foo_variable_attribute_id ); + geode::uuid double_sparse_attribute_id; + test_double_sparse_attribute( manager, double_sparse_attribute_id ); + geode::uuid foo_sparse_attribute_id; + test_foo_sparse_attribute( manager, foo_sparse_attribute_id ); + const auto array_double_attribute_id = test_generic_value( + manager, foo_sparse_attribute_id, double_sparse_attribute_id ); + test_permutation( + manager, int_variable_attribute_id, double_sparse_attribute_id ); test_delete_attribute_elements( manager ); - test_sparse_attribute_after_element_deletion( manager ); - - test_serialize_manager( manager ); + test_sparse_attribute_after_element_deletion( + manager, double_sparse_attribute_id ); - test_copy_manager( manager ); - test_import_manager( manager ); + // test_serialize_manager( manager ); + test_copy_manager( manager, bool_variable_attribute_id ); + test_import_manager( manager, bool_variable_attribute_id, + array_double_attribute_id, double_sparse_attribute_id ); test_multi_import_manager(); - test_attribute_types( manager ); - test_attribute_rename( manager ); + test_attribute_types( manager, bool_variable_attribute_id ); test_number_of_attributes( manager, 8 ); - manager.delete_attribute( "bool" ); + manager.delete_attribute( bool_variable_attribute_id ); test_number_of_attributes( manager, 7 ); manager.clear_attributes(); test_number_of_attributes( manager, 7 ); diff --git a/tests/common.hpp.in b/tests/common.hpp.in index e5fdbdf1b..787bf04d9 100644 --- a/tests/common.hpp.in +++ b/tests/common.hpp.in @@ -43,17 +43,10 @@ namespace geode #define OPENGEODE_TEST( name ) \ int main() \ { \ - try \ - { \ - geode::OpenGeodeBasicLibrary::initialize(); \ - geode::Logger::set_level( geode::Logger::LEVEL::trace ); \ - test(); \ + geode::OpenGeodeBasicLibrary::initialize(); \ + geode::Logger::set_level( geode::Logger::LEVEL::trace ); \ + test(); \ \ - geode::Logger::info( "TEST SUCCESS" ); \ - return 0; \ - } \ - catch( ... ) \ - { \ - return geode::geode_lippincott(); \ - } \ + geode::Logger::info( "TEST SUCCESS" ); \ + return 0; \ } \ No newline at end of file diff --git a/tests/geometry/test-point.cpp b/tests/geometry/test-point.cpp index bae2f7ae2..0d30d2f8f 100644 --- a/tests/geometry/test-point.cpp +++ b/tests/geometry/test-point.cpp @@ -65,9 +65,12 @@ void test_interpolation() { geode::AttributeManager manager; manager.resize( 10 ); - auto attribute = manager.find_or_create_attribute< geode::VariableAttribute, - geode::Point< 3 > >( - "point_3", geode::Point3D{ { 10., 11., 12. } }, { false, true } ); + auto attribute_id = + manager.create_attribute< geode::VariableAttribute, geode::Point< 3 > >( + "points", geode::Point3D{ { 10., 11., 12. } }, { false, true } ); + auto attribute = + manager.find_attribute< geode::VariableAttribute, geode::Point< 3 > >( + attribute_id ); geode::OpenGeodeGeometryException::test( attribute->default_value().value( 0 ) == 10., "Wrong default value" ); geode::OpenGeodeGeometryException::test( diff --git a/tests/image/test-colors.cpp b/tests/image/test-colors.cpp index de74a4d2b..3416dd56c 100644 --- a/tests/image/test-colors.cpp +++ b/tests/image/test-colors.cpp @@ -46,14 +46,19 @@ void test_color_attribute() { geode::AttributeManager manager; manager.resize( 1 ); - const auto rgb_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, - geode::RGBColor >( "rgb_color", geode::RGBColor{} ); + const auto rgb_attribute_id = + manager.create_attribute< geode::VariableAttribute, geode::RGBColor >( + "rgb_color", geode::RGBColor{} ); + auto rgb_attribute = + manager.find_attribute< geode::VariableAttribute, geode::RGBColor >( + rgb_attribute_id ); rgb_attribute->set_value( 0, { 3, 254, 68 } ); - const auto greyscale_attribute = - manager.find_or_create_attribute< geode::VariableAttribute, + const auto greyscale_attribute_id = + manager.create_attribute< geode::VariableAttribute, geode::GreyscaleColor >( "greyscale_color", geode::GreyscaleColor{} ); + auto greyscale_attribute = manager.find_attribute< geode::VariableAttribute, + geode::GreyscaleColor >( greyscale_attribute_id ); greyscale_attribute->set_value( 0, geode::GreyscaleColor{ 67 } ); geode::OpenGeodeImageException::test( rgb_attribute->is_genericable(), "[TEST] Attribute on RGBColor should be genericable." ); diff --git a/tests/mesh/test-convert-surface.cpp b/tests/mesh/test-convert-surface.cpp index 73f5762a2..9d85262ca 100644 --- a/tests/mesh/test-convert-surface.cpp +++ b/tests/mesh/test-convert-surface.cpp @@ -115,22 +115,25 @@ void convert_grid_to_surface() absl::StrCat( geode::DATA_PATH, "old_regular_grid.og_rgd2d" ) ); const auto old_regular_grid_surface = geode::convert_grid_into_triangulated_surface( *old_regular_grid ); + auto test_attribute_id = + old_regular_grid_surface->vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::Point2D >( + "test", geode::Point2D{ { 0., 0. } } ); auto test_attribute = old_regular_grid_surface->vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::Point2D >( "test", geode::Point2D{ { 0., 0. } } ); - auto pt_attribute = old_regular_grid_surface->vertex_attribute_manager() - .find_attribute< geode::Point2D >( "points" ); + .find_attribute< geode::VariableAttribute, geode::Point2D >( + test_attribute_id ); const auto old_regular_grid_surface2 = geode::convert_surface_mesh_into_triangulated_surface( *old_regular_grid ) .value(); + old_regular_grid_surface2->vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::Point2D >( + "test", test_attribute_id, geode::Point2D{ { 0., 0. } } ); auto test_attribute2 = old_regular_grid_surface2->vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::Point2D >( "test", geode::Point2D{ { 0., 0. } } ); - auto pt_attribute2 = old_regular_grid_surface2->vertex_attribute_manager() - .find_attribute< geode::Point2D >( "points" ); + .find_attribute< geode::VariableAttribute, geode::Point2D >( + test_attribute_id ); } void triangulate_surface() diff --git a/tests/mesh/test-edged-curve.cpp b/tests/mesh/test-edged-curve.cpp index 94f13d59c..6e92f86f6 100644 --- a/tests/mesh/test-edged-curve.cpp +++ b/tests/mesh/test-edged-curve.cpp @@ -303,12 +303,13 @@ void test_edge_requests( const geode::EdgedCurve3D& edged_curve, void test_clone( const geode::EdgedCurve3D& edged_curve ) { + auto attribute_id = + edged_curve.edge_attribute_manager() + .create_attribute< geode::VariableAttribute, int >( "edge", 0 ); auto attribute = edged_curve.edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, int >( - "test", 0 ); + .find_attribute< geode::VariableAttribute, int >( attribute_id ); attribute->set_value( 0, 42 ); - const auto edged_curve_clone = edged_curve.clone(); geode::OpenGeodeEdgedCurve3D edged_curve2{ std::move( *dynamic_cast< geode::OpenGeodeEdgedCurve3D* >( @@ -319,7 +320,8 @@ void test_clone( const geode::EdgedCurve3D& edged_curve ) edged_curve2.nb_edges() == 3, "EdgedCurve2 should have 3 edge" ); const auto attribute2 = - edged_curve2.edge_attribute_manager().find_attribute< int >( "test" ); + edged_curve2.edge_attribute_manager().read_attribute< int >( + attribute_id ); geode::OpenGeodeMeshException::test( attribute2->value( 0 ) == 42, "EdgedCurve2 attribute should be 42" ); } diff --git a/tests/mesh/test-euclidean-distance-transform.cpp b/tests/mesh/test-euclidean-distance-transform.cpp index 4f0530a86..7a7faaa74 100644 --- a/tests/mesh/test-euclidean-distance-transform.cpp +++ b/tests/mesh/test-euclidean-distance-transform.cpp @@ -27,6 +27,7 @@ #include #include +#include #include diff --git a/tests/mesh/test-generic-mesh-accessor.cpp b/tests/mesh/test-generic-mesh-accessor.cpp index 9eb02063d..d7e30df06 100644 --- a/tests/mesh/test-generic-mesh-accessor.cpp +++ b/tests/mesh/test-generic-mesh-accessor.cpp @@ -41,7 +41,8 @@ #include #include -std::unique_ptr< geode::EdgedCurve3D > create_edged_curve() +std::unique_ptr< geode::EdgedCurve3D > create_edged_curve( + const geode::uuid& attribute_id ) { auto edged_curve = geode::EdgedCurve3D::create(); auto builder = geode::EdgedCurveBuilder3D::create( *edged_curve ); @@ -50,14 +51,19 @@ std::unique_ptr< geode::EdgedCurve3D > create_edged_curve() builder->create_point( geode::Point3D{ { 0, 1, 0 } } ); builder->create_edge( 0, 1 ); builder->create_edge( 0, 2 ); - auto attribute = edged_curve->edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test_attribute", 2 ); + edged_curve->edge_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "edge", attribute_id, 2 ); + auto attribute = + edged_curve->edge_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); attribute->set_value( 1, 5 ); return edged_curve; } -std::unique_ptr< geode::TriangulatedSurface2D > create_surface() +std::unique_ptr< geode::TriangulatedSurface2D > create_surface( + const geode::uuid& attribute_id ) { auto surface = geode::TriangulatedSurface2D::create(); auto builder = geode::TriangulatedSurfaceBuilder2D::create( *surface ); @@ -68,14 +74,19 @@ std::unique_ptr< geode::TriangulatedSurface2D > create_surface() builder->create_triangle( { 0, 1, 2 } ); builder->create_triangle( { 0, 3, 1 } ); builder->compute_polygon_adjacencies(); - auto attribute = surface->polygon_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test_attribute", 2 ); + surface->polygon_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "surface", attribute_id, 2 ); + auto attribute = + surface->polygon_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); attribute->set_value( 1, 5 ); return surface; } -std::unique_ptr< geode::TetrahedralSolid3D > create_solid() +std::unique_ptr< geode::TetrahedralSolid3D > create_solid( + const geode::uuid& attribute_id ) { auto solid = geode::TetrahedralSolid3D::create(); auto builder = geode::TetrahedralSolidBuilder3D::create( *solid ); @@ -87,15 +98,21 @@ std::unique_ptr< geode::TetrahedralSolid3D > create_solid() builder->create_tetrahedron( { 0, 1, 2, 3 } ); builder->create_tetrahedron( { 3, 2, 4, 1 } ); builder->compute_polyhedron_adjacencies(); - auto attribute = solid->polyhedron_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test_attribute", 2 ); + solid->polyhedron_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "solid", attribute_id, 2 ); + auto attribute = + solid->polyhedron_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); attribute->set_value( 1, 5 ); return solid; } template < typename Mesh > -void test_basic_accessor( const Mesh& mesh, geode::index_t nb_element_vertices ) +void test_basic_accessor( const Mesh& mesh, + geode::index_t nb_element_vertices, + const geode::uuid& attribute_id ) { using Accessor = geode::GenericMeshAccessor< Mesh >; const Accessor accessor{ mesh }; @@ -118,7 +135,7 @@ void test_basic_accessor( const Mesh& mesh, geode::index_t nb_element_vertices ) "Wrong size of element vertices container" ); const auto attribute = accessor.element_attribute_manager() - .template find_attribute< geode::index_t >( "test_attribute" ); + .template read_attribute< geode::index_t >( attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == 2 && attribute->value( 1 ) == 5, "Wrong values of the element attributes." ); @@ -157,14 +174,17 @@ void test() { geode::OpenGeodeMeshLibrary::initialize(); geode::Logger::info( "Test Surface" ); - const auto edged_curve = create_edged_curve(); - test_basic_accessor( *edged_curve, 2 ); - const auto surface = create_surface(); - test_basic_accessor( *surface, 3 ); + geode::uuid edge_curve_attribute_uuid; + const auto edged_curve = create_edged_curve( edge_curve_attribute_uuid ); + test_basic_accessor( *edged_curve, 2, edge_curve_attribute_uuid ); + geode::uuid surface_attribute_uuid; + const auto surface = create_surface( surface_attribute_uuid ); + test_basic_accessor( *surface, 3, surface_attribute_uuid ); test_adjacent_accessor( *surface ); geode::Logger::info( "Test Solid" ); - const auto solid = create_solid(); - test_basic_accessor( *solid, 4 ); + geode::uuid solid_attribute_uuid; + const auto solid = create_solid( solid_attribute_uuid ); + test_basic_accessor( *solid, 4, solid_attribute_uuid ); test_adjacent_accessor( *solid ); } diff --git a/tests/mesh/test-geometrical-operations-on-mesh.cpp b/tests/mesh/test-geometrical-operations-on-mesh.cpp index 2f22b0910..8f188695a 100644 --- a/tests/mesh/test-geometrical-operations-on-mesh.cpp +++ b/tests/mesh/test-geometrical-operations-on-mesh.cpp @@ -47,8 +47,26 @@ std::unique_ptr< geode::TriangulatedSurface3D > create_surface() void test_rescale( geode::TriangulatedSurface3D& surface ) { + DEBUG( "before builder" ); + SDEBUG( surface.point( 0 ) ); + SDEBUG( surface.point( 1 ) ); + SDEBUG( surface.point( 2 ) ); + SDEBUG( surface.point( 3 ) ); + SDEBUG( surface.point( 4 ) ); + auto builder = geode::TriangulatedSurfaceBuilder3D::create( surface ); + SDEBUG( surface.point( 0 ) ); + SDEBUG( surface.point( 1 ) ); + SDEBUG( surface.point( 2 ) ); + SDEBUG( surface.point( 3 ) ); + SDEBUG( surface.point( 4 ) ); geode::rescale_mesh( surface, *builder, { 2, -2, 0.1 } ); + DEBUG( "rescaled" ); + SDEBUG( surface.point( 0 ) ); + SDEBUG( surface.point( 1 ) ); + SDEBUG( surface.point( 2 ) ); + SDEBUG( surface.point( 3 ) ); + SDEBUG( surface.point( 4 ) ); geode::OpenGeodeMeshException::test( surface.point( 0 ).inexact_equal( geode::Point3D{ { 0.2, -0.4, 0.03 } } ), diff --git a/tests/mesh/test-gradient-computation.cpp b/tests/mesh/test-gradient-computation.cpp index acf96d009..e6b791cd5 100644 --- a/tests/mesh/test-gradient-computation.cpp +++ b/tests/mesh/test-gradient-computation.cpp @@ -48,11 +48,13 @@ void test_gradient_grid2D() auto builder = geode::RegularGridBuilder< 2 >::create( *grid ); builder->initialize_grid( geode::Point2D{ { 0, 0 } }, { 3, 3 }, { geode::Vector2D{ { 1, 0 } }, geode::Vector2D{ { 0, 1 } } } ); - const auto scalar_function_name = "scalar_function"; + auto attribute_id = + grid->vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, double >( + "scalar_function", 0 ); auto attribute = grid->vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, double >( - scalar_function_name, 0 ); + .find_attribute< geode::VariableAttribute, double >( attribute_id ); attribute->set_value( 1, 1 ); attribute->set_value( 4, 1 ); attribute->set_value( 6, 1 ); @@ -67,9 +69,9 @@ void test_gradient_grid2D() attribute->set_value( 13, 2 ); attribute->set_value( 14, 3 ); attribute->set_value( 15, 8 ); - const auto gradient_name = geode::compute_surface_scalar_function_gradient( - *grid, scalar_function_name ); - geode::Logger::info( "Gradient attribute name: ", gradient_name ); + const auto gradient_id = + geode::compute_surface_scalar_function_gradient( *grid, attribute_id ); + geode::Logger::info( "Gradient attribute id: ", gradient_id.string() ); geode::save_regular_grid< 2 >( *grid, "grid_with_gradient.og_rgd2d" ); } @@ -99,11 +101,13 @@ void test_gradient_triangulated_surface2D() builder->create_polygon( { 6, 9, 8 } ); builder->create_polygon( { 5, 6, 8 } ); builder->compute_polygon_adjacencies(); - const auto scalar_function_name = "scalar_function"; + auto attribute_id = + surface->vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, double >( + "scalar_function", 0 ); auto attribute = surface->vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, double >( - scalar_function_name, 0 ); + .find_attribute< geode::VariableAttribute, double >( attribute_id ); attribute->set_value( 1, 1 ); attribute->set_value( 2, 1 ); attribute->set_value( 3, 1 ); @@ -112,9 +116,9 @@ void test_gradient_triangulated_surface2D() attribute->set_value( 9, 3 ); attribute->set_value( 7, 2 ); attribute->set_value( 8, 2 ); - const auto gradient_name = geode::compute_surface_scalar_function_gradient( - *surface, scalar_function_name ); - geode::Logger::info( "Gradient attribute name: ", gradient_name ); + const auto gradient_id = geode::compute_surface_scalar_function_gradient( + *surface, attribute_id ); + geode::Logger::info( "Gradient attribute id: ", gradient_id.string() ); geode::save_triangulated_surface< 2 >( *surface, "mesh_with_gradient.og_tsf2d" ); } @@ -126,11 +130,13 @@ void test_gradient_grid3D() builder->initialize_grid( geode::Point3D{ { 0, 0, 0 } }, { 2, 2, 2 }, { geode::Vector3D{ { 1, 0, 0 } }, geode::Vector3D{ { 0, 1, 0 } }, geode::Vector3D{ { 0, 0, 1 } } } ); - const auto scalar_function_name = "scalar_function"; + auto attribute_id = + grid->vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, double >( + "scalar_function", 0 ); auto attribute = grid->vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, double >( - scalar_function_name, 0 ); + .find_attribute< geode::VariableAttribute, double >( attribute_id ); attribute->set_value( 4, 1 ); attribute->set_value( 10, 1 ); attribute->set_value( 12, 1 ); @@ -157,13 +163,14 @@ void test_gradient_grid3D() attribute->set_value( 20, 3 ); attribute->set_value( 24, 3 ); attribute->set_value( 26, 3 ); - const auto gradient_name = geode::compute_solid_scalar_function_gradient( - *grid, scalar_function_name ); - geode::Logger::info( "Gradient attribute name: ", gradient_name ); - const auto [gradient_name_2, vertices_with_no_value] = + const auto gradient_id = + geode::compute_solid_scalar_function_gradient( *grid, attribute->id() ); + geode::Logger::info( "Gradient attribute name: ", gradient_id.string() ); + const auto [gradient_id_2, vertices_with_no_value] = geode::internal::compute_solid_scalar_function_gradient( - *grid, scalar_function_name, { 0, 1 } ); - geode::Logger::info( "Gradient attribute name 2: ", gradient_name_2 ); + *grid, attribute->id(), { 0, 1 } ); + geode::Logger::info( + "Gradient attribute name 2: ", gradient_id_2.string() ); geode::OpenGeodeMeshException::test( vertices_with_no_value.size() == 7, "Wrong number of vertices without value for gradient " "computation, ", diff --git a/tests/mesh/test-light-regular-grid.cpp b/tests/mesh/test-light-regular-grid.cpp index 79d34947d..818be70ec 100644 --- a/tests/mesh/test-light-regular-grid.cpp +++ b/tests/mesh/test-light-regular-grid.cpp @@ -332,10 +332,12 @@ void test_closest_vertex( const geode::LightRegularGrid3D& grid ) void test_attribute( const geode::LightRegularGrid3D& grid ) { + auto attribute_id = + grid.cell_attribute_manager() + .create_attribute< geode::VariableAttribute, double >( "test", -1 ); auto attribute = grid.cell_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, double >( - "toto", -1 ); + .find_attribute< geode::VariableAttribute, double >( attribute_id ); attribute->set_value( 10, 10 ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == -1, "Wrong attribute value" ); diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index 3ee8db458..9ac6b883f 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -82,14 +82,17 @@ void test_bounding_box( const geode::PointSet3D& point_set ) "Wrong computation of bounding box (max)" ); } -void test_create_vertex_attribute( const geode::PointSet3D& point_set ) +geode::uuid test_create_vertex_attribute( const geode::PointSet3D& point_set ) { - auto attribute = + auto attribute_id = point_set.vertex_attribute_manager() - .find_or_create_attribute< geode::ConstantAttribute, bool >( - "test", true ); + .create_attribute< geode::ConstantAttribute, bool >( "bool", true ); + const auto attribute = + point_set.vertex_attribute_manager() + .find_attribute< geode::ConstantAttribute, bool >( attribute_id ); geode::OpenGeodeMeshException::test( attribute->value() == true, "PointSet attribute value should be true" ); + return attribute_id; } void test_delete_vertex( @@ -121,14 +124,16 @@ void test_io( const geode::PointSet3D& point_set, std::string_view filename ) } } -void test_clone( const geode::PointSet3D& point_set ) +void test_clone( + const geode::PointSet3D& point_set, const geode::uuid& attribute_id ) { const auto point_set2 = point_set.clone(); geode::OpenGeodeMeshException::test( point_set2->nb_vertices() == 3, "PointSet2 should have 3 vertices" ); const auto attribute = - point_set2->vertex_attribute_manager().find_attribute< bool >( "test" ); + point_set2->vertex_attribute_manager().read_attribute< bool >( + attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == true, "PointSet2 attribute value should be true" ); @@ -145,13 +150,13 @@ void test() auto builder = geode::PointSetBuilder3D::create( *point_set ); test_create_vertices( *point_set, *builder ); test_bounding_box( *point_set ); - test_create_vertex_attribute( *point_set ); + const auto vertex_attribute_id = test_create_vertex_attribute( *point_set ); test_io( *point_set, absl::StrCat( "test.", point_set->native_extension() ) ); test_permutation( *point_set, *builder ); test_delete_vertex( *point_set, *builder ); - test_clone( *point_set ); + test_clone( *point_set, vertex_attribute_id ); } OPENGEODE_TEST( "point-set" ) \ No newline at end of file diff --git a/tests/mesh/test-polygonal-surface.cpp b/tests/mesh/test-polygonal-surface.cpp index 9f6f7d068..67d786d4b 100644 --- a/tests/mesh/test-polygonal-surface.cpp +++ b/tests/mesh/test-polygonal-surface.cpp @@ -68,13 +68,17 @@ void test_bounding_box( const geode::PolygonalSurface3D& polygonal_surface ) "Wrong computation of bounding box (max)" ); } -void test_create_vertex_attribute( +geode::uuid test_create_vertex_attribute( const geode::PolygonalSurface3D& polygonal_surface ) { + auto attribute_id = + polygonal_surface.vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::PolygonEdge >( + "test", geode::PolygonEdge{} ); auto attribute = polygonal_surface.vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::PolygonEdge >( "test", geode::PolygonEdge{} ); + .find_attribute< geode::VariableAttribute, geode::PolygonEdge >( + attribute_id ); for( const auto v : geode::Range{ polygonal_surface.nb_vertices() } ) { attribute->set_value( v, geode::PolygonEdge{ v, 0 } ); @@ -82,6 +86,7 @@ void test_create_vertex_attribute( geode::PolygonEdge{} != attribute->value( v ), "PolygonalSurface attribute assignation is not correct" ); } + return attribute_id; } void test_permutation( const geode::PolygonalSurface3D& surface, @@ -220,17 +225,24 @@ void test_create_polygons( const geode::PolygonalSurface3D& polygonal_surface, "Wrong polygon vertices list" ); } -void test_create_edge_attribute( +geode::uuid test_create_edge_attribute( const geode::PolygonalSurface3D& polygonal_surface ) { - auto attribute = polygonal_surface.edges() - .edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test", geode::NO_ID ); + auto attribute_id = + polygonal_surface.edges() + .edge_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "edges", geode::NO_ID ); + auto attribute = + polygonal_surface.edges() + .edge_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); for( const auto e : geode::Range{ polygonal_surface.edges().nb_edges() } ) { attribute->set_value( e, e ); } + return attribute_id; } void test_polygon_adjacencies( @@ -337,7 +349,8 @@ void test_polygon_edge_requests( } void test_delete_polygon( const geode::PolygonalSurface3D& polygonal_surface, - geode::PolygonalSurfaceBuilder3D& builder ) + geode::PolygonalSurfaceBuilder3D& builder, + const geode::uuid edge_attribute_id ) { std::vector< bool > to_delete( polygonal_surface.nb_polygons(), false ); to_delete.front() = true; @@ -362,9 +375,10 @@ void test_delete_polygon( const geode::PolygonalSurface3D& polygonal_surface, geode::OpenGeodeMeshException::test( polygonal_surface.edges().nb_edges() == 6, "PolygonalSurface should have 6 edges" ); - const auto attribute = polygonal_surface.edges() - .edge_attribute_manager() - .find_attribute< geode::index_t >( "test" ); + const auto attribute = + polygonal_surface.edges() + .edge_attribute_manager() + .read_attribute< geode::index_t >( edge_attribute_id ); for( const auto e : geode::Range{ 6 } ) { geode::OpenGeodeMeshException::test( attribute->value( e ) == e, @@ -461,7 +475,8 @@ void test_polygon_vertex_normal() } void test_io( const geode::PolygonalSurface3D& polygonal_surface, - const std::string& filename ) + const std::string& filename, + const geode::uuid edge_attribute_id ) { geode::save_polygonal_surface( polygonal_surface, filename ); const auto reloaded = geode::load_polygonal_surface< 3 >( filename ); @@ -490,9 +505,10 @@ void test_io( const geode::PolygonalSurface3D& polygonal_surface, new_polygonal_surface->edges().edge_from_vertices( { 1, 0 } ) == polygonal_surface.edges().edge_from_vertices( { 1, 0 } ), "Reloaded PolygonalSurface has wrong polygon edge index" ); - const auto attribute = new_polygonal_surface->edges() - .edge_attribute_manager() - .find_attribute< geode::index_t >( "test" ); + const auto attribute = + new_polygonal_surface->edges() + .edge_attribute_manager() + .read_attribute< geode::index_t >( edge_attribute_id ); for( const auto e : geode::Range{ new_polygonal_surface->edges().nb_edges() } ) { @@ -531,7 +547,8 @@ void test_backward_io( const std::string& filename ) "Backward polygons around failed" ); } -void test_clone( const geode::PolygonalSurface3D& polygonal_surface ) +void test_clone( const geode::PolygonalSurface3D& polygonal_surface, + geode::uuid vertex_attribute_id ) { const auto polygonal_surface_clone = polygonal_surface.clone(); geode::OpenGeodePolygonalSurface3D polygonal_surface2{ std::move( @@ -545,8 +562,9 @@ void test_clone( const geode::PolygonalSurface3D& polygonal_surface ) geode::OpenGeodeMeshException::test( polygonal_surface2.nb_polygons() == 2, "PolygonalSurface2 should have 2 polygons" ); - const auto attribute2 = polygonal_surface2.vertex_attribute_manager() - .find_attribute< geode::PolygonEdge >( "test" ); + const auto attribute2 = + polygonal_surface2.vertex_attribute_manager() + .read_attribute< geode::PolygonEdge >( vertex_attribute_id ); std::vector< geode::PolygonEdge > att_answer{ { 4, 0 }, { 2, 0 }, { 6, 0 }, { 1, 0 }, { 5, 0 }, { 0, 0 }, { 3, 0 } }; for( const auto v : geode::Range{ polygonal_surface2.nb_vertices() } ) @@ -576,9 +594,6 @@ void test_set_polygon_vertex( void test_replace_vertex( const geode::PolygonalSurface3D& polygonal_surface, geode::PolygonalSurfaceBuilder3D& builder ) { - const auto att = polygonal_surface.edges() - .edge_attribute_manager() - .find_attribute< geode::index_t >( "counter" ); const auto new_id = builder.create_vertex(); const auto polygons_around = polygonal_surface.polygons_around_vertex( 1 ); builder.replace_vertex( 1, new_id ); @@ -667,9 +682,11 @@ void test() test_create_vertices( *polygonal_surface, *builder ); test_bounding_box( *polygonal_surface ); - test_create_vertex_attribute( *polygonal_surface ); + const auto vertex_attribute_id = + test_create_vertex_attribute( *polygonal_surface ); test_create_polygons( *polygonal_surface, *builder ); - test_create_edge_attribute( *polygonal_surface ); + const auto edge_attribute_id = + test_create_edge_attribute( *polygonal_surface ); test_polygon_adjacencies( *polygonal_surface, *builder ); test_polygon_edges_on_borders( *polygonal_surface ); test_previous_next_on_border( *polygonal_surface ); @@ -681,7 +698,8 @@ void test() test_texture( *polygonal_surface ); test_io( *polygonal_surface, - absl::StrCat( "test.", polygonal_surface->native_extension() ) ); + absl::StrCat( "test.", polygonal_surface->native_extension() ), + edge_attribute_id ); test_backward_io( absl::StrCat( geode::DATA_PATH, "test_v7.", polygonal_surface->native_extension() ) ); test_backward_io( absl::StrCat( geode::DATA_PATH, "test_v12.", @@ -689,8 +707,8 @@ void test() test_permutation( *polygonal_surface, *builder ); test_replace_vertex( *polygonal_surface, *builder ); - test_delete_polygon( *polygonal_surface, *builder ); - test_clone( *polygonal_surface ); + test_delete_polygon( *polygonal_surface, *builder, edge_attribute_id ); + test_clone( *polygonal_surface, vertex_attribute_id ); test_set_polygon_vertex( *polygonal_surface, *builder ); test_delete_all( *polygonal_surface, *builder ); diff --git a/tests/mesh/test-polyhedral-solid.cpp b/tests/mesh/test-polyhedral-solid.cpp index 586dcee69..4837cbc64 100644 --- a/tests/mesh/test-polyhedral-solid.cpp +++ b/tests/mesh/test-polyhedral-solid.cpp @@ -127,26 +127,39 @@ void test_create_polyhedra( const geode::PolyhedralSolid3D& polyhedral_solid, "Wrong polyhedron vertices list" ); } -void test_create_facet_attribute( +geode::uuid test_create_facet_attribute( const geode::PolyhedralSolid3D& polyhedral_solid ) { - auto attribute = polyhedral_solid.facets() - .facet_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test", geode::NO_ID ); + auto attribute_id = + polyhedral_solid.facets() + .facet_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "facet_attribute", geode::NO_ID ); + auto attribute = + polyhedral_solid.facets() + .facet_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); for( const auto f : geode::Range{ polyhedral_solid.facets().nb_facets() } ) { attribute->set_value( f, f ); } + return attribute_id; } -void test_create_edge_attribute( +geode::uuid test_create_edge_attribute( const geode::PolyhedralSolid3D& polyhedral_solid ) { - auto attribute = polyhedral_solid.edges() - .edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "test", geode::NO_ID ); + auto attribute_id = + polyhedral_solid.edges() + .edge_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "test", geode::NO_ID ); + auto attribute = + polyhedral_solid.edges() + .edge_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attribute_id ); for( const auto e : geode::Range{ polyhedral_solid.edges().nb_edges() } ) { const auto& vertices = polyhedral_solid.edges().edge_vertices( e ); @@ -156,6 +169,7 @@ void test_create_edge_attribute( attribute->value( 0 ) == 1, "Wrong value for attribute on edge 0" ); geode::OpenGeodeMeshException::test( attribute->value( 1 ) == 3, "Wrong value for attribute on edge 1" ); + return attribute->id(); } void test_polyhedron_adjacencies( @@ -335,7 +349,8 @@ void test_permutation( const geode::PolyhedralSolid3D& solid, } void test_delete_polyhedra( const geode::PolyhedralSolid3D& polyhedral_solid, - geode::PolyhedralSolidBuilder3D& builder ) + geode::PolyhedralSolidBuilder3D& builder, + const geode::uuid& edge_attribute_id ) { std::vector< bool > to_delete( polyhedral_solid.nb_polyhedra(), false ); to_delete.front() = true; @@ -370,7 +385,7 @@ void test_delete_polyhedra( const geode::PolyhedralSolid3D& polyhedral_solid, "PolyhedralSolid should have 12 edges" ); auto attribute = polyhedral_solid.edges() .edge_attribute_manager() - .find_attribute< geode::index_t >( "test" ); + .read_attribute< geode::index_t >( edge_attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == 1, "Wrong value for attribute on edge 0 after vertex deletion" ); geode::OpenGeodeMeshException::test( attribute->value( 1 ) == 3, @@ -378,7 +393,8 @@ void test_delete_polyhedra( const geode::PolyhedralSolid3D& polyhedral_solid, } void test_io( const geode::PolyhedralSolid3D& polyhedral_solid, - const std::string& filename ) + const std::string& filename, + const geode::uuid& facet_attribute_id ) { geode::save_polyhedral_solid( polyhedral_solid, filename ); const auto reloaded = geode::load_polyhedral_solid< 3 >( filename ); @@ -411,9 +427,10 @@ void test_io( const geode::PolyhedralSolid3D& polyhedral_solid, == polyhedral_solid.facets().facet_from_vertices( polyhedral_solid.polyhedron_facet_vertices( { 1, 0 } ) ), "Reloaded PolyhedralSolid has wrong polyhedron facet index" ); - auto attribute = new_polyhedral_solid->facets() - .facet_attribute_manager() - .find_attribute< geode::index_t >( "test" ); + auto attribute = + new_polyhedral_solid->facets() + .facet_attribute_manager() + .read_attribute< geode::index_t >( facet_attribute_id ); for( auto f : geode::Range{ new_polyhedral_solid->facets().nb_facets() } ) { geode::OpenGeodeMeshException::test( attribute->value( f ) == f, @@ -520,20 +537,25 @@ void test_normals() "1)" ); } -void test_create_vertex_attribute( +geode::uuid test_create_vertex_attribute( const geode::PolyhedralSolid3D& polyhedral_solid ) { + auto attribute_id = polyhedral_solid.vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, + geode::PolyhedronFacetVertex >( + "test", geode::PolyhedronFacetVertex{} ); auto attribute = polyhedral_solid.vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::PolyhedronFacetVertex >( - "test", geode::PolyhedronFacetVertex{} ); + .find_attribute< geode::VariableAttribute, + geode::PolyhedronFacetVertex >( attribute_id ); for( const auto v : geode::Range{ polyhedral_solid.nb_vertices() } ) { attribute->set_value( v, geode::PolyhedronFacetVertex{ { v, 0 }, 1 } ); } + return attribute_id; } -void test_clone( const geode::PolyhedralSolid3D& polyhedral_solid ) +void test_clone( const geode::PolyhedralSolid3D& polyhedral_solid, + const geode::uuid vertex_attribute_id ) { const auto polyhedral_solid_clone = polyhedral_solid.clone(); geode::OpenGeodePolyhedralSolid3D polyhedral_solid2{ std::move( @@ -547,9 +569,9 @@ void test_clone( const geode::PolyhedralSolid3D& polyhedral_solid ) geode::OpenGeodeMeshException::test( polyhedral_solid2.nb_polyhedra() == 2, "PolyhedralSolid2 should have 2 polyhedra" ); - const auto attribute2 = - polyhedral_solid2.vertex_attribute_manager() - .find_attribute< geode::PolyhedronFacetVertex >( "test" ); + const auto attribute2 = polyhedral_solid2.vertex_attribute_manager() + .read_attribute< geode::PolyhedronFacetVertex >( + vertex_attribute_id ); std::vector< geode::PolyhedronFacetVertex > att_answer{ { { 4, 0 }, 1 }, { { 2, 0 }, 1 }, { { 6, 0 }, 1 }, { { 1, 0 }, 1 }, { { 5, 0 }, 1 }, { { 0, 0 }, 1 }, { { 7, 0 }, 1 }, { { 3, 0 }, 1 } }; @@ -635,25 +657,29 @@ void test() auto builder = geode::PolyhedralSolidBuilder3D::create( *polyhedral_solid ); test_create_vertices( *polyhedral_solid, *builder ); - test_create_vertex_attribute( *polyhedral_solid ); + const auto vertex_attribute_id = + test_create_vertex_attribute( *polyhedral_solid ); test_create_polyhedra( *polyhedral_solid, *builder ); - test_create_facet_attribute( *polyhedral_solid ); - test_create_edge_attribute( *polyhedral_solid ); + const auto facet_attribute_id = + test_create_facet_attribute( *polyhedral_solid ); + const auto edge_attribute_id = + test_create_edge_attribute( *polyhedral_solid ); test_edges( *polyhedral_solid ); test_facets( *polyhedral_solid ); test_polyhedron_adjacencies( *polyhedral_solid, *builder ); test_texture( *polyhedral_solid ); test_io( *polyhedral_solid, - absl::StrCat( "test.", polyhedral_solid->native_extension() ) ); + absl::StrCat( "test.", polyhedral_solid->native_extension() ), + facet_attribute_id ); test_backward_io( absl::StrCat( geode::DATA_PATH, "test_v7.", polyhedral_solid->native_extension() ) ); test_backward_io( absl::StrCat( geode::DATA_PATH, "test_v12.", polyhedral_solid->native_extension() ) ); test_permutation( *polyhedral_solid, *builder ); - test_delete_polyhedra( *polyhedral_solid, *builder ); - test_clone( *polyhedral_solid ); + test_delete_polyhedra( *polyhedral_solid, *builder, edge_attribute_id ); + test_clone( *polyhedral_solid, vertex_attribute_id ); test_set_polyhedron_vertex( *polyhedral_solid, *builder ); test_delete_all( *polyhedral_solid, *builder ); diff --git a/tests/mesh/test-regular-grid.cpp b/tests/mesh/test-regular-grid.cpp index 27f883f1c..9523965ac 100644 --- a/tests/mesh/test-regular-grid.cpp +++ b/tests/mesh/test-regular-grid.cpp @@ -353,16 +353,19 @@ void test_closest_vertex( const geode::RegularGrid3D& grid ) void test_clone( const geode::RegularGrid3D& grid ) { - const auto attribute_name = "int_attribute"; - const auto attribute_name_d = "double_attribute"; + auto attribute_id = grid.polyhedron_attribute_manager() + .create_attribute< geode::VariableAttribute, int >( + "int_attribute", 0 ); auto attribute = grid.polyhedron_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, int >( - attribute_name, 0 ); - auto attribute_d = + .find_attribute< geode::VariableAttribute, int >( attribute_id ); + auto attribute_d_id = grid.vertex_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, double >( - attribute_name_d, 0 ); + .create_attribute< geode::VariableAttribute, double >( + "double_attribute", 0 ); + auto attribute_d = grid.vertex_attribute_manager() + .find_attribute< geode::VariableAttribute, double >( + attribute_d_id ); for( const auto c : geode::Range{ grid.nb_polyhedra() } ) { attribute->set_value( c, 2 * c ); @@ -414,23 +417,22 @@ void test_clone( const geode::RegularGrid3D& grid ) "Clone wrong cell length in direction 2" ); geode::OpenGeodeMeshException::test( - clone->polyhedron_attribute_manager().attribute_exists( - attribute_name ), + clone->polyhedron_attribute_manager().attribute_exists( attribute_id ), "Clone missing attribute" ); geode::OpenGeodeMeshException::test( - clone->vertex_attribute_manager().attribute_exists( attribute_name_d ), + clone->vertex_attribute_manager().attribute_exists( attribute_d_id ), "Clone missing attribute" ); const auto clone_attribute = - clone->polyhedron_attribute_manager().find_attribute< int >( - attribute_name ); + clone->polyhedron_attribute_manager().read_attribute< int >( + attribute_id ); for( const auto c : geode::TRange< int >{ clone->nb_polyhedra() } ) { geode::OpenGeodeMeshException::test( clone_attribute->value( c ) == 2 * c, "Wrong clone attribute" ); } const auto clone_attribute_d = - clone->vertex_attribute_manager().find_attribute< double >( - attribute_name_d ); + clone->vertex_attribute_manager().read_attribute< double >( + attribute_d_id ); for( const auto c : geode::TRange< int >{ clone->nb_vertices() } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index 5cc694de8..d4146a45d 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -325,19 +325,30 @@ void test_io( void test_clone( const geode::TetrahedralSolid3D& solid ) { - auto attr_from = solid.facets() - .facet_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "facet_id", 0 ); + auto attr_from_id = + solid.facets() + .facet_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "facet_id", 0 ); + auto attr_from = + solid.facets() + .facet_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attr_from_id ); for( const auto f : geode::Range{ solid.facets().nb_facets() } ) { attr_from->set_value( f, f ); } + auto attr_edge_from_id = + solid.edges() + .edge_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "edge_id", 0 ); auto attr_edge_from = solid.edges() .edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "edge_id", 0 ); + .find_attribute< geode::VariableAttribute, geode::index_t >( + attr_edge_from_id ); for( const auto e : geode::Range{ solid.edges().nb_edges() } ) { attr_edge_from->set_value( e, e ); @@ -349,7 +360,7 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) solid2.get() ) ) }; const auto attr_to = solid4.facets() .facet_attribute_manager() - .find_attribute< geode::index_t >( "facet_id" ); + .read_attribute< geode::index_t >( attr_from_id ); for( const auto f : geode::Range{ solid.facets().nb_facets() } ) { geode::OpenGeodeMeshException::test( @@ -367,7 +378,7 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) const auto attr_edge_to = solid4.edges() .edge_attribute_manager() - .find_attribute< geode::index_t >( "edge_id" ); + .read_attribute< geode::index_t >( attr_edge_from_id ); for( const auto e : geode::Range{ solid.edges().nb_edges() } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index a7469abb5..576b4da95 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -239,10 +239,16 @@ void test_io( void test_clone( const geode::TriangulatedSurface3D& surface ) { - auto attr_from = surface.edges() - .edge_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, - geode::index_t >( "edge_id", 0 ); + auto attr_from_id = + surface.edges() + .edge_attribute_manager() + .create_attribute< geode::VariableAttribute, geode::index_t >( + "edge_id", 0 ); + auto attr_from = + surface.edges() + .edge_attribute_manager() + .find_attribute< geode::VariableAttribute, geode::index_t >( + attr_from_id ); for( const auto e : geode::Range{ surface.edges().nb_edges() } ) { attr_from->set_value( e, e ); @@ -259,7 +265,7 @@ void test_clone( const geode::TriangulatedSurface3D& surface ) "TriangulatedSurface2 should have 2 polygons" ); auto attr_to = surface2.edges() .edge_attribute_manager() - .find_attribute< geode::index_t >( "edge_id" ); + .read_attribute< geode::index_t >( attr_from_id ); for( const auto e : geode::Range{ surface.edges().nb_edges() } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/model/test-relationships.cpp b/tests/model/test-relationships.cpp index 2ad692153..c24314e73 100644 --- a/tests/model/test-relationships.cpp +++ b/tests/model/test-relationships.cpp @@ -167,10 +167,12 @@ void test_attributes( const geode::Relationships& relations, geode::OpenGeodeModelException::test( std::get< 1 >( output ).id() == uuids[0], "Wrong relation uuids from index" ); - auto relation_att = + auto relation_att_id = relations.relation_attribute_manager() - .find_or_create_attribute< geode::VariableAttribute, int >( - "int", 0 ); + .create_attribute< geode::VariableAttribute, int >( "int", 0 ); + const auto relation_att = + relations.relation_attribute_manager() + .find_attribute< geode::VariableAttribute, int >( relation_att_id ); relation_att->set_value( 0, 1 ); geode::OpenGeodeModelException::test( relation_att->value( From c7ecbe2bc3a5cdb518cf64d1ee68d3a05a6c486a Mon Sep 17 00:00:00 2001 From: BenPinet Date: Tue, 16 Jun 2026 10:09:33 +0200 Subject: [PATCH 05/19] wip --- include/geode/basic/algorithm.hpp | 7 + include/geode/basic/attribute_manager.hpp | 7 + include/geode/basic/bitsery_archive.hpp | 36 +++++ include/geode/basic/variable_attribute.hpp | 2 + .../geode/mesh/core/detail/facet_storage.hpp | 18 +-- .../geode/mesh/core/internal/points_impl.hpp | 13 +- .../mixin/core/detail/relationships_impl.hpp | 28 +++- .../io/geode/geode_brep_input.hpp | 67 ++++----- src/geode/basic/attribute_manager.cpp | 42 ++++++ src/geode/mesh/builder/graph_builder.cpp | 2 + .../builder/regular_grid_solid_builder.cpp | 3 +- src/geode/mesh/builder/solid_mesh_builder.cpp | 22 ++- .../mesh/builder/surface_mesh_builder.cpp | 6 +- .../coordinate_reference_system_manager.cpp | 2 - src/geode/mesh/core/geode/geode_point_set.cpp | 15 ++ .../mesh/helpers/gradient_computation.cpp | 8 +- .../model/helpers/convert_brep_section.cpp | 4 + src/geode/model/helpers/ray_tracing.cpp | 5 + .../mixin/core/detail/relationships_impl.cpp | 35 +++-- src/geode/model/mixin/core/relationships.cpp | 34 +++-- .../model/mixin/core/vertex_identifier.cpp | 6 + .../model/representation/io/brep_input.cpp | 82 +++++------ tests/basic/test-attribute.cpp | 137 ++++++++++-------- .../{ => backward_io/v12}/test_v12.og_edc3d | Bin .../{ => backward_io/v12}/test_v12.og_psf3d | Bin .../{ => backward_io/v12}/test_v12.og_pso3d | Bin .../{ => backward_io/v12}/test_v12.og_rgd3d | Bin .../data/{ => backward_io/v7}/test_v7.og_grp | Bin .../{ => backward_io/v7}/test_v7.og_psf3d | Bin .../{ => backward_io/v7}/test_v7.og_pso3d | Bin tests/mesh/test-gradient-computation.cpp | 4 +- tests/mesh/test-polyhedral-solid.cpp | 2 +- tests/mesh/test-tetrahedral-solid.cpp | 2 + tests/model/test-brep.cpp | 3 + tests/model/test-convert-brep.cpp | 3 +- tests/model/test-ray-tracing-helpers.cpp | 1 + 36 files changed, 387 insertions(+), 209 deletions(-) rename tests/data/{ => backward_io/v12}/test_v12.og_edc3d (100%) rename tests/data/{ => backward_io/v12}/test_v12.og_psf3d (100%) rename tests/data/{ => backward_io/v12}/test_v12.og_pso3d (100%) rename tests/data/{ => backward_io/v12}/test_v12.og_rgd3d (100%) rename tests/data/{ => backward_io/v7}/test_v7.og_grp (100%) rename tests/data/{ => backward_io/v7}/test_v7.og_psf3d (100%) rename tests/data/{ => backward_io/v7}/test_v7.og_pso3d (100%) diff --git a/include/geode/basic/algorithm.hpp b/include/geode/basic/algorithm.hpp index 4afe92445..5f593c320 100644 --- a/include/geode/basic/algorithm.hpp +++ b/include/geode/basic/algorithm.hpp @@ -56,6 +56,13 @@ namespace geode index_t delete_vector_elements( const DeleteContainer& to_delete, ValueContainer& values ) { + DEBUG( "delete_vector_elements" ); + DEBUG( to_delete.size() ); + DEBUG( values.size() ); + if( values.empty() ) + { + exit( 1 ); + } OpenGeodeBasicException::check_assertion( to_delete.size() == values.size(), "[delete_vector_elements] Number of elements in the two vectors " diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 2ff0b7f8d..025e9fd7c 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -124,8 +124,12 @@ namespace geode attribute_id.string(), "' already exists." ); typed_attribute.reset( new Attribute< T >{ std::move( default_value ), std::move( properties ), {} } ); + DEBUG( "create_attribute" ); + SDEBUG( attribute_id ); + DEBUG( attribute_name ); IdentifierBuilder builder{ *typed_attribute }; builder.set_name( attribute_name ); + builder.set_id( attribute_id ); register_attribute( typed_attribute, attribute_id ); } @@ -260,6 +264,9 @@ namespace geode */ [[nodiscard]] index_t nb_elements() const; + std::optional< std::vector< geode::uuid > > attribute_ids_with_name( + std::string_view name ) const; + void copy( const AttributeManager& attribute_manager ); void import( const AttributeManager& attribute_manager, diff --git a/include/geode/basic/bitsery_archive.hpp b/include/geode/basic/bitsery_archive.hpp index d53f99426..5bfad4aa9 100644 --- a/include/geode/basic/bitsery_archive.hpp +++ b/include/geode/basic/bitsery_archive.hpp @@ -31,6 +31,8 @@ #include #include +#include +#include #include #include @@ -78,6 +80,40 @@ namespace geode }; } // namespace geode +namespace geode +{ + namespace detail + { + template < template < typename > class Attribute, typename T > + void import_old_attribute( AttributeManager &manager, + std::string_view old_attribute_name, + geode::uuid new_attribute_id ) + { + const auto ids = + manager.attribute_ids_with_name( old_attribute_name ).value(); + geode::uuid old_attribute_id; + for( const auto &id : ids ) + { + if( id == new_attribute_id ) + { + continue; + } + old_attribute_id = id; + } + auto old_attribute = manager.read_attribute< T >( ids.at( 0 ) ); + auto new_attribute = + manager.find_attribute< Attribute, T >( new_attribute_id ); + manager.resize( old_attribute->nb_items() ); + for( const auto index : geode::Range{ old_attribute->nb_items() } ) + { + new_attribute->set_value( + index, old_attribute->value( index ) ); + } + manager.delete_attribute( old_attribute_id ); + } + } // namespace detail +} // namespace geode + namespace bitsery { namespace traits diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index f9ccb5d5b..6ff6fd849 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -403,7 +403,9 @@ namespace geode void delete_elements( const std::vector< bool >& to_delete, AttributeBase::AttributeKey /*key*/ ) override { + DEBUG( "delete_elements" ); delete_vector_elements( to_delete, values_ ); + DEBUG( "delete_elements OK" ); } void permute_elements( absl::Span< const index_t > permutation, diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index b01cb0d73..646ee6b84 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -63,6 +63,7 @@ namespace geode facet_attribute_manager_ .create_attribute< VariableAttribute, index_t >( "counter", 1u, { false, false, false } ); + SDEBUG( counter_attribute_id ); counter_ = facet_attribute_manager_ .find_attribute< VariableAttribute, index_t >( counter_attribute_id ); @@ -71,6 +72,7 @@ namespace geode .create_attribute< VariableAttribute, VertexContainer >( "vertices", VertexContainer{}, { false, false, false } ); + SDEBUG( vertices_attribute_id ); vertices_ = facet_attribute_manager_ .find_attribute< VariableAttribute, VertexContainer >( @@ -242,22 +244,16 @@ namespace geode { facet_attribute_manager_.copy( from.facet_attribute_manager() ); facet_indices_ = from.facet_indices_; - const auto counter_attribute_id = - facet_attribute_manager_ - .create_attribute< VariableAttribute, index_t >( - "counter", 1u, { false, false, false } ); + DEBUG( "overwrite" ); + SDEBUG( from.counter_->id() ); counter_ = facet_attribute_manager_ .find_attribute< VariableAttribute, index_t >( - counter_attribute_id ); - const auto vertices_attribute_id = - facet_attribute_manager_ - .create_attribute< VariableAttribute, VertexContainer >( - "vertices", VertexContainer{}, - { false, false, false } ); + from.counter_->id() ); + SDEBUG( from.vertices_->id() ); vertices_ = facet_attribute_manager_ .find_attribute< VariableAttribute, VertexContainer >( - vertices_attribute_id ); + from.vertices_->id() ); } private: diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index 645a1ec9f..7e94fcb12 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -55,18 +55,12 @@ namespace geode [[nodiscard]] const Point< dimension >& get_point( index_t vertex_id ) const { - DEBUG( "get_point" ); - SDEBUG( points_->id() ); return points_->value( vertex_id ); } void set_point( index_t vertex_id, Point< dimension > point ) { - DEBUG( "set_point" ); - SDEBUG( point ); points_->set_value( vertex_id, std::move( point ) ); - SDEBUG( points_->id() ); - SDEBUG( points_->value( vertex_id ) ); } [[nodiscard]] index_t nb_points() const @@ -79,6 +73,11 @@ namespace geode return points_->name().value(); } + [[nodiscard]] const uuid& attribute_id() const + { + return points_->id(); + } + template < typename Mesh > void initialize_crs( Mesh& mesh ) { @@ -141,8 +140,6 @@ namespace geode explicit PointsImpl( Mesh& mesh ) : PointsImpl( mesh.vertex_attribute_manager() ) { - DEBUG( "PointsImpl::PointsImpl" ); - DEBUG( "register_as_active_crs" ); register_as_active_crs( mesh ); } diff --git a/include/geode/model/mixin/core/detail/relationships_impl.hpp b/include/geode/model/mixin/core/detail/relationships_impl.hpp index 266c6f92e..b8e9f038c 100644 --- a/include/geode/model/mixin/core/detail/relationships_impl.hpp +++ b/include/geode/model/mixin/core/detail/relationships_impl.hpp @@ -87,7 +87,7 @@ namespace geode protected: RelationshipsImpl(); - void initialize_attributes(); + void initialize_attributes( const geode::uuid& id ); [[nodiscard]] std::optional< index_t > vertex_id( const uuid& component_id ) const; @@ -104,13 +104,24 @@ namespace geode serializer.ext( *this, Growable< Archive, RelationshipsImpl >{ { []( Archive& archive, RelationshipsImpl& impl ) { - archive.ext( - impl.graph_, bitsery::ext::StdSmartPtr{} ); - archive.object( impl.uuid2index_ ); - archive.ext( - impl.ids_, bitsery::ext::StdSmartPtr{} ); - impl.delete_isolated_vertices(); - } } } ); + archive.ext( + impl.graph_, bitsery::ext::StdSmartPtr{} ); + archive.object( impl.uuid2index_ ); + archive.ext( + impl.ids_, bitsery::ext::StdSmartPtr{} ); + impl.attribute_id_ = impl.ids_->id(); + archive.object( impl.attribute_id_ ); + impl.delete_isolated_vertices(); + }, + []( Archive& archive, RelationshipsImpl& impl ) { + archive.ext( + impl.graph_, bitsery::ext::StdSmartPtr{} ); + archive.object( impl.uuid2index_ ); + archive.ext( + impl.ids_, bitsery::ext::StdSmartPtr{} ); + archive.object( impl.attribute_id_ ); + impl.delete_isolated_vertices(); + } } } ); } index_t register_component( const ComponentID& id ); @@ -127,6 +138,7 @@ namespace geode std::unique_ptr< Graph > graph_; detail::UuidToIndex uuid2index_; std::shared_ptr< VariableAttribute< ComponentID > > ids_; + geode::uuid attribute_id_; }; } // namespace detail } // namespace geode diff --git a/include/geode/model/representation/io/geode/geode_brep_input.hpp b/include/geode/model/representation/io/geode/geode_brep_input.hpp index b77dd3084..b258a684d 100644 --- a/include/geode/model/representation/io/geode/geode_brep_input.hpp +++ b/include/geode/model/representation/io/geode/geode_brep_input.hpp @@ -69,49 +69,42 @@ namespace geode template < typename Model > void load_brep_files( Model& brep, std::string_view directory ) { + DEBUG( "load_brep_files" ); + DEBUG( "BRepBuilder" ); BRepBuilder builder{ brep }; + DEBUG( "BRepBuilder done" ); const auto level = Logger::level(); Logger::set_level( Logger::LEVEL::warn ); - async::parallel_invoke( - [&builder, &directory] { - builder.load_identifier( directory ); - }, - [&builder, &directory] { - builder.load_corners( directory ); - }, - [&builder, &directory] { - builder.load_lines( directory ); - }, - [&builder, &directory] { - builder.load_surfaces( directory ); - }, - [&builder, &directory] { - builder.load_blocks( directory ); - }, - [&builder, &directory] { - builder.load_model_boundaries( directory ); - }, - [&builder, &directory] { - builder.load_corner_collections( directory ); - }, - [&builder, &directory] { - builder.load_line_collections( directory ); - }, - [&builder, &directory] { - builder.load_surface_collections( directory ); - }, - [&builder, &directory] { - builder.load_block_collections( directory ); - }, - [&builder, &directory] { - builder.load_relationships( directory ); - }, - [&builder, &directory] { - builder.load_unique_vertices( directory ); - } ); + DEBUG( "load_identifier" ); + builder.load_identifier( directory ); + DEBUG( "load_corners" ); + builder.load_corners( directory ); + DEBUG( "load_lines" ); + builder.load_lines( directory ); + DEBUG( "load_surfaces" ); + builder.load_surfaces( directory ); + DEBUG( "load_blocks" ); + builder.load_blocks( directory ); + DEBUG( "load_model_boundaries" ); + builder.load_model_boundaries( directory ); + DEBUG( "load_corner_collections" ); + builder.load_corner_collections( directory ); + DEBUG( "load_line_collections" ); + builder.load_line_collections( directory ); + DEBUG( "load_surface_collections" ); + builder.load_surface_collections( directory ); + DEBUG( "load_block_collections" ); + builder.load_block_collections( directory ); + DEBUG( "load_relationships" ); + builder.load_relationships( directory ); + DEBUG( "load_unique_vertices" ); + builder.load_unique_vertices( directory ); Logger::set_level( level ); + DEBUG( "register_all_components" ); detail::register_all_components( brep ); + DEBUG( "filter_unsupported_components" ); detail::filter_unsupported_components( brep ); + DEBUG( "load_brep_files done" ); } } // namespace detail } // namespace geode diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index ae0e8c992..58ff9d072 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -202,6 +202,8 @@ namespace geode { for( auto &attribute_it : attributes_ ) { + DEBUG( attribute_it.second->name().value_or( "unknown" ) ); + SDEBUG( attribute_it.second->id() ); attribute_it.second->delete_elements( to_delete, key ); } nb_elements_ -= @@ -222,14 +224,34 @@ namespace geode return nb_elements_; } + std::optional< std::vector< uuid > > attribute_ids_with_name( + std::string_view name ) const + { + std::vector< uuid > ids; + for( const auto &[attribute_id, attribute] : attributes_ ) + { + if( attribute->name() == name ) + { + ids.push_back( attribute_id ); + } + } + if( ids.empty() ) + { + return std::nullopt; + } + return ids; + } + void copy( const AttributeManager::Impl &attribute_manager, const AttributeBase::AttributeKey &key ) { + DEBUG( "copy attribute_manager" ); nb_elements_ = attribute_manager.nb_elements_; for( const auto &[attribute_id, attribute] : attribute_manager.attributes_ ) { const auto attribute_it = attributes_.find( attribute_id ); + SDEBUG( attribute_id ); if( attribute_it != attributes_.end() ) { try @@ -245,6 +267,8 @@ namespace geode } else { + DEBUG( "emplace" ); + SDEBUG( attribute_id ); attributes_.emplace( attribute_id, attribute->clone( key ) ); } @@ -256,6 +280,7 @@ namespace geode const T &old2new_mapping, const AttributeBase::AttributeKey &key ) { + DEBUG( "import" ); for( const auto &[attribute_id, attribute_from] : attribute_manager.attributes_ ) { @@ -275,6 +300,9 @@ namespace geode } else { + DEBUG( "import emplace" ); + SDEBUG( attribute_id ); + DEBUG( nb_elements_ ); attributes_.emplace( attribute_id, attribute_from->extract( old2new_mapping, nb_elements_, key ) ); @@ -288,6 +316,7 @@ namespace geode geode::uuid attribute_id, const AttributeBase::AttributeKey &key ) { + DEBUG( "import" ); auto it = attribute_manager.attributes_.find( attribute_id ); OpenGeodeBasicException::check_exception( it != attribute_manager.attributes_.end(), nullptr, @@ -317,6 +346,9 @@ namespace geode } else { + DEBUG( "import emplace" ); + SDEBUG( attribute_id ); + DEBUG( nb_elements_ ); attributes_.emplace( attribute_id, it->second->extract( old2new_mapping, nb_elements_, key ) ); } @@ -506,14 +538,18 @@ namespace geode void AttributeManager::delete_elements( const std::vector< bool > &to_delete ) { + DEBUG( "delete_elements" ); if( absl::c_find( to_delete, true ) != to_delete.end() ) { + DEBUG( to_delete.size() ); + DEBUG( nb_elements() ); OpenGeodeBasicException::check_assertion( to_delete.size() == nb_elements(), "[AttributeManager::delete_elements] Vector to_delete should " "have the same size as the number of elements" ); impl_->delete_elements( to_delete, {} ); } + DEBUG( "delete_elements OK" ); } void AttributeManager::permute_elements( @@ -532,6 +568,12 @@ namespace geode impl_->copy( *attribute_manager.impl_, {} ); } + std::optional< std::vector< geode::uuid > > + AttributeManager::attribute_ids_with_name( std::string_view name ) const + { + return impl_->attribute_ids_with_name( name ); + } + void AttributeManager::import( const AttributeManager &attribute_manager, absl::Span< const index_t > old2new ) { diff --git a/src/geode/mesh/builder/graph_builder.cpp b/src/geode/mesh/builder/graph_builder.cpp index 7beb04af0..42b24a468 100644 --- a/src/geode/mesh/builder/graph_builder.cpp +++ b/src/geode/mesh/builder/graph_builder.cpp @@ -178,7 +178,9 @@ namespace geode return old2new; } update_edges_around( graph_, *this, old2new ); + DEBUG( "edge attribute manager" ); graph_.edge_attribute_manager().delete_elements( to_delete ); + DEBUG( "done" ); do_delete_edges( to_delete, old2new ); return old2new; } diff --git a/src/geode/mesh/builder/regular_grid_solid_builder.cpp b/src/geode/mesh/builder/regular_grid_solid_builder.cpp index 5231370d4..81d6d65c6 100644 --- a/src/geode/mesh/builder/regular_grid_solid_builder.cpp +++ b/src/geode/mesh/builder/regular_grid_solid_builder.cpp @@ -195,7 +195,8 @@ namespace geode OpenGeodeException::TYPE::data, "[RegularGridBuilder::copy] Cannot copy a mesh into an " "already initialized mesh." ); - SolidMeshBuilder3D::copy( grid ); GridBuilder3D::copy( grid ); + + SolidMeshBuilder3D::copy( grid ); } } // namespace geode diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index 53a60a861..1b61e36a4 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -231,8 +231,13 @@ namespace template < geode::index_t dimension > void copy_polyhedra( const geode::SolidMesh< dimension >& solid, + const geode::SolidMesh< dimension >& solid_to_build, geode::SolidMeshBuilder< dimension >& builder ) { + if( solid_to_build.nb_polyhedra() != 0 ) + { + return; + } for( const auto p : geode::Range{ solid.nb_polyhedra() } ) { absl::FixedArray< geode::index_t > vertices( @@ -958,8 +963,18 @@ namespace geode solid_mesh_.disable_facets(); } VertexSetBuilder::copy( solid_mesh ); + // if( solid_mesh.impl_name() == solid_mesh_.impl_name() ) + // { + // do_copy_points( solid_mesh ); + // do_copy_polyhedra( solid_mesh ); + // } + copy_points( solid_mesh, *this ); + DEBUG( solid_mesh.impl_name().get() ); solid_mesh_.polyhedron_attribute_manager().copy( solid_mesh.polyhedron_attribute_manager() ); + copy_polyhedra( solid_mesh, solid_mesh_, *this ); + // solid_mesh_.polyhedron_attribute_manager().copy( + // solid_mesh.polyhedron_attribute_manager() ); if( solid_mesh.are_edges_enabled() ) { solid_mesh_.copy_edges( solid_mesh, {} ); @@ -968,13 +983,6 @@ namespace geode { solid_mesh_.copy_facets( solid_mesh, {} ); } - // if( solid_mesh.impl_name() == solid_mesh_.impl_name() ) - // { - // do_copy_points( solid_mesh ); - // do_copy_polyhedra( solid_mesh ); - // } - copy_points( solid_mesh, *this ); - copy_polyhedra( solid_mesh, *this ); } template class opengeode_mesh_api SolidMeshBuilder< 3 >; diff --git a/src/geode/mesh/builder/surface_mesh_builder.cpp b/src/geode/mesh/builder/surface_mesh_builder.cpp index e30bcfafc..e76fe5773 100644 --- a/src/geode/mesh/builder/surface_mesh_builder.cpp +++ b/src/geode/mesh/builder/surface_mesh_builder.cpp @@ -837,14 +837,14 @@ namespace geode // do_copy_points( surface_mesh ); // do_copy_polygons( surface_mesh ); // } - surface_mesh_.polygon_attribute_manager().copy( - surface_mesh.polygon_attribute_manager() ); - copy_points( surface_mesh, *this ); copy_polygons( surface_mesh, *this ); if( surface_mesh.are_edges_enabled() ) { surface_mesh_.copy_edges( surface_mesh, {} ); } + surface_mesh_.polygon_attribute_manager().copy( + surface_mesh.polygon_attribute_manager() ); + copy_points( surface_mesh, *this ); } template class opengeode_mesh_api SurfaceMeshBuilder< 2 >; diff --git a/src/geode/mesh/core/coordinate_reference_system_manager.cpp b/src/geode/mesh/core/coordinate_reference_system_manager.cpp index 28cca6492..846b216f5 100644 --- a/src/geode/mesh/core/coordinate_reference_system_manager.cpp +++ b/src/geode/mesh/core/coordinate_reference_system_manager.cpp @@ -91,8 +91,6 @@ namespace geode void register_coordinate_reference_system( std::string_view name, std::shared_ptr< CoordinateReferenceSystem< dimension > >&& crs ) { - DEBUG( "register_coordinate_reference_system" ); - DEBUG( name ); const auto status = crss_.emplace( to_string( name ), std::move( crs ) ); OpenGeodeMeshException::check_exception( status.second, nullptr, diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index ee191eaed..b564f5c7d 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -96,7 +96,22 @@ namespace geode bitsery::ext::BaseClass< PointSet< dimension > >{} ); archive.object( point_set.impl_ ); point_set.impl_->initialize_crs( point_set ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + point_set.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + point_set.impl_->attribute_id() ); }, + []( Archive& archive, OpenGeodePointSet& point_set ) { + archive.ext( point_set, bitsery::ext::BaseClass< + PointSet< dimension > >{} ); + archive.object( point_set.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + point_set.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + point_set.impl_->attribute_id() ); + }, []( Archive& archive, OpenGeodePointSet& point_set ) { archive.ext( point_set, bitsery::ext::BaseClass< PointSet< dimension > >{} ); diff --git a/src/geode/mesh/helpers/gradient_computation.cpp b/src/geode/mesh/helpers/gradient_computation.cpp index 1b9357931..f9ca920e4 100644 --- a/src/geode/mesh/helpers/gradient_computation.cpp +++ b/src/geode/mesh/helpers/gradient_computation.cpp @@ -96,19 +96,23 @@ namespace void initialize_attribute_and_id( const geode::uuid& scalar_function_id ) { + DEBUG( "initialize_attribute_and_id" ); + SDEBUG( scalar_function_id ); + DEBUG( mesh_.vertex_attribute_manager().attribute_exists( + scalar_function_id ) ); geode::OpenGeodeMeshException::check_exception( mesh_.vertex_attribute_manager().attribute_exists( scalar_function_id ), nullptr, geode::OpenGeodeException::TYPE::data, "[compute_scalar_function_gradient] No attribute exists with " - "given name." ); + "given id." ); geode::OpenGeodeMeshException::check_exception( mesh_.vertex_attribute_manager().attribute_type( scalar_function_id ) == typeid( double ).name(), nullptr, geode::OpenGeodeException::TYPE::data, "[compute_scalar_function_gradient] The attribute linked to " - "given name is not scalar." ); + "given id is not scalar." ); scalar_function_ = mesh_.vertex_attribute_manager() .template read_attribute< double >( scalar_function_id ); diff --git a/src/geode/model/helpers/convert_brep_section.cpp b/src/geode/model/helpers/convert_brep_section.cpp index 2cd67cc99..c202f5c82 100644 --- a/src/geode/model/helpers/convert_brep_section.cpp +++ b/src/geode/model/helpers/convert_brep_section.cpp @@ -62,7 +62,9 @@ namespace mappings[geode::Line< dimension >::component_type_static()] ); geode::detail::copy_surface_components( from, builder_to, mappings[geode::Surface< dimension >::component_type_static()] ); + DEBUG( "copy relationships" ); builder_to.copy_relationships( mappings, from ); + DEBUG( "copy relationships ok" ); return mappings; } @@ -481,8 +483,10 @@ namespace geode { Section section; SectionBuilder builder{ section }; + DEBUG( "copy components" ); auto mappings = copy_components< BRep, SectionBuilder >( brep, builder ); + DEBUG( "copy components ok" ); for( const auto& corner : brep.corners() ) { builder.update_corner_mesh( diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index 7076e9a0e..8ba1449f5 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -159,6 +159,7 @@ namespace geode bool is_point_inside_surface( const Point2D& point, const Surface2D& surface ) { + DEBUG( "is_point_inside_surface" ); for( const auto& direction : ::directions_2D() ) { const Ray2D ray{ direction, point }; @@ -166,6 +167,7 @@ namespace geode bool could_determine{ true }; for( const auto& line : section_.boundaries( surface ) ) { + SDEBUG( line.id() ); auto intersections = count_real_intersections_with_boundary( ray, line.mesh(), line_aabb( line ) ); if( !intersections.has_value() ) @@ -188,8 +190,10 @@ namespace geode std::optional< uuid > surface_containing_point( const Point2D& point ) { + SDEBUG( point ); for( const auto& surface : section_.surfaces() ) { + SDEBUG( surface.id() ); if( is_point_inside_surface( point, surface ) ) { return surface.id(); @@ -264,6 +268,7 @@ namespace geode bool could_determine{ true }; for( const auto& surface : brep_.boundaries( block ) ) { + SDEBUG( surface.id() ); auto intersections = count_real_intersections_with_boundaries( ray, surface.mesh(), surface_aabb( surface ) ); diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index 8b8195d2a..87ed3c7a8 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -43,7 +43,9 @@ namespace geode { RelationshipsImpl::RelationshipsImpl() : graph_{ Graph::create() } { - initialize_attributes(); + DEBUG( "RelationshipsImpl::RelationshipsImpl" ); + geode::uuid new_id{}; + initialize_attributes( new_id ); } index_t RelationshipsImpl::nb_components_with_relations() const @@ -97,6 +99,7 @@ namespace geode void RelationshipsImpl::remove_component( const uuid& component_id ) { + DEBUG( "remove_component" ); const auto index = vertex_id( component_id ); if( !index ) { @@ -114,6 +117,7 @@ namespace geode const auto old2new = builder->delete_isolated_vertices( { index.value() } ); uuid2index_.update( old2new ); + DEBUG( "remove_component done" ); } index_t RelationshipsImpl::add_relation_edge( @@ -190,7 +194,8 @@ namespace geode const RelationshipsImpl& impl, const ModelCopyMapping& mapping ) { graph_ = impl.graph_->clone(); - initialize_attributes(); + const auto attribute_id = impl.ids_->id(); + initialize_attributes( attribute_id ); std::vector< index_t > vertices_to_delete; for( const auto vertex_id : Range{ graph_->nb_vertices() } ) { @@ -214,6 +219,7 @@ namespace geode { return; } + DEBUG( graph_->nb_edges() ); std::vector< bool > edges_to_delete( graph_->nb_edges(), false ); for( const auto vertex_id : vertices_to_delete ) { @@ -224,21 +230,32 @@ namespace geode } } auto builder = GraphBuilder::create( *graph_ ); + DEBUG( "delete edges" ); builder->delete_edges( edges_to_delete ); + DEBUG( "delete edges ok" ); + DEBUG( "delete vertices" ); const auto old2new = builder->delete_isolated_vertices( vertices_to_delete ); + DEBUG( "delete vertices ok" ); uuid2index_.update( old2new ); } - void RelationshipsImpl::initialize_attributes() + void RelationshipsImpl::initialize_attributes( const geode::uuid& id ) { - const auto ids_attribute_id = - graph_->vertex_attribute_manager() - .create_attribute< VariableAttribute, ComponentID >( - "id", ComponentID{} ); + if( graph_->vertex_attribute_manager().attribute_exists( id ) ) + { + DEBUG( "attribute do exists" ); + ids_ = + graph_->vertex_attribute_manager() + .find_attribute< VariableAttribute, ComponentID >( id ); + return; + } + DEBUG( "initialize_attributes" ); + graph_->vertex_attribute_manager() + .create_attribute< VariableAttribute, ComponentID >( + "id", id, ComponentID{} ); ids_ = graph_->vertex_attribute_manager() - .find_attribute< VariableAttribute, ComponentID >( - ids_attribute_id ); + .find_attribute< VariableAttribute, ComponentID >( id ); } std::optional< index_t > RelationshipsImpl::vertex_id( diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index 43e559bd7..b6578334c 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -60,7 +60,8 @@ namespace geode Impl() : RelationshipsImpl() { - initialize_relation_attribute(); + geode::uuid relation_attribute_id; + initialize_relation_attribute( relation_attribute_id ); } RelationType relation_type( const index_t edge_id ) const @@ -159,7 +160,8 @@ namespace geode void copy( const Impl& impl, const ModelCopyMapping& mapping ) { detail::RelationshipsImpl::copy( impl, mapping ); - initialize_relation_attribute(); + const auto relation_attribute_id = impl.relation_type_->id(); + initialize_relation_attribute( relation_attribute_id ); } void save( std::string_view directory ) const @@ -211,8 +213,12 @@ namespace geode impl.relation_type_, bitsery::ext::StdSmartPtr{} ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); impl.graph_ = graph.clone(); - impl.initialize_attributes(); - impl.initialize_relation_attribute(); + geode::uuid new_attribute_id; + DEBUG( "serialize" ); + SDEBUG( new_attribute_id ); + geode::uuid new_relation_id; + impl.initialize_attributes( new_attribute_id ); + impl.initialize_relation_attribute( new_relation_id ); impl.delete_isolated_vertices(); }, []( Archive& archive, Impl& impl ) { @@ -234,16 +240,22 @@ namespace geode } } } ); } - void initialize_relation_attribute() + void initialize_relation_attribute( const geode::uuid& id ) { - const auto relation_type_attribute_id = - relation_attribute_manager() - .create_attribute< VariableAttribute, RelationType >( - "relation_type", NO_ID ); + if( relation_attribute_manager().attribute_exists( id ) ) + { + relation_type_ = + relation_attribute_manager() + .find_attribute< VariableAttribute, RelationType >( + id ); + return; + } + relation_attribute_manager() + .create_attribute< VariableAttribute, RelationType >( + "relation_type", id, NO_ID ); relation_type_ = relation_attribute_manager() - .find_attribute< VariableAttribute, RelationType >( - relation_type_attribute_id ); + .find_attribute< VariableAttribute, RelationType >( id ); } std::string relation_to_string( index_t relation_type ) const diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 697019916..2c1666cf6 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -179,6 +179,7 @@ namespace geode template < typename MeshComponent > void register_component( const MeshComponent& component ) { + DEBUG( "register_component" ); auto it = vertex2unique_vertex_.find( component.id() ); const auto& mesh = component.mesh(); if( it == vertex2unique_vertex_.end() ) @@ -212,14 +213,17 @@ namespace geode } it->second = std::move( attribute ); } + DEBUG( " register_component done" ); } template < typename MeshComponent > void unregister_component( const MeshComponent& component ) { + DEBUG( "unregister_component" ); const auto& mesh = component.mesh(); auto attribute = vertex2unique_vertex_.at( component.id() ); const auto attribute_id = attribute->id(); + SDEBUG( attribute_id ); mesh.vertex_attribute_manager().delete_attribute( attribute_id ); vertex2unique_vertex_.erase( component.id() ); filter_component_vertices( component.id() ); @@ -324,11 +328,13 @@ namespace geode } if( need_to_delete ) { + DEBUG( "need to delete" ); component_vertices_->modify_value( uv, [&to_delete]( std::vector< ComponentMeshVertex >& vertices ) { delete_vector_elements( to_delete, vertices ); } ); + DEBUG( "end need to delete" ); } } ); } diff --git a/src/geode/model/representation/io/brep_input.cpp b/src/geode/model/representation/io/brep_input.cpp index 5c901ff3b..d64823322 100644 --- a/src/geode/model/representation/io/brep_input.cpp +++ b/src/geode/model/representation/io/brep_input.cpp @@ -39,37 +39,36 @@ namespace geode BRep load_brep( std::string_view filename ) { constexpr auto TYPE = "BRep"; - try - { - auto brep = detail::geode_object_input_impl< BRepInputFactory >( - TYPE, filename ); - auto message = absl::StrCat( TYPE, " has: " ); - detail::add_to_message( message, brep.nb_blocks(), " Blocks, " ); - detail::add_to_message( - message, brep.nb_surfaces(), " Surfaces, " ); - detail::add_to_message( message, brep.nb_lines(), " Lines, " ); - detail::add_to_message( message, brep.nb_corners(), " Corners, " ); - detail::add_to_message( - message, brep.nb_model_boundaries(), " ModelBoundaries, " ); - detail::add_to_message( - message, brep.nb_corner_collections(), " CornerCollections, " ); - detail::add_to_message( - message, brep.nb_line_collections(), " LineCollections, " ); - detail::add_to_message( message, brep.nb_surface_collections(), - " SurfaceCollections, " ); - detail::add_to_message( - message, brep.nb_block_collections(), " BlockCollections" ); - Logger::info( message ); - return brep; - } - catch( const OpenGeodeException& e ) - { - Logger::error( e.what() ); - print_available_extensions< BRepInputFactory >( TYPE ); - throw OpenGeodeModelException{ nullptr, - OpenGeodeException::TYPE::data, - "Cannot load BRep from file: ", filename }; - } + // try + // { + auto brep = detail::geode_object_input_impl< BRepInputFactory >( + TYPE, filename ); + auto message = absl::StrCat( TYPE, " has: " ); + detail::add_to_message( message, brep.nb_blocks(), " Blocks, " ); + detail::add_to_message( message, brep.nb_surfaces(), " Surfaces, " ); + detail::add_to_message( message, brep.nb_lines(), " Lines, " ); + detail::add_to_message( message, brep.nb_corners(), " Corners, " ); + detail::add_to_message( + message, brep.nb_model_boundaries(), " ModelBoundaries, " ); + detail::add_to_message( + message, brep.nb_corner_collections(), " CornerCollections, " ); + detail::add_to_message( + message, brep.nb_line_collections(), " LineCollections, " ); + detail::add_to_message( + message, brep.nb_surface_collections(), " SurfaceCollections, " ); + detail::add_to_message( + message, brep.nb_block_collections(), " BlockCollections" ); + Logger::info( message ); + return brep; + // } + // catch( const OpenGeodeException& e ) + // { + // Logger::error( e.what() ); + // print_available_extensions< BRepInputFactory >( TYPE ); + // throw OpenGeodeModelException{ nullptr, + // OpenGeodeException::TYPE::data, + // "Cannot load BRep from file: ", filename }; + // } } AdditionalFiles brep_additional_files( std::string_view filename ) @@ -81,17 +80,16 @@ namespace geode Percentage is_brep_loadable( std::string_view filename ) { - try - { - const auto input = - detail::geode_object_input_reader< BRepInputFactory >( - filename ); - return input->is_loadable(); - } - catch( ... ) - { - return Percentage{ 0 }; - } + // try + // { + const auto input = + detail::geode_object_input_reader< BRepInputFactory >( filename ); + return input->is_loadable(); + // } + // catch( ... ) + // { + // return Percentage{ 0 }; + // } } index_t brep_object_priority( std::string_view filename ) diff --git a/tests/basic/test-attribute.cpp b/tests/basic/test-attribute.cpp index 0c592860e..a79b94c11 100644 --- a/tests/basic/test-attribute.cpp +++ b/tests/basic/test-attribute.cpp @@ -375,71 +375,79 @@ void check_one_attribute_values( geode::AttributeManager& manager, { geode::OpenGeodeBasicException::test( in_att->value( i ) == out_att->value( i ), - "At least one value of Attribute ", attribute_id, + "At least one value of Attribute ", attribute_id.string(), " is not correct after reloading" ); } } -// void check_attribute_values( geode::AttributeManager& manager, -// geode::AttributeManager& reloaded_manager ) -// { -// check_one_attribute_values< bool >( manager, reloaded_manager, "bool" ); -// check_one_attribute_values< int >( manager, reloaded_manager, "int" ); -// check_one_attribute_values< double >( manager, reloaded_manager, "double" -// ); check_one_attribute_values< bool >( manager, reloaded_manager, -// "bool_var" ); check_one_attribute_values< Foo >( manager, -// reloaded_manager, "foo_cst" ); check_one_attribute_values< Foo >( -// manager, reloaded_manager, "foo_var" ); check_one_attribute_values< Foo -// >( manager, reloaded_manager, "foo_spr" ); -// } - -// void test_serialize_manager( geode::AttributeManager& manager ) -// { -// const auto filename = "manager.out"; -// std::ofstream file{ filename, std::ofstream::binary }; -// geode::TContext context{}; -// geode::register_attribute_type< Foo, geode::Serializer >( -// std::get< 0 >( context ), "Foo" ); -// geode::register_basic_serialize_pcontext( std::get< 0 >( context ) ); -// geode::register_attribute_type< std::array< double, 2 >, -// geode::Serializer >( std::get< 0 >( context ), "array_double_2" ); -// geode::Serializer archive{ context, file }; -// archive.object( manager ); -// archive.adapter().flush(); -// geode::OpenGeodeBasicException::test( std::get< 1 >( context ).isValid(), -// "Error while writing file: ", filename ); - -// std::ifstream infile{ filename, std::ifstream::binary }; -// geode::AttributeManager reloaded_manager; -// geode::TContext reload_context{}; -// geode::register_attribute_type< std::array< double, 30 >, -// geode::Serializer >( std::get< 0 >( context ), "array_double_30" ); -// geode::register_basic_deserialize_pcontext( -// std::get< 0 >( reload_context ) ); -// geode::register_attribute_type< Foo, geode::Deserializer >( -// std::get< 0 >( reload_context ), "Foo" ); -// geode::register_attribute_type< std::array< double, 2 >, -// geode::Deserializer >( -// std::get< 0 >( reload_context ), "array_double_2" ); -// geode::Deserializer unarchive{ reload_context, infile }; -// unarchive.object( reloaded_manager ); -// const auto& adapter = unarchive.adapter(); -// geode::OpenGeodeBasicException::test( -// adapter.error() == bitsery::ReaderError::NoError -// && adapter.isCompletedSuccessfully() -// && std::get< 1 >( context ).isValid(), -// "Error while reading file: ", filename ); - -// geode::OpenGeodeBasicException::test( -// reloaded_manager.nb_elements() == manager.nb_elements(), -// "Number of elements in reloaded AttributeManager is not " -// "correct" ); -// geode::OpenGeodeBasicException::test( -// managers_have_same_attributes( manager, reloaded_manager ), -// "Number and names of attributes in reloaded AttributeManager " -// "are not correct" ); -// check_attribute_values( manager, reloaded_manager ); -// } +void check_attribute_values( geode::AttributeManager& manager, + geode::AttributeManager& reloaded_manager, + const std::array< geode::uuid, 7 >& attribute_to_check ) +{ + check_one_attribute_values< bool >( + manager, reloaded_manager, attribute_to_check[0] ); + check_one_attribute_values< int >( + manager, reloaded_manager, attribute_to_check[1] ); + check_one_attribute_values< double >( + manager, reloaded_manager, attribute_to_check[2] ); + check_one_attribute_values< bool >( + manager, reloaded_manager, attribute_to_check[3] ); + check_one_attribute_values< Foo >( + manager, reloaded_manager, attribute_to_check[4] ); + check_one_attribute_values< Foo >( + manager, reloaded_manager, attribute_to_check[5] ); + check_one_attribute_values< Foo >( + manager, reloaded_manager, attribute_to_check[6] ); +} + +void test_serialize_manager( geode::AttributeManager& manager, + const std::array< geode::uuid, 7 >& attribute_to_check ) +{ + const auto filename = "manager.out"; + std::ofstream file{ filename, std::ofstream::binary }; + geode::TContext context{}; + geode::register_attribute_type< Foo, geode::Serializer >( + std::get< 0 >( context ), "Foo" ); + geode::register_basic_serialize_pcontext( std::get< 0 >( context ) ); + geode::register_attribute_type< std::array< double, 2 >, + geode::Serializer >( std::get< 0 >( context ), "array_double_2" ); + geode::Serializer archive{ context, file }; + archive.object( manager ); + archive.adapter().flush(); + geode::OpenGeodeBasicException::test( std::get< 1 >( context ).isValid(), + "Error while writing file: ", filename ); + + std::ifstream infile{ filename, std::ifstream::binary }; + geode::AttributeManager reloaded_manager; + geode::TContext reload_context{}; + geode::register_attribute_type< std::array< double, 30 >, + geode::Serializer >( std::get< 0 >( context ), "array_double_30" ); + geode::register_basic_deserialize_pcontext( + std::get< 0 >( reload_context ) ); + geode::register_attribute_type< Foo, geode::Deserializer >( + std::get< 0 >( reload_context ), "Foo" ); + geode::register_attribute_type< std::array< double, 2 >, + geode::Deserializer >( + std::get< 0 >( reload_context ), "array_double_2" ); + geode::Deserializer unarchive{ reload_context, infile }; + unarchive.object( reloaded_manager ); + const auto& adapter = unarchive.adapter(); + geode::OpenGeodeBasicException::test( + adapter.error() == bitsery::ReaderError::NoError + && adapter.isCompletedSuccessfully() + && std::get< 1 >( context ).isValid(), + "Error while reading file: ", filename ); + + geode::OpenGeodeBasicException::test( + reloaded_manager.nb_elements() == manager.nb_elements(), + "Number of elements in reloaded AttributeManager is not " + "correct" ); + geode::OpenGeodeBasicException::test( + managers_have_same_attributes( manager, reloaded_manager ), + "Number and names of attributes in reloaded AttributeManager " + "are not correct" ); + check_attribute_values( manager, reloaded_manager, attribute_to_check ); +} void test_attribute_types( geode::AttributeManager& manager, const geode::uuid& bool_variable_attribute_id ) @@ -729,8 +737,11 @@ void test() test_delete_attribute_elements( manager ); test_sparse_attribute_after_element_deletion( manager, double_sparse_attribute_id ); - - // test_serialize_manager( manager ); + std::array< geode::uuid, 7 > attribute_to_check{ constant_attribute_id, + int_variable_attribute_id, double_sparse_attribute_id, + bool_variable_attribute_id, foo_variable_attribute_id, + foo_constant_attribute_id, foo_sparse_attribute_id }; + test_serialize_manager( manager, attribute_to_check ); test_copy_manager( manager, bool_variable_attribute_id ); test_import_manager( manager, bool_variable_attribute_id, array_double_attribute_id, double_sparse_attribute_id ); diff --git a/tests/data/test_v12.og_edc3d b/tests/data/backward_io/v12/test_v12.og_edc3d similarity index 100% rename from tests/data/test_v12.og_edc3d rename to tests/data/backward_io/v12/test_v12.og_edc3d diff --git a/tests/data/test_v12.og_psf3d b/tests/data/backward_io/v12/test_v12.og_psf3d similarity index 100% rename from tests/data/test_v12.og_psf3d rename to tests/data/backward_io/v12/test_v12.og_psf3d diff --git a/tests/data/test_v12.og_pso3d b/tests/data/backward_io/v12/test_v12.og_pso3d similarity index 100% rename from tests/data/test_v12.og_pso3d rename to tests/data/backward_io/v12/test_v12.og_pso3d diff --git a/tests/data/test_v12.og_rgd3d b/tests/data/backward_io/v12/test_v12.og_rgd3d similarity index 100% rename from tests/data/test_v12.og_rgd3d rename to tests/data/backward_io/v12/test_v12.og_rgd3d diff --git a/tests/data/test_v7.og_grp b/tests/data/backward_io/v7/test_v7.og_grp similarity index 100% rename from tests/data/test_v7.og_grp rename to tests/data/backward_io/v7/test_v7.og_grp diff --git a/tests/data/test_v7.og_psf3d b/tests/data/backward_io/v7/test_v7.og_psf3d similarity index 100% rename from tests/data/test_v7.og_psf3d rename to tests/data/backward_io/v7/test_v7.og_psf3d diff --git a/tests/data/test_v7.og_pso3d b/tests/data/backward_io/v7/test_v7.og_pso3d similarity index 100% rename from tests/data/test_v7.og_pso3d rename to tests/data/backward_io/v7/test_v7.og_pso3d diff --git a/tests/mesh/test-gradient-computation.cpp b/tests/mesh/test-gradient-computation.cpp index e6b791cd5..4c55ef1d6 100644 --- a/tests/mesh/test-gradient-computation.cpp +++ b/tests/mesh/test-gradient-computation.cpp @@ -164,11 +164,11 @@ void test_gradient_grid3D() attribute->set_value( 24, 3 ); attribute->set_value( 26, 3 ); const auto gradient_id = - geode::compute_solid_scalar_function_gradient( *grid, attribute->id() ); + geode::compute_solid_scalar_function_gradient( *grid, attribute_id ); geode::Logger::info( "Gradient attribute name: ", gradient_id.string() ); const auto [gradient_id_2, vertices_with_no_value] = geode::internal::compute_solid_scalar_function_gradient( - *grid, attribute->id(), { 0, 1 } ); + *grid, attribute_id, { 0, 1 } ); geode::Logger::info( "Gradient attribute name 2: ", gradient_id_2.string() ); geode::OpenGeodeMeshException::test( vertices_with_no_value.size() == 7, diff --git a/tests/mesh/test-polyhedral-solid.cpp b/tests/mesh/test-polyhedral-solid.cpp index 4837cbc64..5c8a1c517 100644 --- a/tests/mesh/test-polyhedral-solid.cpp +++ b/tests/mesh/test-polyhedral-solid.cpp @@ -169,7 +169,7 @@ geode::uuid test_create_edge_attribute( attribute->value( 0 ) == 1, "Wrong value for attribute on edge 0" ); geode::OpenGeodeMeshException::test( attribute->value( 1 ) == 3, "Wrong value for attribute on edge 1" ); - return attribute->id(); + return attribute_id; } void test_polyhedron_adjacencies( diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index d4146a45d..66b43bcd1 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -368,6 +368,8 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) "Error in facet attribute transfer during cloning" ); const auto from_vertices = solid.facets().facet_vertices( f ); const auto to_vertices = solid4.facets().facet_vertices( f ); + DEBUG( from_vertices.size() ); + DEBUG( to_vertices.size() ); for( const auto v : geode::Indices{ from_vertices } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index 7dba368c2..0b8499797 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -1491,16 +1491,19 @@ void test_backward_io() "mesh." ); } test_registry( brep, 4, 13, 17, 7, 1, 0, 0, 0, 0, 0, 0 ); + DEBUG( "test_backward_io OK" ); } void test_components_filter() { + DEBUG( "test_components_filter" ); const auto brep = geode::load_brep( absl::StrCat( geode::DATA_PATH, "structural_model.og_brep" ) ); geode::OpenGeodeModelException::test( brep.nb_components_with_relations() == 9, "Wrong number of components with relations, there are ", brep.nb_components_with_relations(), " instead of 9" ); + DEBUG( "test components filter OK" ); } std::tuple< geode::BRep, geode::ModelCopyMapping > copy_model( diff --git a/tests/model/test-convert-brep.cpp b/tests/model/test-convert-brep.cpp index a2ff52c2d..78e91c27b 100644 --- a/tests/model/test-convert-brep.cpp +++ b/tests/model/test-convert-brep.cpp @@ -38,14 +38,13 @@ void test_convert_brep_section() absl::StrCat( geode::DATA_PATH, "random_dfn.og_brep" ) ); const auto section = std::get< 0 >( geode::convert_brep_into_section( brep, 2 ) ); - geode::OpenGeodeModelException::test( section.nb_corners() == 172, "Section should have 172 corners" ); geode::OpenGeodeModelException::test( section.nb_lines() == 288, "Section should have 288 lines" ); geode::OpenGeodeModelException::test( section.nb_surfaces() == 117, "Section should have 117 surfaces" ); - + DEBUG( "converting section into brep" ); const auto brep2 = std::get< 0 >( geode::convert_section_into_brep( section, 2, 10. ) ); diff --git a/tests/model/test-ray-tracing-helpers.cpp b/tests/model/test-ray-tracing-helpers.cpp index a8a2e4712..b0bf42a28 100644 --- a/tests/model/test-ray-tracing-helpers.cpp +++ b/tests/model/test-ray-tracing-helpers.cpp @@ -47,6 +47,7 @@ void test() // get the block geode::BRepRayTracing brep_ray_tracing{ brep }; const auto block_id = brep_ray_tracing.block_containing_point( center ); + SDEBUG( block_id.value() ); geode::OpenGeodeModelException::test( block_id.has_value(), "Failed to recover block_containing_point." ); From 6882d5b6b91046bc896858260e2e1b58e10d4fcf Mon Sep 17 00:00:00 2001 From: BenPinet Date: Tue, 16 Jun 2026 16:00:39 +0200 Subject: [PATCH 06/19] wip --- include/geode/basic/bitsery_archive.hpp | 6 +- .../geode/mesh/core/geode/geode_point_set.hpp | 5 -- .../geode/mesh/core/internal/edges_impl.hpp | 7 +++ .../geode/mesh/core/internal/points_impl.hpp | 9 ++- .../helpers/detail/bitsery_mesh_helper.hpp | 57 ++++++++++++++++++ src/geode/basic/attribute_manager.cpp | 19 ++++++ src/geode/mesh/CMakeLists.txt | 1 + src/geode/mesh/core/geode/geode_point_set.cpp | 42 ++++++++----- src/geode/mesh/core/point_set.cpp | 3 + tests/data/backward_io/v17/v17.og_edc3d | Bin 0 -> 652 bytes tests/data/backward_io/v17/v17.og_grp | Bin 0 -> 286 bytes tests/data/backward_io/v17/v17.og_hso3d | Bin 0 -> 2472 bytes tests/data/backward_io/v17/v17.og_psf3d | Bin 0 -> 1402 bytes tests/data/backward_io/v17/v17.og_pso3d | Bin 0 -> 2450 bytes tests/data/backward_io/v17/v17.og_pts3d | Bin 0 -> 339 bytes tests/data/backward_io/v17/v17.og_rgd3d | Bin 0 -> 45956 bytes tests/data/backward_io/v17/v17.og_tsf3d | Bin 0 -> 1156 bytes tests/data/backward_io/v17/v17.og_tso3d | Bin 0 -> 1872 bytes tests/mesh/test-edged-curve.cpp | 9 ++- tests/mesh/test-point-set.cpp | 35 +++++++++-- 20 files changed, 163 insertions(+), 30 deletions(-) create mode 100644 include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp create mode 100644 tests/data/backward_io/v17/v17.og_edc3d create mode 100644 tests/data/backward_io/v17/v17.og_grp create mode 100644 tests/data/backward_io/v17/v17.og_hso3d create mode 100644 tests/data/backward_io/v17/v17.og_psf3d create mode 100644 tests/data/backward_io/v17/v17.og_pso3d create mode 100644 tests/data/backward_io/v17/v17.og_pts3d create mode 100644 tests/data/backward_io/v17/v17.og_rgd3d create mode 100644 tests/data/backward_io/v17/v17.og_tsf3d create mode 100644 tests/data/backward_io/v17/v17.og_tso3d diff --git a/include/geode/basic/bitsery_archive.hpp b/include/geode/basic/bitsery_archive.hpp index 5bfad4aa9..599d5ca46 100644 --- a/include/geode/basic/bitsery_archive.hpp +++ b/include/geode/basic/bitsery_archive.hpp @@ -91,6 +91,7 @@ namespace geode { const auto ids = manager.attribute_ids_with_name( old_attribute_name ).value(); + DEBUG( ids.size() ); geode::uuid old_attribute_id; for( const auto &id : ids ) { @@ -98,14 +99,17 @@ namespace geode { continue; } + DEBUG( "found old attribute " ); old_attribute_id = id; } - auto old_attribute = manager.read_attribute< T >( ids.at( 0 ) ); + auto old_attribute = + manager.read_attribute< T >( old_attribute_id ); auto new_attribute = manager.find_attribute< Attribute, T >( new_attribute_id ); manager.resize( old_attribute->nb_items() ); for( const auto index : geode::Range{ old_attribute->nb_items() } ) { + SDEBUG( old_attribute->value( index ) ); new_attribute->set_value( index, old_attribute->value( index ) ); } diff --git a/include/geode/mesh/core/geode/geode_point_set.hpp b/include/geode/mesh/core/geode/geode_point_set.hpp index 023dad010..d14d203a7 100644 --- a/include/geode/mesh/core/geode/geode_point_set.hpp +++ b/include/geode/mesh/core/geode/geode_point_set.hpp @@ -82,11 +82,6 @@ namespace geode return native_extension_static(); } - public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGPointSetKey /*key*/ ); - private: friend class bitsery::Access; template < typename Archive > diff --git a/include/geode/mesh/core/internal/edges_impl.hpp b/include/geode/mesh/core/internal/edges_impl.hpp index d588b4831..993d12257 100644 --- a/include/geode/mesh/core/internal/edges_impl.hpp +++ b/include/geode/mesh/core/internal/edges_impl.hpp @@ -37,6 +37,8 @@ namespace geode class EdgesImpl { public: + static constexpr auto EDGES_NAME = "edges"; + explicit EdgesImpl( Graph& graph ) : edges_() { const auto edge_attribute_id = @@ -68,6 +70,11 @@ namespace geode } ); } + [[nodiscard]] const uuid& edges_attribute_id() const + { + return edges_->id(); + } + protected: EdgesImpl() = default; diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index 7e94fcb12..a42e1b0e8 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -52,6 +52,8 @@ namespace geode public: static constexpr auto POINTS_NAME = "points"; + PointsImpl() = default; + [[nodiscard]] const Point< dimension >& get_point( index_t vertex_id ) const { @@ -96,6 +98,7 @@ namespace geode serializer.ext( *this, Growable< Archive, PointsImpl >{ { []( Archive& archive, PointsImpl& impl ) { + DEBUG( "PointsImpl::serialize" ); archive.ext( impl.points_, bitsery::ext::StdSmartPtr{} ); if( !impl.points_ ) @@ -108,10 +111,13 @@ namespace geode { old_points_properties.assignable, old_points_properties.interpolable, false } ); + DEBUG( "PointsImpl::serialize end" ); }, []( Archive& archive, PointsImpl& impl ) { + DEBUG( "PointsImpl::serialize" ); archive.ext( impl.points_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "PointsImpl::serialize end" ); } } } ); } @@ -134,8 +140,6 @@ namespace geode } protected: - PointsImpl() = default; - template < typename Mesh > explicit PointsImpl( Mesh& mesh ) : PointsImpl( mesh.vertex_attribute_manager() ) @@ -151,6 +155,7 @@ namespace geode PointsImpl( AttributeManager& manager, std::string_view attribute_name ) { + DEBUG( "PointsImpl" ); const auto attribute_id = manager.template create_attribute< VariableAttribute, Point< dimension > >( attribute_name, diff --git a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp new file mode 100644 index 000000000..5fbc80fce --- /dev/null +++ b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 - 2026 Geode-solutions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#pragma once + +#include + +#include +#include +#include + +namespace geode +{ + namespace detail + { + template < typename Mesh > + void initialize_crs( Mesh &mesh ) + { + DEBUG( "initialize_crs" ); + CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } + .main_coordinate_reference_system_manager_builder() + .delete_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + auto crs_manager_builder = + CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } + .main_coordinate_reference_system_manager_builder(); + crs_manager_builder.register_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME, + std::shared_ptr< CoordinateReferenceSystem< Mesh::dim > >{ + std::make_shared< + AttributeCoordinateReferenceSystem< Mesh::dim > >( + mesh.vertex_attribute_manager() ) } ); + crs_manager_builder.set_active_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + } + } // namespace detail +} // namespace geode diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 58ff9d072..5e4b69541 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -227,9 +227,11 @@ namespace geode std::optional< std::vector< uuid > > attribute_ids_with_name( std::string_view name ) const { + DEBUG( "attribute_ids_with_name" ); std::vector< uuid > ids; for( const auto &[attribute_id, attribute] : attributes_ ) { + DEBUG( attribute->name().value_or( "unknown" ) ); if( attribute->name() == name ) { ids.push_back( attribute_id ); @@ -399,10 +401,19 @@ namespace geode for( auto &[attribute_name, attribute] : old_map ) { IdentifierBuilder builder{ *attribute }; + DEBUG( attribute_name ); builder.set_name( attribute_name ); impl.attributes_.emplace( attribute->id(), std::move( attribute ) ); } + DEBUG( "AttributeManager::serialize" ); + for( const auto &[current_attribute_id, + current_attribute] : impl.attributes_ ) + { + DEBUG( current_attribute->name().value_or( + "unknown" ) ); + SDEBUG( current_attribute_id ); + } }, []( Archive &local_archive, Impl &impl ) { local_archive.value4b( impl.nb_elements_ ); @@ -431,6 +442,14 @@ namespace geode attribute->type() }; } } ); + DEBUG( "AttributeManager::serialize" ); + for( const auto &[current_attribute_id, + current_attribute] : impl.attributes_ ) + { + DEBUG( current_attribute->name().value_or( + "unknown" ) ); + SDEBUG( current_attribute_id ); + } } } } ); } diff --git a/src/geode/mesh/CMakeLists.txt b/src/geode/mesh/CMakeLists.txt index 8b7b1d9db..3c21a77b4 100644 --- a/src/geode/mesh/CMakeLists.txt +++ b/src/geode/mesh/CMakeLists.txt @@ -326,6 +326,7 @@ add_geode_library( "helpers/detail/surface_merger.hpp" "helpers/detail/surface_mesh_validity_fix.hpp" "helpers/detail/vertex_merger.hpp" + "helpers/detail/bitsery_mesh_helper.hpp" INTERNAL_HEADERS "core/internal/edges_impl.hpp" "core/internal/facet_edges_impl.hpp" diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index b564f5c7d..63d8e96da 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -31,33 +31,35 @@ #include #include +#include namespace geode { template < index_t dimension > class OpenGeodePointSet< dimension >::Impl - : public internal::PointsImpl< dimension > { friend class bitsery::Access; public: explicit Impl( OpenGeodePointSet< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< OpenGeodePointSet< dimension > >( + mesh ); } private: Impl() = default; + private: template < typename Archive > void serialize( Archive& serializer ) { serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive& archive, Impl& impl ) { - archive.ext( impl, - bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + geode_unused( impl ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); } } } ); } }; @@ -78,13 +80,6 @@ namespace geode template < index_t dimension > OpenGeodePointSet< dimension >::~OpenGeodePointSet() = default; - template < index_t dimension > - void OpenGeodePointSet< dimension >::set_vertex( - index_t vertex_id, Point< dimension > point, OGPointSetKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > template < typename Archive > void OpenGeodePointSet< dimension >::serialize( Archive& serializer ) @@ -92,17 +87,32 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePointSet >{ { []( Archive& archive, OpenGeodePointSet& point_set ) { + DEBUG( "OpenGeodePointSet::serialize" ); + const auto new_attribute_id = + point_set.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( point_set, bitsery::ext::BaseClass< PointSet< dimension > >{} ); archive.object( point_set.impl_ ); - point_set.impl_->initialize_crs( point_set ); detail::import_old_attribute< VariableAttribute, Point< dimension > >( point_set.vertex_attribute_manager(), internal::PointsImpl< dimension >::POINTS_NAME, - point_set.impl_->attribute_id() ); + new_attribute_id ); + detail::template initialize_crs< + OpenGeodePointSet< dimension > >( point_set ); }, []( Archive& archive, OpenGeodePointSet& point_set ) { + DEBUG( "OpenGeodePointSet::serialize" ); + const auto new_attribute_id = + point_set.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( point_set, bitsery::ext::BaseClass< PointSet< dimension > >{} ); archive.object( point_set.impl_ ); @@ -110,7 +120,9 @@ namespace geode Point< dimension > >( point_set.vertex_attribute_manager(), internal::PointsImpl< dimension >::POINTS_NAME, - point_set.impl_->attribute_id() ); + new_attribute_id ); + detail::template initialize_crs< + OpenGeodePointSet< dimension > >( point_set ); }, []( Archive& archive, OpenGeodePointSet& point_set ) { archive.ext( point_set, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/point_set.cpp b/src/geode/mesh/core/point_set.cpp index e7368243f..d60b23d84 100644 --- a/src/geode/mesh/core/point_set.cpp +++ b/src/geode/mesh/core/point_set.cpp @@ -65,12 +65,15 @@ namespace geode point_set, bitsery::ext::BaseClass< VertexSet >{} ); }, []( Archive& archive, PointSet& point_set ) { + DEBUG( "PointSet::serialize" ); archive.ext( point_set, bitsery::ext::BaseClass< VertexSet >{} ); + DEBUG( "PointSet::serialize 2" ); archive.ext( point_set, bitsery::ext::BaseClass< CoordinateReferenceSystemManagers< dimension > >{} ); + DEBUG( "PointSet::serialize 3" ); } } } ); } diff --git a/tests/data/backward_io/v17/v17.og_edc3d b/tests/data/backward_io/v17/v17.og_edc3d new file mode 100644 index 0000000000000000000000000000000000000000..d7e3782e9e880a97218d46f7b5c8d11821b47811 GIT binary patch literal 652 zcmZuvyGjF55WVN_=H)AzL{JOSU?Fyz56A{%VJ8Y{mreFY7UHhl+(-f<{)QG-b~d(t zf}j!fL+k`Ay{}D^3@m5&?3rQC%uojukPn4R2%*`_B#K4fS!)G63feu^5Q0bTfnX=< zN3AKfR0^#Q@^xmoxW7~JQaAWouj%-zNoIqUlYPX=-5UokG&(5+5&exy_lEoy0v^)M@)xZ0kagl@-tfI7;gqdDW>P__^O zGL+)scu)1{Mq~0(RL; zJCkELOcEYOaUj?!>oU&b4m%t51-noOf})(xQhFiFl32mS2T+m(P}Ys00+2jbK?~IR E2V_vHs{jB1 literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_grp b/tests/data/backward_io/v17/v17.og_grp new file mode 100644 index 0000000000000000000000000000000000000000..ae2095f0eb30c7a8cbbc062a285e279257020db4 GIT binary patch literal 286 zcmZQ%WMX6lVkSlw1_lO3;nbA$)Z+NWqWsdll=!mLqLS1KW~H#iqRhmkoK(k>lA_F{ z(vnnHkSa&8qA;);pb<D=Di|OfMkZzuhZ!se(F+lR8pOcJ2-La;o;7+HaWY!Iiif}P5)fZ@2rqN2pg_{_YN)Qb3$cq6EZ5as`& b0OVN)uzP?s$mJmCfM}2yn9s<;$ixl+K#M;l literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_hso3d b/tests/data/backward_io/v17/v17.og_hso3d new file mode 100644 index 0000000000000000000000000000000000000000..bbfeb759e9b41f0d6d5807f332b449e4cbfb4af4 GIT binary patch literal 2472 zcmb7_&raJw5XL>W`5OuWLXx(ZR;twAT9pR?L@(S>D{+lXvZ#?DLB>?%$XoPO^$q$I zJ@-|3gLZ#ok8x~rsL^_MXTF*FW_BDxi9!(x{a-5xf@t}AI-X=VQU5GS$I1DnJIbbwBes%ngr#x<>&B0`ss)3k?O};h-L>ZU~AH zmb~dv0v051cvz_5uzx+hoPBkpbUGO%>GXCo8hmqU=I-LxPjuU$X9_9WzA!}im#4+m z1VO0W^zH8zh3cbRgpp!+i|#|!N4k%CMlzY_xb&gH@i-a!YEFxyk|QlCr+adBeOXXm z6fkW0y!MDJhoSuVbN~K+mVJNwa_e{J=dVCy#n0v{6^N|mV%zes>&ncenPTvb=agW0@DhAz_?84umf?yJTPBx#z=1_iaj z$AVnV&qvaS3QLaMK1&->$R#hAi?!+{Yt1k8NFMfZ1BX8tVqmY=K>m^}`DIOla2p8*fWVLH_v(O9;W-zQMBMZj7s4o^hSa>}EBbOd?h{5bcd3lMMAe(+BklJ@o=YGvq~}j_ z!$vA7nhS)iF?RFV>NrwY?VPnt!1Rr;o@^cczgxVB&Xx>FN<;Gatv>9ldd`N&U$c;! LTKTN`NeQEWa*-El literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_psf3d b/tests/data/backward_io/v17/v17.og_psf3d new file mode 100644 index 0000000000000000000000000000000000000000..45283dc474130372c1845d146f258a45be4ff48c GIT binary patch literal 1402 zcmah}!EO^V5Z!S$*@l!hgru|uRaM1-8&dND*{J2vTLn@s99G+`Q&viMqg@A@BOief zNbn1s`2-{o2X1@@LR`UbY)5I6idoq+_RPE)kH;%2f{29v0?+e&U&&Hc9t`3ljnBri zuT+tqO_e;&$FuW1dyZ7n>H*i!rj1$wPX5YN026_$OTt31~**Cu(IsnXwG5kV`u z#|GWmF(Uk~Q$X+Efj;*P|I+I+{piuRuOKfp{J`?v&|>Y`jdo}}c0w}3emG+K(=(o} z&_cDWhlBjxv%wE6MCYa$O$%8II}=mDC@%78mP9XQq2y(CZ$%ln&;!=nVyt$)T6kl9c^o0Upl zphxI734h%>(S|Q*lhAP#=&Gt|A)Aku4t0`^(@Z75w=WnWa7k}v!3fXBs#A9S5^@$UVKCr3xoHb-TM~jEY4e8 z5S%~jb)uy2*KUb{59<4=SI5eU6DZzXMf&s+>#C9BFO9ma9}W8U70U@yyk+rfU~R2i z#$u3atOS%28^MXJKaEtg5?E6etDz=;H>~q5Yoa>I$GkO}53B}R#&nQ|y%5ySvf4Mp zxHpK}%{Nm1+~zGM(l!lu$eCy&ZCWvHne7t_X`7e!Qohn^=0nI^){w%{i1JUzBH9aE zJU2Q%;jSc*26u3J*0s%?WYFbtN*7UqgS!0w?(NTh`1$={_44Y&FNdhe(>sO65lyG4 zL}X`UW;>hTy2v6+7| zme)bl?L?-1WLiltZXRN0>-){;_DZOt12eh&0#OAgbdSoYpWK+m@d@ulZFAmCtPzpI zr79yaSi%(r#!W#ZfN_ha7^WFYmY!ieYxji~k4$3X>K*PJ6@)YK2m)S)F=zmyz?q&a zA9(HrPlOC=4}0V@tA7G4To8@Fz6|lNV@!yeW(|CR7FT z-~+G+##;j#7<#%#B|!s24!BI}5m+Vys**B3YKPPT+9P7HgkF$}pgAIj6Ld>Vt0S1t zGLemZAchn5C8nVR5Yvbfy(SGEO&32nnPaFfEfdu+dMkv8ycMWiB9y||BQY~V**w{ zj7kq(M%Brc^No%u$p@M*GIg~}h13PmhG&~6h z1db&oAJW4Oz$s-#gkP~a(h6{|We~QE_efLHs{m^nJJMQPC3?UwxqViN*7@-zdWa~p zMH_rM=4sQ#{ANiYWSB!Z!!*n*UtM7@ei0X}?C{SKFX!{9kmKe&@^dc#?r~htW6%84 zXNVT3Z~$YfUtzk+P-9qQSZCN|*k*Xlu){Em1|tz*T_~;6OlCBAkd;W05~_pC>-zry DpRuY1 literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_pts3d b/tests/data/backward_io/v17/v17.og_pts3d new file mode 100644 index 0000000000000000000000000000000000000000..2d082c014b18a1d80678b0fe936c370e3e79a2a1 GIT binary patch literal 339 zcmZQ#Vq#=uWCB7K1_lNuwu1c3ypm#OiLk_?%*3ReRL7E%qRgbylGFf@gs}@yEfY{7 zR2?Ibi50Lg&YB4VJMAI#Nqb{3xNOgO_6!IxI6!D6C@tl{m<9$+4iE!H93VPA@5gOP zNosKki>PycUU5lcUJ2Z(N%{FX5O*@NfRq3|$O`o4yz|Srzn34{P;_PMmX!CJ42+Cy zKpA$B@r;Zd5Q-Bh2nhl%6}WlM`T0dDnR$sNsX?h}sYR)I$*IAW#U-h^px|KSW@KXK Kf`tbUkOKf)qgf{a literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_rgd3d b/tests/data/backward_io/v17/v17.og_rgd3d new file mode 100644 index 0000000000000000000000000000000000000000..3463c24c39375cc89a5ebd3765fe72eb440a084e GIT binary patch literal 45956 zcmeI5fuH5|yvBdO@19*ND`TvTBu7?8k};Bzz0!@uRrFL4O_Qu7+KP{_Smh* zAG>bTh6A>3+j{)ElecX+=-A`%U^PB}fIYs}o_^hl^-cJjhCIs_`x}Ps!YV#CVChMqXIzrTo;A7teRS@}U$evp+PWL0V{V&w-}`9W5Gkd+@~KxrKgh}tvhsth{2(ho$m+$5S@}U$evp+PWaS50`5{_0`WCTD zhG>-x(JC3DRWd}YWRO+=Vpe{Tl^-x z(JC2a6)*kx=CbmGto$G=Kgh}tvhsth;-#Nh`9W5Gkd+@~-xvg%*tW@z|9R(_C`A7teRS@|Ja>C*36>>DQz(JFaGv`U6(l?>4; z8DteN{rKj|H%=U6Bl$M-R=ij`9W5Gkd+@~-x(JC2a)xXHipl_V0D=YsBS@}U$evp+PqLnWF-o?Ig;t;KpS4691 zh*rrEt&%}j@zRfPo_yoPL00}1vhsth{2(ho$SPj?@y%uB2U+<+R(_C`A7teRS#|T1 zORW4LD?iA}53=%uto$IWc&K~{c{l^-xvWk~}eDnBwmH9zdevp+PWaS50`9W6k z(od}XAS*w}$`7*ggRJ}@t8RXBiIpE@y!7LnC*L@6kd=Rhto$G=Kgh}t zvWk~}d~;d(K~{c{l^&K~{c{l^=^pk|A0pL$peUXq61I>R;q$&^J!h zm6d;mto$G=Kgh}t(Mp&8s}}pli9@tXUJF>YTH%=U)Rq~2xl?>4;8KPA($SPj?@y(NOoH)qJzd}}i zkd+@~& zK~{c{l^3geWh*rrEt&$;HB}24I23hql zax>@~C+f<|zd}}ikd+@~<%eh$Fa1Vkk#8Ig(JFaGv`U6(l?>4;8DzyvUvI9v-4C+z zgRJ}@D?iA}53=H=pIZ4rR(_C`A7teRS@}U$-JMS^weo|k{2(ho$jT40@`J2+>8DnH zkd+@~=^pl0jDe zi`)$H8%Mgb@~@DUA7teRS@|Ja#Y;asaFK5u4bdujMYKwWXq61nDj8(OOJ8s9zi~9k z%D+NZevp+PWaS50@zU3u%gPV3@`J4WAS*w}$`7*Y<|mhYf_{*dA7teRS@}U$evlO} z{q*-x(JC3D zRWit`f03IZe&a}2R{j;T@`J4WAS*vat9a=*4qD_JM?u&dhto$G=Kgh}tvhsthc4;8KPA( zM5| zoBMAZ4YKmDkd+@~8DnHkd+@~-xvg%*tW{BT7(v_8eg{=G_D?iA}578=K`i(;t`Nq)@t&&$nt7M2)$q=oQ zK~}u<_2#ye z`~hKGHh2E4Fa9Asi~cRb-;2NSr+sC`U&S8@hPEGsC3Y^U^RU#;%dDSZz1;eV>OAaV z=Oz%BhVcnz7!!zx?v-PvAcd>r9IuE*reUrq09j?7YhQ`PREzzd)UbUOT_gdJpRtS?{UN!;9^_m-S1m`>bE8?mQDh z@k|KCGa(eugit)w=_R2b=PbO;dT;BOTkoUJ!z=7OVEsz#eXU=m&cl9oezo=f*7ip% zg^Hbv&cgwAKG6Cg>($l=tMhP(onLD`X#G0tL)CeBy`2xUeuMSl)^Akjp=#$hSs!8j zX6rTTJiNuuYpvgEJ!Jhhbsmni^V_YDvVMp4(ds-LW9ORnvDWLXk5hM^3899c388o< zgyNYHif1~#B&^3d3mdFATEEkJSe=LC?RrUYJHmZd#z7b=iz;JKEwL`)(z_qsPk~9oj+*3-TFh;XQ}h>VLOjn zf5iH1>yN7QaE_fnW__;p$F0ZIdH95#&$Ird_4(GHQg@ySp?D^Q;+YVNXF@2R>GYCt z0nS))!lUUY&=goxfmxiS-w)FIDH^OLo4@`pec6)?ZQQ z;c`2F)%ptSuUTKI&coO3JZb$6>#MB4sm{aIcK(+2HP+v@o>J%GJ9fU-`n%TGS$|KR zhwJV9ee0I>53Fxc=i!HTzR~(e);C%ISlxLhgyNYHif2M7o(Z9NrqfHpG|pN0iS^Ca zKefI^orj;<`Bv+nThCbkLY;@(?EFjX+pT|PeTO;^zqa$N^>3{2wEnF+4|m!5ch+}X z|K7T-&ch$%Un)X#H>MJj~nq->o0A z{txSi)p__&J3nImU)BrO|E=yk6GHJ!2*ooY6wicEJk#kV;ZdBk@ITg%S^ux~_=5<3^2hmxI_S}(JHg7tEB9-e6D9ju>Zy~6s*>OAad=cibASwGdf zTb+le*?Fb))2(;1eug>^J$8Pk_0HDMvff3VhiBV)SL^3km#v?x&ckkYexCIz>*rhV zuFk^??A&YpLhC)OU!?9l6GHJ!2*ooY6wicEJk#kVVNaa1@M7z|tY2c?r_RGm?c8tu zGV8sqU#`x>K6ZYE^?>y&t@l;u;Z=6t&-&HY`&-)|oEVDEgZ(*%;Q;&j1Fa9TUaii< z!FE2x`nA@B)~{3N;ZQrj-uf`>H&`F8&chq+T(y3a^%2%@R_9@jo!?@;*7~j1L+U)d z&CW+!zuo#M>vyO-&xBAs6GHJ!2*ooY6wh>eNjMtkEF5E9vp&{(ojMQ4*?GP72J4O1 z?^Neu*v`jWpJ4qi>rLuBoM`9G)?2LW*6&v5VXK`_vfgHWvh^wIJiN!wBi5%{pJx4D zbskQ)^ZTsNuztUFL!E~Y*!fKB4_a@x{*XEkXW99~)}z)Ru|8X!hmYF%9P5u+pKJYb zb?2E7if2M7o(Z9NCWPXdPA>^#IA`G#*5_G&()xUL9zJE~3#>nFJ#PIObsjFX^JlFu zvi_X)#p*nK-p)I4_~qK<O5R&=dW8& zT7Sd(Ds>*dY3Hl0zh!-m^|#e|n6mSCtgp5HuJv{5Jbcg2*IR$zx@G+Xb?2E7if2M7 zo(Z9NCWPXdPA>^J;GBgYTHk2>BkP;gdHAuNr>%cteY5pX)p@wZ&Ofuh)%xewGwMA2 z!p^r@|I+$)>tCt!aEG0LZ9QxK8|ypOdHAiJ@3Q`#_1)ILSLdN^=Ra8AWBo_#d)0aP zlb!Fg{xZoWL*02MgyNYHif2M7o(Z9N zrqfHp!#HQ*Kdm3J{x9nVbsqlP&W~FEkM(2L|Etc!<97bLbry=hXKro(%{=}H-{QMq ziTzB;da3m?>nEu5u-wj1wBEt`N!BaWd3ds&ceH+rb(i&1)p_W)^V6(XT0h--Cv_g4 zVdoy}XIk%U{Va7JcCqubt#`G4j_&l3mxAQ*M zudp7lex*7O``YZGoe#Bs zz4c+%Z&2sqa67-zx@!F<>m$^8c(a|?Sii-3t@T^goo7NQo(Z9NCWPXd5Q=9yy(A3b zoQ1bpA8Gw|>!Z|pc!!;jwm!zXW__$W59{oFob`I^4b~ggd3dLthpmsdKEe83>O5?+ z^NH4*t+!a$)p>Zgowr(_WWCM$WOW`+vGaSZN32h^K24p6_uBb%>-SloVf}t}9vXK3 zfc2TyAGF@C&clc7e3tcxtw*gtqV7BsLh(!p#WNuk&xBAs)9EGQY@D<3QR{Q8KW2Td zIu9SW^O*G~tk1Llq&g4h+xb)07g&GVdR(1{&)E4w>(5$WWc@jH9xk@?=dGL8U$DMJ zorf>l`BLjISzl)TWpy4V?EDq$%dNj^eT6y?U$gU-)?c@twEl)V4_Ddwo7Pubf6MwB zbsoNL=PB#&SYK=XU3KS~5Q=9)D4q$ScqWA6nNBYW*WsLn?^$1O{eA0}IuAdv^9|NN zw7${$N9sJ>Wal4SPh0=Q`et<=ero4itbb;GtM$*-d6=>DFRX8~{-yQp>OB0)&UaY< z+IrUdH|jjxY3JWs-(~$f>$}x?_`RLm)_<_R$NG=zJlt#NKUv>r{b%brbsqj==liYy zYW;xq-_)IFLMWaIp?D^Q;+YVNXFA>aEK2rSltS@YltS@YltS@Ybb6_M7Nt;p7Nt;p z7Nt;p7Nt;p7M)&dpG7GYpG7GYpG7GYpG7GYpGBva+GkM;#b;3p#b;3p#b;3p#b?p! zrS@5rLh)IYLh)IYLh)IYLh)I2dZ~RDrBHkprBHkprBHkprBHkponC66MJW`YMJW`Y zMJW`YMJW`YMW>hAXHg2pXHg2pXHg2pXHg2pXVK}U_F0rd@mZ8Y@mZ8Y@mZ8Y@mX|w zseKkD`+Y9i?{mq1pG)@p-099U%j}tD_RKPSW|=+H=_hop-*WQ0O&g9mcH6eC$FDni z+lFP&Nd9*toku$V8<9MD0sd`ee{C=G5K-wIy2u`~Os*n($vw$FvY*_W+=m<>_a*lu z_a`gl0px+?LF8)kVDb?1wd5fAI`UBR_2gmX8_2`SHKT!>@EB;nXToI$?UECF_{hV$7J?4{+P^;+K7ThE}0;4tdKRbK{m-2*(S47_&XgPBO7FsY>{m;JDsm5D`bsqkWI2hw#n>$d_7qqYh;6L zk}a}LW@qsAWQDAe4YEnL$Tpe1pRXq?WQ}Z)O|nI{$*j?NeHU3K`^XAeC2M4zY>;DQ zlbj@55{Yh;~lkYi+%oFrT14A~~<$!t5{pDdGo zWQDAfHL^}N$T6}>PLeHhhHR7bWcDGxKUpUG$O>5{Yh;~lkYi+%oFrT14A~~<$?Pn? zKUpUG$O>5{Yh;~lkYi+%oFrT14A~~<$?U^?f3i&WkrlE^*2p^9AjiliIZ3w28L~~z zli4WWpDdGoWQDAfHL^}N$T6}>PLeHhhHR7bWcCrhKUpUG$O>5{Yh;~lkYi+%oFrT1 z4A~~<$?R;tKUpUG$O>5{Yh;~lkYi+%oFrT14A~~<$?T(if3i&WkrlE^*2p^9Ajili zIZ3w28L~~zli4|Zf3i&WkrlE^*2p^9AjiliIZ3w28L~~zliA1k{$!c#BP(Q;tdVuH zL5`74a*}M3Gh~~bC$n?;{$!c#BP(Q;tdVuHL5`74a*}M3Gh~~bC$o?9{mC-fM^?xx zStILYgB&B9?Qli0kT34l2vkutdYZHog5(>1ifob7;)2k`v@4IYqX}X>x{~CEMg2IZrN-+4=nSlU-yFStfhQK5~Gp zkb`8E93pGvFj*%@$Obt|j*;VJlbj$Y$tki$PLng_EZHXK$a!*s%s$0mKiNh0kY%!$ z>>~%r3OPtt$sw{v4wH3qglv$b(oJN)C}Va+s`>BV>adCCA8dvPn*mljIcHBB#k2a+Yk9bL2d^KxUuj zub=E9d&n}`OZJfiWQ80gtK<+_BZtX4IYKtbQF4qNC!6F1IY~~DEpnQiA!o@pIY-Wu z3uHFVUq9JJ_K;<=m+T`4$O<_~R>>ifUJ;%WR)BuYveFlCr8KzIZBR^<7AVZAScNwvPDjl zGvqAUCg;d`a)Hb)TgB&Ht$Z@hs zPLPx26xkxD$r*B%Y?E{3Jh?z-7xC9mc9A_~nd~L|$N{oK4w6-Jh^&#rWStx#8{{ZC zMvjwBa)O*Br^psLP0o!`y7A$WEa^(mdReSj~pN?^ZQ zl0#&T9471J2-zS<$uV-AY?2e?BsoR4$Z2whoF&`j963)ekXf_y>o1YZ$rWT5xsvQ5 zcOlECH->KOuw+ ze|_xhhYmHsgV&t6G0XGid7eKp$B*-ThYp^U=gaC_j^DiPq!p_Ui2vlpL0h(LU4Q)M zW4CQMV#CG_TQ_VzZo`{TJ!#v96JNF(e}gCE|IB0sUzG1y3i(s=2k~b4lks=?|9^U; zYi06JZ(!#?y77;X!Y4cP!J-T260!_gj_iP}Kz2mBkZxopvJ=vS?2PP!?243;-H=tt z?np1P2eK!!7t)9HBYPwJAOpz0$bQKFNCi0%S&bZm3?hdjhara}Rpba{4YC#)LXJd^ zLXJji$U0;_vJn|ZPCzyxn~^%Q71@TIf{Y-iA*Ul}APwY9WIJ*eGK!pyoP(T;j3MVC z=OY&&$S%mPNEz7;S%vJ5^dfs8dm?)weMmpD zH?j{hfb5IxhwP73kOPs`$RWreawu{bayU{&jzHERYmp)3NaQHwXrzX$L)If3kzwQn zWD~L(sUusFZOAFe2yz;7I&ucmK+Z(ABWEF_$l1s_$hpWEavpL%ase`qT!>tRT#Pi4 zOOQ*E%a94=a^wo+N@Nnb3b`7&2AM*xMXp1xM_R}Y$c@NN$TV^@atm@RGK1WP+>YFV z%p!LpcOiEpZR8&0UgSPx4!IwB0C^CZM;<~RMjk;HkVlcnkjIhY-~7d;RYH~_%aI+B z708ZA7t)QaM0P@Yke!iTkX?~7vKz7r*&XRc_CWST_CorQeq?WCA7lX87ugTlAE_V* zBCC-@kU`{73DYtU=ZyL&%ZHQOMCq4Oxe*M>ZnE$O*_MWHVAnwj$e*Q;-ql zG~{&T45WdaiEKyCLPn9Zk#mr9kul^v(mm-%T6UgPr708vy zBytsUHF6CygWM5=IWPhZB9Ehw&4nYQyLy^Of!;va- z1hNKMiwq%0B1a)dBQ<0lvL4xp3?nBXn~=>&9odR(Lry_PkkgRUku#76awf7JISUy@ z&PL8b&PB$M^N{nA3y^W-LgXUkVx);&f?SGRhD;!rBUd0-B9q8f$koU-$P{udavgF# z(n4-PZbWWErjeVGTaa6k8RRzPcH|CZ7P%9-3%MIMqJdR`~eEvuYS%xe}c0g7jJ0e|3H?k7h3F$$0Ms`7VMasx-$SP!aq!-x( z*%R3d=|lRFy^(#80c2lfKV*NTf*gpfMh-y+kwcNgki(HGas;vlS&IxIMvMKyE~CLZ*?Mkz0^k zks0JRGJIWGAEt*%{dd*%c`xyCJKP-H~2o4`fedFQgCYNA^bcK?ab0 zk^PYUkqUAkvKl!A8AJ|64nqz{s>l(@8e}apgdB++g&d94kafsxkLZ} literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_tsf3d b/tests/data/backward_io/v17/v17.og_tsf3d new file mode 100644 index 0000000000000000000000000000000000000000..1f449537127fe3db500aefee487e2c390cf743c6 GIT binary patch literal 1156 zcma)6y>8S%5Z+mz&m@8T9Cry&L=l353Muyhb_5MoqC`q-ZS1{Zbg@r+8Na^tY0w+U>(qppg zT&>k9E@r9W8M--GUZ8}?Ed-4~qhlirj?f-eMQO+3y#^w;(0|Sp><1XxBq5x}W@+=U2@^8>dD zmTn0q)BRU6>%12?;v5tSVp0}96Z~$<2(!D&%FUz9-BznjZ~9Dg8<^NTB0=O?P~V(K qba6Znu2LdC8S+OXTnqI6_%k5@OtS6Wa24NP7ho9#tVkIyE?ff97(U7X literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_tso3d b/tests/data/backward_io/v17/v17.og_tso3d new file mode 100644 index 0000000000000000000000000000000000000000..c38671e6c6d038f1f41f49710ce5b554804c3154 GIT binary patch literal 1872 zcmb7F&2G~`5caIov`tG}Nl}kBQAmtjl$yOMpcC^`|M&ia(01}UZ z#3LYqIPd@*c>#pP3HBTB7&kuxHuBES?|$=RM^UJVNV#7%2!gOW%#zfO!e%EnNqjQU z2iBV8dVK+ME^`o78Zbm-TruUGL-`oE3pY7aZ&wDnb<}e$KpX$EJ(r#?B^R(Z6u8q|f zmAx4Wi)n{VeCBgQs9#uBR3`{{C*HYULC7R8UbrPN;>#!&?oFXMjC&66v4c{$28=dy_lkv#vGt2|6k_uO3Ag)vttx<>)G_1BJmTLE(#XaptYkhYr$Jm&7 z+)dKHzUbQS1E14ucP?^i3jw>t^AUB&!I4Wk*w)La(EOyQM;reNYNq$(^~gTJUBCgR ze6DyN6uJfXR2HrhZ6a^FMypPs)=piuEDtB})&GX?zAxH@p9{qcF&PCYPo<+}WIzbM zj2H;P3sOPOh@Bi%GFa@nm&t0=nEr71zIuRShznP-$s;#|;(=VK*tkh^Qs7vG1;hX# zz%JPr>B6eWjROd14ghC-`j|m@XbDo}R|A6xV3xtig-gOfv*Mmc{W{SWde|hmDM@wv ze`->j%o&%@l1+4a=kC;Nb(9X0RQEf&XERg0UadKkQsXyC3VViydXiaqMZ z0iZ4zXqgcykBmern4;JemJPYb1u7VEpBRALi&#|Hu!<#a;{kvKw(f7v?Ghcaaxakp g3%9nIJ81scK%aLUHws`3#P$x+4GQR{QsKt>Z$NRBTL1t6 literal 0 HcmV?d00001 diff --git a/tests/mesh/test-edged-curve.cpp b/tests/mesh/test-edged-curve.cpp index 6e92f86f6..cefabcbdc 100644 --- a/tests/mesh/test-edged-curve.cpp +++ b/tests/mesh/test-edged-curve.cpp @@ -346,9 +346,12 @@ void test() test_io( *edged_curve, absl::StrCat( "test.", edged_curve->native_extension() ) ); - test_backward_io( absl::StrCat( - geode::DATA_PATH, "test_v12.", edged_curve->native_extension() ) ); - + DEBUG( "v12" ); + test_backward_io( absl::StrCat( geode::DATA_PATH, + "backward_io/v12/test_v12.", edged_curve->native_extension() ) ); + DEBUG( "v17" ); + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", + edged_curve->native_extension() ) ); test_permutation( *edged_curve, *builder ); test_delete_edge( *edged_curve, *builder ); test_clone( *edged_curve ); diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index 9ac6b883f..a2e96e21e 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -41,8 +41,11 @@ void test_create_vertices( const geode::PointSet3D& point_set, geode::PointSetBuilder3D& builder ) { + DEBUG( "first point" ); builder.create_point( geode::Point3D{ { 0.1, 0.2, 0.3 } } ); + DEBUG( "second point" ); builder.create_point( geode::Point3D{ { 2.1, 9.4, 6.7 } } ); + DEBUG( point_set.nb_vertices() ); geode::OpenGeodeMeshException::test( point_set.nb_vertices() == 2, "PointSet should have 2 vertices" ); builder.create_vertices( 2 ); @@ -110,11 +113,13 @@ void test_delete_vertex( void test_io( const geode::PointSet3D& point_set, std::string_view filename ) { + DEBUG( "test_io" ); geode::save_point_set( point_set, filename ); const auto reload = geode::load_point_set< 3 >( filename ); geode_unused( reload ); const auto point_set2 = geode::load_point_set< 3 >( geode::OpenGeodePointSet3D::impl_name_static(), filename ); + DEBUG( point_set.nb_vertices() ); for( const auto vertex_id : geode::Range{ point_set.nb_vertices() } ) { geode::OpenGeodeMeshException::test( @@ -124,6 +129,20 @@ void test_io( const geode::PointSet3D& point_set, std::string_view filename ) } } +void test_backward_io( + std::string_view filename, const geode::uuid& attribute_id ) +{ + const auto point_set = geode::load_point_set< 3 >( filename ); + SDEBUG( point_set->point( 0 ) ); + SDEBUG( point_set->point( 1 ) ); + SDEBUG( point_set->point( 2 ) ); + geode::OpenGeodeMeshException::test( + point_set->nb_vertices() == 4, "PointSet should have 4 vertices" ); + const geode::Point3D answer{ { 2.1, 9.4, 6.7 } }; + geode::OpenGeodeMeshException::test( point_set->point( 2 ) == answer, + "PointSet2 vertex coordinates are not correct" ); +} + void test_clone( const geode::PointSet3D& point_set, const geode::uuid& attribute_id ) { @@ -145,18 +164,26 @@ void test_clone( void test() { geode::OpenGeodeMeshLibrary::initialize(); + DEBUG( "test_point_set" ); auto point_set = geode::PointSet3D::create( geode::OpenGeodePointSet3D::impl_name_static() ); + DEBUG( "builder" ); auto builder = geode::PointSetBuilder3D::create( *point_set ); + DEBUG( "test_create_vertices" ); test_create_vertices( *point_set, *builder ); + DEBUG( "bounding_box" ); test_bounding_box( *point_set ); + DEBUG( "test_create_vertex_attribute" ); const auto vertex_attribute_id = test_create_vertex_attribute( *point_set ); test_io( *point_set, absl::StrCat( "test.", point_set->native_extension() ) ); - - test_permutation( *point_set, *builder ); - test_delete_vertex( *point_set, *builder ); - test_clone( *point_set, vertex_attribute_id ); + DEBUG( "test_backward_io" ); + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", + point_set->native_extension() ), + vertex_attribute_id ); + // test_permutation( *point_set, *builder ); + // test_delete_vertex( *point_set, *builder ); + // test_clone( *point_set, vertex_attribute_id ); } OPENGEODE_TEST( "point-set" ) \ No newline at end of file From 6ec0e962c6f00f05c287932e664c44061a5d5776 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Wed, 17 Jun 2026 17:42:48 +0200 Subject: [PATCH 07/19] wip --- include/geode/basic/bitsery_archive.hpp | 15 +++- include/geode/basic/growable.hpp | 1 + include/geode/basic/uuid.hpp | 2 + .../attribute_coordinate_reference_system.hpp | 2 +- .../geode/mesh/core/detail/facet_storage.hpp | 4 +- .../mesh/core/geode/geode_edged_curve.hpp | 6 +- include/geode/mesh/core/geode/geode_graph.hpp | 2 + .../mesh/core/geode/geode_hybrid_solid.hpp | 6 +- .../geode/mesh/core/geode/geode_point_set.hpp | 2 + .../core/geode/geode_polygonal_surface.hpp | 6 +- .../core/geode/geode_polyhedral_solid.hpp | 6 +- .../core/geode/geode_regular_grid_solid.hpp | 2 + .../core/geode/geode_regular_grid_surface.hpp | 2 + .../core/geode/geode_tetrahedral_solid.hpp | 6 +- .../core/geode/geode_triangulated_surface.hpp | 6 +- .../mesh/core/geode/geode_vertex_set.hpp | 4 + include/geode/mesh/core/hybrid_solid.hpp | 4 + .../geode/mesh/core/internal/edges_impl.hpp | 1 - .../mesh/core/internal/facet_edges_impl.hpp | 4 + .../geode/mesh/core/internal/points_impl.hpp | 47 +++++----- .../geode/mesh/core/internal/texture_impl.hpp | 29 +++---- include/geode/mesh/core/polygonal_surface.hpp | 2 + include/geode/mesh/core/polyhedral_solid.hpp | 4 + .../geode/mesh/core/regular_grid_solid.hpp | 4 + .../geode/mesh/core/regular_grid_surface.hpp | 4 + include/geode/mesh/core/solid_mesh.hpp | 3 + include/geode/mesh/core/surface_edges.hpp | 1 + include/geode/mesh/core/surface_mesh.hpp | 3 + include/geode/mesh/core/tetrahedral_solid.hpp | 4 + .../geode/mesh/core/triangulated_surface.hpp | 4 + .../helpers/detail/bitsery_mesh_helper.hpp | 28 +++++- .../io/geode/geode_bitsery_mesh_input.hpp | 6 +- .../mesh/io/geode/geode_edged_curve_input.hpp | 56 ++++++++++++ .../attribute_coordinate_reference_system.cpp | 9 +- .../mesh/core/geode/geode_edged_curve.cpp | 68 +++++++++++---- src/geode/mesh/core/geode/geode_graph.cpp | 4 + .../mesh/core/geode/geode_hybrid_solid.cpp | 62 ++++++++++--- src/geode/mesh/core/geode/geode_point_set.cpp | 22 ++++- .../core/geode/geode_polygonal_surface.cpp | 86 ++++++++++++++----- .../core/geode/geode_polyhedral_solid.cpp | 70 +++++++++++---- .../core/geode/geode_regular_grid_solid.cpp | 63 +++++++++++--- .../core/geode/geode_regular_grid_surface.cpp | 66 +++++++++++--- .../core/geode/geode_tetrahedral_solid.cpp | 38 ++++---- .../core/geode/geode_triangulated_surface.cpp | 73 ++++++++++++---- src/geode/mesh/core/hybrid_solid.cpp | 6 ++ src/geode/mesh/core/polygonal_surface.cpp | 6 ++ src/geode/mesh/core/polyhedral_solid.cpp | 6 ++ src/geode/mesh/core/regular_grid_solid.cpp | 4 + src/geode/mesh/core/regular_grid_surface.cpp | 5 ++ src/geode/mesh/core/solid_edges.cpp | 5 +- src/geode/mesh/core/solid_facets.cpp | 8 +- src/geode/mesh/core/solid_mesh.cpp | 9 +- src/geode/mesh/core/surface_edges.cpp | 5 +- src/geode/mesh/core/surface_mesh.cpp | 13 ++- src/geode/mesh/core/tetrahedral_solid.cpp | 6 ++ src/geode/mesh/core/triangulated_surface.cpp | 7 ++ .../mesh/test-coordinate-reference-system.cpp | 2 +- tests/mesh/test-edged-curve.cpp | 5 ++ tests/mesh/test-hybrid-solid.cpp | 27 +++++- tests/mesh/test-point-set.cpp | 9 +- tests/mesh/test-polygonal-surface.cpp | 9 +- tests/mesh/test-polyhedral-solid.cpp | 11 +-- tests/mesh/test-tetrahedral-solid.cpp | 18 +++- tests/mesh/test-triangulated-surface.cpp | 23 ++++- 64 files changed, 784 insertions(+), 237 deletions(-) diff --git a/include/geode/basic/bitsery_archive.hpp b/include/geode/basic/bitsery_archive.hpp index 599d5ca46..9c604ca81 100644 --- a/include/geode/basic/bitsery_archive.hpp +++ b/include/geode/basic/bitsery_archive.hpp @@ -48,6 +48,11 @@ namespace geode using Deserializer = bitsery::Deserializer< bitsery::InputStreamAdapter, TContext >; + enum struct BITSERY + { + constructor + }; + /*! * Register all the information needed by Bitsery to serialize the objects * in the basic library. @@ -87,8 +92,10 @@ namespace geode template < template < typename > class Attribute, typename T > void import_old_attribute( AttributeManager &manager, std::string_view old_attribute_name, - geode::uuid new_attribute_id ) + geode::uuid new_attribute_id, + index_t attribute_size ) { + DEBUG( "import_old_attribute" ); const auto ids = manager.attribute_ids_with_name( old_attribute_name ).value(); DEBUG( ids.size() ); @@ -106,14 +113,14 @@ namespace geode manager.read_attribute< T >( old_attribute_id ); auto new_attribute = manager.find_attribute< Attribute, T >( new_attribute_id ); - manager.resize( old_attribute->nb_items() ); - for( const auto index : geode::Range{ old_attribute->nb_items() } ) + manager.resize( attribute_size ); + for( const auto index : geode::Range{ attribute_size } ) { - SDEBUG( old_attribute->value( index ) ); new_attribute->set_value( index, old_attribute->value( index ) ); } manager.delete_attribute( old_attribute_id ); + DEBUG( "import_old_attribute done" ); } } // namespace detail } // namespace geode diff --git a/include/geode/basic/growable.hpp b/include/geode/basic/growable.hpp index 8a9ebb472..d6c44064a 100644 --- a/include/geode/basic/growable.hpp +++ b/include/geode/basic/growable.hpp @@ -28,6 +28,7 @@ #include #include +#include #include namespace geode diff --git a/include/geode/basic/uuid.hpp b/include/geode/basic/uuid.hpp index 4b0962455..cb5d4fc30 100644 --- a/include/geode/basic/uuid.hpp +++ b/include/geode/basic/uuid.hpp @@ -68,6 +68,7 @@ namespace geode { serializer.ext( *this, Growable< Archive, uuid >{ { []( Archive &archive, uuid &id ) { + DEBUG( "uuid::serialize" ); uint64_t ab; uint64_t cd; archive.value8b( ab ); @@ -88,6 +89,7 @@ namespace geode id.bytes_[13] = ( cd >> 16 ) & 0xFF; id.bytes_[14] = ( cd >> 8 ) & 0xFF; id.bytes_[15] = ( cd >> 0 ) & 0xFF; + DEBUG( "uuid::serialize end" ); }, []( Archive &archive, uuid &id ) { archive.container1b( id.bytes_ ); diff --git a/include/geode/mesh/core/attribute_coordinate_reference_system.hpp b/include/geode/mesh/core/attribute_coordinate_reference_system.hpp index ad1374547..589149287 100644 --- a/include/geode/mesh/core/attribute_coordinate_reference_system.hpp +++ b/include/geode/mesh/core/attribute_coordinate_reference_system.hpp @@ -43,7 +43,7 @@ namespace geode public: explicit AttributeCoordinateReferenceSystem( - AttributeManager& manager ); + AttributeManager& manager, const geode::uuid& uuid ); AttributeCoordinateReferenceSystem( AttributeManager& manager, std::string_view attribute_name ); ~AttributeCoordinateReferenceSystem(); diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index 646ee6b84..72ded3129 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -57,6 +57,8 @@ namespace geode } protected: + FacetStorage( BITSERY ) {} + FacetStorage() { const auto counter_attribute_id = @@ -70,7 +72,7 @@ namespace geode const auto vertices_attribute_id = facet_attribute_manager_ .create_attribute< VariableAttribute, VertexContainer >( - "vertices", VertexContainer{}, + "facet_vertices", VertexContainer{}, { false, false, false } ); SDEBUG( vertices_attribute_id ); vertices_ = diff --git a/include/geode/mesh/core/geode/geode_edged_curve.hpp b/include/geode/mesh/core/geode/geode_edged_curve.hpp index 847036685..4514eec26 100644 --- a/include/geode/mesh/core/geode/geode_edged_curve.hpp +++ b/include/geode/mesh/core/geode/geode_edged_curve.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -49,6 +50,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodeEdgedCurve(); + OpenGeodeEdgedCurve( BITSERY ); OpenGeodeEdgedCurve( OpenGeodeEdgedCurve&& other ) noexcept; OpenGeodeEdgedCurve& operator=( OpenGeodeEdgedCurve&& other ) noexcept; ~OpenGeodeEdgedCurve(); @@ -82,10 +84,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGEdgedCurveKey /*key*/ ); - void set_edge_vertex( const EdgeVertex& edge_vertex, index_t vertex_id, OGEdgedCurveKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_graph.hpp b/include/geode/mesh/core/geode/geode_graph.hpp index 76d9f4325..406ae3b97 100644 --- a/include/geode/mesh/core/geode/geode_graph.hpp +++ b/include/geode/mesh/core/geode/geode_graph.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -44,6 +45,7 @@ namespace geode using Builder = OpenGeodeGraphBuilder; OpenGeodeGraph(); + OpenGeodeGraph( BITSERY ); OpenGeodeGraph( OpenGeodeGraph&& other ) noexcept; OpenGeodeGraph& operator=( OpenGeodeGraph&& other ) noexcept; ~OpenGeodeGraph(); diff --git a/include/geode/mesh/core/geode/geode_hybrid_solid.hpp b/include/geode/mesh/core/geode/geode_hybrid_solid.hpp index 203d45ffc..4e1997eae 100644 --- a/include/geode/mesh/core/geode/geode_hybrid_solid.hpp +++ b/include/geode/mesh/core/geode/geode_hybrid_solid.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -51,6 +52,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodeHybridSolid(); + OpenGeodeHybridSolid( BITSERY ); OpenGeodeHybridSolid( OpenGeodeHybridSolid&& other ) noexcept; OpenGeodeHybridSolid& operator=( OpenGeodeHybridSolid&& other ) noexcept; @@ -85,10 +87,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGHybridSolidKey /*key*/ ); - void set_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex, index_t vertex_id, OGHybridSolidKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_point_set.hpp b/include/geode/mesh/core/geode/geode_point_set.hpp index d14d203a7..9ef33a5a9 100644 --- a/include/geode/mesh/core/geode/geode_point_set.hpp +++ b/include/geode/mesh/core/geode/geode_point_set.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -50,6 +51,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodePointSet(); + OpenGeodePointSet( BITSERY ); OpenGeodePointSet( OpenGeodePointSet&& other ) noexcept; OpenGeodePointSet& operator=( OpenGeodePointSet&& other ) noexcept; ~OpenGeodePointSet(); diff --git a/include/geode/mesh/core/geode/geode_polygonal_surface.hpp b/include/geode/mesh/core/geode/geode_polygonal_surface.hpp index 7b1b570c1..1ca923754 100644 --- a/include/geode/mesh/core/geode/geode_polygonal_surface.hpp +++ b/include/geode/mesh/core/geode/geode_polygonal_surface.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -49,6 +50,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodePolygonalSurface(); + OpenGeodePolygonalSurface( BITSERY ); OpenGeodePolygonalSurface( OpenGeodePolygonalSurface&& other ) noexcept; OpenGeodePolygonalSurface& operator=( OpenGeodePolygonalSurface&& other ) noexcept; @@ -83,10 +85,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGPolygonalSurfaceKey /*key*/ ); - void set_polygon_vertex( const PolygonVertex& polygon_vertex, index_t vertex_id, OGPolygonalSurfaceKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_polyhedral_solid.hpp b/include/geode/mesh/core/geode/geode_polyhedral_solid.hpp index 2c0a92f19..bae5f00c9 100644 --- a/include/geode/mesh/core/geode/geode_polyhedral_solid.hpp +++ b/include/geode/mesh/core/geode/geode_polyhedral_solid.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -49,6 +50,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodePolyhedralSolid(); + OpenGeodePolyhedralSolid( BITSERY ); OpenGeodePolyhedralSolid( OpenGeodePolyhedralSolid&& other ) noexcept; OpenGeodePolyhedralSolid& operator=( OpenGeodePolyhedralSolid&& other ) noexcept; @@ -83,10 +85,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGPolyhedralSolidKey /*key*/ ); - void add_polyhedron( absl::Span< const index_t > vertices, absl::Span< const std::vector< local_index_t > > facets, OGPolyhedralSolidKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_regular_grid_solid.hpp b/include/geode/mesh/core/geode/geode_regular_grid_solid.hpp index 4fb139caa..c9dd2dd5c 100644 --- a/include/geode/mesh/core/geode/geode_regular_grid_solid.hpp +++ b/include/geode/mesh/core/geode/geode_regular_grid_solid.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -52,6 +53,7 @@ namespace geode static constexpr index_t dim{ 3 }; OpenGeodeRegularGrid(); + OpenGeodeRegularGrid( BITSERY ); OpenGeodeRegularGrid( OpenGeodeRegularGrid&& other ) noexcept; OpenGeodeRegularGrid& operator=( OpenGeodeRegularGrid&& other ) noexcept; diff --git a/include/geode/mesh/core/geode/geode_regular_grid_surface.hpp b/include/geode/mesh/core/geode/geode_regular_grid_surface.hpp index a19e7d219..467f5bd3a 100644 --- a/include/geode/mesh/core/geode/geode_regular_grid_surface.hpp +++ b/include/geode/mesh/core/geode/geode_regular_grid_surface.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -52,6 +53,7 @@ namespace geode static constexpr index_t dim{ 2 }; OpenGeodeRegularGrid(); + OpenGeodeRegularGrid( BITSERY ); OpenGeodeRegularGrid( OpenGeodeRegularGrid&& other ) noexcept; OpenGeodeRegularGrid& operator=( OpenGeodeRegularGrid&& other ) noexcept; diff --git a/include/geode/mesh/core/geode/geode_tetrahedral_solid.hpp b/include/geode/mesh/core/geode/geode_tetrahedral_solid.hpp index af8687649..f59af0f21 100644 --- a/include/geode/mesh/core/geode/geode_tetrahedral_solid.hpp +++ b/include/geode/mesh/core/geode/geode_tetrahedral_solid.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -51,6 +52,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodeTetrahedralSolid(); + OpenGeodeTetrahedralSolid( BITSERY ); OpenGeodeTetrahedralSolid( OpenGeodeTetrahedralSolid&& other ) noexcept; OpenGeodeTetrahedralSolid& operator=( OpenGeodeTetrahedralSolid&& other ) noexcept; @@ -85,10 +87,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGTetrahedralSolidKey /*key*/ ); - void set_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex, index_t vertex_id, OGTetrahedralSolidKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_triangulated_surface.hpp b/include/geode/mesh/core/geode/geode_triangulated_surface.hpp index 9ce4844ca..97dc1b625 100644 --- a/include/geode/mesh/core/geode/geode_triangulated_surface.hpp +++ b/include/geode/mesh/core/geode/geode_triangulated_surface.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -51,6 +52,7 @@ namespace geode static constexpr auto dim = dimension; OpenGeodeTriangulatedSurface(); + OpenGeodeTriangulatedSurface( BITSERY bitsery ); OpenGeodeTriangulatedSurface( OpenGeodeTriangulatedSurface&& other ) noexcept; OpenGeodeTriangulatedSurface& operator=( @@ -86,10 +88,6 @@ namespace geode } public: - void set_vertex( index_t vertex_id, - Point< dimension > point, - OGTriangulatedSurfaceKey /*key*/ ); - void set_polygon_vertex( const PolygonVertex& polygon_vertex, index_t vertex_id, OGTriangulatedSurfaceKey /*key*/ ); diff --git a/include/geode/mesh/core/geode/geode_vertex_set.hpp b/include/geode/mesh/core/geode/geode_vertex_set.hpp index 067015c4b..f1eeb19c1 100644 --- a/include/geode/mesh/core/geode/geode_vertex_set.hpp +++ b/include/geode/mesh/core/geode/geode_vertex_set.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -42,6 +43,9 @@ namespace geode public: using Builder = OpenGeodeVertexSetBuilder; + OpenGeodeVertexSet() = default; + OpenGeodeVertexSet( BITSERY ) {}; + [[nodiscard]] static MeshImpl impl_name_static() { return MeshImpl{ "OpenGeodeVertexSet" }; diff --git a/include/geode/mesh/core/hybrid_solid.hpp b/include/geode/mesh/core/hybrid_solid.hpp index 52ab85443..9afcf86f1 100644 --- a/include/geode/mesh/core/hybrid_solid.hpp +++ b/include/geode/mesh/core/hybrid_solid.hpp @@ -26,6 +26,8 @@ #include #include +#include + namespace geode { FORWARD_DECLARATION_DIMENSION_CLASS( HybridSolidBuilder ); @@ -51,6 +53,8 @@ namespace geode pyramid }; + HybridSolid( BITSERY ); + /*! * Create a new HybridSolid using default data structure. */ diff --git a/include/geode/mesh/core/internal/edges_impl.hpp b/include/geode/mesh/core/internal/edges_impl.hpp index 993d12257..e90e90c2d 100644 --- a/include/geode/mesh/core/internal/edges_impl.hpp +++ b/include/geode/mesh/core/internal/edges_impl.hpp @@ -105,6 +105,5 @@ namespace geode std::shared_ptr< VariableAttribute< std::array< index_t, 2 > > > edges_; }; - } // namespace internal } // namespace geode diff --git a/include/geode/mesh/core/internal/facet_edges_impl.hpp b/include/geode/mesh/core/internal/facet_edges_impl.hpp index 9a257a1b1..6749d1cdd 100644 --- a/include/geode/mesh/core/internal/facet_edges_impl.hpp +++ b/include/geode/mesh/core/internal/facet_edges_impl.hpp @@ -44,6 +44,10 @@ namespace geode public: FacetEdgesImpl() = default; + FacetEdgesImpl( BITSERY bitsery ) + : detail::FacetStorage< std::array< index_t, 2 > >( bitsery ) + { + } [[nodiscard]] std::optional< index_t > find_edge( const std::array< index_t, 2 >& edge_vertices ) const diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index a42e1b0e8..da2bd982a 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -54,6 +54,26 @@ namespace geode PointsImpl() = default; + PointsImpl( + AttributeManager& manager, std::string_view attribute_name ) + { + DEBUG( "PointsImpl" ); + const auto attribute_id = + manager.template create_attribute< VariableAttribute, + Point< dimension > >( attribute_name, + Point< dimension >{}, { false, false, false } ); + points_ = manager.template find_attribute< VariableAttribute, + Point< dimension > >( attribute_id ); + } + + PointsImpl( + AttributeManager& manager, const geode::uuid& attribute_id ) + { + DEBUG( "PointsImpl" ); + points_ = manager.template find_attribute< VariableAttribute, + Point< dimension > >( attribute_id ); + } + [[nodiscard]] const Point< dimension >& get_point( index_t vertex_id ) const { @@ -134,36 +154,11 @@ namespace geode std::shared_ptr< CoordinateReferenceSystem< dimension > >{ std::make_shared< AttributeCoordinateReferenceSystem< dimension > >( - mesh.vertex_attribute_manager() ) } ); + mesh.vertex_attribute_manager(), "points" ) } ); crs_manager_builder.set_active_coordinate_reference_system( POINTS_NAME ); } - protected: - template < typename Mesh > - explicit PointsImpl( Mesh& mesh ) - : PointsImpl( mesh.vertex_attribute_manager() ) - { - register_as_active_crs( mesh ); - } - - explicit PointsImpl( AttributeManager& manager ) - : PointsImpl{ manager, POINTS_NAME } - { - } - - PointsImpl( - AttributeManager& manager, std::string_view attribute_name ) - { - DEBUG( "PointsImpl" ); - const auto attribute_id = - manager.template create_attribute< VariableAttribute, - Point< dimension > >( attribute_name, - Point< dimension >{}, { false, false, false } ); - points_ = manager.template find_attribute< VariableAttribute, - Point< dimension > >( attribute_id ); - } - private: std::shared_ptr< VariableAttribute< Point< dimension > > > points_; }; diff --git a/include/geode/mesh/core/internal/texture_impl.hpp b/include/geode/mesh/core/internal/texture_impl.hpp index 321d3f74a..6e58459cb 100644 --- a/include/geode/mesh/core/internal/texture_impl.hpp +++ b/include/geode/mesh/core/internal/texture_impl.hpp @@ -52,9 +52,9 @@ namespace geode return image_; } - [[nodiscard]] geode::uuid texture_id() const + [[nodiscard]] const geode::uuid& texture_id() const { - return texture_id_; + return coordinates_->id(); } void set_image( RasterImage< dimension >&& image ) @@ -92,10 +92,11 @@ namespace geode TextureImpl( AttributeManager& manager, std::string_view name ) { - texture_id_ = manager.create_attribute< VariableAttribute, - ElementTextureCoordinates >( name, {} ); + const auto texture_id = + manager.create_attribute< VariableAttribute, + ElementTextureCoordinates >( name, {} ); coordinates_ = manager.find_attribute< VariableAttribute, - ElementTextureCoordinates >( texture_id_ ); + ElementTextureCoordinates >( texture_id ); } TextureImpl() = default; @@ -107,24 +108,14 @@ namespace geode serializer.ext( *this, Growable< Archive, TextureImpl >{ { []( Archive& archive, TextureImpl& impl ) { - archive.object( impl.image_ ); - geode::uuid texture_id; - archive.object( texture_id ); - impl.texture_id_ = texture_id; - archive.ext( impl.coordinates_, - bitsery::ext::StdSmartPtr{} ); - }, - []( Archive& archive, TextureImpl& impl ) { - archive.object( impl.image_ ); - archive.object( impl.texture_id_ ); - archive.ext( impl.coordinates_, - bitsery::ext::StdSmartPtr{} ); - } } } ); + archive.object( impl.image_ ); + archive.ext( impl.coordinates_, + bitsery::ext::StdSmartPtr{} ); + } } } ); } private: RasterImage< dimension > image_; - geode::uuid texture_id_; std::shared_ptr< VariableAttribute< ElementTextureCoordinates > > coordinates_; }; diff --git a/include/geode/mesh/core/polygonal_surface.hpp b/include/geode/mesh/core/polygonal_surface.hpp index 885da1bf7..bae65223d 100644 --- a/include/geode/mesh/core/polygonal_surface.hpp +++ b/include/geode/mesh/core/polygonal_surface.hpp @@ -47,6 +47,8 @@ namespace geode using Builder = PolygonalSurfaceBuilder< dimension >; static constexpr auto dim = dimension; + PolygonalSurface( BITSERY ); + /*! * Create a new PolygonalSurface using default data structure. */ diff --git a/include/geode/mesh/core/polyhedral_solid.hpp b/include/geode/mesh/core/polyhedral_solid.hpp index de80c7649..3c808302a 100644 --- a/include/geode/mesh/core/polyhedral_solid.hpp +++ b/include/geode/mesh/core/polyhedral_solid.hpp @@ -27,6 +27,8 @@ #include +#include + #include #include @@ -52,6 +54,8 @@ namespace geode using Builder = PolyhedralSolidBuilder< dimension >; static constexpr auto dim = dimension; + PolyhedralSolid( BITSERY ); + /*! * Create a new PolyhedralSolid using default data structure. */ diff --git a/include/geode/mesh/core/regular_grid_solid.hpp b/include/geode/mesh/core/regular_grid_solid.hpp index 32f630955..6ad609e0c 100644 --- a/include/geode/mesh/core/regular_grid_solid.hpp +++ b/include/geode/mesh/core/regular_grid_solid.hpp @@ -23,6 +23,8 @@ #pragma once +#include + #include #include #include @@ -48,6 +50,8 @@ namespace geode using Builder = RegularGridBuilder< 3 >; static constexpr index_t dim{ 3 }; + RegularGrid( BITSERY ); + /*! * Create a new RegularGrid using default data structure. */ diff --git a/include/geode/mesh/core/regular_grid_surface.hpp b/include/geode/mesh/core/regular_grid_surface.hpp index 0e19b8dfc..1932257e4 100644 --- a/include/geode/mesh/core/regular_grid_surface.hpp +++ b/include/geode/mesh/core/regular_grid_surface.hpp @@ -23,6 +23,8 @@ #pragma once +#include + #include #include #include @@ -46,6 +48,8 @@ namespace geode using Builder = RegularGridBuilder< 2 >; static constexpr index_t dim{ 2 }; + RegularGrid( BITSERY ); + /*! * Create a new RegularGrid using default data structure. */ diff --git a/include/geode/mesh/core/solid_mesh.hpp b/include/geode/mesh/core/solid_mesh.hpp index 48058090a..e9ddfe3a3 100644 --- a/include/geode/mesh/core/solid_mesh.hpp +++ b/include/geode/mesh/core/solid_mesh.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -277,6 +278,8 @@ namespace geode static constexpr auto dim = dimension; using VerticesAroundVertex = absl::InlinedVector< index_t, 20 >; + SolidMesh( BITSERY ); + ~SolidMesh(); /*! diff --git a/include/geode/mesh/core/surface_edges.hpp b/include/geode/mesh/core/surface_edges.hpp index 261916dda..a5317dce3 100644 --- a/include/geode/mesh/core/surface_edges.hpp +++ b/include/geode/mesh/core/surface_edges.hpp @@ -27,6 +27,7 @@ #include +#include #include #include #include diff --git a/include/geode/mesh/core/surface_mesh.hpp b/include/geode/mesh/core/surface_mesh.hpp index 5cd43bc17..fd8d95b6f 100644 --- a/include/geode/mesh/core/surface_mesh.hpp +++ b/include/geode/mesh/core/surface_mesh.hpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -170,6 +171,8 @@ namespace geode static constexpr auto dim = dimension; using VerticesAroundVertex = absl::InlinedVector< index_t, 10 >; + SurfaceMesh( BITSERY ); + ~SurfaceMesh(); /*! diff --git a/include/geode/mesh/core/tetrahedral_solid.hpp b/include/geode/mesh/core/tetrahedral_solid.hpp index 1c1515111..83d62b6a3 100644 --- a/include/geode/mesh/core/tetrahedral_solid.hpp +++ b/include/geode/mesh/core/tetrahedral_solid.hpp @@ -25,6 +25,8 @@ #include +#include + #include #include @@ -46,6 +48,8 @@ namespace geode using Builder = TetrahedralSolidBuilder< dimension >; static constexpr auto dim = dimension; + TetrahedralSolid( BITSERY ); + /*! * Create a new TetrahedralSolid using default data structure. */ diff --git a/include/geode/mesh/core/triangulated_surface.hpp b/include/geode/mesh/core/triangulated_surface.hpp index a96390eb8..e264f1ce4 100644 --- a/include/geode/mesh/core/triangulated_surface.hpp +++ b/include/geode/mesh/core/triangulated_surface.hpp @@ -23,6 +23,8 @@ #pragma once +#include + #include #include @@ -45,6 +47,8 @@ namespace geode using Builder = TriangulatedSurfaceBuilder< dimension >; static constexpr auto dim = dimension; + TriangulatedSurface( BITSERY ); + /*! * Create a new TriangulatedSurface using default data structure. */ diff --git a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp index 5fbc80fce..f1eb1f4f1 100644 --- a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp +++ b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp @@ -41,6 +41,7 @@ namespace geode .main_coordinate_reference_system_manager_builder() .delete_coordinate_reference_system( internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + DEBUG( "delete_crs" ); auto crs_manager_builder = CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } .main_coordinate_reference_system_manager_builder(); @@ -49,9 +50,34 @@ namespace geode std::shared_ptr< CoordinateReferenceSystem< Mesh::dim > >{ std::make_shared< AttributeCoordinateReferenceSystem< Mesh::dim > >( - mesh.vertex_attribute_manager() ) } ); + mesh.vertex_attribute_manager(), + internal::PointsImpl< Mesh::dim >::POINTS_NAME ) } ); + DEBUG( "register_crs" ); crs_manager_builder.set_active_coordinate_reference_system( internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + DEBUG( "initialize_crs done" ); + } + + template < typename Mesh > + void initialize_crs( Mesh &mesh, const geode::uuid &attribute_id ) + { + DEBUG( "initialize_crs" ); + CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } + .main_coordinate_reference_system_manager_builder() + .delete_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + auto crs_manager_builder = + CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } + .main_coordinate_reference_system_manager_builder(); + crs_manager_builder.register_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME, + std::shared_ptr< CoordinateReferenceSystem< Mesh::dim > >{ + std::make_shared< + AttributeCoordinateReferenceSystem< Mesh::dim > >( + mesh.vertex_attribute_manager(), attribute_id ) } ); + crs_manager_builder.set_active_coordinate_reference_system( + internal::PointsImpl< Mesh::dim >::POINTS_NAME ); + DEBUG( "initialize_crs done" ); } } // namespace detail } // namespace geode diff --git a/include/geode/mesh/io/geode/geode_bitsery_mesh_input.hpp b/include/geode/mesh/io/geode/geode_bitsery_mesh_input.hpp index aa45f6569..6717f9ec9 100644 --- a/include/geode/mesh/io/geode/geode_bitsery_mesh_input.hpp +++ b/include/geode/mesh/io/geode/geode_bitsery_mesh_input.hpp @@ -32,7 +32,8 @@ #include #define BITSERY_READ( Mesh ) \ - [[nodiscard]] std::unique_ptr< Mesh > read( const MeshImpl& impl ) final \ + [[nodiscard]] std::unique_ptr< Mesh > read( const MeshImpl& /*impl*/ ) \ + final \ { \ std::ifstream file{ to_string( this->filename() ), \ std::ifstream::binary }; \ @@ -44,7 +45,8 @@ BitseryExtensions::register_deserialize_pcontext( \ std::get< 0 >( context ) ); \ Deserializer archive{ context, file }; \ - auto mesh = Mesh::create( impl ); \ + std::unique_ptr< Mesh > mesh{ new OpenGeode##Mesh{ \ + BITSERY::constructor } }; \ archive.object( dynamic_cast< OpenGeode##Mesh& >( *mesh ) ); \ const auto& adapter = archive.adapter(); \ geode::OpenGeodeMeshException::check_exception( \ diff --git a/include/geode/mesh/io/geode/geode_edged_curve_input.hpp b/include/geode/mesh/io/geode/geode_edged_curve_input.hpp index bedf88969..fe4ecdfa4 100644 --- a/include/geode/mesh/io/geode/geode_edged_curve_input.hpp +++ b/include/geode/mesh/io/geode/geode_edged_curve_input.hpp @@ -30,4 +30,60 @@ namespace geode { BITSERY_INPUT_MESH_DIMENSION( EdgedCurve ); + + // template < index_t dimension > + // class OpenGeodeEdgedCurveInput : public EdgedCurveInput< dimension > + // { + // public: + // explicit OpenGeodeEdgedCurveInput( std::string_view filename ) + // : EdgedCurveInput< dimension >( filename ) + // { + // } + + // [[nodiscard]] AdditionalFiles additional_files() const final + // { + // return {}; + // } + + // [[nodiscard]] std::unique_ptr< EdgedCurve< dimension > > read( + // const MeshImpl& /*impl*/ ) final + // { + // std::ifstream file{ to_string( this->filename() ), + // std::ifstream::binary }; + // geode::OpenGeodeMeshException::check_exception( !file.fail(), + // nullptr, geode::OpenGeodeException::TYPE::data, + // "[Bitsery::read] Failed to open file: ", + // to_string( this->filename() ) ); + // TContext context{}; + // BitseryExtensions::register_deserialize_pcontext( + // std::get< 0 >( context ) ); + // Deserializer archive{ context, file }; + // // auto mesh = Mesh::create( impl ); + // std::unique_ptr< EdgedCurve< dimension > > mesh{ + // new OpenGeodeEdgedCurve< dimension >{ BITSERY::constructor } + // }; + // archive.object( + // dynamic_cast< OpenGeodeEdgedCurve< dimension >& >( *mesh ) ); + // const auto& adapter = archive.adapter(); + // geode::OpenGeodeMeshException::check_exception( + // adapter.error() == bitsery::ReaderError::NoError + // && adapter.isCompletedSuccessfully() + // && std::get< 1 >( context ).isValid(), + // nullptr, geode::OpenGeodeException::TYPE::internal, + // "[Bitsery::read] Error while reading file: ", + // this->filename() ); + // return mesh; + // } + + // index_t object_priority() const final + // { + // return 0; + // } + + // Percentage is_loadable() const final + // { + // return Percentage{ 1 }; + // } + // }; + // ALIAS_2D_AND_3D( OpenGeodeEdgedCurveInput ); } // namespace geode diff --git a/src/geode/mesh/core/attribute_coordinate_reference_system.cpp b/src/geode/mesh/core/attribute_coordinate_reference_system.cpp index 562f88b62..52386627b 100644 --- a/src/geode/mesh/core/attribute_coordinate_reference_system.cpp +++ b/src/geode/mesh/core/attribute_coordinate_reference_system.cpp @@ -37,8 +37,8 @@ namespace geode friend class bitsery::Access; public: - Impl( AttributeManager& manager ) - : internal::PointsImpl< dimension >{ manager } + Impl( AttributeManager& manager, const geode::uuid& uuid ) + : internal::PointsImpl< dimension >{ manager, uuid } { } Impl( AttributeManager& manager, std::string_view attribute_name ) @@ -68,8 +68,9 @@ namespace geode template < index_t dimension > AttributeCoordinateReferenceSystem< dimension >:: - AttributeCoordinateReferenceSystem( AttributeManager& manager ) - : impl_{ manager } + AttributeCoordinateReferenceSystem( + AttributeManager& manager, const geode::uuid& uuid ) + : impl_{ manager, uuid } { } diff --git a/src/geode/mesh/core/geode/geode_edged_curve.cpp b/src/geode/mesh/core/geode/geode_edged_curve.cpp index 7cf0aa3b8..a6672901e 100644 --- a/src/geode/mesh/core/geode/geode_edged_curve.cpp +++ b/src/geode/mesh/core/geode/geode_edged_curve.cpp @@ -38,17 +38,22 @@ namespace geode { template < index_t dimension > - class OpenGeodeEdgedCurve< dimension >::Impl - : public internal::EdgesImpl, - public internal::PointsImpl< dimension > + class OpenGeodeEdgedCurve< dimension >::Impl : public internal::EdgesImpl { friend class bitsery::Access; public: explicit Impl( OpenGeodeEdgedCurve< dimension >& mesh ) - : internal::EdgesImpl( mesh ), - internal::PointsImpl< dimension >( mesh ) + : internal::EdgesImpl( mesh ) { + detail::template initialize_crs< OpenGeodeEdgedCurve< dimension > >( + mesh ); + } + + Impl( OpenGeodeEdgedCurve< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< OpenGeodeEdgedCurve< dimension > >( + mesh ); } private: @@ -62,9 +67,8 @@ namespace geode { []( Archive& archive, Impl& impl ) { archive.ext( impl, bitsery::ext::BaseClass< internal::EdgesImpl >{} ); - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); } } } ); } }; @@ -74,6 +78,12 @@ namespace geode { } + template < index_t dimension > + OpenGeodeEdgedCurve< dimension >::OpenGeodeEdgedCurve( BITSERY bitsery ) + : impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodeEdgedCurve< dimension >::OpenGeodeEdgedCurve( OpenGeodeEdgedCurve&& ) noexcept = default; @@ -86,13 +96,6 @@ namespace geode template < index_t dimension > OpenGeodeEdgedCurve< dimension >::~OpenGeodeEdgedCurve() = default; - template < index_t dimension > - void OpenGeodeEdgedCurve< dimension >::set_vertex( - index_t vertex_id, Point< dimension > point, OGEdgedCurveKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodeEdgedCurve< dimension >::get_edge_vertex( const EdgeVertex& edge_vertex ) const @@ -116,11 +119,44 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeEdgedCurve >{ { []( Archive& archive, OpenGeodeEdgedCurve& edged_curve ) { + const auto new_point_attribute_id = + edged_curve.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( edged_curve, bitsery::ext::BaseClass< EdgedCurve< dimension > >{} ); archive.object( edged_curve.impl_ ); - edged_curve.impl_->initialize_crs( edged_curve ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + edged_curve.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, edged_curve.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeEdgedCurve< dimension > >( + edged_curve, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodeEdgedCurve& edged_curve ) { + const auto new_point_attribute_id = + edged_curve.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( + edged_curve, bitsery::ext::BaseClass< + EdgedCurve< dimension > >{} ); + archive.object( edged_curve.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + edged_curve.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, edged_curve.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeEdgedCurve< dimension > >( + edged_curve, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeEdgedCurve& edged_curve ) { archive.ext( edged_curve, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/geode/geode_graph.cpp b/src/geode/mesh/core/geode/geode_graph.cpp index eeff4b0fa..829832add 100644 --- a/src/geode/mesh/core/geode/geode_graph.cpp +++ b/src/geode/mesh/core/geode/geode_graph.cpp @@ -39,6 +39,8 @@ namespace geode public: explicit Impl( OpenGeodeGraph& mesh ) : internal::EdgesImpl( mesh ) {} + Impl( BITSERY ) {} + private: Impl() = default; @@ -56,6 +58,8 @@ namespace geode OpenGeodeGraph::OpenGeodeGraph() : impl_( *this ) {} + OpenGeodeGraph::OpenGeodeGraph( BITSERY bitsery ) : impl_( bitsery ) {} + OpenGeodeGraph::OpenGeodeGraph( OpenGeodeGraph&& ) noexcept = default; OpenGeodeGraph& OpenGeodeGraph::operator=( diff --git a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp index 9448476bb..09db1577d 100644 --- a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp @@ -37,6 +37,7 @@ #include #include +#include namespace { @@ -93,19 +94,25 @@ namespace geode { template < index_t dimension > class OpenGeodeHybridSolid< dimension >::Impl - : public internal::PointsImpl< dimension > { friend class bitsery::Access; using TYPE = HybridSolid3D::TYPE; public: explicit Impl( OpenGeodeHybridSolid< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< + OpenGeodeHybridSolid< dimension > >( mesh ); polyhedron_vertex_ptr_.emplace_back( 0 ); polyhedron_adjacent_ptr_.emplace_back( 0 ); } + Impl( OpenGeodeHybridSolid< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< + OpenGeodeHybridSolid< dimension > >( mesh ); + } + index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const { @@ -425,9 +432,8 @@ namespace geode impl.polyhedron_adjacents_.max_size() ); archive.container4b( impl.polyhedron_adjacent_ptr_, impl.polyhedron_adjacent_ptr_.max_size() ); - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); } } } ); } @@ -470,6 +476,12 @@ namespace geode { } + template < index_t dimension > + OpenGeodeHybridSolid< dimension >::OpenGeodeHybridSolid( BITSERY bitsery ) + : HybridSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodeHybridSolid< dimension >::OpenGeodeHybridSolid( OpenGeodeHybridSolid&& ) noexcept = default; @@ -482,13 +494,6 @@ namespace geode template < index_t dimension > OpenGeodeHybridSolid< dimension >::~OpenGeodeHybridSolid() = default; - template < index_t dimension > - void OpenGeodeHybridSolid< dimension >::set_vertex( - index_t vertex_id, Point< dimension > point, OGHybridSolidKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodeHybridSolid< dimension >::get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -633,11 +638,42 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeHybridSolid >{ { []( Archive& archive, OpenGeodeHybridSolid& solid ) { + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( solid, bitsery::ext::BaseClass< HybridSolid< dimension > >{} ); archive.object( solid.impl_ ); - solid.impl_->initialize_crs( solid ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( solid.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, solid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeHybridSolid< dimension > >( + solid, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodeHybridSolid& solid ) { + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( solid, bitsery::ext::BaseClass< + HybridSolid< dimension > >{} ); + archive.object( solid.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + solid.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, solid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeHybridSolid< dimension > >( + solid, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeHybridSolid& solid ) { archive.ext( solid, bitsery::ext::BaseClass< HybridSolid< dimension > >{} ); diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index 63d8e96da..23d1bcad9 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -47,6 +47,12 @@ namespace geode mesh ); } + Impl( OpenGeodePointSet< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< OpenGeodePointSet< dimension > >( + mesh ); + } + private: Impl() = default; @@ -69,6 +75,12 @@ namespace geode { } + template < index_t dimension > + OpenGeodePointSet< dimension >::OpenGeodePointSet( BITSERY bitsery ) + : impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodePointSet< dimension >::OpenGeodePointSet( OpenGeodePointSet&& ) noexcept = default; @@ -101,9 +113,10 @@ namespace geode Point< dimension > >( point_set.vertex_attribute_manager(), internal::PointsImpl< dimension >::POINTS_NAME, - new_attribute_id ); + new_attribute_id, point_set.nb_vertices() ); detail::template initialize_crs< - OpenGeodePointSet< dimension > >( point_set ); + OpenGeodePointSet< dimension > >( + point_set, new_attribute_id ); }, []( Archive& archive, OpenGeodePointSet& point_set ) { DEBUG( "OpenGeodePointSet::serialize" ); @@ -120,9 +133,10 @@ namespace geode Point< dimension > >( point_set.vertex_attribute_manager(), internal::PointsImpl< dimension >::POINTS_NAME, - new_attribute_id ); + new_attribute_id, point_set.nb_vertices() ); detail::template initialize_crs< - OpenGeodePointSet< dimension > >( point_set ); + OpenGeodePointSet< dimension > >( + point_set, new_attribute_id ); }, []( Archive& archive, OpenGeodePointSet& point_set ) { archive.ext( point_set, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp index 217a170a6..b9cd2ceab 100644 --- a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp +++ b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp @@ -34,6 +34,8 @@ #include +#include + namespace geode { template < index_t dimension > @@ -44,11 +46,18 @@ namespace geode public: explicit Impl( OpenGeodePolygonalSurface< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< + OpenGeodePolygonalSurface< dimension > >( mesh ); polygon_ptr_.emplace_back( 0 ); } + Impl( OpenGeodePolygonalSurface< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< + OpenGeodePolygonalSurface< dimension > >( mesh ); + } + index_t get_polygon_vertex( const PolygonVertex& polygon_vertex ) const { return polygon_vertices_[starting_index( polygon_vertex.polygon_id ) @@ -184,19 +193,18 @@ namespace geode template < typename Archive > void serialize( Archive& serializer ) { - serializer.ext( *this, - Growable< Archive, Impl >{ - { []( Archive& archive, Impl& impl ) { - archive.container4b( impl.polygon_vertices_, - impl.polygon_vertices_.max_size() ); - archive.container4b( impl.polygon_adjacents_, - impl.polygon_adjacents_.max_size() ); - archive.container4b( - impl.polygon_ptr_, impl.polygon_ptr_.max_size() ); - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); - } } } ); + serializer.ext( + *this, Growable< Archive, Impl >{ + { []( Archive& archive, Impl& impl ) { + archive.container4b( impl.polygon_vertices_, + impl.polygon_vertices_.max_size() ); + archive.container4b( impl.polygon_adjacents_, + impl.polygon_adjacents_.max_size() ); + archive.container4b( impl.polygon_ptr_, + impl.polygon_ptr_.max_size() ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); + } } } ); } index_t get_polygon_adjacent_impl( @@ -223,6 +231,13 @@ namespace geode { } + template < index_t dimension > + OpenGeodePolygonalSurface< dimension >::OpenGeodePolygonalSurface( + BITSERY bitsery ) + : PolygonalSurface< dimension >{ bitsery }, impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodePolygonalSurface< dimension >::OpenGeodePolygonalSurface( OpenGeodePolygonalSurface&& ) noexcept = default; @@ -236,14 +251,6 @@ namespace geode OpenGeodePolygonalSurface< dimension >::~OpenGeodePolygonalSurface() = default; - template < index_t dimension > - void OpenGeodePolygonalSurface< dimension >::set_vertex( index_t vertex_id, - Point< dimension > point, - OGPolygonalSurfaceKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodePolygonalSurface< dimension >::get_polygon_vertex( const PolygonVertex& polygon_vertex ) const @@ -275,12 +282,45 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePolygonalSurface >{ { []( Archive& archive, OpenGeodePolygonalSurface& surface ) { + const auto new_point_attribute_id = + surface.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( surface, bitsery::ext::BaseClass< PolygonalSurface< dimension > >{} ); archive.object( surface.impl_ ); - surface.impl_->initialize_crs( surface ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + surface.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, surface.nb_vertices() ); + detail::template initialize_crs< + OpenGeodePolygonalSurface< dimension > >( + surface, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodePolygonalSurface& surface ) { + const auto new_point_attribute_id = + surface.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( + surface, bitsery::ext::BaseClass< + PolygonalSurface< dimension > >{} ); + archive.object( surface.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + surface.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, surface.nb_vertices() ); + detail::template initialize_crs< + OpenGeodePolygonalSurface< dimension > >( + surface, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodePolygonalSurface& surface ) { archive.ext( surface, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp index 70369a6b1..a24250117 100644 --- a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp @@ -33,24 +33,31 @@ #include #include +#include namespace geode { template < index_t dimension > class OpenGeodePolyhedralSolid< dimension >::Impl - : public internal::PointsImpl< dimension > { friend class bitsery::Access; public: explicit Impl( OpenGeodePolyhedralSolid< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< + OpenGeodePolyhedralSolid< dimension > >( mesh ); polyhedron_vertex_ptr_.emplace_back( 0 ); polyhedron_facet_ptr_.emplace_back( 0 ); polyhedron_adjacent_ptr_.emplace_back( 0 ); } + Impl( OpenGeodePolyhedralSolid< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< + OpenGeodePolyhedralSolid< dimension > >( mesh ); + } + index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const { @@ -345,9 +352,8 @@ namespace geode impl.polyhedron_adjacents_.max_size() ); archive.container4b( impl.polyhedron_adjacent_ptr_, impl.polyhedron_adjacent_ptr_.max_size() ); - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); }, []( Archive& archive, Impl& impl ) { archive.container4b( impl.polyhedron_vertices_, @@ -362,9 +368,8 @@ namespace geode impl.polyhedron_adjacents_.max_size() ); archive.container4b( impl.polyhedron_adjacent_ptr_, impl.polyhedron_adjacent_ptr_.max_size() ); - archive.ext( impl, - bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); } } } ); } @@ -414,6 +419,13 @@ namespace geode { } + template < index_t dimension > + OpenGeodePolyhedralSolid< dimension >::OpenGeodePolyhedralSolid( + BITSERY bitsery ) + : PolyhedralSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodePolyhedralSolid< dimension >::OpenGeodePolyhedralSolid( OpenGeodePolyhedralSolid&& ) noexcept = default; @@ -427,14 +439,6 @@ namespace geode OpenGeodePolyhedralSolid< dimension >::~OpenGeodePolyhedralSolid() = default; - template < index_t dimension > - void OpenGeodePolyhedralSolid< dimension >::set_vertex( index_t vertex_id, - Point< dimension > point, - OGPolyhedralSolidKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodePolyhedralSolid< dimension >::get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -538,11 +542,43 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePolyhedralSolid >{ { []( Archive& archive, OpenGeodePolyhedralSolid& solid ) { + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( solid, bitsery::ext::BaseClass< PolyhedralSolid< dimension > >{} ); archive.object( solid.impl_ ); - solid.impl_->initialize_crs( solid ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( solid.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, solid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodePolyhedralSolid< dimension > >( + solid, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodePolyhedralSolid& solid ) { + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( + solid, bitsery::ext::BaseClass< + PolyhedralSolid< dimension > >{} ); + archive.object( solid.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + solid.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, solid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodePolyhedralSolid< dimension > >( + solid, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodePolyhedralSolid& solid ) { archive.ext( solid, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp index 3502956b7..a49cd2b1b 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace { @@ -58,8 +59,15 @@ namespace geode public: Impl( OpenGeodeRegularGrid< 3 >& mesh ) - : internal::PointsImpl< 3 >( mesh ) { + detail::template initialize_crs< OpenGeodeRegularGrid< 3 > >( + mesh ); + } + + Impl( OpenGeodeRegularGrid< 3 >& mesh, BITSERY ) + { + detail::template initialize_crs< OpenGeodeRegularGrid< 3 > >( + mesh ); } void update_origin( RegularGrid3D& grid, const Point3D& origin ) @@ -128,19 +136,24 @@ namespace geode template < typename Archive > void serialize( Archive& serializer ) { - serializer.ext( *this, Growable< Archive, - Impl >{ { []( Archive& archive, - Impl& impl ) { - archive.ext( impl, - bitsery::ext::BaseClass< internal::PointsImpl< 3 > >{} ); - archive.ext( impl, - bitsery::ext::BaseClass< internal::GridImpl< 3 > >{} ); - } } } ); + serializer.ext( + *this, Growable< Archive, Impl >{ { []( Archive& archive, + Impl& impl ) { + internal::PointsImpl< 3 > temp; + archive.object( temp ); + archive.ext( impl, + bitsery::ext::BaseClass< internal::GridImpl< 3 > >{} ); + } } } ); } }; OpenGeodeRegularGrid< 3 >::OpenGeodeRegularGrid() : impl_( *this ) {} + OpenGeodeRegularGrid< 3 >::OpenGeodeRegularGrid( BITSERY bitsery ) + : RegularGrid< 3 >{ bitsery }, impl_( *this, bitsery ) + { + } + OpenGeodeRegularGrid< 3 >::OpenGeodeRegularGrid( OpenGeodeRegularGrid&& ) noexcept = default; @@ -211,11 +224,41 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeRegularGrid >{ { []( Archive& archive, OpenGeodeRegularGrid& grid ) { + const auto new_point_attribute_id = + grid.vertex_attribute_manager() + .attribute_ids_with_name( + internal::PointsImpl< 3 >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( grid, bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); archive.object( grid.impl_ ); - grid.impl_->initialize_crs( grid ); + detail::import_old_attribute< VariableAttribute, + Point< 3 > >( grid.vertex_attribute_manager(), + internal::PointsImpl< 3 >::POINTS_NAME, + new_point_attribute_id, grid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeRegularGrid< 3 > >( + grid, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodeRegularGrid& grid ) { + const auto new_point_attribute_id = + grid.vertex_attribute_manager() + .attribute_ids_with_name( + internal::PointsImpl< 3 >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( grid, + bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); + archive.object( grid.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< 3 > >( grid.vertex_attribute_manager(), + internal::PointsImpl< 3 >::POINTS_NAME, + new_point_attribute_id, grid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeRegularGrid< 3 > >( + grid, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeRegularGrid& grid ) { archive.ext( grid, bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); diff --git a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp index 62ee9f0a4..3f75114d4 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace { @@ -47,15 +48,21 @@ namespace namespace geode { - class OpenGeodeRegularGrid< 2 >::Impl : public internal::PointsImpl< 2 >, - public internal::GridImpl< 2 > + class OpenGeodeRegularGrid< 2 >::Impl : public internal::GridImpl< 2 > { friend class bitsery::Access; public: Impl( OpenGeodeRegularGrid< 2 >& mesh ) - : internal::PointsImpl< 2 >( mesh ) { + detail::template initialize_crs< OpenGeodeRegularGrid< 2 > >( + mesh ); + } + + Impl( OpenGeodeRegularGrid< 2 >& mesh, BITSERY ) + { + detail::template initialize_crs< OpenGeodeRegularGrid< 2 > >( + mesh ); } void update_origin( RegularGrid2D& grid, const Point2D& origin ) @@ -113,19 +120,24 @@ namespace geode template < typename Archive > void serialize( Archive& serializer ) { - serializer.ext( *this, Growable< Archive, - Impl >{ { []( Archive& archive, - Impl& impl ) { - archive.ext( impl, - bitsery::ext::BaseClass< internal::PointsImpl< 2 > >{} ); - archive.ext( impl, - bitsery::ext::BaseClass< internal::GridImpl< 2 > >{} ); - } } } ); + serializer.ext( + *this, Growable< Archive, Impl >{ { []( Archive& archive, + Impl& impl ) { + internal::PointsImpl< 2 > temp; + archive.object( temp ); + archive.ext( impl, + bitsery::ext::BaseClass< internal::GridImpl< 2 > >{} ); + } } } ); } }; OpenGeodeRegularGrid< 2 >::OpenGeodeRegularGrid() : impl_( *this ) {} + OpenGeodeRegularGrid< 2 >::OpenGeodeRegularGrid( BITSERY bitsery ) + : RegularGrid< 2 >{ bitsery }, impl_( *this, bitsery ) + { + } + OpenGeodeRegularGrid< 2 >::OpenGeodeRegularGrid( OpenGeodeRegularGrid&& ) noexcept = default; @@ -190,11 +202,41 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeRegularGrid >{ { []( Archive& archive, OpenGeodeRegularGrid& grid ) { + const auto new_point_attribute_id = + grid.vertex_attribute_manager() + .attribute_ids_with_name( + internal::PointsImpl< 2 >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( grid, bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); archive.object( grid.impl_ ); - grid.impl_->initialize_crs( grid ); + detail::import_old_attribute< VariableAttribute, + Point< 2 > >( grid.vertex_attribute_manager(), + internal::PointsImpl< 2 >::POINTS_NAME, + new_point_attribute_id, grid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeRegularGrid< 2 > >( + grid, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodeRegularGrid& grid ) { + const auto new_point_attribute_id = + grid.vertex_attribute_manager() + .attribute_ids_with_name( + internal::PointsImpl< 2 >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( grid, + bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); + archive.object( grid.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< 2 > >( grid.vertex_attribute_manager(), + internal::PointsImpl< 2 >::POINTS_NAME, + new_point_attribute_id, grid.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeRegularGrid< 2 > >( + grid, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeRegularGrid& grid ) { archive.ext( grid, bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); diff --git a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp index f4cf760a0..402c4fbac 100644 --- a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp @@ -37,19 +37,20 @@ #include #include +#include namespace geode { template < index_t dimension > class OpenGeodeTetrahedralSolid< dimension >::Impl - : public internal::PointsImpl< dimension > { friend class bitsery::Access; public: explicit Impl( OpenGeodeTetrahedralSolid< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< + OpenGeodeTetrahedralSolid< dimension > >( mesh ); const auto tetrahedron_vertices_id = mesh.polyhedron_attribute_manager() .template create_attribute< VariableAttribute, @@ -72,6 +73,12 @@ namespace geode std::array< index_t, 4 > >( tetrahedron_adjacents_id ); } + Impl( OpenGeodeTetrahedralSolid< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< + OpenGeodeTetrahedralSolid< dimension > >( mesh ); + } + index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const { @@ -139,9 +146,8 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive& archive, Impl& impl ) { - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); archive.ext( impl.tetrahedron_vertices_, bitsery::ext::StdSmartPtr{} ); archive.ext( impl.tetrahedron_adjacents_, @@ -162,9 +168,8 @@ namespace geode false } ); }, []( Archive& archive, Impl& impl ) { - archive.ext( impl, - bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); archive.ext( impl.tetrahedron_vertices_, bitsery::ext::StdSmartPtr{} ); archive.ext( impl.tetrahedron_adjacents_, @@ -185,6 +190,13 @@ namespace geode { } + template < index_t dimension > + OpenGeodeTetrahedralSolid< dimension >::OpenGeodeTetrahedralSolid( + BITSERY bitsery ) + : TetrahedralSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodeTetrahedralSolid< dimension >::OpenGeodeTetrahedralSolid( OpenGeodeTetrahedralSolid&& ) noexcept = default; @@ -198,14 +210,6 @@ namespace geode OpenGeodeTetrahedralSolid< dimension >::~OpenGeodeTetrahedralSolid() = default; - template < index_t dimension > - void OpenGeodeTetrahedralSolid< dimension >::set_vertex( index_t vertex_id, - Point< dimension > point, - OGTetrahedralSolidKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodeTetrahedralSolid< dimension >::get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -241,7 +245,7 @@ namespace geode solid, bitsery::ext::BaseClass< TetrahedralSolid< dimension > >{} ); archive.object( solid.impl_ ); - solid.impl_->initialize_crs( solid ); + // solid.impl_->initialize_crs( solid ); }, []( Archive& archive, OpenGeodeTetrahedralSolid& solid ) { archive.ext( diff --git a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp index f2e1c6890..3f755858a 100644 --- a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp +++ b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp @@ -35,19 +35,20 @@ #include #include +#include namespace geode { template < index_t dimension > class OpenGeodeTriangulatedSurface< dimension >::Impl - : public internal::PointsImpl< dimension > { friend class bitsery::Access; public: explicit Impl( OpenGeodeTriangulatedSurface< dimension >& mesh ) - : internal::PointsImpl< dimension >( mesh ) { + detail::template initialize_crs< + OpenGeodeTriangulatedSurface< dimension > >( mesh ); const auto triangle_vertices_id = mesh.polygon_attribute_manager() .template create_attribute< VariableAttribute, @@ -70,6 +71,12 @@ namespace geode std::array< index_t, 3 > >( triangle_adjacents_id ); } + Impl( OpenGeodeTriangulatedSurface< dimension >& mesh, BITSERY ) + { + detail::template initialize_crs< + OpenGeodeTriangulatedSurface< dimension > >( mesh ); + } + index_t get_polygon_vertex( const PolygonVertex& polygon_vertex ) const { return triangle_vertices_->value( polygon_vertex.polygon_id ) @@ -126,9 +133,8 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive& archive, Impl& impl ) { - archive.ext( - impl, bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); archive.ext( impl.triangle_vertices_, bitsery::ext::StdSmartPtr{} ); archive.ext( impl.triangle_adjacents_, @@ -147,9 +153,8 @@ namespace geode false } ); }, []( Archive& archive, Impl& impl ) { - archive.ext( impl, - bitsery::ext::BaseClass< - internal::PointsImpl< dimension > >{} ); + internal::PointsImpl< dimension > temp; + archive.object( temp ); archive.ext( impl.triangle_vertices_, bitsery::ext::StdSmartPtr{} ); archive.ext( impl.triangle_adjacents_, @@ -170,6 +175,13 @@ namespace geode { } + template < index_t dimension > + OpenGeodeTriangulatedSurface< dimension >::OpenGeodeTriangulatedSurface( + BITSERY bitsery ) + : TriangulatedSurface< dimension >{ bitsery }, impl_( *this, bitsery ) + { + } + template < index_t dimension > OpenGeodeTriangulatedSurface< dimension >::OpenGeodeTriangulatedSurface( OpenGeodeTriangulatedSurface&& ) noexcept = default; @@ -183,15 +195,6 @@ namespace geode OpenGeodeTriangulatedSurface< dimension >::~OpenGeodeTriangulatedSurface() = default; - template < index_t dimension > - void OpenGeodeTriangulatedSurface< dimension >::set_vertex( - index_t vertex_id, - Point< dimension > point, - OGTriangulatedSurfaceKey /*key*/ ) - { - impl_->set_point( vertex_id, std::move( point ) ); - } - template < index_t dimension > index_t OpenGeodeTriangulatedSurface< dimension >::get_polygon_vertex( const PolygonVertex& polygon_vertex ) const @@ -216,12 +219,46 @@ namespace geode Growable< Archive, OpenGeodeTriangulatedSurface >{ { []( Archive& archive, OpenGeodeTriangulatedSurface& surface ) { + const auto new_point_attribute_id = + surface.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); archive.ext( surface, bitsery::ext::BaseClass< TriangulatedSurface< dimension > >{} ); archive.object( surface.impl_ ); - surface.impl_->initialize_crs( surface ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + surface.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, surface.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeTriangulatedSurface< dimension > >( + surface, new_point_attribute_id ); }, + []( Archive& archive, + OpenGeodeTriangulatedSurface& surface ) { + const auto new_point_attribute_id = + surface.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + archive.ext( + surface, bitsery::ext::BaseClass< + TriangulatedSurface< dimension > >{} ); + archive.object( surface.impl_ ); + detail::import_old_attribute< VariableAttribute, + Point< dimension > >( + surface.vertex_attribute_manager(), + internal::PointsImpl< dimension >::POINTS_NAME, + new_point_attribute_id, surface.nb_vertices() ); + detail::template initialize_crs< + OpenGeodeTriangulatedSurface< dimension > >( + surface, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeTriangulatedSurface& surface ) { archive.ext( diff --git a/src/geode/mesh/core/hybrid_solid.cpp b/src/geode/mesh/core/hybrid_solid.cpp index 10f51aeee..3277fb456 100644 --- a/src/geode/mesh/core/hybrid_solid.cpp +++ b/src/geode/mesh/core/hybrid_solid.cpp @@ -30,6 +30,12 @@ namespace geode { + template < index_t dimension > + HybridSolid< dimension >::HybridSolid( BITSERY bitsery ) + : SolidMesh< dimension >{ bitsery } + { + } + template < index_t dimension > std::unique_ptr< HybridSolid< dimension > > HybridSolid< dimension >::create() diff --git a/src/geode/mesh/core/polygonal_surface.cpp b/src/geode/mesh/core/polygonal_surface.cpp index 70568e84c..6b3163edf 100644 --- a/src/geode/mesh/core/polygonal_surface.cpp +++ b/src/geode/mesh/core/polygonal_surface.cpp @@ -28,6 +28,12 @@ namespace geode { + template < index_t dimension > + PolygonalSurface< dimension >::PolygonalSurface( BITSERY bitsery ) + : SurfaceMesh< dimension >{ bitsery } + { + } + template < index_t dimension > std::unique_ptr< PolygonalSurface< dimension > > PolygonalSurface< dimension >::create() diff --git a/src/geode/mesh/core/polyhedral_solid.cpp b/src/geode/mesh/core/polyhedral_solid.cpp index 38d9c8a4b..d18d9fe4b 100644 --- a/src/geode/mesh/core/polyhedral_solid.cpp +++ b/src/geode/mesh/core/polyhedral_solid.cpp @@ -30,6 +30,12 @@ namespace geode { + template < index_t dimension > + PolyhedralSolid< dimension >::PolyhedralSolid( BITSERY bitsery ) + : SolidMesh< dimension >{ bitsery } + { + } + template < index_t dimension > std::unique_ptr< PolyhedralSolid< dimension > > PolyhedralSolid< dimension >::create() diff --git a/src/geode/mesh/core/regular_grid_solid.cpp b/src/geode/mesh/core/regular_grid_solid.cpp index 9c98bda2c..ba05efed8 100644 --- a/src/geode/mesh/core/regular_grid_solid.cpp +++ b/src/geode/mesh/core/regular_grid_solid.cpp @@ -32,6 +32,10 @@ namespace geode { + RegularGrid< 3 >::RegularGrid( BITSERY bitsery ) : SolidMesh< 3 >{ bitsery } + { + } + std::unique_ptr< RegularGrid< 3 > > RegularGrid< 3 >::create() { return MeshFactory::create_default_mesh< RegularGrid< 3 > >( diff --git a/src/geode/mesh/core/regular_grid_surface.cpp b/src/geode/mesh/core/regular_grid_surface.cpp index 8aba27c74..e84901e10 100644 --- a/src/geode/mesh/core/regular_grid_surface.cpp +++ b/src/geode/mesh/core/regular_grid_surface.cpp @@ -32,6 +32,11 @@ namespace geode { + RegularGrid< 2 >::RegularGrid( BITSERY bitsery ) + : SurfaceMesh< 2 >{ bitsery } + { + } + std::unique_ptr< RegularGrid< 2 > > RegularGrid< 2 >::create() { return MeshFactory::create_default_mesh< RegularGrid< 2 > >( diff --git a/src/geode/mesh/core/solid_edges.cpp b/src/geode/mesh/core/solid_edges.cpp index bf10fde3a..fe2d57459 100644 --- a/src/geode/mesh/core/solid_edges.cpp +++ b/src/geode/mesh/core/solid_edges.cpp @@ -65,7 +65,10 @@ namespace geode friend class bitsery::Access; public: - Impl() = default; + Impl() : internal::FacetEdgesImpl< dimension >{ BITSERY::constructor } + { + } + Impl( const SolidMesh< dimension >& solid ) { for( const auto p : Range{ solid.nb_polyhedra() } ) diff --git a/src/geode/mesh/core/solid_facets.cpp b/src/geode/mesh/core/solid_facets.cpp index 2991ea9a9..c5e49e203 100644 --- a/src/geode/mesh/core/solid_facets.cpp +++ b/src/geode/mesh/core/solid_facets.cpp @@ -68,7 +68,13 @@ namespace geode detail::VertexCycle< PolyhedronFacetVertices >; public: - Impl() = default; + Impl() + : detail::FacetStorage< PolyhedronFacetVertices >{ + BITSERY::constructor + } + { + } + Impl( const SolidMesh< dimension >& solid ) { for( const auto p : Range{ solid.nb_polyhedra() } ) diff --git a/src/geode/mesh/core/solid_mesh.cpp b/src/geode/mesh/core/solid_mesh.cpp index 427a9414a..72a3434e8 100644 --- a/src/geode/mesh/core/solid_mesh.cpp +++ b/src/geode/mesh/core/solid_mesh.cpp @@ -712,9 +712,9 @@ namespace geode return cached.value(); } - private: Impl() = default; + private: template < typename Archive > void serialize( Archive& serializer ) { @@ -830,6 +830,11 @@ namespace geode { } + template < index_t dimension > + SolidMesh< dimension >::SolidMesh( BITSERY ) + { + } + template < index_t dimension > SolidMesh< dimension >::SolidMesh( SolidMesh&& ) noexcept = default; @@ -1742,8 +1747,8 @@ namespace geode { []( Archive& archive, SolidMesh& solid ) { archive.ext( solid, bitsery::ext::BaseClass< VertexSet >{} ); - archive.object( solid.impl_ ); solid.impl_->initialize_polyhedra_around_vertex( solid ); + archive.object( solid.impl_ ); }, []( Archive& archive, SolidMesh& solid ) { archive.ext( diff --git a/src/geode/mesh/core/surface_edges.cpp b/src/geode/mesh/core/surface_edges.cpp index 499ee7b81..f8f42ffce 100644 --- a/src/geode/mesh/core/surface_edges.cpp +++ b/src/geode/mesh/core/surface_edges.cpp @@ -64,7 +64,10 @@ namespace geode friend class bitsery::Access; public: - Impl() = default; + Impl() : internal::FacetEdgesImpl< dimension >{ BITSERY::constructor } + { + } + Impl( const SurfaceMesh< dimension >& surface ) { for( const auto p : Range{ surface.nb_polygons() } ) diff --git a/src/geode/mesh/core/surface_mesh.cpp b/src/geode/mesh/core/surface_mesh.cpp index ec1d82bde..95277823e 100644 --- a/src/geode/mesh/core/surface_mesh.cpp +++ b/src/geode/mesh/core/surface_mesh.cpp @@ -390,7 +390,7 @@ namespace geode edges_.reset( new SurfaceEdges< dimension >{ surface } ); } - void copy_edges( const SurfaceMesh< dimension >& surface ) const + void copy_edges( const SurfaceMesh< dimension >& from_surface ) const { OpenGeodeMeshException::check_exception( !are_edges_enabled(), nullptr, OpenGeodeException::TYPE::data, @@ -398,7 +398,7 @@ namespace geode "already enabled." ); edges_.reset( new SurfaceEdges< dimension >{} ); SurfaceEdgesBuilder< dimension > edges_builder{ *edges_ }; - edges_builder.copy( surface.edges() ); + edges_builder.copy( from_surface.edges() ); } void disable_edges() const @@ -446,9 +446,9 @@ namespace geode CachedPolygons >( attribute_id ); } - private: Impl() = default; + private: template < typename Archive > void serialize( Archive& serializer ) { @@ -572,6 +572,11 @@ namespace geode { } + template < index_t dimension > + SurfaceMesh< dimension >::SurfaceMesh( BITSERY ) + { + } + template < index_t dimension > SurfaceMesh< dimension >::SurfaceMesh( SurfaceMesh&& ) noexcept = default; @@ -1098,9 +1103,9 @@ namespace geode { []( Archive& archive, SurfaceMesh& surface ) { archive.ext( surface, bitsery::ext::BaseClass< VertexSet >{} ); - archive.object( surface.impl_ ); surface.impl_->initialize_polygons_around_vertex( surface ); + archive.object( surface.impl_ ); }, []( Archive& archive, SurfaceMesh& surface ) { archive.ext( diff --git a/src/geode/mesh/core/tetrahedral_solid.cpp b/src/geode/mesh/core/tetrahedral_solid.cpp index e3a9d5507..507485ba8 100644 --- a/src/geode/mesh/core/tetrahedral_solid.cpp +++ b/src/geode/mesh/core/tetrahedral_solid.cpp @@ -156,6 +156,12 @@ namespace namespace geode { + template < index_t dimension > + TetrahedralSolid< dimension >::TetrahedralSolid( BITSERY bitsery ) + : SolidMesh< dimension >{ bitsery } + { + } + template < index_t dimension > std::unique_ptr< TetrahedralSolid< dimension > > TetrahedralSolid< dimension >::create() diff --git a/src/geode/mesh/core/triangulated_surface.cpp b/src/geode/mesh/core/triangulated_surface.cpp index 3d2d7bda4..c47b76d7e 100644 --- a/src/geode/mesh/core/triangulated_surface.cpp +++ b/src/geode/mesh/core/triangulated_surface.cpp @@ -32,6 +32,13 @@ namespace geode { + + template < index_t dimension > + TriangulatedSurface< dimension >::TriangulatedSurface( BITSERY bitsery ) + : SurfaceMesh< dimension >{ bitsery } + { + } + template < index_t dimension > std::unique_ptr< TriangulatedSurface< dimension > > TriangulatedSurface< dimension >::create() diff --git a/tests/mesh/test-coordinate-reference-system.cpp b/tests/mesh/test-coordinate-reference-system.cpp index 679f96335..197a833bf 100644 --- a/tests/mesh/test-coordinate-reference-system.cpp +++ b/tests/mesh/test-coordinate-reference-system.cpp @@ -45,7 +45,7 @@ void test() const auto crs_name = "test"; crs_manager_builder.register_coordinate_reference_system( crs_name, std::make_shared< geode::AttributeCoordinateReferenceSystem3D >( - att_manager ) ); + att_manager, crs_name ) ); geode::OpenGeodeMeshException::test( crs_manager.nb_coordinate_reference_systems() == 1, "Wrong number of CRS" ); diff --git a/tests/mesh/test-edged-curve.cpp b/tests/mesh/test-edged-curve.cpp index cefabcbdc..f7a5de3fe 100644 --- a/tests/mesh/test-edged-curve.cpp +++ b/tests/mesh/test-edged-curve.cpp @@ -283,6 +283,11 @@ void test_backward_io( const std::string& filename ) const auto curve = geode::load_edged_curve< 3 >( filename ); geode::OpenGeodeMeshException::test( curve->nb_edges() == 4, "Backward EdgedCurve has wrong number of edges" ); + const geode::Point3D answer{ { 2.1, 9.4, 6.7 } }; + geode::OpenGeodeMeshException::test( curve->point( 1 ) == answer, + "Backward EdgedCurve vertex coordinates are not correct" ); + geode::OpenGeodeMeshException::test( curve->edge_vertex( { 0, 0 } ) == 0, + "Backward EdgedCurve edge vertex index is not correct" ); geode::OpenGeodeMeshException::test( curve->nb_vertices() == 4, "Backward EdgedCurve has wrong number of vertices" ); } diff --git a/tests/mesh/test-hybrid-solid.cpp b/tests/mesh/test-hybrid-solid.cpp index d0033c3a2..298c22f18 100644 --- a/tests/mesh/test-hybrid-solid.cpp +++ b/tests/mesh/test-hybrid-solid.cpp @@ -414,6 +414,30 @@ void test_io( "Reloaded HybridSolid has wrong polyhedron facet index" ); } +void test_backward_io( const std::string& filename ) +{ + DEBUG( "test_backward_io" ); + const auto solid = geode::load_hybrid_solid< 3 >( filename ); + geode::OpenGeodeMeshException::test( solid->nb_vertices() == 11, + "Backward HybridSolid should have 11 vertices" ); + SDEBUG( solid->point( 0 ) ); + geode::OpenGeodeMeshException::test( solid->nb_polyhedra() == 4, + "Backward HybridSolid should have 4 polyhedra" ); + geode::OpenGeodeMeshException::test( solid->facets().nb_facets() == 16, + "Backward HybridSolid should have 16 facets" ); + geode::OpenGeodeMeshException::test( solid->edges().nb_edges() == 22, + "Backward HybridSolid should have 22 edges" ); + DEBUG( solid->facets() + .facet_from_vertices( solid->polyhedron_facet_vertices( { 1, 0 } ) ) + .value() ); + geode::OpenGeodeMeshException::test( + solid->facets().facet_from_vertices( + solid->polyhedron_facet_vertices( { 1, 0 } ) ) + == solid->facets().facet_from_vertices( + solid->polyhedron_facet_vertices( { 1, 0 } ) ), + "Backward HybridSolid has wrong polyhedron facet index" ); +} + void test_clone( const geode::HybridSolid3D& hybrid_solid ) { const auto hybrid_solid_clone = hybrid_solid.clone(); @@ -474,7 +498,8 @@ void test() test_polyhedron_adjacencies( *hybrid_solid, *builder ); test_io( *hybrid_solid, absl::StrCat( "test.", hybrid_solid->native_extension() ) ); - + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", + hybrid_solid->native_extension() ) ); test_permutation( *hybrid_solid, *builder ); test_delete_polyhedra( *hybrid_solid, *builder ); test_clone( *hybrid_solid ); diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index a2e96e21e..421e0ea54 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -116,6 +116,10 @@ void test_io( const geode::PointSet3D& point_set, std::string_view filename ) DEBUG( "test_io" ); geode::save_point_set( point_set, filename ); const auto reload = geode::load_point_set< 3 >( filename ); + SDEBUG( reload->point( 0 ) ); + SDEBUG( reload->point( 1 ) ); + SDEBUG( reload->point( 2 ) ); + SDEBUG( reload->point( 3 ) ); geode_unused( reload ); const auto point_set2 = geode::load_point_set< 3 >( geode::OpenGeodePointSet3D::impl_name_static(), filename ); @@ -136,11 +140,12 @@ void test_backward_io( SDEBUG( point_set->point( 0 ) ); SDEBUG( point_set->point( 1 ) ); SDEBUG( point_set->point( 2 ) ); + SDEBUG( point_set->point( 3 ) ); geode::OpenGeodeMeshException::test( point_set->nb_vertices() == 4, "PointSet should have 4 vertices" ); const geode::Point3D answer{ { 2.1, 9.4, 6.7 } }; - geode::OpenGeodeMeshException::test( point_set->point( 2 ) == answer, - "PointSet2 vertex coordinates are not correct" ); + geode::OpenGeodeMeshException::test( point_set->point( 1 ) == answer, + "PointSet vertex coordinates are not correct" ); } void test_clone( diff --git a/tests/mesh/test-polygonal-surface.cpp b/tests/mesh/test-polygonal-surface.cpp index 67d786d4b..440d3ba2d 100644 --- a/tests/mesh/test-polygonal-surface.cpp +++ b/tests/mesh/test-polygonal-surface.cpp @@ -700,11 +700,12 @@ void test() test_io( *polygonal_surface, absl::StrCat( "test.", polygonal_surface->native_extension() ), edge_attribute_id ); - test_backward_io( absl::StrCat( - geode::DATA_PATH, "test_v7.", polygonal_surface->native_extension() ) ); - test_backward_io( absl::StrCat( geode::DATA_PATH, "test_v12.", + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v7/test_v7.", + polygonal_surface->native_extension() ) ); + test_backward_io( absl::StrCat( geode::DATA_PATH, + "backward_io/v12/test_v12.", polygonal_surface->native_extension() ) ); + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", polygonal_surface->native_extension() ) ); - test_permutation( *polygonal_surface, *builder ); test_replace_vertex( *polygonal_surface, *builder ); test_delete_polygon( *polygonal_surface, *builder, edge_attribute_id ); diff --git a/tests/mesh/test-polyhedral-solid.cpp b/tests/mesh/test-polyhedral-solid.cpp index 5c8a1c517..5463982f0 100644 --- a/tests/mesh/test-polyhedral-solid.cpp +++ b/tests/mesh/test-polyhedral-solid.cpp @@ -672,11 +672,12 @@ void test() test_io( *polyhedral_solid, absl::StrCat( "test.", polyhedral_solid->native_extension() ), facet_attribute_id ); - test_backward_io( absl::StrCat( - geode::DATA_PATH, "test_v7.", polyhedral_solid->native_extension() ) ); - test_backward_io( absl::StrCat( - geode::DATA_PATH, "test_v12.", polyhedral_solid->native_extension() ) ); - + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v7/test_v7.", + polyhedral_solid->native_extension() ) ); + test_backward_io( absl::StrCat( geode::DATA_PATH, + "backward_io/v12/test_v12.", polyhedral_solid->native_extension() ) ); + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", + polyhedral_solid->native_extension() ) ); test_permutation( *polyhedral_solid, *builder ); test_delete_polyhedra( *polyhedral_solid, *builder, edge_attribute_id ); test_clone( *polyhedral_solid, vertex_attribute_id ); diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index 66b43bcd1..bb2fe06ce 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -323,6 +323,21 @@ void test_io( "Reloaded TetrahedralSolid should have 3 polyhedra" ); } +void test_backward_io( const std::string& filename ) +{ + DEBUG( "test_backward_io" ); + const auto solid = geode::load_tetrahedral_solid< 3 >( filename ); + geode::OpenGeodeMeshException::test( solid->nb_vertices() == 6, + "Backward TetrahedralSolid should have 6 vertices" ); + geode::OpenGeodeMeshException::test( solid->nb_polyhedra() == 3, + "Backward TetrahedralSolid should have 3 polyhedra" ); + geode::OpenGeodeMeshException::test( solid->edges().nb_edges() == 12, + "Backward TetrahedralSolid should have 12 edges" ); + geode::OpenGeodeMeshException::test( solid->facets().nb_facets() == 10, + "Backward TetrahedralSolid should have 10 facets" ); + test_is_on_border( *solid ); +} + void test_clone( const geode::TetrahedralSolid3D& solid ) { auto attr_from_id = @@ -443,7 +458,8 @@ void test() test_polyhedron_adjacencies( *solid, *builder ); test_is_on_border( *solid ); test_io( *solid, absl::StrCat( "test.", solid->native_extension() ) ); - + test_backward_io( absl::StrCat( + geode::DATA_PATH, "backward_io/v17/v17.", solid->native_extension() ) ); test_permutation( *solid, *builder ); test_delete_polyhedron( *solid, *builder ); test_clone( *solid ); diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index 576b4da95..aabd8b19d 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -237,6 +237,26 @@ void test_io( } } +void test_backward_io( const std::string& filename ) +{ + DEBUG( "test_backward_io" ); + const auto surface = geode::load_triangulated_surface< 3 >( filename ); + geode::OpenGeodeMeshException::test( surface->nb_vertices() == 5, + "Backward TriangulatedSurface should have 5 vertices" ); + geode::OpenGeodeMeshException::test( surface->nb_polygons() == 3, + "Backward TriangulatedSurface should have 3 polygons" ); + geode::OpenGeodeMeshException::test( + surface->polygon_adjacent( { 0, 1 } ) == 1, + "TriangulatedSurface adjacent index is not correct" ); + geode::OpenGeodeMeshException::test( surface->edges().nb_edges() == 7, + "Backward TriangulatedSurface should have 7 edges" ); + geode::OpenGeodeMeshException::test( + surface->polygon_around_vertex( 0 ).value().polygon_id == 0, + "Wrong polygon_around_vertex for backward triangulated surface" ); + geode::OpenGeodeMeshException::test( + surface->polygons_around_vertex( 0 ).size() == 1, + "Wrong polygons_around_vertex for backward triangulated surface" ); +} void test_clone( const geode::TriangulatedSurface3D& surface ) { auto attr_from_id = @@ -321,7 +341,8 @@ void test() test_create_polygons( *surface, *builder ); test_polygon_adjacencies( *surface, *builder ); test_io( *surface, absl::StrCat( "test.", surface->native_extension() ) ); - + test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", + surface->native_extension() ) ); test_permutation( *surface, *builder ); test_delete_polygon( *surface, *builder ); test_clone( *surface ); From be288e05cd76022934cc3e0f4c588452e7b972b7 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 19 Jun 2026 12:07:27 +0200 Subject: [PATCH 08/19] wip --- include/geode/basic/attribute.hpp | 8 +- include/geode/basic/attribute_manager.hpp | 13 +-- include/geode/basic/constant_attribute.hpp | 23 ++++-- include/geode/basic/sparse_attribute.hpp | 28 +++++-- include/geode/basic/variable_attribute.hpp | 48 +++++++---- include/geode/mesh/core/edged_curve.hpp | 3 + include/geode/mesh/core/graph.hpp | 3 + .../geode/mesh/core/internal/edges_impl.hpp | 5 ++ .../mixin/core/detail/relationships_impl.hpp | 10 ++- .../model/mixin/core/detail/uuid_to_index.hpp | 2 + .../geode/model/mixin/core/relationships.hpp | 2 + include/geode/model/mixin/core/topology.hpp | 6 ++ .../model/mixin/core/vertex_identifier.hpp | 2 + .../geode/model/representation/core/brep.hpp | 2 + .../model/representation/core/section.hpp | 2 + .../io/geode/geode_brep_input.hpp | 2 +- .../io/geode/geode_section_input.hpp | 75 ++++++++++-------- src/geode/basic/attribute_manager.cpp | 17 ++++ src/geode/mesh/builder/graph_builder.cpp | 1 + src/geode/mesh/core/edged_curve.cpp | 5 ++ .../mesh/core/geode/geode_edged_curve.cpp | 34 +++----- src/geode/mesh/core/geode/geode_graph.cpp | 6 +- .../mesh/core/geode/geode_hybrid_solid.cpp | 31 ++------ src/geode/mesh/core/geode/geode_point_set.cpp | 34 ++------ .../core/geode/geode_polygonal_surface.cpp | 36 +++------ .../core/geode/geode_polyhedral_solid.cpp | 33 +++----- .../core/geode/geode_regular_grid_solid.cpp | 30 ++----- .../core/geode/geode_regular_grid_surface.cpp | 30 ++----- .../core/geode/geode_tetrahedral_solid.cpp | 35 +++++--- .../core/geode/geode_triangulated_surface.cpp | 36 +++------ src/geode/mesh/core/graph.cpp | 12 ++- .../mixin/core/detail/relationships_impl.cpp | 44 ++++++---- src/geode/model/mixin/core/relationships.cpp | 61 +++++++++----- .../model/mixin/core/vertex_identifier.cpp | 3 + src/geode/model/representation/core/brep.cpp | 2 + .../model/representation/core/section.cpp | 2 + .../io/geode/geode_brep_input.cpp | 3 +- .../io/geode/geode_section_input.cpp | 3 +- tests/basic/test-attribute.cpp | 13 +++ tests/data/backward_io/v17/v17.og_rgd3d | Bin 45956 -> 45956 bytes tests/mesh/test-edged-curve.cpp | 3 + tests/mesh/test-graph.cpp | 7 +- tests/mesh/test-hybrid-solid.cpp | 40 +++++----- tests/mesh/test-point-set.cpp | 1 + tests/mesh/test-regular-grid.cpp | 21 ++++- tests/mesh/test-triangulated-surface.cpp | 5 ++ tests/model/test-brep.cpp | 1 + tests/model/test-ray-tracing-helpers.cpp | 1 + tests/model/test-relationships.cpp | 6 +- 49 files changed, 447 insertions(+), 343 deletions(-) diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index f6ced2f6f..5e0733b0b 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -150,9 +150,10 @@ namespace geode } protected: - AttributeBase( AttributeProperties properties ) + AttributeBase( std::string_view name, AttributeProperties properties ) : properties_( std::move( properties ) ) { + set_name( name ); } private: @@ -200,8 +201,9 @@ namespace geode } protected: - ReadOnlyAttribute( AttributeProperties properties ) - : AttributeBase( std::move( properties ) ) + ReadOnlyAttribute( + std::string_view name, AttributeProperties properties ) + : AttributeBase( name, std::move( properties ) ) { } diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 025e9fd7c..5aa409f68 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -122,13 +122,13 @@ namespace geode OpenGeodeException::TYPE::data, "[AttributeManager::create_attribute] Attribute '", attribute_id.string(), "' already exists." ); - typed_attribute.reset( new Attribute< T >{ - std::move( default_value ), std::move( properties ), {} } ); + typed_attribute.reset( + new Attribute< T >{ std::move( default_value ), attribute_name, + std::move( properties ), {} } ); DEBUG( "create_attribute" ); SDEBUG( attribute_id ); DEBUG( attribute_name ); IdentifierBuilder builder{ *typed_attribute }; - builder.set_name( attribute_name ); builder.set_id( attribute_id ); register_attribute( typed_attribute, attribute_id ); } @@ -264,7 +264,10 @@ namespace geode */ [[nodiscard]] index_t nb_elements() const; - std::optional< std::vector< geode::uuid > > attribute_ids_with_name( + [[nodiscard]] std::optional< std::string_view > attribute_name( + const uuid& ) const; + + std::optional< std::vector< uuid > > attribute_ids_with_name( std::string_view name ) const; void copy( const AttributeManager& attribute_manager ); @@ -274,7 +277,7 @@ namespace geode void import( const AttributeManager& attribute_manager, absl::Span< const index_t > old2new, - geode::uuid attribute_id ); + uuid attribute_id ); void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping ); diff --git a/include/geode/basic/constant_attribute.hpp b/include/geode/basic/constant_attribute.hpp index c57ee08b2..7a9eed7c3 100644 --- a/include/geode/basic/constant_attribute.hpp +++ b/include/geode/basic/constant_attribute.hpp @@ -56,9 +56,11 @@ namespace geode public: ConstantAttribute( T value, + std::string_view name, AttributeProperties properties, AttributeBase::AttributeKey /*key*/ ) - : ConstantAttribute( std::move( value ), std::move( properties ) ) + : ConstantAttribute( + std::move( value ), name, std::move( properties ) ) { } @@ -102,14 +104,18 @@ namespace geode } private: - ConstantAttribute( T value, AttributeProperties properties ) - : ReadOnlyAttribute< T >( std::move( properties ) ) + ConstantAttribute( + T value, std::string_view name, AttributeProperties properties ) + : ReadOnlyAttribute< T >( name, std::move( properties ) ) { set_value( std::move( value ) ); } + ConstantAttribute( std::string_view name ) + : ReadOnlyAttribute< T >( name, AttributeProperties{} ) {}; + ConstantAttribute() - : ReadOnlyAttribute< T >( AttributeProperties{} ) {}; + : ReadOnlyAttribute< T >( "default", AttributeProperties{} ) {}; template < typename Archive > void serialize( Archive& serializer ) @@ -150,7 +156,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< ConstantAttribute< T > > attribute{ - new ConstantAttribute< T >{ value_, this->properties() } + new ConstantAttribute< T >{ + value_, this->name().value(), this->properties() } }; return attribute; } @@ -169,7 +176,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< ConstantAttribute< T > > attribute{ - new ConstantAttribute< T >{ value_, this->properties() } + new ConstantAttribute< T >{ + value_, this->name().value(), this->properties() } }; return attribute; } @@ -180,7 +188,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< ConstantAttribute< T > > attribute{ - new ConstantAttribute< T >{ value_, this->properties() } + new ConstantAttribute< T >{ + value_, this->name().value(), this->properties() } }; return attribute; } diff --git a/include/geode/basic/sparse_attribute.hpp b/include/geode/basic/sparse_attribute.hpp index b9449d551..c258d115d 100644 --- a/include/geode/basic/sparse_attribute.hpp +++ b/include/geode/basic/sparse_attribute.hpp @@ -63,10 +63,11 @@ namespace geode public: SparseAttribute( T default_value, + std::string_view name, AttributeProperties properties, AttributeBase::AttributeKey /*key*/ ) : SparseAttribute( - std::move( default_value ), std::move( properties ) ) + std::move( default_value ), name, std::move( properties ) ) { } @@ -113,14 +114,24 @@ namespace geode } private: - SparseAttribute( T default_value, AttributeProperties properties ) - : ReadOnlyAttribute< T >( std::move( properties ) ), + SparseAttribute( T default_value, + std::string_view name, + AttributeProperties properties ) + : ReadOnlyAttribute< T >( name, std::move( properties ) ), default_value_( std::move( default_value ) ) { values_.reserve( 10 ); } - SparseAttribute() : ReadOnlyAttribute< T >( AttributeProperties{} ) {} + SparseAttribute( std::string_view name ) + : ReadOnlyAttribute< T >( name, AttributeProperties{} ) + { + } + + SparseAttribute() + : ReadOnlyAttribute< T >( "default", AttributeProperties{} ) + { + } template < typename Archive > void serialize( Archive& serializer ) @@ -186,7 +197,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< SparseAttribute< T > > attribute{ - new SparseAttribute< T >{ default_value_, this->properties() } + new SparseAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; attribute->values_ = values_; return attribute; @@ -217,7 +229,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< SparseAttribute< T > > attribute{ - new SparseAttribute< T >{ default_value_, this->properties() } + new SparseAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; for( const auto i : Indices{ old2new } ) { @@ -242,7 +255,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< SparseAttribute< T > > attribute{ - new SparseAttribute< T >{ default_value_, this->properties() } + new SparseAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; for( const auto& [in, outs] : old2new_mapping.in2out_map() ) { diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index 6ff6fd849..eb3fdf53e 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -57,10 +57,11 @@ namespace geode public: VariableAttribute( T default_value, + std::string_view name, AttributeProperties properties, AttributeBase::AttributeKey /*key*/ ) : VariableAttribute( - std::move( default_value ), std::move( properties ) ) + std::move( default_value ), name, std::move( properties ) ) { } @@ -106,15 +107,20 @@ namespace geode } protected: - VariableAttribute( T default_value, AttributeProperties properties ) - : ReadOnlyAttribute< T >( std::move( properties ) ), + VariableAttribute( T default_value, + std::string_view name, + AttributeProperties properties ) + : ReadOnlyAttribute< T >( name, std::move( properties ) ), default_value_( std::move( default_value ) ) { values_.reserve( 10 ); } + VariableAttribute( std::string_view name ) + : ReadOnlyAttribute< T >( name, AttributeProperties{} ) {}; + VariableAttribute() - : ReadOnlyAttribute< T >( AttributeProperties{} ) {}; + : ReadOnlyAttribute< T >( "default", AttributeProperties{} ) {}; template < typename Archive > void serialize( Archive& serializer ) @@ -170,7 +176,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< VariableAttribute< T > > attribute{ - new VariableAttribute< T >{ default_value_, this->properties() } + new VariableAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; attribute->values_ = values_; return attribute; @@ -199,7 +206,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< VariableAttribute< T > > attribute{ - new VariableAttribute< T >{ default_value_, this->properties() } + new VariableAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; attribute->values_.resize( nb_elements, default_value_ ); for( const auto i : Indices{ old2new } ) @@ -228,7 +236,8 @@ namespace geode AttributeBase::AttributeKey /*key*/ ) const override { std::shared_ptr< VariableAttribute< T > > attribute{ - new VariableAttribute< T >{ default_value_, this->properties() } + new VariableAttribute< T >{ + default_value_, this->name().value(), this->properties() } }; attribute->values_.resize( nb_elements, default_value_ ); for( const auto& [input, outputs] : old2new_mapping.in2out_map() ) @@ -307,9 +316,10 @@ namespace geode public: VariableAttribute( bool default_value, + std::string_view name, AttributeProperties properties, AttributeBase::AttributeKey /*key*/ ) - : VariableAttribute( default_value, std::move( properties ) ) + : VariableAttribute( default_value, name, std::move( properties ) ) { } @@ -355,15 +365,22 @@ namespace geode } protected: - VariableAttribute( bool default_value, AttributeProperties properties ) - : ReadOnlyAttribute< bool >( std::move( properties ) ), + VariableAttribute( bool default_value, + std::string_view name, + AttributeProperties properties ) + : ReadOnlyAttribute< bool >( name, std::move( properties ) ), default_value_( default_value ) { values_.reserve( 10 ); } + VariableAttribute( std::string_view name ) + : ReadOnlyAttribute< bool >( name, AttributeProperties{} ) {}; + VariableAttribute() - : ReadOnlyAttribute< bool >( AttributeProperties{} ) {}; + : ReadOnlyAttribute< bool >( "default", AttributeProperties{} ) + { + } template < typename Archive > void serialize( Archive& serializer ) @@ -419,7 +436,8 @@ namespace geode { std::shared_ptr< VariableAttribute< bool > > attribute{ new VariableAttribute< bool >{ - static_cast< bool >( default_value_ ), this->properties() } + static_cast< bool >( default_value_ ), this->name().value(), + this->properties() } }; attribute->values_ = values_; return attribute; @@ -449,7 +467,8 @@ namespace geode { std::shared_ptr< VariableAttribute< bool > > attribute{ new VariableAttribute< bool >{ - static_cast< bool >( default_value_ ), this->properties() } + static_cast< bool >( default_value_ ), this->name().value(), + this->properties() } }; attribute->values_.resize( nb_elements, default_value_ ); for( const auto i : Indices{ old2new } ) @@ -479,7 +498,8 @@ namespace geode { std::shared_ptr< VariableAttribute< bool > > attribute{ new VariableAttribute< bool >{ - static_cast< bool >( default_value_ ), this->properties() } + static_cast< bool >( default_value_ ), this->name().value(), + this->properties() } }; attribute->values_.resize( nb_elements, default_value_ ); for( const auto& [in, outs] : old2new_mapping.in2out_map() ) diff --git a/include/geode/mesh/core/edged_curve.hpp b/include/geode/mesh/core/edged_curve.hpp index 008337456..fb77bc665 100644 --- a/include/geode/mesh/core/edged_curve.hpp +++ b/include/geode/mesh/core/edged_curve.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -50,6 +51,8 @@ namespace geode using Builder = EdgedCurveBuilder< dimension >; static constexpr auto dim = dimension; + EdgedCurve( BITSERY ); + ~EdgedCurve(); [[nodiscard]] static std::unique_ptr< EdgedCurve< dimension > > diff --git a/include/geode/mesh/core/graph.hpp b/include/geode/mesh/core/graph.hpp index a9e0af3ef..2d00c9c04 100644 --- a/include/geode/mesh/core/graph.hpp +++ b/include/geode/mesh/core/graph.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -111,6 +112,8 @@ namespace geode public: using Builder = GraphBuilder; + Graph( BITSERY ); + ~Graph(); /*! diff --git a/include/geode/mesh/core/internal/edges_impl.hpp b/include/geode/mesh/core/internal/edges_impl.hpp index e90e90c2d..5cab01370 100644 --- a/include/geode/mesh/core/internal/edges_impl.hpp +++ b/include/geode/mesh/core/internal/edges_impl.hpp @@ -41,6 +41,7 @@ namespace geode explicit EdgesImpl( Graph& graph ) : edges_() { + DEBUG( "EdgesImpl" ); const auto edge_attribute_id = graph.edge_attribute_manager() .template create_attribute< VariableAttribute, @@ -86,6 +87,7 @@ namespace geode serializer.ext( *this, Growable< Archive, EdgesImpl >{ { []( Archive& archive, EdgesImpl& impl ) { + DEBUG( "serialize EdgesIMPL" ); archive.ext( impl.edges_, bitsery::ext::StdSmartPtr{} ); const auto& old_edges_properties = @@ -94,10 +96,13 @@ namespace geode { old_edges_properties.assignable, old_edges_properties.interpolable, false } ); + DEBUG( "serialize EdgesIMPL end" ); }, []( Archive& archive, EdgesImpl& impl ) { + DEBUG( "serialize EdgesIMPL" ); archive.ext( impl.edges_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "serialize EdgesIMPL end" ); } } } ); } diff --git a/include/geode/model/mixin/core/detail/relationships_impl.hpp b/include/geode/model/mixin/core/detail/relationships_impl.hpp index b8e9f038c..0654f709d 100644 --- a/include/geode/model/mixin/core/detail/relationships_impl.hpp +++ b/include/geode/model/mixin/core/detail/relationships_impl.hpp @@ -26,8 +26,10 @@ #include #include +#include #include +#include #include #include @@ -48,6 +50,8 @@ namespace geode public: using Iterator = typename EdgesAroundVertex::const_iterator; + RelationshipsImpl( BITSERY ); + [[nodiscard]] index_t nb_components_with_relations() const; [[nodiscard]] index_t nb_relations( @@ -87,7 +91,7 @@ namespace geode protected: RelationshipsImpl(); - void initialize_attributes( const geode::uuid& id ); + void initialize_attributes(); [[nodiscard]] std::optional< index_t > vertex_id( const uuid& component_id ) const; @@ -104,13 +108,15 @@ namespace geode serializer.ext( *this, Growable< Archive, RelationshipsImpl >{ { []( Archive& archive, RelationshipsImpl& impl ) { + DEBUG( "serialize RelationshipsIMPL" ); + impl.graph_ = std::make_unique< OpenGeodeGraph >( + BITSERY::constructor ); archive.ext( impl.graph_, bitsery::ext::StdSmartPtr{} ); archive.object( impl.uuid2index_ ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); impl.attribute_id_ = impl.ids_->id(); - archive.object( impl.attribute_id_ ); impl.delete_isolated_vertices(); }, []( Archive& archive, RelationshipsImpl& impl ) { diff --git a/include/geode/model/mixin/core/detail/uuid_to_index.hpp b/include/geode/model/mixin/core/detail/uuid_to_index.hpp index 7433cfdd4..e05485f8b 100644 --- a/include/geode/model/mixin/core/detail/uuid_to_index.hpp +++ b/include/geode/model/mixin/core/detail/uuid_to_index.hpp @@ -78,6 +78,8 @@ namespace geode { for( auto& it : uuid2index_ ) { + DEBUG( old2new.size() ); + DEBUG( it.second ); const auto new_index = old2new[it.second]; OpenGeodeModelException::check_assertion( new_index != NO_ID, diff --git a/include/geode/model/mixin/core/relationships.hpp b/include/geode/model/mixin/core/relationships.hpp index 3dfa505f2..f968c4f14 100644 --- a/include/geode/model/mixin/core/relationships.hpp +++ b/include/geode/model/mixin/core/relationships.hpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -357,6 +358,7 @@ namespace geode public: Relationships(); + Relationships( BITSERY ); ~Relationships(); [[nodiscard]] index_t nb_components_with_relations() const; diff --git a/include/geode/model/mixin/core/topology.hpp b/include/geode/model/mixin/core/topology.hpp index b58fc4143..3c3ebbde1 100644 --- a/include/geode/model/mixin/core/topology.hpp +++ b/include/geode/model/mixin/core/topology.hpp @@ -46,6 +46,12 @@ namespace geode public Relationships, public VertexIdentifier { + public: + Topology( BITSERY bitsery ) + : Relationships{ bitsery }, VertexIdentifier{ bitsery } + { + } + protected: Topology() = default; Topology( Topology&& other ) = default; diff --git a/include/geode/model/mixin/core/vertex_identifier.hpp b/include/geode/model/mixin/core/vertex_identifier.hpp index cf1d425f2..2381e989a 100644 --- a/include/geode/model/mixin/core/vertex_identifier.hpp +++ b/include/geode/model/mixin/core/vertex_identifier.hpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -93,6 +94,7 @@ namespace geode public: VertexIdentifier(); + VertexIdentifier( BITSERY ); ~VertexIdentifier(); [[nodiscard]] index_t nb_unique_vertices() const; diff --git a/include/geode/model/representation/core/brep.hpp b/include/geode/model/representation/core/brep.hpp index fc35cc931..0cd7e89f3 100644 --- a/include/geode/model/representation/core/brep.hpp +++ b/include/geode/model/representation/core/brep.hpp @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -388,6 +389,7 @@ namespace geode public: BRep(); + BRep( BITSERY ); BRep( BRep&& brep ) noexcept; BRep& operator=( BRep&& brep ); ~BRep(); diff --git a/include/geode/model/representation/core/section.hpp b/include/geode/model/representation/core/section.hpp index 012583a8a..c6d5b6be4 100644 --- a/include/geode/model/representation/core/section.hpp +++ b/include/geode/model/representation/core/section.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include @@ -286,6 +287,7 @@ namespace geode public: Section(); + Section( BITSERY ); Section( Section&& section ) noexcept; Section& operator=( Section&& section ); ~Section(); diff --git a/include/geode/model/representation/io/geode/geode_brep_input.hpp b/include/geode/model/representation/io/geode/geode_brep_input.hpp index b258a684d..8e06466da 100644 --- a/include/geode/model/representation/io/geode/geode_brep_input.hpp +++ b/include/geode/model/representation/io/geode/geode_brep_input.hpp @@ -74,7 +74,7 @@ namespace geode BRepBuilder builder{ brep }; DEBUG( "BRepBuilder done" ); const auto level = Logger::level(); - Logger::set_level( Logger::LEVEL::warn ); + // Logger::set_level( Logger::LEVEL::trace ); DEBUG( "load_identifier" ); builder.load_identifier( directory ); DEBUG( "load_corners" ); diff --git a/include/geode/model/representation/io/geode/geode_section_input.hpp b/include/geode/model/representation/io/geode/geode_section_input.hpp index 6780c119a..994423a18 100644 --- a/include/geode/model/representation/io/geode/geode_section_input.hpp +++ b/include/geode/model/representation/io/geode/geode_section_input.hpp @@ -71,38 +71,49 @@ namespace geode { SectionBuilder builder{ section }; const auto level = Logger::level(); - Logger::set_level( Logger::LEVEL::warn ); - async::parallel_invoke( - [&builder, &directory] { - builder.load_identifier( directory ); - }, - [&builder, &directory] { - builder.load_corners( directory ); - }, - [&builder, &directory] { - builder.load_lines( directory ); - }, - [&builder, &directory] { - builder.load_surfaces( directory ); - }, - [&builder, &directory] { - builder.load_model_boundaries( directory ); - }, - [&builder, &directory] { - builder.load_corner_collections( directory ); - }, - [&builder, &directory] { - builder.load_line_collections( directory ); - }, - [&builder, &directory] { - builder.load_surface_collections( directory ); - }, - [&builder, &directory] { - builder.load_relationships( directory ); - }, - [&builder, &directory] { - builder.load_unique_vertices( directory ); - } ); + // Logger::set_level( Logger::LEVEL::warn ); + // async::parallel_invoke( + // [&builder, &directory] { + // builder.load_identifier( directory ); + // }, + // [&builder, &directory] { + // builder.load_corners( directory ); + // }, + // [&builder, &directory] { + // builder.load_lines( directory ); + // }, + // [&builder, &directory] { + // builder.load_surfaces( directory ); + // }, + // [&builder, &directory] { + // builder.load_model_boundaries( directory ); + // }, + // [&builder, &directory] { + // builder.load_corner_collections( directory ); + // }, + // [&builder, &directory] { + // builder.load_line_collections( directory ); + // }, + // [&builder, &directory] { + // builder.load_surface_collections( directory ); + // }, + // [&builder, &directory] { + // builder.load_relationships( directory ); + // }, + // [&builder, &directory] { + // builder.load_unique_vertices( directory ); + // } ); + builder.load_identifier( directory ); + builder.load_corners( directory ); + builder.load_lines( directory ); + builder.load_surfaces( directory ); + builder.load_model_boundaries( directory ); + builder.load_corner_collections( directory ); + builder.load_line_collections( directory ); + builder.load_surface_collections( directory ); + DEBUG( "load_relationships" ); + builder.load_relationships( directory ); + builder.load_unique_vertices( directory ); Logger::set_level( level ); detail::register_all_components( section ); detail::filter_unsupported_components( section ); diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 5e4b69541..095afb14a 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -60,6 +60,8 @@ namespace geode const uuid &attribute_id, const AttributeBase::AttributeKey &key ) { + DEBUG( "register_attribute" ); + DEBUG( nb_elements_ ); attribute->resize( nb_elements_, key ); attributes_.emplace( attribute_id, attribute ); } @@ -224,6 +226,11 @@ namespace geode return nb_elements_; } + std::optional< std::string_view > attribute_name( const uuid &id ) const + { + return attributes_.at( id )->name().value_or( "unknown" ); + } + std::optional< std::vector< uuid > > attribute_ids_with_name( std::string_view name ) const { @@ -374,6 +381,8 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive &local_archive, Impl &impl ) { + DEBUG( "AttributeManager::serialize" ); + DEBUG( impl.nb_elements_ ); local_archive.value4b( impl.nb_elements_ ); absl::linked_hash_map< std::string, std::shared_ptr< AttributeBase > > @@ -416,6 +425,8 @@ namespace geode } }, []( Archive &local_archive, Impl &impl ) { + DEBUG( "AttributeManager::serialize" ); + DEBUG( impl.nb_elements_ ); local_archive.value4b( impl.nb_elements_ ); local_archive.ext( impl.attributes_, bitsery::ext::StdMap{ @@ -593,6 +604,12 @@ namespace geode return impl_->attribute_ids_with_name( name ); } + std::optional< std::string_view > AttributeManager::attribute_name( + const uuid &id ) const + { + return impl_->attribute_name( id ); + } + void AttributeManager::import( const AttributeManager &attribute_manager, absl::Span< const index_t > old2new ) { diff --git a/src/geode/mesh/builder/graph_builder.cpp b/src/geode/mesh/builder/graph_builder.cpp index 42b24a468..7662e023d 100644 --- a/src/geode/mesh/builder/graph_builder.cpp +++ b/src/geode/mesh/builder/graph_builder.cpp @@ -239,6 +239,7 @@ namespace geode void GraphBuilder::copy( const Graph& graph ) { + DEBUG( "GraphBuilder::copy" ); OpenGeodeMeshException::check_exception( graph_.nb_vertices() == 0 && graph_.nb_edges() == 0, nullptr, OpenGeodeException::TYPE::data, diff --git a/src/geode/mesh/core/edged_curve.cpp b/src/geode/mesh/core/edged_curve.cpp index 267bab09d..cf6008c46 100644 --- a/src/geode/mesh/core/edged_curve.cpp +++ b/src/geode/mesh/core/edged_curve.cpp @@ -67,6 +67,11 @@ namespace geode template < index_t dimension > EdgedCurve< dimension >::EdgedCurve() = default; + template < index_t dimension > + EdgedCurve< dimension >::EdgedCurve( BITSERY bitsery ) : Graph{ bitsery } + { + } + template < index_t dimension > EdgedCurve< dimension >::EdgedCurve( EdgedCurve&& ) noexcept = default; diff --git a/src/geode/mesh/core/geode/geode_edged_curve.cpp b/src/geode/mesh/core/geode/geode_edged_curve.cpp index a6672901e..ae4e8a3a8 100644 --- a/src/geode/mesh/core/geode/geode_edged_curve.cpp +++ b/src/geode/mesh/core/geode/geode_edged_curve.cpp @@ -50,15 +50,9 @@ namespace geode mesh ); } - Impl( OpenGeodeEdgedCurve< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< OpenGeodeEdgedCurve< dimension > >( - mesh ); - } - - private: Impl() = default; + private: template < typename Archive > void serialize( Archive& serializer ) { @@ -80,7 +74,7 @@ namespace geode template < index_t dimension > OpenGeodeEdgedCurve< dimension >::OpenGeodeEdgedCurve( BITSERY bitsery ) - : impl_( *this, bitsery ) + : EdgedCurve< dimension >{ bitsery } { } @@ -119,40 +113,30 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeEdgedCurve >{ { []( Archive& archive, OpenGeodeEdgedCurve& edged_curve ) { + archive.ext( edged_curve, + bitsery::ext::BaseClass< EdgedCurve< dimension > >{} ); + archive.object( edged_curve.impl_ ); const auto new_point_attribute_id = edged_curve.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( edged_curve, - bitsery::ext::BaseClass< EdgedCurve< dimension > >{} ); - archive.object( edged_curve.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - edged_curve.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, edged_curve.nb_vertices() ); detail::template initialize_crs< OpenGeodeEdgedCurve< dimension > >( edged_curve, new_point_attribute_id ); }, []( Archive& archive, OpenGeodeEdgedCurve& edged_curve ) { + archive.ext( + edged_curve, bitsery::ext::BaseClass< + EdgedCurve< dimension > >{} ); + archive.object( edged_curve.impl_ ); const auto new_point_attribute_id = edged_curve.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - edged_curve, bitsery::ext::BaseClass< - EdgedCurve< dimension > >{} ); - archive.object( edged_curve.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - edged_curve.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, edged_curve.nb_vertices() ); detail::template initialize_crs< OpenGeodeEdgedCurve< dimension > >( edged_curve, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_graph.cpp b/src/geode/mesh/core/geode/geode_graph.cpp index 829832add..d8a74c8f4 100644 --- a/src/geode/mesh/core/geode/geode_graph.cpp +++ b/src/geode/mesh/core/geode/geode_graph.cpp @@ -39,11 +39,9 @@ namespace geode public: explicit Impl( OpenGeodeGraph& mesh ) : internal::EdgesImpl( mesh ) {} - Impl( BITSERY ) {} - - private: Impl() = default; + private: template < typename Archive > void serialize( Archive& serializer ) { @@ -58,7 +56,7 @@ namespace geode OpenGeodeGraph::OpenGeodeGraph() : impl_( *this ) {} - OpenGeodeGraph::OpenGeodeGraph( BITSERY bitsery ) : impl_( bitsery ) {} + OpenGeodeGraph::OpenGeodeGraph( BITSERY bitsery ) : Graph{ bitsery } {} OpenGeodeGraph::OpenGeodeGraph( OpenGeodeGraph&& ) noexcept = default; diff --git a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp index 09db1577d..eb9daa975 100644 --- a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp @@ -107,11 +107,7 @@ namespace geode polyhedron_adjacent_ptr_.emplace_back( 0 ); } - Impl( OpenGeodeHybridSolid< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< - OpenGeodeHybridSolid< dimension > >( mesh ); - } + Impl() = default; index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -416,8 +412,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -478,7 +472,7 @@ namespace geode template < index_t dimension > OpenGeodeHybridSolid< dimension >::OpenGeodeHybridSolid( BITSERY bitsery ) - : HybridSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + : HybridSolid< dimension >{ bitsery } { } @@ -638,38 +632,29 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeHybridSolid >{ { []( Archive& archive, OpenGeodeHybridSolid& solid ) { + archive.ext( solid, bitsery::ext::BaseClass< + HybridSolid< dimension > >{} ); + archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( solid, bitsery::ext::BaseClass< - HybridSolid< dimension > >{} ); - archive.object( solid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( solid.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, solid.nb_vertices() ); detail::template initialize_crs< OpenGeodeHybridSolid< dimension > >( solid, new_point_attribute_id ); }, []( Archive& archive, OpenGeodeHybridSolid& solid ) { + archive.ext( solid, bitsery::ext::BaseClass< + HybridSolid< dimension > >{} ); + archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( solid, bitsery::ext::BaseClass< - HybridSolid< dimension > >{} ); - archive.object( solid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - solid.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, solid.nb_vertices() ); detail::template initialize_crs< OpenGeodeHybridSolid< dimension > >( solid, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index 23d1bcad9..a3790d065 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -47,13 +47,6 @@ namespace geode mesh ); } - Impl( OpenGeodePointSet< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< OpenGeodePointSet< dimension > >( - mesh ); - } - - private: Impl() = default; private: @@ -76,8 +69,7 @@ namespace geode } template < index_t dimension > - OpenGeodePointSet< dimension >::OpenGeodePointSet( BITSERY bitsery ) - : impl_( *this, bitsery ) + OpenGeodePointSet< dimension >::OpenGeodePointSet( BITSERY ) { } @@ -99,41 +91,29 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePointSet >{ { []( Archive& archive, OpenGeodePointSet& point_set ) { - DEBUG( "OpenGeodePointSet::serialize" ); + archive.ext( point_set, + bitsery::ext::BaseClass< PointSet< dimension > >{} ); + archive.object( point_set.impl_ ); const auto new_attribute_id = point_set.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( point_set, - bitsery::ext::BaseClass< PointSet< dimension > >{} ); - archive.object( point_set.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - point_set.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_attribute_id, point_set.nb_vertices() ); detail::template initialize_crs< OpenGeodePointSet< dimension > >( point_set, new_attribute_id ); }, []( Archive& archive, OpenGeodePointSet& point_set ) { - DEBUG( "OpenGeodePointSet::serialize" ); + archive.ext( point_set, bitsery::ext::BaseClass< + PointSet< dimension > >{} ); + archive.object( point_set.impl_ ); const auto new_attribute_id = point_set.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( point_set, bitsery::ext::BaseClass< - PointSet< dimension > >{} ); - archive.object( point_set.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - point_set.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_attribute_id, point_set.nb_vertices() ); detail::template initialize_crs< OpenGeodePointSet< dimension > >( point_set, new_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp index b9cd2ceab..bb8f6c620 100644 --- a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp +++ b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp @@ -52,11 +52,7 @@ namespace geode polygon_ptr_.emplace_back( 0 ); } - Impl( OpenGeodePolygonalSurface< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< - OpenGeodePolygonalSurface< dimension > >( mesh ); - } + Impl() = default; index_t get_polygon_vertex( const PolygonVertex& polygon_vertex ) const { @@ -188,8 +184,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -234,7 +228,7 @@ namespace geode template < index_t dimension > OpenGeodePolygonalSurface< dimension >::OpenGeodePolygonalSurface( BITSERY bitsery ) - : PolygonalSurface< dimension >{ bitsery }, impl_( *this, bitsery ) + : PolygonalSurface< dimension >{ bitsery } { } @@ -282,41 +276,31 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePolygonalSurface >{ { []( Archive& archive, OpenGeodePolygonalSurface& surface ) { + archive.ext( + surface, bitsery::ext::BaseClass< + PolygonalSurface< dimension > >{} ); + archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - surface, bitsery::ext::BaseClass< - PolygonalSurface< dimension > >{} ); - archive.object( surface.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - surface.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, surface.nb_vertices() ); detail::template initialize_crs< OpenGeodePolygonalSurface< dimension > >( surface, new_point_attribute_id ); }, []( Archive& archive, OpenGeodePolygonalSurface& surface ) { + archive.ext( + surface, bitsery::ext::BaseClass< + PolygonalSurface< dimension > >{} ); + archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - surface, bitsery::ext::BaseClass< - PolygonalSurface< dimension > >{} ); - archive.object( surface.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - surface.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, surface.nb_vertices() ); detail::template initialize_crs< OpenGeodePolygonalSurface< dimension > >( surface, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp index a24250117..2ec841ff2 100644 --- a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp @@ -52,11 +52,7 @@ namespace geode polyhedron_adjacent_ptr_.emplace_back( 0 ); } - Impl( OpenGeodePolyhedralSolid< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< - OpenGeodePolyhedralSolid< dimension > >( mesh ); - } + Impl() = default; index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -326,8 +322,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -422,7 +416,7 @@ namespace geode template < index_t dimension > OpenGeodePolyhedralSolid< dimension >::OpenGeodePolyhedralSolid( BITSERY bitsery ) - : PolyhedralSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + : PolyhedralSolid< dimension >{ bitsery } { } @@ -542,39 +536,30 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodePolyhedralSolid >{ { []( Archive& archive, OpenGeodePolyhedralSolid& solid ) { + archive.ext( solid, bitsery::ext::BaseClass< + PolyhedralSolid< dimension > >{} ); + archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( solid, bitsery::ext::BaseClass< - PolyhedralSolid< dimension > >{} ); - archive.object( solid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( solid.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, solid.nb_vertices() ); detail::template initialize_crs< OpenGeodePolyhedralSolid< dimension > >( solid, new_point_attribute_id ); }, []( Archive& archive, OpenGeodePolyhedralSolid& solid ) { + archive.ext( + solid, bitsery::ext::BaseClass< + PolyhedralSolid< dimension > >{} ); + archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - solid, bitsery::ext::BaseClass< - PolyhedralSolid< dimension > >{} ); - archive.object( solid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - solid.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, solid.nb_vertices() ); detail::template initialize_crs< OpenGeodePolyhedralSolid< dimension > >( solid, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp index a49cd2b1b..1c8d8603c 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp @@ -64,11 +64,7 @@ namespace geode mesh ); } - Impl( OpenGeodeRegularGrid< 3 >& mesh, BITSERY ) - { - detail::template initialize_crs< OpenGeodeRegularGrid< 3 > >( - mesh ); - } + Impl() = default; void update_origin( RegularGrid3D& grid, const Point3D& origin ) { @@ -131,8 +127,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -150,7 +144,7 @@ namespace geode OpenGeodeRegularGrid< 3 >::OpenGeodeRegularGrid() : impl_( *this ) {} OpenGeodeRegularGrid< 3 >::OpenGeodeRegularGrid( BITSERY bitsery ) - : RegularGrid< 3 >{ bitsery }, impl_( *this, bitsery ) + : RegularGrid< 3 >{ bitsery } { } @@ -224,37 +218,29 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeRegularGrid >{ { []( Archive& archive, OpenGeodeRegularGrid& grid ) { + archive.ext( + grid, bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); + archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< 3 >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - grid, bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); - archive.object( grid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< 3 > >( grid.vertex_attribute_manager(), - internal::PointsImpl< 3 >::POINTS_NAME, - new_point_attribute_id, grid.nb_vertices() ); detail::template initialize_crs< OpenGeodeRegularGrid< 3 > >( grid, new_point_attribute_id ); }, []( Archive& archive, OpenGeodeRegularGrid& grid ) { + archive.ext( grid, + bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); + archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< 3 >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( grid, - bitsery::ext::BaseClass< RegularGrid< 3 > >{} ); - archive.object( grid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< 3 > >( grid.vertex_attribute_manager(), - internal::PointsImpl< 3 >::POINTS_NAME, - new_point_attribute_id, grid.nb_vertices() ); detail::template initialize_crs< OpenGeodeRegularGrid< 3 > >( grid, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp index 3f75114d4..639a2aee5 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp @@ -59,11 +59,7 @@ namespace geode mesh ); } - Impl( OpenGeodeRegularGrid< 2 >& mesh, BITSERY ) - { - detail::template initialize_crs< OpenGeodeRegularGrid< 2 > >( - mesh ); - } + Impl() = default; void update_origin( RegularGrid2D& grid, const Point2D& origin ) { @@ -115,8 +111,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -134,7 +128,7 @@ namespace geode OpenGeodeRegularGrid< 2 >::OpenGeodeRegularGrid() : impl_( *this ) {} OpenGeodeRegularGrid< 2 >::OpenGeodeRegularGrid( BITSERY bitsery ) - : RegularGrid< 2 >{ bitsery }, impl_( *this, bitsery ) + : RegularGrid< 2 >{ bitsery } { } @@ -202,37 +196,29 @@ namespace geode serializer.ext( *this, Growable< Archive, OpenGeodeRegularGrid >{ { []( Archive& archive, OpenGeodeRegularGrid& grid ) { + archive.ext( + grid, bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); + archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< 2 >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - grid, bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); - archive.object( grid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< 2 > >( grid.vertex_attribute_manager(), - internal::PointsImpl< 2 >::POINTS_NAME, - new_point_attribute_id, grid.nb_vertices() ); detail::template initialize_crs< OpenGeodeRegularGrid< 2 > >( grid, new_point_attribute_id ); }, []( Archive& archive, OpenGeodeRegularGrid& grid ) { + archive.ext( grid, + bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); + archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< 2 >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( grid, - bitsery::ext::BaseClass< RegularGrid< 2 > >{} ); - archive.object( grid.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< 2 > >( grid.vertex_attribute_manager(), - internal::PointsImpl< 2 >::POINTS_NAME, - new_point_attribute_id, grid.nb_vertices() ); detail::template initialize_crs< OpenGeodeRegularGrid< 2 > >( grid, new_point_attribute_id ); diff --git a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp index 402c4fbac..97fc77078 100644 --- a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp @@ -73,11 +73,7 @@ namespace geode std::array< index_t, 4 > >( tetrahedron_adjacents_id ); } - Impl( OpenGeodeTetrahedralSolid< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< - OpenGeodeTetrahedralSolid< dimension > >( mesh ); - } + Impl() = default; index_t get_polyhedron_vertex( const PolyhedronVertex& polyhedron_vertex ) const @@ -138,8 +134,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -193,7 +187,7 @@ namespace geode template < index_t dimension > OpenGeodeTetrahedralSolid< dimension >::OpenGeodeTetrahedralSolid( BITSERY bitsery ) - : TetrahedralSolid< dimension >{ bitsery }, impl_( *this, bitsery ) + : TetrahedralSolid< dimension >{ bitsery } { } @@ -245,8 +239,31 @@ namespace geode solid, bitsery::ext::BaseClass< TetrahedralSolid< dimension > >{} ); archive.object( solid.impl_ ); - // solid.impl_->initialize_crs( solid ); + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + detail::template initialize_crs< + OpenGeodeTetrahedralSolid< dimension > >( + solid, new_point_attribute_id ); }, + []( Archive& archive, OpenGeodeTetrahedralSolid& solid ) { + archive.ext( + solid, bitsery::ext::BaseClass< + TetrahedralSolid< dimension > >{} ); + archive.object( solid.impl_ ); + const auto new_point_attribute_id = + solid.vertex_attribute_manager() + .attribute_ids_with_name( internal::PointsImpl< + dimension >::POINTS_NAME ) + .value() + .at( 0 ); + detail::template initialize_crs< + OpenGeodeTetrahedralSolid< dimension > >( + solid, new_point_attribute_id ); + }, []( Archive& archive, OpenGeodeTetrahedralSolid& solid ) { archive.ext( solid, bitsery::ext::BaseClass< diff --git a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp index 3f755858a..c134222d5 100644 --- a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp +++ b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp @@ -71,11 +71,7 @@ namespace geode std::array< index_t, 3 > >( triangle_adjacents_id ); } - Impl( OpenGeodeTriangulatedSurface< dimension >& mesh, BITSERY ) - { - detail::template initialize_crs< - OpenGeodeTriangulatedSurface< dimension > >( mesh ); - } + Impl() = default; index_t get_polygon_vertex( const PolygonVertex& polygon_vertex ) const { @@ -125,8 +121,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -178,7 +172,7 @@ namespace geode template < index_t dimension > OpenGeodeTriangulatedSurface< dimension >::OpenGeodeTriangulatedSurface( BITSERY bitsery ) - : TriangulatedSurface< dimension >{ bitsery }, impl_( *this, bitsery ) + : TriangulatedSurface< dimension >{ bitsery } { } @@ -219,42 +213,32 @@ namespace geode Growable< Archive, OpenGeodeTriangulatedSurface >{ { []( Archive& archive, OpenGeodeTriangulatedSurface& surface ) { + archive.ext( + surface, bitsery::ext::BaseClass< + TriangulatedSurface< dimension > >{} ); + archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - surface, bitsery::ext::BaseClass< - TriangulatedSurface< dimension > >{} ); - archive.object( surface.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - surface.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, surface.nb_vertices() ); detail::template initialize_crs< OpenGeodeTriangulatedSurface< dimension > >( surface, new_point_attribute_id ); }, []( Archive& archive, OpenGeodeTriangulatedSurface& surface ) { + archive.ext( + surface, bitsery::ext::BaseClass< + TriangulatedSurface< dimension > >{} ); + archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() .attribute_ids_with_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); - archive.ext( - surface, bitsery::ext::BaseClass< - TriangulatedSurface< dimension > >{} ); - archive.object( surface.impl_ ); - detail::import_old_attribute< VariableAttribute, - Point< dimension > >( - surface.vertex_attribute_manager(), - internal::PointsImpl< dimension >::POINTS_NAME, - new_point_attribute_id, surface.nb_vertices() ); detail::template initialize_crs< OpenGeodeTriangulatedSurface< dimension > >( surface, new_point_attribute_id ); diff --git a/src/geode/mesh/core/graph.cpp b/src/geode/mesh/core/graph.cpp index 9eb185190..ae3979036 100644 --- a/src/geode/mesh/core/graph.cpp +++ b/src/geode/mesh/core/graph.cpp @@ -48,6 +48,7 @@ namespace geode public: explicit Impl( Graph& graph ) { + DEBUG( "GRAPH IMPL" ); const auto attribute_id = graph.vertex_attribute_manager() .template create_attribute< VariableAttribute, @@ -59,6 +60,8 @@ namespace geode EdgesAroundVertex >( attribute_id ); } + Impl() = default; + AttributeManager& edge_attribute_manager() const { return edge_attribute_manager_; @@ -112,8 +115,6 @@ namespace geode } private: - Impl() = default; - template < typename Archive > void serialize( Archive& serializer ) { @@ -123,6 +124,7 @@ namespace geode archive.object( impl.edge_attribute_manager_ ); archive.ext( impl.edges_around_vertex_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "SERIALIZE GRAPH IMPL" ); const auto& old_edges_around_vertex_properties = impl.edges_around_vertex_->properties(); impl.edges_around_vertex_->set_properties( @@ -132,6 +134,7 @@ namespace geode false } ); }, []( Archive& archive, Impl& impl ) { + DEBUG( "SERIALIZE GRAPH IMPL" ); archive.object( impl.edge_attribute_manager_ ); archive.ext( impl.edges_around_vertex_, bitsery::ext::StdSmartPtr{} ); @@ -163,6 +166,8 @@ namespace geode Graph::Graph() : impl_( *this ) {} + Graph::Graph( BITSERY ) {} + Graph::Graph( Graph&& ) noexcept = default; Graph& Graph::operator=( Graph&& ) noexcept = default; @@ -282,8 +287,11 @@ namespace geode { serializer.ext( *this, Growable< Archive, Graph >{ { []( Archive& archive, Graph& graph ) { + DEBUG( "SERIALIZE GRAPH" ); archive.ext( graph, bitsery::ext::BaseClass< VertexSet >{} ); + DEBUG( "SERIALIZE GRAPH 2" ); archive.object( graph.impl_ ); + DEBUG( "SERIALIZE GRAPH 3" ); } } } ); } diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index 87ed3c7a8..e70f45a63 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -44,10 +44,11 @@ namespace geode RelationshipsImpl::RelationshipsImpl() : graph_{ Graph::create() } { DEBUG( "RelationshipsImpl::RelationshipsImpl" ); - geode::uuid new_id{}; - initialize_attributes( new_id ); + initialize_attributes(); } + RelationshipsImpl::RelationshipsImpl( BITSERY ) {} + index_t RelationshipsImpl::nb_components_with_relations() const { return graph_->nb_vertices(); @@ -113,6 +114,7 @@ namespace geode edges_to_delete[edge.edge_id] = true; } auto builder = GraphBuilder::create( *graph_ ); + DEBUG( graph_->nb_edges() ); builder->delete_edges( edges_to_delete ); const auto old2new = builder->delete_isolated_vertices( { index.value() } ); @@ -193,9 +195,16 @@ namespace geode void RelationshipsImpl::copy( const RelationshipsImpl& impl, const ModelCopyMapping& mapping ) { + DEBUG( impl.graph_->edge_attribute_manager() + .attribute_ids_with_name( "edges" ) + .value() + .size() ); graph_ = impl.graph_->clone(); - const auto attribute_id = impl.ids_->id(); - initialize_attributes( attribute_id ); + DEBUG( graph_->edge_attribute_manager() + .attribute_ids_with_name( "edges" ) + .value() + .size() ); + initialize_attributes(); std::vector< index_t > vertices_to_delete; for( const auto vertex_id : Range{ graph_->nb_vertices() } ) { @@ -240,20 +249,25 @@ namespace geode uuid2index_.update( old2new ); } - void RelationshipsImpl::initialize_attributes( const geode::uuid& id ) + void RelationshipsImpl::initialize_attributes() { - if( graph_->vertex_attribute_manager().attribute_exists( id ) ) + DEBUG( "initialize_attributes" ); + const auto ids = + graph_->vertex_attribute_manager().attribute_ids_with_name( + "id" ); + DEBUG( ids.has_value() ); + if( ids.has_value() ) { - DEBUG( "attribute do exists" ); - ids_ = - graph_->vertex_attribute_manager() - .find_attribute< VariableAttribute, ComponentID >( id ); + ids_ = graph_->vertex_attribute_manager() + .find_attribute< VariableAttribute, ComponentID >( + ids.value()[0] ); return; } - DEBUG( "initialize_attributes" ); - graph_->vertex_attribute_manager() - .create_attribute< VariableAttribute, ComponentID >( - "id", id, ComponentID{} ); + DEBUG( "create id attribute" ); + const auto id = + graph_->vertex_attribute_manager() + .create_attribute< VariableAttribute, ComponentID >( + "id", ComponentID{} ); ids_ = graph_->vertex_attribute_manager() .find_attribute< VariableAttribute, ComponentID >( id ); } @@ -290,6 +304,8 @@ namespace geode void RelationshipsImpl::delete_isolated_vertices() { + DEBUG( "delete_isolated_vertices" ); + DEBUG( graph_->nb_vertices() ); auto builder = GraphBuilder::create( *graph_ ); const auto old2new = builder->delete_isolated_vertices(); for( const auto v : Indices{ old2new } ) diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index b6578334c..0996e9576 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -60,10 +60,11 @@ namespace geode Impl() : RelationshipsImpl() { - geode::uuid relation_attribute_id; - initialize_relation_attribute( relation_attribute_id ); + initialize_relation_attribute(); } + Impl( BITSERY bitsery ) : RelationshipsImpl( bitsery ) {} + RelationType relation_type( const index_t edge_id ) const { return relation_type_->value( edge_id ); @@ -159,9 +160,9 @@ namespace geode void copy( const Impl& impl, const ModelCopyMapping& mapping ) { + DEBUG( "copy relationships" ); detail::RelationshipsImpl::copy( impl, mapping ); - const auto relation_attribute_id = impl.relation_type_->id(); - initialize_relation_attribute( relation_attribute_id ); + initialize_relation_attribute(); } void save( std::string_view directory ) const @@ -206,32 +207,49 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive& archive, Impl& impl ) { - OpenGeodeGraph graph; + DEBUG( "serialize relationships youpi" ); + OpenGeodeGraph graph{ BITSERY::constructor }; archive.object( graph ); + DEBUG( graph.nb_edges() ); + DEBUG( "serialize relationships youpi 2" ); archive.object( impl.uuid2index_ ); + DEBUG( "serialize relationships youpi 3" ); archive.ext( impl.relation_type_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "serialize relationships youpi 4" ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); - impl.graph_ = graph.clone(); - geode::uuid new_attribute_id; - DEBUG( "serialize" ); - SDEBUG( new_attribute_id ); - geode::uuid new_relation_id; - impl.initialize_attributes( new_attribute_id ); - impl.initialize_relation_attribute( new_relation_id ); + DEBUG( "serialize relationships youpi 5" ); + // impl.graph_ = graph.clone(); + impl.graph_ = std::make_unique< OpenGeodeGraph >( + std::move( graph ) ); + DEBUG( impl.graph_->nb_edges() ); + DEBUG( "serialize relationships youpi 6" ); + impl.initialize_attributes(); + DEBUG( "serialize relationships youpi 7" ); + impl.initialize_relation_attribute(); + DEBUG( "serialize relationships youpi 8" ); impl.delete_isolated_vertices(); + DEBUG( "serialize relationships youpi 9" ); }, []( Archive& archive, Impl& impl ) { + DEBUG( "serialize relationships a" ); + impl.graph_ = std::make_unique< OpenGeodeGraph >( + BITSERY::constructor ); archive.ext( impl.graph_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "serialize relationships b" ); archive.object( impl.uuid2index_ ); + DEBUG( "serialize relationships c" ); archive.ext( impl.relation_type_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "serialize relationships d" ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); + DEBUG( "serialize relationships e" ); impl.delete_isolated_vertices(); }, []( Archive& archive, Impl& impl ) { + DEBUG( "serialize relationships hihi" ); archive.ext( impl, bitsery::ext::BaseClass< detail::RelationshipsImpl >{} ); @@ -240,19 +258,25 @@ namespace geode } } } ); } - void initialize_relation_attribute( const geode::uuid& id ) + void initialize_relation_attribute() { - if( relation_attribute_manager().attribute_exists( id ) ) + const auto ids = + relation_attribute_manager().attribute_ids_with_name( + "relation_type" ); + if( ids.has_value() ) { + DEBUG( ids.value().size() ); relation_type_ = relation_attribute_manager() .find_attribute< VariableAttribute, RelationType >( - id ); + ids.value()[0] ); return; } - relation_attribute_manager() - .create_attribute< VariableAttribute, RelationType >( - "relation_type", id, NO_ID ); + DEBUG( "create relation_type attribute" ); + const auto id = + relation_attribute_manager() + .create_attribute< VariableAttribute, RelationType >( + "relation_type", NO_ID ); relation_type_ = relation_attribute_manager() .find_attribute< VariableAttribute, RelationType >( id ); @@ -284,6 +308,7 @@ namespace geode }; Relationships::Relationships() = default; + Relationships::Relationships( BITSERY bitsery ) : impl_{ bitsery } {} Relationships::Relationships( Relationships&& ) noexcept = default; Relationships& Relationships::operator=( Relationships&& ) noexcept = default; diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 2c1666cf6..189e45774 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -120,6 +120,8 @@ namespace geode unique_vertices_attribute_id ); } + Impl( BITSERY ) {} + index_t nb_unique_vertices() const { return unique_vertices_.nb_vertices(); @@ -496,6 +498,7 @@ namespace geode }; VertexIdentifier::VertexIdentifier() = default; + VertexIdentifier::VertexIdentifier( BITSERY bitsery ) : impl_{ bitsery } {} VertexIdentifier::VertexIdentifier( VertexIdentifier&& ) noexcept = default; VertexIdentifier& VertexIdentifier::operator=( diff --git a/src/geode/model/representation/core/brep.cpp b/src/geode/model/representation/core/brep.cpp index 6157f6456..7c2e2d14f 100644 --- a/src/geode/model/representation/core/brep.cpp +++ b/src/geode/model/representation/core/brep.cpp @@ -681,6 +681,8 @@ namespace geode BRep::BRep() = default; + BRep::BRep( BITSERY bitsery ) : Topology{ bitsery } {} + BRep::BRep( BRep&& brep ) noexcept : Topology{ std::move( brep ) }, Corners3D{ std::move( brep ) }, diff --git a/src/geode/model/representation/core/section.cpp b/src/geode/model/representation/core/section.cpp index b61973dbc..5e47abbc3 100644 --- a/src/geode/model/representation/core/section.cpp +++ b/src/geode/model/representation/core/section.cpp @@ -451,6 +451,8 @@ namespace geode Section::Section() = default; + Section::Section( BITSERY bitsery ) : Topology{ bitsery } {} + Section::Section( Section&& section ) noexcept : Topology{ std::move( section ) }, Corners2D{ std::move( section ) }, diff --git a/src/geode/model/representation/io/geode/geode_brep_input.cpp b/src/geode/model/representation/io/geode/geode_brep_input.cpp index aa612a366..ca1da282c 100644 --- a/src/geode/model/representation/io/geode/geode_brep_input.cpp +++ b/src/geode/model/representation/io/geode/geode_brep_input.cpp @@ -23,6 +23,7 @@ #include +#include #include #include @@ -43,7 +44,7 @@ namespace geode { const UnzipFile zip_reader{ filename(), uuid{}.string() }; zip_reader.extract_all(); - BRep brep; + BRep brep{ BITSERY::constructor }; detail::load_brep_files( brep, zip_reader.directory() ); return brep; } diff --git a/src/geode/model/representation/io/geode/geode_section_input.cpp b/src/geode/model/representation/io/geode/geode_section_input.cpp index 66a707c39..ecd25b4bb 100644 --- a/src/geode/model/representation/io/geode/geode_section_input.cpp +++ b/src/geode/model/representation/io/geode/geode_section_input.cpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -43,7 +44,7 @@ namespace geode { const UnzipFile zip_reader{ filename(), uuid{}.string() }; zip_reader.extract_all(); - Section section; + Section section{ BITSERY::constructor }; detail::load_section_files( section, zip_reader.directory() ); return section; } diff --git a/tests/basic/test-attribute.cpp b/tests/basic/test-attribute.cpp index a79b94c11..05cab2530 100644 --- a/tests/basic/test-attribute.cpp +++ b/tests/basic/test-attribute.cpp @@ -462,6 +462,18 @@ void test_attribute_types( geode::AttributeManager& manager, "Returned attribute type is not correct (should be undefined)" ); } +void test_attribute_names( geode::AttributeManager& manager, + const geode::uuid& bool_variable_attribute_id ) +{ + geode::OpenGeodeBasicException::test( + manager.find_attribute< geode::VariableAttribute, bool >( + bool_variable_attribute_id ) + ->name() + .value() + == "bool", + "Returned attribute name is not correct (should be bool)" ); +} + void test_number_of_attributes( geode::AttributeManager& manager, geode::index_t nb ) { @@ -541,6 +553,7 @@ void test_copy_manager( geode::AttributeManager& manager, manager2.reserve( 15 ); test_attribute_types( manager2, bool_variable_attribute_id ); test_number_of_attributes( manager2, 8 ); + test_attribute_names( manager2, bool_variable_attribute_id ); } void test_import_manager( geode::AttributeManager& manager, diff --git a/tests/data/backward_io/v17/v17.og_rgd3d b/tests/data/backward_io/v17/v17.og_rgd3d index 3463c24c39375cc89a5ebd3765fe72eb440a084e..430f74ee1ec77a47e98a51e4882a0382baadec85 100644 GIT binary patch delta 145 zcmZp9&eZapNr{PxnTe5+kqHPDSQr>s1XA)#lX6ny6H7{pGLuS6Qkf^)w8}6tY>sS| zRh&GBMU|U@fq|_cKQphSm~rw&7U9VcSXeecW=T#5s&UVGEHN=rf{|^arYR%C#&}y6 wQAS2~CML#t*IZ_Km+#z`{lvHVON;O1?qwZ7s#0&CsDl<}3iW1`!i}FkJQsT=}i%L=}m?twY zGG%1kY`MsmWpa$7DmNno16x6UW?o4#nb_vertices() == 4, "Backward EdgedCurve has wrong number of vertices" ); + geode::OpenGeodeMeshException::test( + curve->edges_around_vertex( 0 ).size() == 2, + "Backward EdgedCurve has wrong number of edges around vertex 0" ); } void test_edge_requests( const geode::EdgedCurve3D& edged_curve, diff --git a/tests/mesh/test-graph.cpp b/tests/mesh/test-graph.cpp index 7fd4ee7ac..976614bd2 100644 --- a/tests/mesh/test-graph.cpp +++ b/tests/mesh/test-graph.cpp @@ -168,9 +168,10 @@ void test() test_create_vertices( *graph, *builder ); test_create_edges( *graph, *builder ); test_io( *graph, absl::StrCat( "test.", graph->native_extension() ) ); - test_backward_io( absl::StrCat( - geode::DATA_PATH, "test_v7.", graph->native_extension() ) ); - + test_backward_io( absl::StrCat( geode::DATA_PATH, + "/backward_io/v7/test_v7.", graph->native_extension() ) ); + test_backward_io( absl::StrCat( geode::DATA_PATH, "/backward_io/v17/v17.", + graph->native_extension() ) ); test_delete_edge( *graph, *builder ); test_clone( *graph ); test_delete_isolated_vertices( *graph, *builder ); diff --git a/tests/mesh/test-hybrid-solid.cpp b/tests/mesh/test-hybrid-solid.cpp index 298c22f18..2b927fb01 100644 --- a/tests/mesh/test-hybrid-solid.cpp +++ b/tests/mesh/test-hybrid-solid.cpp @@ -416,25 +416,22 @@ void test_io( void test_backward_io( const std::string& filename ) { - DEBUG( "test_backward_io" ); const auto solid = geode::load_hybrid_solid< 3 >( filename ); geode::OpenGeodeMeshException::test( solid->nb_vertices() == 11, "Backward HybridSolid should have 11 vertices" ); - SDEBUG( solid->point( 0 ) ); + geode::OpenGeodeMeshException::test( + solid->point( 2 ) == geode::Point3D{ { 2, 1, 0 } }, + "Backward HybridSolid has wrong point coordinates" ); geode::OpenGeodeMeshException::test( solid->nb_polyhedra() == 4, "Backward HybridSolid should have 4 polyhedra" ); geode::OpenGeodeMeshException::test( solid->facets().nb_facets() == 16, "Backward HybridSolid should have 16 facets" ); geode::OpenGeodeMeshException::test( solid->edges().nb_edges() == 22, "Backward HybridSolid should have 22 edges" ); - DEBUG( solid->facets() - .facet_from_vertices( solid->polyhedron_facet_vertices( { 1, 0 } ) ) - .value() ); geode::OpenGeodeMeshException::test( solid->facets().facet_from_vertices( solid->polyhedron_facet_vertices( { 1, 0 } ) ) - == solid->facets().facet_from_vertices( - solid->polyhedron_facet_vertices( { 1, 0 } ) ), + == 6, "Backward HybridSolid has wrong polyhedron facet index" ); } @@ -487,23 +484,24 @@ void test() geode::OpenGeodeMeshLibrary::initialize(); auto hybrid_solid = geode::HybridSolid3D::create( geode::OpenGeodeHybridSolid3D::impl_name_static() ); - hybrid_solid->enable_edges(); - hybrid_solid->enable_facets(); - auto builder = geode::HybridSolidBuilder3D::create( *hybrid_solid ); + // hybrid_solid->enable_edges(); + // hybrid_solid->enable_facets(); + // auto builder = geode::HybridSolidBuilder3D::create( *hybrid_solid ); - test_create_vertices( *hybrid_solid, *builder ); - test_create_polyhedra( *hybrid_solid, *builder ); - test_edges( *hybrid_solid ); - test_facets( *hybrid_solid ); - test_polyhedron_adjacencies( *hybrid_solid, *builder ); - test_io( *hybrid_solid, - absl::StrCat( "test.", hybrid_solid->native_extension() ) ); + // test_create_vertices( *hybrid_solid, *builder ); + // test_create_polyhedra( *hybrid_solid, *builder ); + // test_edges( *hybrid_solid ); + // test_facets( *hybrid_solid ); + // test_polyhedron_adjacencies( *hybrid_solid, *builder ); + // test_io( *hybrid_solid, + // absl::StrCat( "test.", hybrid_solid->native_extension() ) ); test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", hybrid_solid->native_extension() ) ); - test_permutation( *hybrid_solid, *builder ); - test_delete_polyhedra( *hybrid_solid, *builder ); - test_clone( *hybrid_solid ); - test_delete_all( *hybrid_solid, *builder ); + DEBUG( "coucou" ); + // test_permutation( *hybrid_solid, *builder ); + // test_delete_polyhedra( *hybrid_solid, *builder ); + // test_clone( *hybrid_solid ); + // test_delete_all( *hybrid_solid, *builder ); } OPENGEODE_TEST( "hybrid-solid" ) diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index 421e0ea54..16321d057 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -180,6 +180,7 @@ void test() test_bounding_box( *point_set ); DEBUG( "test_create_vertex_attribute" ); const auto vertex_attribute_id = test_create_vertex_attribute( *point_set ); + DEBUG( "test_io" ); test_io( *point_set, absl::StrCat( "test.", point_set->native_extension() ) ); DEBUG( "test_backward_io" ); diff --git a/tests/mesh/test-regular-grid.cpp b/tests/mesh/test-regular-grid.cpp index 9523965ac..8fbc7fc77 100644 --- a/tests/mesh/test-regular-grid.cpp +++ b/tests/mesh/test-regular-grid.cpp @@ -457,6 +457,19 @@ void test_io( const geode::RegularGrid3D& grid, std::string_view filename ) "Wrong reload nb_cells_in_direction(2)" ); } +void test_backward_io( std::string_view filename ) +{ + const auto grid = geode::load_regular_grid< 3 >( filename ); + geode::OpenGeodeMeshException::test( + grid->nb_cells() == 750, "Wrong Backward grid nb_cells()" ); + geode::OpenGeodeMeshException::test( grid->nb_cells_in_direction( 0 ) == 5, + "Wrong Backward grid nb_cells_in_direction(0)" ); + geode::OpenGeodeMeshException::test( grid->nb_cells_in_direction( 1 ) == 10, + "Wrong Backward grid nb_cells_in_direction(1)" ); + geode::OpenGeodeMeshException::test( grid->nb_cells_in_direction( 2 ) == 15, + "Wrong Backward grid nb_cells_in_direction(2)" ); +} + void test_adjacencies2D() { auto grid = geode::RegularGrid2D::create(); @@ -541,14 +554,16 @@ void test() geode::Vector3D{ { 0, -3, 0 } } } ); test_grid( *grid ); - auto grid_v12 = geode::load_regular_grid< 3 >( - absl::StrCat( geode::DATA_PATH, "test_v12.og_rgd3d" ) ); + auto grid_v12 = + geode::load_regular_grid< 3 >( absl::StrCat( geode::DATA_PATH, + "backward_io/v12/test_v12.", grid->native_extension() ) ); auto builder_v12 = geode::RegularGridBuilder3D::create( *grid_v12 ); builder_v12->update_origin_and_directions( geode::Point3D{ { 1.5, 0, 1 } }, { geode::Vector3D{ { 0, 0, 1 } }, geode::Vector3D{ { -2, 0, 0 } }, geode::Vector3D{ { 0, -3, 0 } } } ); test_grid( *grid_v12 ); - + test_backward_io( absl::StrCat( + geode::DATA_PATH, "backward_io/v17/v17.", grid->native_extension() ) ); test_adjacencies2D(); } diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index aabd8b19d..9c1043d48 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -245,6 +245,11 @@ void test_backward_io( const std::string& filename ) "Backward TriangulatedSurface should have 5 vertices" ); geode::OpenGeodeMeshException::test( surface->nb_polygons() == 3, "Backward TriangulatedSurface should have 3 polygons" ); + SDEBUG( surface->point( 0 ) ); + geode::OpenGeodeMeshException::test( + surface->point( 0 ) == geode::Point3D{ { 0.1, 0.2, 0.3 } }, + "Backward TriangulatedSurface should have point ( 0.1, 0.2, 0.3 ) at " + "index 0" ); geode::OpenGeodeMeshException::test( surface->polygon_adjacent( { 0, 1 } ) == 1, "TriangulatedSurface adjacent index is not correct" ); diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index 0b8499797..5a64ba176 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -1189,6 +1189,7 @@ void test_compare_brep( const geode::BRep& model, const geode::BRep& model2 ) void test_clone( const geode::BRep& brep ) { + DEBUG( "test_clone" ); geode::BRep brep2; geode::BRepBuilder builder{ brep2 }; builder.copy( brep ); diff --git a/tests/model/test-ray-tracing-helpers.cpp b/tests/model/test-ray-tracing-helpers.cpp index b0bf42a28..8ba36af4f 100644 --- a/tests/model/test-ray-tracing-helpers.cpp +++ b/tests/model/test-ray-tracing-helpers.cpp @@ -65,6 +65,7 @@ void test() "Point [", outside.string(), "] should be outside the block." ); // load a section with various surfaces to test 2D + DEBUG( "Loading section" ); auto section = geode::load_section( absl::StrCat( geode::DATA_PATH, "fractures.og_sctn" ) ); geode::Point2D section_center{ { 230., 240. } }; diff --git a/tests/model/test-relationships.cpp b/tests/model/test-relationships.cpp index c24314e73..f5556c806 100644 --- a/tests/model/test-relationships.cpp +++ b/tests/model/test-relationships.cpp @@ -209,11 +209,15 @@ void test() add_boundary_relations( relationships, uuids ); add_internal_relations( relationships, uuids ); add_items_in_collections( relationships, uuids ); + DEBUG( "testing relationships" ); test_relations( relationships, uuids ); + DEBUG( "testing attributes" ); test_attributes( relationships, uuids ); - + DEBUG( "saving relationships" ); relationships.save_relationships( "." ); + DEBUG( "loading relationships" ); test_io( absl::StrCat( geode::DATA_PATH, "relationships_v12" ), uuids ); + DEBUG( "loading relationships 1" ); test_io( ".", uuids ); } From 19297f1b95ca4cdfb78419e25158b96f415368cc Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 19 Jun 2026 13:55:52 +0200 Subject: [PATCH 09/19] wip --- include/geode/basic/algorithm.hpp | 3 - include/geode/basic/attribute_manager.hpp | 3 - include/geode/basic/bitsery_archive.hpp | 4 - include/geode/basic/uuid.hpp | 2 - include/geode/basic/variable_attribute.hpp | 2 - .../geode/mesh/core/detail/facet_storage.hpp | 5 -- .../geode/mesh/core/internal/edges_impl.hpp | 5 -- .../geode/mesh/core/internal/points_impl.hpp | 6 -- .../helpers/detail/bitsery_mesh_helper.hpp | 6 -- .../mixin/core/detail/relationships_impl.hpp | 1 - .../model/mixin/core/detail/uuid_to_index.hpp | 2 - .../io/geode/geode_brep_input.hpp | 69 ++++++++-------- .../io/geode/geode_section_input.hpp | 75 ++++++++---------- src/geode/basic/attribute_manager.cpp | 43 ---------- src/geode/mesh/builder/graph_builder.cpp | 7 -- src/geode/mesh/builder/solid_mesh_builder.cpp | 8 -- src/geode/mesh/core/graph.cpp | 6 -- src/geode/mesh/core/point_set.cpp | 3 - src/geode/mesh/core/triangulated_surface.cpp | 6 -- .../mesh/helpers/gradient_computation.cpp | 4 - .../model/helpers/convert_brep_section.cpp | 4 - .../split_along_surface_mesh_borders.cpp | 1 - src/geode/model/helpers/ray_tracing.cpp | 5 -- .../mixin/core/detail/relationships_impl.cpp | 22 ----- src/geode/model/mixin/core/relationships.cpp | 23 +----- .../model/mixin/core/vertex_identifier.cpp | 6 -- tests/data/backward_io/v17/v17.og_brep | Bin 0 -> 24867 bytes tests/data/backward_io/v17/v17.og_sctn | Bin 0 -> 14643 bytes tests/mesh/test-point-set.cpp | 26 +----- tests/mesh/test-tetrahedral-solid.cpp | 3 - tests/model/test-brep.cpp | 33 ++++++-- tests/model/test-convert-brep.cpp | 1 - tests/model/test-relationships.cpp | 5 -- tests/model/test-section.cpp | 3 +- 34 files changed, 102 insertions(+), 290 deletions(-) create mode 100644 tests/data/backward_io/v17/v17.og_brep create mode 100644 tests/data/backward_io/v17/v17.og_sctn diff --git a/include/geode/basic/algorithm.hpp b/include/geode/basic/algorithm.hpp index 5f593c320..6bceb689a 100644 --- a/include/geode/basic/algorithm.hpp +++ b/include/geode/basic/algorithm.hpp @@ -56,9 +56,6 @@ namespace geode index_t delete_vector_elements( const DeleteContainer& to_delete, ValueContainer& values ) { - DEBUG( "delete_vector_elements" ); - DEBUG( to_delete.size() ); - DEBUG( values.size() ); if( values.empty() ) { exit( 1 ); diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 5aa409f68..37d96f243 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -125,9 +125,6 @@ namespace geode typed_attribute.reset( new Attribute< T >{ std::move( default_value ), attribute_name, std::move( properties ), {} } ); - DEBUG( "create_attribute" ); - SDEBUG( attribute_id ); - DEBUG( attribute_name ); IdentifierBuilder builder{ *typed_attribute }; builder.set_id( attribute_id ); register_attribute( typed_attribute, attribute_id ); diff --git a/include/geode/basic/bitsery_archive.hpp b/include/geode/basic/bitsery_archive.hpp index 9c604ca81..f0df3e790 100644 --- a/include/geode/basic/bitsery_archive.hpp +++ b/include/geode/basic/bitsery_archive.hpp @@ -95,10 +95,8 @@ namespace geode geode::uuid new_attribute_id, index_t attribute_size ) { - DEBUG( "import_old_attribute" ); const auto ids = manager.attribute_ids_with_name( old_attribute_name ).value(); - DEBUG( ids.size() ); geode::uuid old_attribute_id; for( const auto &id : ids ) { @@ -106,7 +104,6 @@ namespace geode { continue; } - DEBUG( "found old attribute " ); old_attribute_id = id; } auto old_attribute = @@ -120,7 +117,6 @@ namespace geode index, old_attribute->value( index ) ); } manager.delete_attribute( old_attribute_id ); - DEBUG( "import_old_attribute done" ); } } // namespace detail } // namespace geode diff --git a/include/geode/basic/uuid.hpp b/include/geode/basic/uuid.hpp index cb5d4fc30..4b0962455 100644 --- a/include/geode/basic/uuid.hpp +++ b/include/geode/basic/uuid.hpp @@ -68,7 +68,6 @@ namespace geode { serializer.ext( *this, Growable< Archive, uuid >{ { []( Archive &archive, uuid &id ) { - DEBUG( "uuid::serialize" ); uint64_t ab; uint64_t cd; archive.value8b( ab ); @@ -89,7 +88,6 @@ namespace geode id.bytes_[13] = ( cd >> 16 ) & 0xFF; id.bytes_[14] = ( cd >> 8 ) & 0xFF; id.bytes_[15] = ( cd >> 0 ) & 0xFF; - DEBUG( "uuid::serialize end" ); }, []( Archive &archive, uuid &id ) { archive.container1b( id.bytes_ ); diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index eb3fdf53e..72a881b70 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -420,9 +420,7 @@ namespace geode void delete_elements( const std::vector< bool >& to_delete, AttributeBase::AttributeKey /*key*/ ) override { - DEBUG( "delete_elements" ); delete_vector_elements( to_delete, values_ ); - DEBUG( "delete_elements OK" ); } void permute_elements( absl::Span< const index_t > permutation, diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index 72ded3129..37a855531 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -65,7 +65,6 @@ namespace geode facet_attribute_manager_ .create_attribute< VariableAttribute, index_t >( "counter", 1u, { false, false, false } ); - SDEBUG( counter_attribute_id ); counter_ = facet_attribute_manager_ .find_attribute< VariableAttribute, index_t >( counter_attribute_id ); @@ -74,7 +73,6 @@ namespace geode .create_attribute< VariableAttribute, VertexContainer >( "facet_vertices", VertexContainer{}, { false, false, false } ); - SDEBUG( vertices_attribute_id ); vertices_ = facet_attribute_manager_ .find_attribute< VariableAttribute, VertexContainer >( @@ -246,12 +244,9 @@ namespace geode { facet_attribute_manager_.copy( from.facet_attribute_manager() ); facet_indices_ = from.facet_indices_; - DEBUG( "overwrite" ); - SDEBUG( from.counter_->id() ); counter_ = facet_attribute_manager_ .find_attribute< VariableAttribute, index_t >( from.counter_->id() ); - SDEBUG( from.vertices_->id() ); vertices_ = facet_attribute_manager_ .find_attribute< VariableAttribute, VertexContainer >( diff --git a/include/geode/mesh/core/internal/edges_impl.hpp b/include/geode/mesh/core/internal/edges_impl.hpp index 5cab01370..e90e90c2d 100644 --- a/include/geode/mesh/core/internal/edges_impl.hpp +++ b/include/geode/mesh/core/internal/edges_impl.hpp @@ -41,7 +41,6 @@ namespace geode explicit EdgesImpl( Graph& graph ) : edges_() { - DEBUG( "EdgesImpl" ); const auto edge_attribute_id = graph.edge_attribute_manager() .template create_attribute< VariableAttribute, @@ -87,7 +86,6 @@ namespace geode serializer.ext( *this, Growable< Archive, EdgesImpl >{ { []( Archive& archive, EdgesImpl& impl ) { - DEBUG( "serialize EdgesIMPL" ); archive.ext( impl.edges_, bitsery::ext::StdSmartPtr{} ); const auto& old_edges_properties = @@ -96,13 +94,10 @@ namespace geode { old_edges_properties.assignable, old_edges_properties.interpolable, false } ); - DEBUG( "serialize EdgesIMPL end" ); }, []( Archive& archive, EdgesImpl& impl ) { - DEBUG( "serialize EdgesIMPL" ); archive.ext( impl.edges_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize EdgesIMPL end" ); } } } ); } diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index da2bd982a..69e244eaa 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -57,7 +57,6 @@ namespace geode PointsImpl( AttributeManager& manager, std::string_view attribute_name ) { - DEBUG( "PointsImpl" ); const auto attribute_id = manager.template create_attribute< VariableAttribute, Point< dimension > >( attribute_name, @@ -69,7 +68,6 @@ namespace geode PointsImpl( AttributeManager& manager, const geode::uuid& attribute_id ) { - DEBUG( "PointsImpl" ); points_ = manager.template find_attribute< VariableAttribute, Point< dimension > >( attribute_id ); } @@ -118,7 +116,6 @@ namespace geode serializer.ext( *this, Growable< Archive, PointsImpl >{ { []( Archive& archive, PointsImpl& impl ) { - DEBUG( "PointsImpl::serialize" ); archive.ext( impl.points_, bitsery::ext::StdSmartPtr{} ); if( !impl.points_ ) @@ -131,13 +128,10 @@ namespace geode { old_points_properties.assignable, old_points_properties.interpolable, false } ); - DEBUG( "PointsImpl::serialize end" ); }, []( Archive& archive, PointsImpl& impl ) { - DEBUG( "PointsImpl::serialize" ); archive.ext( impl.points_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "PointsImpl::serialize end" ); } } } ); } diff --git a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp index f1eb1f4f1..e8ceb80c4 100644 --- a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp +++ b/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp @@ -36,12 +36,10 @@ namespace geode template < typename Mesh > void initialize_crs( Mesh &mesh ) { - DEBUG( "initialize_crs" ); CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } .main_coordinate_reference_system_manager_builder() .delete_coordinate_reference_system( internal::PointsImpl< Mesh::dim >::POINTS_NAME ); - DEBUG( "delete_crs" ); auto crs_manager_builder = CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } .main_coordinate_reference_system_manager_builder(); @@ -52,16 +50,13 @@ namespace geode AttributeCoordinateReferenceSystem< Mesh::dim > >( mesh.vertex_attribute_manager(), internal::PointsImpl< Mesh::dim >::POINTS_NAME ) } ); - DEBUG( "register_crs" ); crs_manager_builder.set_active_coordinate_reference_system( internal::PointsImpl< Mesh::dim >::POINTS_NAME ); - DEBUG( "initialize_crs done" ); } template < typename Mesh > void initialize_crs( Mesh &mesh, const geode::uuid &attribute_id ) { - DEBUG( "initialize_crs" ); CoordinateReferenceSystemManagersBuilder< Mesh::dim >{ mesh } .main_coordinate_reference_system_manager_builder() .delete_coordinate_reference_system( @@ -77,7 +72,6 @@ namespace geode mesh.vertex_attribute_manager(), attribute_id ) } ); crs_manager_builder.set_active_coordinate_reference_system( internal::PointsImpl< Mesh::dim >::POINTS_NAME ); - DEBUG( "initialize_crs done" ); } } // namespace detail } // namespace geode diff --git a/include/geode/model/mixin/core/detail/relationships_impl.hpp b/include/geode/model/mixin/core/detail/relationships_impl.hpp index 0654f709d..9d5673876 100644 --- a/include/geode/model/mixin/core/detail/relationships_impl.hpp +++ b/include/geode/model/mixin/core/detail/relationships_impl.hpp @@ -108,7 +108,6 @@ namespace geode serializer.ext( *this, Growable< Archive, RelationshipsImpl >{ { []( Archive& archive, RelationshipsImpl& impl ) { - DEBUG( "serialize RelationshipsIMPL" ); impl.graph_ = std::make_unique< OpenGeodeGraph >( BITSERY::constructor ); archive.ext( diff --git a/include/geode/model/mixin/core/detail/uuid_to_index.hpp b/include/geode/model/mixin/core/detail/uuid_to_index.hpp index e05485f8b..7433cfdd4 100644 --- a/include/geode/model/mixin/core/detail/uuid_to_index.hpp +++ b/include/geode/model/mixin/core/detail/uuid_to_index.hpp @@ -78,8 +78,6 @@ namespace geode { for( auto& it : uuid2index_ ) { - DEBUG( old2new.size() ); - DEBUG( it.second ); const auto new_index = old2new[it.second]; OpenGeodeModelException::check_assertion( new_index != NO_ID, diff --git a/include/geode/model/representation/io/geode/geode_brep_input.hpp b/include/geode/model/representation/io/geode/geode_brep_input.hpp index 8e06466da..b77dd3084 100644 --- a/include/geode/model/representation/io/geode/geode_brep_input.hpp +++ b/include/geode/model/representation/io/geode/geode_brep_input.hpp @@ -69,42 +69,49 @@ namespace geode template < typename Model > void load_brep_files( Model& brep, std::string_view directory ) { - DEBUG( "load_brep_files" ); - DEBUG( "BRepBuilder" ); BRepBuilder builder{ brep }; - DEBUG( "BRepBuilder done" ); const auto level = Logger::level(); - // Logger::set_level( Logger::LEVEL::trace ); - DEBUG( "load_identifier" ); - builder.load_identifier( directory ); - DEBUG( "load_corners" ); - builder.load_corners( directory ); - DEBUG( "load_lines" ); - builder.load_lines( directory ); - DEBUG( "load_surfaces" ); - builder.load_surfaces( directory ); - DEBUG( "load_blocks" ); - builder.load_blocks( directory ); - DEBUG( "load_model_boundaries" ); - builder.load_model_boundaries( directory ); - DEBUG( "load_corner_collections" ); - builder.load_corner_collections( directory ); - DEBUG( "load_line_collections" ); - builder.load_line_collections( directory ); - DEBUG( "load_surface_collections" ); - builder.load_surface_collections( directory ); - DEBUG( "load_block_collections" ); - builder.load_block_collections( directory ); - DEBUG( "load_relationships" ); - builder.load_relationships( directory ); - DEBUG( "load_unique_vertices" ); - builder.load_unique_vertices( directory ); + Logger::set_level( Logger::LEVEL::warn ); + async::parallel_invoke( + [&builder, &directory] { + builder.load_identifier( directory ); + }, + [&builder, &directory] { + builder.load_corners( directory ); + }, + [&builder, &directory] { + builder.load_lines( directory ); + }, + [&builder, &directory] { + builder.load_surfaces( directory ); + }, + [&builder, &directory] { + builder.load_blocks( directory ); + }, + [&builder, &directory] { + builder.load_model_boundaries( directory ); + }, + [&builder, &directory] { + builder.load_corner_collections( directory ); + }, + [&builder, &directory] { + builder.load_line_collections( directory ); + }, + [&builder, &directory] { + builder.load_surface_collections( directory ); + }, + [&builder, &directory] { + builder.load_block_collections( directory ); + }, + [&builder, &directory] { + builder.load_relationships( directory ); + }, + [&builder, &directory] { + builder.load_unique_vertices( directory ); + } ); Logger::set_level( level ); - DEBUG( "register_all_components" ); detail::register_all_components( brep ); - DEBUG( "filter_unsupported_components" ); detail::filter_unsupported_components( brep ); - DEBUG( "load_brep_files done" ); } } // namespace detail } // namespace geode diff --git a/include/geode/model/representation/io/geode/geode_section_input.hpp b/include/geode/model/representation/io/geode/geode_section_input.hpp index 994423a18..6780c119a 100644 --- a/include/geode/model/representation/io/geode/geode_section_input.hpp +++ b/include/geode/model/representation/io/geode/geode_section_input.hpp @@ -71,49 +71,38 @@ namespace geode { SectionBuilder builder{ section }; const auto level = Logger::level(); - // Logger::set_level( Logger::LEVEL::warn ); - // async::parallel_invoke( - // [&builder, &directory] { - // builder.load_identifier( directory ); - // }, - // [&builder, &directory] { - // builder.load_corners( directory ); - // }, - // [&builder, &directory] { - // builder.load_lines( directory ); - // }, - // [&builder, &directory] { - // builder.load_surfaces( directory ); - // }, - // [&builder, &directory] { - // builder.load_model_boundaries( directory ); - // }, - // [&builder, &directory] { - // builder.load_corner_collections( directory ); - // }, - // [&builder, &directory] { - // builder.load_line_collections( directory ); - // }, - // [&builder, &directory] { - // builder.load_surface_collections( directory ); - // }, - // [&builder, &directory] { - // builder.load_relationships( directory ); - // }, - // [&builder, &directory] { - // builder.load_unique_vertices( directory ); - // } ); - builder.load_identifier( directory ); - builder.load_corners( directory ); - builder.load_lines( directory ); - builder.load_surfaces( directory ); - builder.load_model_boundaries( directory ); - builder.load_corner_collections( directory ); - builder.load_line_collections( directory ); - builder.load_surface_collections( directory ); - DEBUG( "load_relationships" ); - builder.load_relationships( directory ); - builder.load_unique_vertices( directory ); + Logger::set_level( Logger::LEVEL::warn ); + async::parallel_invoke( + [&builder, &directory] { + builder.load_identifier( directory ); + }, + [&builder, &directory] { + builder.load_corners( directory ); + }, + [&builder, &directory] { + builder.load_lines( directory ); + }, + [&builder, &directory] { + builder.load_surfaces( directory ); + }, + [&builder, &directory] { + builder.load_model_boundaries( directory ); + }, + [&builder, &directory] { + builder.load_corner_collections( directory ); + }, + [&builder, &directory] { + builder.load_line_collections( directory ); + }, + [&builder, &directory] { + builder.load_surface_collections( directory ); + }, + [&builder, &directory] { + builder.load_relationships( directory ); + }, + [&builder, &directory] { + builder.load_unique_vertices( directory ); + } ); Logger::set_level( level ); detail::register_all_components( section ); detail::filter_unsupported_components( section ); diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 095afb14a..947695a0c 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -60,8 +60,6 @@ namespace geode const uuid &attribute_id, const AttributeBase::AttributeKey &key ) { - DEBUG( "register_attribute" ); - DEBUG( nb_elements_ ); attribute->resize( nb_elements_, key ); attributes_.emplace( attribute_id, attribute ); } @@ -204,8 +202,6 @@ namespace geode { for( auto &attribute_it : attributes_ ) { - DEBUG( attribute_it.second->name().value_or( "unknown" ) ); - SDEBUG( attribute_it.second->id() ); attribute_it.second->delete_elements( to_delete, key ); } nb_elements_ -= @@ -234,11 +230,9 @@ namespace geode std::optional< std::vector< uuid > > attribute_ids_with_name( std::string_view name ) const { - DEBUG( "attribute_ids_with_name" ); std::vector< uuid > ids; for( const auto &[attribute_id, attribute] : attributes_ ) { - DEBUG( attribute->name().value_or( "unknown" ) ); if( attribute->name() == name ) { ids.push_back( attribute_id ); @@ -254,13 +248,11 @@ namespace geode void copy( const AttributeManager::Impl &attribute_manager, const AttributeBase::AttributeKey &key ) { - DEBUG( "copy attribute_manager" ); nb_elements_ = attribute_manager.nb_elements_; for( const auto &[attribute_id, attribute] : attribute_manager.attributes_ ) { const auto attribute_it = attributes_.find( attribute_id ); - SDEBUG( attribute_id ); if( attribute_it != attributes_.end() ) { try @@ -276,8 +268,6 @@ namespace geode } else { - DEBUG( "emplace" ); - SDEBUG( attribute_id ); attributes_.emplace( attribute_id, attribute->clone( key ) ); } @@ -289,7 +279,6 @@ namespace geode const T &old2new_mapping, const AttributeBase::AttributeKey &key ) { - DEBUG( "import" ); for( const auto &[attribute_id, attribute_from] : attribute_manager.attributes_ ) { @@ -309,9 +298,6 @@ namespace geode } else { - DEBUG( "import emplace" ); - SDEBUG( attribute_id ); - DEBUG( nb_elements_ ); attributes_.emplace( attribute_id, attribute_from->extract( old2new_mapping, nb_elements_, key ) ); @@ -325,7 +311,6 @@ namespace geode geode::uuid attribute_id, const AttributeBase::AttributeKey &key ) { - DEBUG( "import" ); auto it = attribute_manager.attributes_.find( attribute_id ); OpenGeodeBasicException::check_exception( it != attribute_manager.attributes_.end(), nullptr, @@ -355,9 +340,6 @@ namespace geode } else { - DEBUG( "import emplace" ); - SDEBUG( attribute_id ); - DEBUG( nb_elements_ ); attributes_.emplace( attribute_id, it->second->extract( old2new_mapping, nb_elements_, key ) ); } @@ -381,8 +363,6 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive &local_archive, Impl &impl ) { - DEBUG( "AttributeManager::serialize" ); - DEBUG( impl.nb_elements_ ); local_archive.value4b( impl.nb_elements_ ); absl::linked_hash_map< std::string, std::shared_ptr< AttributeBase > > @@ -410,23 +390,12 @@ namespace geode for( auto &[attribute_name, attribute] : old_map ) { IdentifierBuilder builder{ *attribute }; - DEBUG( attribute_name ); builder.set_name( attribute_name ); impl.attributes_.emplace( attribute->id(), std::move( attribute ) ); } - DEBUG( "AttributeManager::serialize" ); - for( const auto &[current_attribute_id, - current_attribute] : impl.attributes_ ) - { - DEBUG( current_attribute->name().value_or( - "unknown" ) ); - SDEBUG( current_attribute_id ); - } }, []( Archive &local_archive, Impl &impl ) { - DEBUG( "AttributeManager::serialize" ); - DEBUG( impl.nb_elements_ ); local_archive.value4b( impl.nb_elements_ ); local_archive.ext( impl.attributes_, bitsery::ext::StdMap{ @@ -453,14 +422,6 @@ namespace geode attribute->type() }; } } ); - DEBUG( "AttributeManager::serialize" ); - for( const auto &[current_attribute_id, - current_attribute] : impl.attributes_ ) - { - DEBUG( current_attribute->name().value_or( - "unknown" ) ); - SDEBUG( current_attribute_id ); - } } } } ); } @@ -568,18 +529,14 @@ namespace geode void AttributeManager::delete_elements( const std::vector< bool > &to_delete ) { - DEBUG( "delete_elements" ); if( absl::c_find( to_delete, true ) != to_delete.end() ) { - DEBUG( to_delete.size() ); - DEBUG( nb_elements() ); OpenGeodeBasicException::check_assertion( to_delete.size() == nb_elements(), "[AttributeManager::delete_elements] Vector to_delete should " "have the same size as the number of elements" ); impl_->delete_elements( to_delete, {} ); } - DEBUG( "delete_elements OK" ); } void AttributeManager::permute_elements( diff --git a/src/geode/mesh/builder/graph_builder.cpp b/src/geode/mesh/builder/graph_builder.cpp index 7662e023d..7c5413209 100644 --- a/src/geode/mesh/builder/graph_builder.cpp +++ b/src/geode/mesh/builder/graph_builder.cpp @@ -178,9 +178,7 @@ namespace geode return old2new; } update_edges_around( graph_, *this, old2new ); - DEBUG( "edge attribute manager" ); graph_.edge_attribute_manager().delete_elements( to_delete ); - DEBUG( "done" ); do_delete_edges( to_delete, old2new ); return old2new; } @@ -239,7 +237,6 @@ namespace geode void GraphBuilder::copy( const Graph& graph ) { - DEBUG( "GraphBuilder::copy" ); OpenGeodeMeshException::check_exception( graph_.nb_vertices() == 0 && graph_.nb_edges() == 0, nullptr, OpenGeodeException::TYPE::data, @@ -248,10 +245,6 @@ namespace geode VertexSetBuilder::copy( graph ); create_edges( graph.nb_edges() ); graph_.edge_attribute_manager().copy( graph.edge_attribute_manager() ); - // if( graph_.impl_name() == graph.impl_name() ) - // { - // do_copy_edges( graph ); - // } for( const auto e : Range{ graph.nb_edges() } ) { for( const auto v : LRange{ 2 } ) diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index 1b61e36a4..1b25101e8 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -963,18 +963,10 @@ namespace geode solid_mesh_.disable_facets(); } VertexSetBuilder::copy( solid_mesh ); - // if( solid_mesh.impl_name() == solid_mesh_.impl_name() ) - // { - // do_copy_points( solid_mesh ); - // do_copy_polyhedra( solid_mesh ); - // } copy_points( solid_mesh, *this ); - DEBUG( solid_mesh.impl_name().get() ); solid_mesh_.polyhedron_attribute_manager().copy( solid_mesh.polyhedron_attribute_manager() ); copy_polyhedra( solid_mesh, solid_mesh_, *this ); - // solid_mesh_.polyhedron_attribute_manager().copy( - // solid_mesh.polyhedron_attribute_manager() ); if( solid_mesh.are_edges_enabled() ) { solid_mesh_.copy_edges( solid_mesh, {} ); diff --git a/src/geode/mesh/core/graph.cpp b/src/geode/mesh/core/graph.cpp index ae3979036..943bae5aa 100644 --- a/src/geode/mesh/core/graph.cpp +++ b/src/geode/mesh/core/graph.cpp @@ -48,7 +48,6 @@ namespace geode public: explicit Impl( Graph& graph ) { - DEBUG( "GRAPH IMPL" ); const auto attribute_id = graph.vertex_attribute_manager() .template create_attribute< VariableAttribute, @@ -124,7 +123,6 @@ namespace geode archive.object( impl.edge_attribute_manager_ ); archive.ext( impl.edges_around_vertex_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "SERIALIZE GRAPH IMPL" ); const auto& old_edges_around_vertex_properties = impl.edges_around_vertex_->properties(); impl.edges_around_vertex_->set_properties( @@ -134,7 +132,6 @@ namespace geode false } ); }, []( Archive& archive, Impl& impl ) { - DEBUG( "SERIALIZE GRAPH IMPL" ); archive.object( impl.edge_attribute_manager_ ); archive.ext( impl.edges_around_vertex_, bitsery::ext::StdSmartPtr{} ); @@ -287,11 +284,8 @@ namespace geode { serializer.ext( *this, Growable< Archive, Graph >{ { []( Archive& archive, Graph& graph ) { - DEBUG( "SERIALIZE GRAPH" ); archive.ext( graph, bitsery::ext::BaseClass< VertexSet >{} ); - DEBUG( "SERIALIZE GRAPH 2" ); archive.object( graph.impl_ ); - DEBUG( "SERIALIZE GRAPH 3" ); } } } ); } diff --git a/src/geode/mesh/core/point_set.cpp b/src/geode/mesh/core/point_set.cpp index d60b23d84..e7368243f 100644 --- a/src/geode/mesh/core/point_set.cpp +++ b/src/geode/mesh/core/point_set.cpp @@ -65,15 +65,12 @@ namespace geode point_set, bitsery::ext::BaseClass< VertexSet >{} ); }, []( Archive& archive, PointSet& point_set ) { - DEBUG( "PointSet::serialize" ); archive.ext( point_set, bitsery::ext::BaseClass< VertexSet >{} ); - DEBUG( "PointSet::serialize 2" ); archive.ext( point_set, bitsery::ext::BaseClass< CoordinateReferenceSystemManagers< dimension > >{} ); - DEBUG( "PointSet::serialize 3" ); } } } ); } diff --git a/src/geode/mesh/core/triangulated_surface.cpp b/src/geode/mesh/core/triangulated_surface.cpp index c47b76d7e..723fcd2f2 100644 --- a/src/geode/mesh/core/triangulated_surface.cpp +++ b/src/geode/mesh/core/triangulated_surface.cpp @@ -67,13 +67,7 @@ namespace geode std::unique_ptr< TriangulatedSurface< dimension > > TriangulatedSurface< dimension >::clone() const { - DEBUG( "CLONE" ); auto clone = create( this->impl_name() ); - DEBUG( "clone" ); - for( const auto vertex : geode::Range{ clone->nb_vertices() } ) - { - SDEBUG( clone->point( vertex ) ); - } auto builder = TriangulatedSurfaceBuilder< dimension >::create( *clone ); builder->copy_identifier( *this ); diff --git a/src/geode/mesh/helpers/gradient_computation.cpp b/src/geode/mesh/helpers/gradient_computation.cpp index f9ca920e4..dfdf6f508 100644 --- a/src/geode/mesh/helpers/gradient_computation.cpp +++ b/src/geode/mesh/helpers/gradient_computation.cpp @@ -96,10 +96,6 @@ namespace void initialize_attribute_and_id( const geode::uuid& scalar_function_id ) { - DEBUG( "initialize_attribute_and_id" ); - SDEBUG( scalar_function_id ); - DEBUG( mesh_.vertex_attribute_manager().attribute_exists( - scalar_function_id ) ); geode::OpenGeodeMeshException::check_exception( mesh_.vertex_attribute_manager().attribute_exists( scalar_function_id ), diff --git a/src/geode/model/helpers/convert_brep_section.cpp b/src/geode/model/helpers/convert_brep_section.cpp index c202f5c82..2cd67cc99 100644 --- a/src/geode/model/helpers/convert_brep_section.cpp +++ b/src/geode/model/helpers/convert_brep_section.cpp @@ -62,9 +62,7 @@ namespace mappings[geode::Line< dimension >::component_type_static()] ); geode::detail::copy_surface_components( from, builder_to, mappings[geode::Surface< dimension >::component_type_static()] ); - DEBUG( "copy relationships" ); builder_to.copy_relationships( mappings, from ); - DEBUG( "copy relationships ok" ); return mappings; } @@ -483,10 +481,8 @@ namespace geode { Section section; SectionBuilder builder{ section }; - DEBUG( "copy components" ); auto mappings = copy_components< BRep, SectionBuilder >( brep, builder ); - DEBUG( "copy components ok" ); for( const auto& corner : brep.corners() ) { builder.update_corner_mesh( diff --git a/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp b/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp index edf55cb24..6cdc5b69f 100644 --- a/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp +++ b/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp @@ -126,7 +126,6 @@ namespace geode .get(); } ) .get(); - DEBUG( "end of split" ); return mapping; } diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index b8b5d6659..b21f44d86 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -159,7 +159,6 @@ namespace geode bool is_point_inside_surface( const Point2D& point, const Surface2D& surface ) { - DEBUG( "is_point_inside_surface" ); for( const auto& direction : ::directions_2D() ) { const Ray2D ray{ direction, point }; @@ -167,7 +166,6 @@ namespace geode bool could_determine{ true }; for( const auto& line : section_.boundaries( surface ) ) { - SDEBUG( line.id() ); auto intersections = count_real_intersections_with_boundary( ray, line.mesh(), line_aabb( line ) ); if( !intersections.has_value() ) @@ -190,10 +188,8 @@ namespace geode std::optional< uuid > surface_containing_point( const Point2D& point ) { - SDEBUG( point ); for( const auto& surface : section_.surfaces() ) { - SDEBUG( surface.id() ); if( is_point_inside_surface( point, surface ) ) { return surface.id(); @@ -268,7 +264,6 @@ namespace geode bool could_determine{ true }; for( const auto& surface : brep_.boundaries( block ) ) { - SDEBUG( surface.id() ); auto intersections = count_real_intersections_with_boundaries( ray, surface.mesh(), surface_aabb( surface ) ); diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index e70f45a63..aa58d0a0a 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -43,7 +43,6 @@ namespace geode { RelationshipsImpl::RelationshipsImpl() : graph_{ Graph::create() } { - DEBUG( "RelationshipsImpl::RelationshipsImpl" ); initialize_attributes(); } @@ -100,7 +99,6 @@ namespace geode void RelationshipsImpl::remove_component( const uuid& component_id ) { - DEBUG( "remove_component" ); const auto index = vertex_id( component_id ); if( !index ) { @@ -114,12 +112,10 @@ namespace geode edges_to_delete[edge.edge_id] = true; } auto builder = GraphBuilder::create( *graph_ ); - DEBUG( graph_->nb_edges() ); builder->delete_edges( edges_to_delete ); const auto old2new = builder->delete_isolated_vertices( { index.value() } ); uuid2index_.update( old2new ); - DEBUG( "remove_component done" ); } index_t RelationshipsImpl::add_relation_edge( @@ -195,15 +191,7 @@ namespace geode void RelationshipsImpl::copy( const RelationshipsImpl& impl, const ModelCopyMapping& mapping ) { - DEBUG( impl.graph_->edge_attribute_manager() - .attribute_ids_with_name( "edges" ) - .value() - .size() ); graph_ = impl.graph_->clone(); - DEBUG( graph_->edge_attribute_manager() - .attribute_ids_with_name( "edges" ) - .value() - .size() ); initialize_attributes(); std::vector< index_t > vertices_to_delete; for( const auto vertex_id : Range{ graph_->nb_vertices() } ) @@ -228,7 +216,6 @@ namespace geode { return; } - DEBUG( graph_->nb_edges() ); std::vector< bool > edges_to_delete( graph_->nb_edges(), false ); for( const auto vertex_id : vertices_to_delete ) { @@ -239,23 +226,17 @@ namespace geode } } auto builder = GraphBuilder::create( *graph_ ); - DEBUG( "delete edges" ); builder->delete_edges( edges_to_delete ); - DEBUG( "delete edges ok" ); - DEBUG( "delete vertices" ); const auto old2new = builder->delete_isolated_vertices( vertices_to_delete ); - DEBUG( "delete vertices ok" ); uuid2index_.update( old2new ); } void RelationshipsImpl::initialize_attributes() { - DEBUG( "initialize_attributes" ); const auto ids = graph_->vertex_attribute_manager().attribute_ids_with_name( "id" ); - DEBUG( ids.has_value() ); if( ids.has_value() ) { ids_ = graph_->vertex_attribute_manager() @@ -263,7 +244,6 @@ namespace geode ids.value()[0] ); return; } - DEBUG( "create id attribute" ); const auto id = graph_->vertex_attribute_manager() .create_attribute< VariableAttribute, ComponentID >( @@ -304,8 +284,6 @@ namespace geode void RelationshipsImpl::delete_isolated_vertices() { - DEBUG( "delete_isolated_vertices" ); - DEBUG( graph_->nb_vertices() ); auto builder = GraphBuilder::create( *graph_ ); const auto old2new = builder->delete_isolated_vertices(); for( const auto v : Indices{ old2new } ) diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index 0996e9576..10d30beda 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -160,7 +160,6 @@ namespace geode void copy( const Impl& impl, const ModelCopyMapping& mapping ) { - DEBUG( "copy relationships" ); detail::RelationshipsImpl::copy( impl, mapping ); initialize_relation_attribute(); } @@ -207,49 +206,31 @@ namespace geode serializer.ext( *this, Growable< Archive, Impl >{ { []( Archive& archive, Impl& impl ) { - DEBUG( "serialize relationships youpi" ); OpenGeodeGraph graph{ BITSERY::constructor }; archive.object( graph ); - DEBUG( graph.nb_edges() ); - DEBUG( "serialize relationships youpi 2" ); archive.object( impl.uuid2index_ ); - DEBUG( "serialize relationships youpi 3" ); archive.ext( impl.relation_type_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize relationships youpi 4" ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize relationships youpi 5" ); - // impl.graph_ = graph.clone(); impl.graph_ = std::make_unique< OpenGeodeGraph >( std::move( graph ) ); - DEBUG( impl.graph_->nb_edges() ); - DEBUG( "serialize relationships youpi 6" ); impl.initialize_attributes(); - DEBUG( "serialize relationships youpi 7" ); impl.initialize_relation_attribute(); - DEBUG( "serialize relationships youpi 8" ); impl.delete_isolated_vertices(); - DEBUG( "serialize relationships youpi 9" ); }, []( Archive& archive, Impl& impl ) { - DEBUG( "serialize relationships a" ); impl.graph_ = std::make_unique< OpenGeodeGraph >( BITSERY::constructor ); archive.ext( impl.graph_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize relationships b" ); archive.object( impl.uuid2index_ ); - DEBUG( "serialize relationships c" ); archive.ext( impl.relation_type_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize relationships d" ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); - DEBUG( "serialize relationships e" ); impl.delete_isolated_vertices(); }, []( Archive& archive, Impl& impl ) { - DEBUG( "serialize relationships hihi" ); archive.ext( impl, bitsery::ext::BaseClass< detail::RelationshipsImpl >{} ); @@ -260,19 +241,17 @@ namespace geode void initialize_relation_attribute() { - const auto ids = + const auto ids = relation_attribute_manager().attribute_ids_with_name( "relation_type" ); if( ids.has_value() ) { - DEBUG( ids.value().size() ); relation_type_ = relation_attribute_manager() .find_attribute< VariableAttribute, RelationType >( ids.value()[0] ); return; } - DEBUG( "create relation_type attribute" ); const auto id = relation_attribute_manager() .create_attribute< VariableAttribute, RelationType >( diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 189e45774..adae22d5a 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -181,7 +181,6 @@ namespace geode template < typename MeshComponent > void register_component( const MeshComponent& component ) { - DEBUG( "register_component" ); auto it = vertex2unique_vertex_.find( component.id() ); const auto& mesh = component.mesh(); if( it == vertex2unique_vertex_.end() ) @@ -215,17 +214,14 @@ namespace geode } it->second = std::move( attribute ); } - DEBUG( " register_component done" ); } template < typename MeshComponent > void unregister_component( const MeshComponent& component ) { - DEBUG( "unregister_component" ); const auto& mesh = component.mesh(); auto attribute = vertex2unique_vertex_.at( component.id() ); const auto attribute_id = attribute->id(); - SDEBUG( attribute_id ); mesh.vertex_attribute_manager().delete_attribute( attribute_id ); vertex2unique_vertex_.erase( component.id() ); filter_component_vertices( component.id() ); @@ -330,13 +326,11 @@ namespace geode } if( need_to_delete ) { - DEBUG( "need to delete" ); component_vertices_->modify_value( uv, [&to_delete]( std::vector< ComponentMeshVertex >& vertices ) { delete_vector_elements( to_delete, vertices ); } ); - DEBUG( "end need to delete" ); } } ); } diff --git a/tests/data/backward_io/v17/v17.og_brep b/tests/data/backward_io/v17/v17.og_brep new file mode 100644 index 0000000000000000000000000000000000000000..e59f306129039bd48b839d101c5ad4abbc384ddc GIT binary patch literal 24867 zcmeHP36NaHd4An9vxm^Js}mj80ZI&lfjM?A6Pp!6T;dRyI0Rbecms=(~AF_4j}E-*5f8SbVP0)nyp>lwZ2Wu&){1Fw*q@{J~)}l`fgJdd^H{ z3e`%oP^g*7Qo2-6mh0JiJ=Ir9SMug5jq3-@S~XkaF~%9An|@S2)-lo;9Bz)qj@?im z9V}Od%+<~2=wM~MX|BhM?3t7o8SQ+`uHP5&&^PvrcTcy<$k;IEn6>N8v4QevV|=(a zu-P1Knm5Of^R;6wa;+AbHi$fSi-L+9R<8_0bk1P2#)k(#H*PKm@WHA%mhg9TaJXjP zJkYd(dJFsyT^s=}#yU7>+kd+0le@RPdha7op8oE-#ltKyM01d3o%E`Up|dO@I@Z11 z*Ol_(`by=28YW{ z^AfXej+(<&^U|$jP4gzq9-GB@Y^I#P9!ltC2Aj=zH;=7f*V$G7?W2DRY{I=h5Z884 zV`kG`ZHx|^qXX5((2!Ye4mO6z2sOlTOg5jq|D7|p{rmV=e#vI95!u$LT-1mddK!?` z2QkfJz)TGBWb@n4-MZ}i&(807J01cvpE%5% z4)k`^94d07Z~D*p67k{_A}omTG7(;mkkFe##ydqg zA4z

V2M5yB49CWFUCQbL4D5v~#8nFu??YsNe1KjU-7i+LiB2?!LAFMIfO?=#}6F00`Bz)JzE8E_@YVuPE%br$h6 zi($wjzj*rP8}6)6kAKHg;`Jvto%{GLpTF?~PrAd1y^!A6e*fiXeVAXo%2Q(RA3pro zqaVF=*Muki=XYQDi$>+T-kH8Oy>-{T51-ll;>Hc060hB1Zv0hd@}I8rm3Ze1s~+Ea z>+=sk?J4oE_dU4jyC+sB9`K~UdtYYB={v6(d&39m-=0d0Y<}eV4@g3Bjo{l)Eco#8 zE0#QZqOZjJ_dI)TGWqPQV~llPIzC!2SM6b+Y~K0gp0EGGihXZ<*8l46?WgY8_R7M1 z)&FYS6DMzf=(d;kyybs&|C3LB@E#+D{OtpKPYTQM z*zNn4)UF=i^ATe`UU@{;;)pEac^tWd%>?>7QjLW2%wu2u&92q2u6~rHgy0;1b??5V z>t0{=v-e5zvZuofX3xay_g;O%Ll0g5=S!n9z4_3uZvV@<8&c1ZP$x#z59ghof46by zy?=P*zX&UA>F9;cd+z-nD1#Vz5hESK3eq7!AssQwB1TyV%NS2cJ{Uj5 z7%#*aAH*1sg>+*a5aU`zH~Nbh{X~rZAx8fo^PoS7(GSFEKVq~SG1|9;ZnO_E+J_kJ zgS3S9Ax2-8(v5ba3}U3Ay?929XS5s7i1Cc};~6oY(GNT$#xweZXT*5Mg&6%pjD8_T zzmN|xp3y%%BgQlOiD$%kMt|{)7|-Z8o)P02{l_z6Jfpve(O<-IQla@YwoFoN#g~x5 zO58Q!NF6FsQ$R6IR?gj96bDCpBuvGzfFLrbl1$KZnN#snOplegYeGpX7<*Y%1Ycdq2wFjk<6)t8%(myspJ}9n3bq8PN2G#IN4P40oJ8VR5Ae;sVuJe zC02x$xNAZQZ$NcfT!~HsH*FJz5}L5+WKJdD0Q)3NB|>63CAwjch(Gwldth=anv+-uhgu=lk# zgfVb^+maOb%L@l)FchXTYMRlHfUbTKQcUuqExPQQP;<^YEyGTp1RLsDCwj$5lo3%k zC0bUoY5QvxBbpGOCaq%A=>anm`_Fwp!I2 z1M9grjSLa)VC9E^<8i_-KF_YpT~%VKuPVC|m-#lhFc*D^+ZHWq0O_M*jz!4r3F|mm z_8&V^83dc8M42FCi+>__KLWb?MJVtX(za#GRAgTuEvd?)Q)J+! z%&_rF{GGnP_&bAaYttqE&ZGe&GcPJm#0g#xS$KOH=&@+FctQUWgBNw^2&4bUODhM( zyaP*O?%Lrefb_V7m&9e17tE{z9nWPQwk^4PCKQ!ry&k>AZ5(#x^umK}n3~YpwfFDu zTZ&3?2REq&-ApGdsZ=gmNEPy>dNp4!6#ByGrai&|{t;vY5%H%E)>=@YK%11M|m6(F5GU7&n`i2ROUMq{c}377Je&EW0c&o;?$r z2aL^8dkO-RE;VVdjkX$MiuE}nsm=P*WbCt-lqNDJG`Qf5A#f!r(n?Cy$gnQ%ms7em zxY&mZfqRTqlX$ylpOTkqoCEPyN02{&z(D&JfF=5C zAPfiXC!0!%?bQJT?^^(t_^*L5fcL=9`KM&oV!Ck$BSVcOgb4AsSR=_dL!JlaQmR%> zm$Lc1&`6p>{3Y5(?ZeVNgz~S=umia0fiY|;Arj_$E{JT}r8v4*LNxmATvDc#Ic040 z2g|^RQh*MT=Q|FCdO%v5O%#I{AlxO|A_&I=1YzDwZY)H4hD_mE0_TsORtD3ot@QYd z>OwLR?_jZdwyLpQyOB0s$gQS#f2#~A>#9?K(EleoNZg-I;y$hGcuy}@@!7_*7qL!p z2e0CHh{b@UORpF#No!$>u8|9cy}hUWW@3wdI^AaS0cng5T(E{V#e}LDPz<^aX^OTe z^e@kR@0Qm-+Wfs2jo3UN51Eo@PD~#P3*_!C%5D~*CAOBNxdbV}DN|IZU+J6zIAuQU zY701JXKS^8V|eup^wZZ_WwM;shSq6f$1zg@rwnR}i%y>k7@vtm;-eCOS_0h zF{B<#;?bcqyMV_ zf)BbRK-aFlDs^Wxu65J$&CnPK6T5F~ze(Kha%@Nj>zIO4<+C)uqd>O;7NP0x?-lDWpi>T#~TB5dm zV)@Q!qPCO91)h%f=33C^yXHm5=Gfa?j%&Gl|J{|>4^!KM*IW?eVNj*EspVyJ{7}_K ze0=lYJc|zD4qjTV9JI2ux+oQ#S+L7fo4Fe zl=x3u2uQGnmH@(jU_y)Bev`{r#*WZ}`dwGp!nesZ$vbv-73+*d*_esEw@ZIKEDl;f z{buiN(GFTsB6K~KEM>BpWV)KIm(5(YKz5T*ZqqKSi6q`~Qf2H+u9_k_WrsoD_9_Sg z;!bNjol+2VZlg@97Pl!K(cC8LtoV-SUuV(WriIzG2+!DTGMDSi*NfSFx{@gi89KmY zxn0O6jh!|oDF;qEG~oF-K!DFc>j@V&8{KTG_H3ltl#cng%WUfRy!-rnyYkUy(=L)& zae@H8ZDXukZfiORFgxIGCp~xODSsDycA>Urd~`Ft(;RlRJsS&~HE$hl?=_*IqVJ(l zr68}Bw4iG4Ioh`tx)oIT=7d6(UO8Gx3##UkwtI^*qRdcG;g}N&Rl4M8B`v6$Kicjs zYD2bHL4{XNC{*c>qm{IvYTjs?ygE-og)dqtROyYTm9(G=Uo?pWYA<@Bg1RUQ>SB8< zUpoY2K`pQ)(j!kZ7<@uOrBjXJZC$3I`b-VW9jJ;l*D$xw|f}}I*+|gy{ z{LY1UoD|JCKS#!b2+z7w9@eM6WV&2Q^_7c7GhIy!&gs@$2$hX^$mUM$5Nz%Q>j;Nt z&#GPaP`PI(*NTjl^ywtXMP#cMehtDaLImhNtwo5?%`N5R*+!kjYt<56BdeA?Gy)7# zyF;#)5rSHWLo6%TpZ&>k&jD$12b0f#ru^{vzX@mj2PzG5$bXQ85b^`HPQ|EWlWdmj zLjZ1*!(`LR*KLE@su>!z^M3IlIMT?VC5MH$y~*(W;4}lEtgM)vK24(P06!BX)K39#cJ0Q4pktd zbbZJAr(`sXt>lhqeJpBAW9?U0eJz@;w9v=QWHFT?$BAm8RH#++rD{b8F-O-4Qc166 z3{$UM^V(rvsgL!wPapH2Abo1(+I`XbSc@6SB`djFA(<~0%lUk&N}un`glWiaS^kH_ zv4}{Y=hA0H`CZBxA(xGIX~_N=x#sI{4@A!htm8P$KUgD|?ZNt>IcgL7T@$ZElJLE7^-KmB85#(m(Vy+%G`)lxNCsTDGHvz8^-v1%x3Ze_NzIb3~K&C{x?RFZKRWG-;0#BWgtwBeLmawvx)`OND&7&?o#8KlY4} z3jwiraX9a!z;CBGi$gc-Iwmyn3DEQrjcZY2#K}LrGVkCTeQ_@4d~jC(JZM@C&=-vF z-i8O54s}O~mY<(pzs?O_|0XBCNn%|9KSX+kb(&V+vhmY>}4R-hl9hiY$KsNiP$OpLwHs@Kr+3liQM^po&7 zg74ID7kwW_ob-$uJpI_Vdjyu!7jHsFAnNeEw|)A#X=s8@`<|jN$aqd$`zA;~E{n6( zPU&s*p&JV~e1-G_tvE^R6ndFHgd>K;S4Kbgh;va+nH%Y|F!pw|uathy%00bXmWNJn zAWz@@Ila zAabAE3trz;bFZKW`$Jby)YhiA0)6WNdvn$W3|V!Cy;J8cqFa#NT{hPScR6y0!V6xv z=DFwWM`wr6S(H)QTZ3*FbMt~n&-2>|y`^>pFPAYu}!$9lo*qNN*r b?6MH>QL4-Ob#&mFt`+p#PTg#5z|;Q%cgHA| literal 0 HcmV?d00001 diff --git a/tests/data/backward_io/v17/v17.og_sctn b/tests/data/backward_io/v17/v17.og_sctn new file mode 100644 index 0000000000000000000000000000000000000000..511e2eb403f0474b1fa235f6eb6a9a4fe51ca230 GIT binary patch literal 14643 zcmeHOe~es39e*?X<8IsDwb%CALJ?e4p>;a%R$-MsmJ=R4o|&iB{Mjckm?mm8g(hVcdKg-;poa~v~_Ed4%QZ`SN)I#aYO zWBnDgVp$b)pqv>n3+Y11%vx5iubj{1GnxLg>RU$}lM{Uv&N*X@(+}Y=_~NNr^|Mp< znk($)WVLKh#8z#wnpLYbZVydPHmjwnNxNFB*jJ8D5)dZ{Kfu4~VJMP~dbKt=5pPE@ zf)9P?xCq>S7`^2Y^yn>vj3tQJJ+FTH<-I#rUiYQ<+;^sB^%{&NX#yR9XRMR{a>h-q zRRj;$>&;5FW=+}`*<*Iou9fYJw@*yk+dus6ai18?z; z1af{S@gPS-Up&t6t%V!FiY)-I#VvJZHldO*uhPa=T zvtoT5tk<6vjr#cZt@YZ(sMV}b)heS{S^LWP`nGi)w#t{;l@Yi5km$WdbUuGuW87V> z5Oh3Fa>RSxv08^poY*#$JBWkb#T*RG#a!YX%VI#@43bn;a(CU5vlX(qzzej_^Tye- zVKAh@7?eF+5Nco@u3Szxe(;U`H+0=*U7vG=k);H&BxF)97apx#k_;vnD!J?uc)E!Z zia3BF!udG`^eJsft=63tm_~$@9-r%_%N*P8MeQny~mYC9I)y4#o z+x_8&T|3vVSL}0}R^u|FU;M;aFLma;T8W>~CfvjIZH;=(u1%irsyIgd7)#OSv&X76 zyCQX1^3JcGb=-&6J^Gto#^M*y7di30H-E6letKy4L6RDWjS{5$#`@v+{cF$Dn|u(D z?1>#dwZquCs|}*(v1fMwHvRsuE%8A-_S9eAyZW5Fu07G$e&E5O{sXJ-{MF@cn3jL} zr`O)wxqJFlAH=}}L;pPfW0&68XoFBn+6VE}Hy^I7>#H4J)dq3=uJhuj-0{l&^rgd9 zsgfzrKJljmwM22rz3rdWremyY6Rp+w2535~xn06O|HQMu{?Vm7??{JrIP~p9yEcFK z(B%c%Q+~mfNIcmN@8iiK>&A+D;_qPD*SO@tH+R2z(F+G(B;g9~@rfs%fB7@1za2i0 zu^yKP?PxB&ZFu66k$)7PjOtYS{JvlQHFMvnxy-I?wS5*KaY~!yegM66#qX--AaJ8M zDb$VQ1u(vdHiW^KiSh(dz8huS(MhiUUL`)9ijuY_m5e7uiM?m=<)VCtD9=Pm8(jP$ z^c9DdH286%T#GWv@qzTDD7(?b7mE_x)8HqfObR&0$z`IhOVGqui1H*+o`EtU=pa=n znmR;zyeQv^GRe`z_ySS(poy;(#Y+Bn#-8ql;xx3NnF3q_K?08UvTCrE$ z8aoDmW0OI&@f|hVQA4V+FYp~TL>DrScGNefd_jCcu)fmYS08Z#@J9K;0M}(7d7yr z242*dA8O!14LqnpKWaR{g>g|QC^p~=SZ|v-0MSn4-W|$DVl=7pl|l!Z5?tAMYE$5z zc~_0o4P~h@a|y1@G{~0&DSeOm%bv>EVq#9C7CwO+vZpfSV1;Z{o(1^eH12CC>jQ>M zoXXPx$0fKjh*(P5sO+`iuj@K08!d#!ZB%v{k|IY}CRB)p=(%@?@*J?Pavg+BpJm4{xw9xS3`e71HI*Qo*j6rF`B__h*Zlbg>c;(t!!{6Vk=xR!8jy1hbB+ zW3IY*<7}c2&!E&F&Ywm=1QZ;Z%|lohgG|wCp>U!a9ui+B=Q&)BiL{3owkbg&D@8ek zxrJ@<;IK_FI+3IioUjcN;%RMtkp)Aeh5A`FF6P<=Mv;M#^>mEI)qAjkx_M`-Bmcc zER*Ay($oj(rKe5&5#CF;WxAnMq;y-bsLZj*so5EDAr>g&$VD+X1H~56uudkc>u56u z-Q-Posf@v5K^ld9lp!$KQpQs}0R^~m)om*vFL;BcX@+cK#w=ya8M9cl`?Kk+ZKX3p zo`SN8E-?X_tfN~Ue-7}Cv;6`Zpa@%h#PIy2o=sGyi#F$+vx%{QY+?+Y=SPYgqO*xJ zaGvsrb|r5P*u_e^P%K(@U-lTv;|`LH(?dH<%i}7CX+Ag~n#Xch_6;9L-KA-O+arYye}+RKiQ_(2H$K)Keae?4=(P0V9Dp>3Fq)5*j}2q!4`4 z^6uTCAPv^(;ZtIf((pk$hTvPM=u?meTjb$WnW!!eUw1gZ#R{K-G}sakpYk?)G<-|L z@hwyM6r{nHJK4$D{-3>sg~A)WjFIL&Z(0R1@7ewm9WN9IDt6v_+q{#^i$|Gv_ixX< zyA7@8T}4&Lu6ZB2`j*Yn=6yd+9bw;ub7ZAu@0AzKQf}f=s)f~>S`f!c*0}1SsfX!? zLZPV#?NlV8BZhvM0kPB*8VaE&U`}7}TYn$sf;V{I)F@)cOyyxF_OIjYQX~09Wtpk> zjyqSkC1I|hLymfLbkpz_H~$g~%ubjNHES+;krBwM$iNJ6tPx4D;TNccQDj)l`WW&PQ zpljimvM-C~h)UagU9&;el4g*6Q^}+5*`W0CP20qaXM?WoY+F*PqOv8kLEA>9vI0GG zLI)jnHZ0xg6$SVu+KcDlV$sO0iyCX??kr*oNNu~dB9wnKO0k+wZ5m8FI5N(CId zw*BgxCtr-V?R$tX$jQ34Jvfq4*;}^EHR9g+qCc4N`i2EFD(M^#!{)^^s&8OCbMX2j zy_f*r;LS2ad~BJ8a;{*ebA5fqe5GRbX9{8Q@w{aw28mcagKte{LJJq(!pua+?bZv? z@o|)zDy7Y$oz9wLrM_%>AWf->LOE1T&6V-tyM9ot1LYU~2WdzDV$aR1(=&|9v->|) zQ?bYlqsVg&KXCX!w3>R2LR}nOA=@&6TRO-hOgEH@W=W)2Wbo0ef)89!s0>dvub^)& zVTXcj2|E-o6AB+hwb#V4~8 z8l;w$(6ZA#3LkP3q4;E0LW2}p3ArB1`|DNsRz%@j>4rel4FzeiRZf=UCqqv!#j@iK zR_>81CTo_;V_7p>%9L`sVqw6}*l)Rtar8;RnZPlwV$^~1v8!SpI`ZO=qg70#G?h)u zvdU&Y*Jow>^7dHCaTMM@5`)M~3oFInJ0c!*n_7;)1LHJCeHQ_tDZ6 z?RchbvyjV=kpq-1k5!5`#cIx#fPf43bM=4Zk(d|t_BuzM&*@k6z|9$BHmyo6J&U2ly|9br9oapHH0A~Cz5dQ%BZE)O$aUKkC6>V=f zYSc%V@t+<1Bj|UsaWBdn!KPe^b6};1uYP#_9uIB|dGJHzS;~8a6S&9i2i5OWv`%gl z-Q^0KT-3E6{|NdSJMLw8#NnzMd|N;7B5!H<(d!4vt;>Jm^3dgvI=1%@pr4nv4)8;| z9U3BEQK!@X0raCwdCAW(AYU8kUM<3csI}Km%y7Kvv3C{SRCQ#hZPoRIk=8YNm97*A zu1VCc8$X45gxSh~(rLjAh|E#=(d)4a!c>m|kDTEK zt$q;QA#J7Txpg5FMTIne^ty-Aihdbgc@7lbC?D64UN^(73udhkTd+u{$3K8>7hCuH nFVgL{-4CssLfB4kJ-$WE@GR-bM!H@{&r13^ofO001*`r8T>{2k literal 0 HcmV?d00001 diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index 16321d057..e7cc4ee54 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -41,11 +41,8 @@ void test_create_vertices( const geode::PointSet3D& point_set, geode::PointSetBuilder3D& builder ) { - DEBUG( "first point" ); builder.create_point( geode::Point3D{ { 0.1, 0.2, 0.3 } } ); - DEBUG( "second point" ); builder.create_point( geode::Point3D{ { 2.1, 9.4, 6.7 } } ); - DEBUG( point_set.nb_vertices() ); geode::OpenGeodeMeshException::test( point_set.nb_vertices() == 2, "PointSet should have 2 vertices" ); builder.create_vertices( 2 ); @@ -113,17 +110,11 @@ void test_delete_vertex( void test_io( const geode::PointSet3D& point_set, std::string_view filename ) { - DEBUG( "test_io" ); geode::save_point_set( point_set, filename ); const auto reload = geode::load_point_set< 3 >( filename ); - SDEBUG( reload->point( 0 ) ); - SDEBUG( reload->point( 1 ) ); - SDEBUG( reload->point( 2 ) ); - SDEBUG( reload->point( 3 ) ); geode_unused( reload ); const auto point_set2 = geode::load_point_set< 3 >( geode::OpenGeodePointSet3D::impl_name_static(), filename ); - DEBUG( point_set.nb_vertices() ); for( const auto vertex_id : geode::Range{ point_set.nb_vertices() } ) { geode::OpenGeodeMeshException::test( @@ -137,10 +128,6 @@ void test_backward_io( std::string_view filename, const geode::uuid& attribute_id ) { const auto point_set = geode::load_point_set< 3 >( filename ); - SDEBUG( point_set->point( 0 ) ); - SDEBUG( point_set->point( 1 ) ); - SDEBUG( point_set->point( 2 ) ); - SDEBUG( point_set->point( 3 ) ); geode::OpenGeodeMeshException::test( point_set->nb_vertices() == 4, "PointSet should have 4 vertices" ); const geode::Point3D answer{ { 2.1, 9.4, 6.7 } }; @@ -169,27 +156,20 @@ void test_clone( void test() { geode::OpenGeodeMeshLibrary::initialize(); - DEBUG( "test_point_set" ); auto point_set = geode::PointSet3D::create( geode::OpenGeodePointSet3D::impl_name_static() ); - DEBUG( "builder" ); auto builder = geode::PointSetBuilder3D::create( *point_set ); - DEBUG( "test_create_vertices" ); test_create_vertices( *point_set, *builder ); - DEBUG( "bounding_box" ); test_bounding_box( *point_set ); - DEBUG( "test_create_vertex_attribute" ); const auto vertex_attribute_id = test_create_vertex_attribute( *point_set ); - DEBUG( "test_io" ); test_io( *point_set, absl::StrCat( "test.", point_set->native_extension() ) ); - DEBUG( "test_backward_io" ); test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", point_set->native_extension() ), vertex_attribute_id ); - // test_permutation( *point_set, *builder ); - // test_delete_vertex( *point_set, *builder ); - // test_clone( *point_set, vertex_attribute_id ); + test_permutation( *point_set, *builder ); + test_delete_vertex( *point_set, *builder ); + test_clone( *point_set, vertex_attribute_id ); } OPENGEODE_TEST( "point-set" ) \ No newline at end of file diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index bb2fe06ce..a5fe19129 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -325,7 +325,6 @@ void test_io( void test_backward_io( const std::string& filename ) { - DEBUG( "test_backward_io" ); const auto solid = geode::load_tetrahedral_solid< 3 >( filename ); geode::OpenGeodeMeshException::test( solid->nb_vertices() == 6, "Backward TetrahedralSolid should have 6 vertices" ); @@ -383,8 +382,6 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) "Error in facet attribute transfer during cloning" ); const auto from_vertices = solid.facets().facet_vertices( f ); const auto to_vertices = solid4.facets().facet_vertices( f ); - DEBUG( from_vertices.size() ); - DEBUG( to_vertices.size() ); for( const auto v : geode::Indices{ from_vertices } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index 5a64ba176..e58db87df 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -66,7 +66,6 @@ std::array< geode::uuid, 6 > add_corners( { uuids[c] = builder.add_corner(); builder.set_corner_name( uuids[c], absl::StrCat( "corner", c + 1 ) ); - SDEBUG( uuids[c] ); } const auto& temp_corner = model.corner( builder.add_corner( geode::OpenGeodePointSet3D::impl_name_static() ) ); @@ -164,11 +163,9 @@ geode::uuid add_block( const geode::BRep& model, geode::BRepBuilder& builder ) geode::detail::count_range_elements( model.blocks() ) == 1, message ); geode::OpenGeodeModelException::test( model.block( block_uuid ).name() == "block1", "Wrong Block name" ); - DEBUG( model.nb_active_blocks() ); geode::OpenGeodeModelException::test( model.nb_active_blocks() == 1, message ); builder.set_block_active( block_uuid, false ); - DEBUG( model.nb_active_blocks() ); geode::OpenGeodeModelException::test( model.nb_active_blocks() == 0, "BRep should have 0 active block" ); geode::OpenGeodeModelException::test( @@ -1189,7 +1186,6 @@ void test_compare_brep( const geode::BRep& model, const geode::BRep& model2 ) void test_clone( const geode::BRep& brep ) { - DEBUG( "test_clone" ); geode::BRep brep2; geode::BRepBuilder builder{ brep2 }; builder.copy( brep ); @@ -1492,19 +1488,42 @@ void test_backward_io() "mesh." ); } test_registry( brep, 4, 13, 17, 7, 1, 0, 0, 0, 0, 0, 0 ); - DEBUG( "test_backward_io OK" ); + auto brep_v17 = geode::load_brep( + absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.og_brep" ) ); + for( const auto& block : brep_v17.blocks() ) + { + geode::OpenGeodeModelException::test( block.id() == block.mesh().id(), + "[Backward_IO] Brep block should have the same uuid as its mesh." ); + } + for( const auto& surface : brep_v17.surfaces() ) + { + geode::OpenGeodeModelException::test( + surface.id() == surface.mesh().id(), + "[Backward_IO] Brep surface should have the same uuid as its " + "mesh." ); + } + for( const auto& line : brep_v17.lines() ) + { + geode::OpenGeodeModelException::test( line.id() == line.mesh().id(), + "[Backward_IO] Brep line should have the same uuid as its mesh." ); + } + for( const auto& corner : brep_v17.corners() ) + { + geode::OpenGeodeModelException::test( corner.id() == corner.mesh().id(), + "[Backward_IO] Brep corner should have the same uuid as its " + "mesh." ); + } + test_registry( brep_v17, 4, 6, 9, 5, 1, 5, 2, 2, 2, 1, 3 ); } void test_components_filter() { - DEBUG( "test_components_filter" ); const auto brep = geode::load_brep( absl::StrCat( geode::DATA_PATH, "structural_model.og_brep" ) ); geode::OpenGeodeModelException::test( brep.nb_components_with_relations() == 9, "Wrong number of components with relations, there are ", brep.nb_components_with_relations(), " instead of 9" ); - DEBUG( "test components filter OK" ); } std::tuple< geode::BRep, geode::ModelCopyMapping > copy_model( diff --git a/tests/model/test-convert-brep.cpp b/tests/model/test-convert-brep.cpp index 78e91c27b..b5b32aab2 100644 --- a/tests/model/test-convert-brep.cpp +++ b/tests/model/test-convert-brep.cpp @@ -44,7 +44,6 @@ void test_convert_brep_section() section.nb_lines() == 288, "Section should have 288 lines" ); geode::OpenGeodeModelException::test( section.nb_surfaces() == 117, "Section should have 117 surfaces" ); - DEBUG( "converting section into brep" ); const auto brep2 = std::get< 0 >( geode::convert_section_into_brep( section, 2, 10. ) ); diff --git a/tests/model/test-relationships.cpp b/tests/model/test-relationships.cpp index f5556c806..334c97547 100644 --- a/tests/model/test-relationships.cpp +++ b/tests/model/test-relationships.cpp @@ -209,15 +209,10 @@ void test() add_boundary_relations( relationships, uuids ); add_internal_relations( relationships, uuids ); add_items_in_collections( relationships, uuids ); - DEBUG( "testing relationships" ); test_relations( relationships, uuids ); - DEBUG( "testing attributes" ); test_attributes( relationships, uuids ); - DEBUG( "saving relationships" ); relationships.save_relationships( "." ); - DEBUG( "loading relationships" ); test_io( absl::StrCat( geode::DATA_PATH, "relationships_v12" ), uuids ); - DEBUG( "loading relationships 1" ); test_io( ".", uuids ); } diff --git a/tests/model/test-section.cpp b/tests/model/test-section.cpp index 8fa565e89..37b8e0bd0 100644 --- a/tests/model/test-section.cpp +++ b/tests/model/test-section.cpp @@ -1018,7 +1018,8 @@ void test() const auto file_io = absl::StrCat( "test.", model.native_extension() ); geode::save_section( model, file_io ); - + auto backward_model = geode::load_section( absl::StrCat( + geode::DATA_PATH, "backward_io/v17/v17.", model.native_extension() ) ); auto model2 = geode::load_section( file_io ); test_compare_section( model, model2 ); From 3f5977191ba83a59fe77f671395f2cb445fa7a0e Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 19 Jun 2026 14:16:56 +0200 Subject: [PATCH 10/19] clean --- include/geode/basic/algorithm.hpp | 4 - include/geode/basic/bitsery_archive.hpp | 36 -------- .../geode/mesh/core/internal/points_impl.hpp | 28 ------- ...ery_mesh_helper.hpp => initialize_crs.hpp} | 0 .../mesh/io/geode/geode_edged_curve_input.hpp | 56 ------------- .../mixin/core/detail/relationships_impl.hpp | 3 - src/geode/mesh/CMakeLists.txt | 2 +- .../mesh/builder/edged_curve_builder.cpp | 4 - src/geode/mesh/builder/point_set_builder.cpp | 4 - .../mesh/builder/surface_mesh_builder.cpp | 5 -- .../mesh/core/geode/geode_hybrid_solid.cpp | 2 +- src/geode/mesh/core/geode/geode_point_set.cpp | 2 +- .../core/geode/geode_polygonal_surface.cpp | 2 +- .../core/geode/geode_polyhedral_solid.cpp | 2 +- .../core/geode/geode_regular_grid_solid.cpp | 2 +- .../core/geode/geode_regular_grid_surface.cpp | 2 +- .../core/geode/geode_tetrahedral_solid.cpp | 2 +- .../core/geode/geode_triangulated_surface.cpp | 2 +- .../model/representation/io/brep_input.cpp | 82 ++++++++++--------- tests/common.hpp.in | 17 ++-- tests/mesh/test-edged-curve.cpp | 2 - .../test-geometrical-operations-on-mesh.cpp | 18 ---- tests/mesh/test-hybrid-solid.cpp | 29 ++++--- tests/model/test-ray-tracing-helpers.cpp | 2 - 24 files changed, 77 insertions(+), 231 deletions(-) rename include/geode/mesh/helpers/detail/{bitsery_mesh_helper.hpp => initialize_crs.hpp} (100%) diff --git a/include/geode/basic/algorithm.hpp b/include/geode/basic/algorithm.hpp index 6bceb689a..4afe92445 100644 --- a/include/geode/basic/algorithm.hpp +++ b/include/geode/basic/algorithm.hpp @@ -56,10 +56,6 @@ namespace geode index_t delete_vector_elements( const DeleteContainer& to_delete, ValueContainer& values ) { - if( values.empty() ) - { - exit( 1 ); - } OpenGeodeBasicException::check_assertion( to_delete.size() == values.size(), "[delete_vector_elements] Number of elements in the two vectors " diff --git a/include/geode/basic/bitsery_archive.hpp b/include/geode/basic/bitsery_archive.hpp index f0df3e790..40ffc3486 100644 --- a/include/geode/basic/bitsery_archive.hpp +++ b/include/geode/basic/bitsery_archive.hpp @@ -85,42 +85,6 @@ namespace geode }; } // namespace geode -namespace geode -{ - namespace detail - { - template < template < typename > class Attribute, typename T > - void import_old_attribute( AttributeManager &manager, - std::string_view old_attribute_name, - geode::uuid new_attribute_id, - index_t attribute_size ) - { - const auto ids = - manager.attribute_ids_with_name( old_attribute_name ).value(); - geode::uuid old_attribute_id; - for( const auto &id : ids ) - { - if( id == new_attribute_id ) - { - continue; - } - old_attribute_id = id; - } - auto old_attribute = - manager.read_attribute< T >( old_attribute_id ); - auto new_attribute = - manager.find_attribute< Attribute, T >( new_attribute_id ); - manager.resize( attribute_size ); - for( const auto index : geode::Range{ attribute_size } ) - { - new_attribute->set_value( - index, old_attribute->value( index ) ); - } - manager.delete_attribute( old_attribute_id ); - } - } // namespace detail -} // namespace geode - namespace bitsery { namespace traits diff --git a/include/geode/mesh/core/internal/points_impl.hpp b/include/geode/mesh/core/internal/points_impl.hpp index 69e244eaa..3262665fb 100644 --- a/include/geode/mesh/core/internal/points_impl.hpp +++ b/include/geode/mesh/core/internal/points_impl.hpp @@ -98,16 +98,6 @@ namespace geode return points_->id(); } - template < typename Mesh > - void initialize_crs( Mesh& mesh ) - { - CoordinateReferenceSystemManagersBuilder< dimension >{ mesh } - .main_coordinate_reference_system_manager_builder() - .delete_coordinate_reference_system( POINTS_NAME ); - register_as_active_crs( mesh ); - points_.reset(); - } - private: friend class bitsery::Access; template < typename Archive > @@ -135,24 +125,6 @@ namespace geode } } } ); } - template < typename Mesh > - void register_as_active_crs( Mesh& mesh ) - { - auto crs_manager_builder = - CoordinateReferenceSystemManagersBuilder< dimension >{ - mesh - } - .main_coordinate_reference_system_manager_builder(); - crs_manager_builder.register_coordinate_reference_system( - POINTS_NAME, - std::shared_ptr< CoordinateReferenceSystem< dimension > >{ - std::make_shared< - AttributeCoordinateReferenceSystem< dimension > >( - mesh.vertex_attribute_manager(), "points" ) } ); - crs_manager_builder.set_active_coordinate_reference_system( - POINTS_NAME ); - } - private: std::shared_ptr< VariableAttribute< Point< dimension > > > points_; }; diff --git a/include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp b/include/geode/mesh/helpers/detail/initialize_crs.hpp similarity index 100% rename from include/geode/mesh/helpers/detail/bitsery_mesh_helper.hpp rename to include/geode/mesh/helpers/detail/initialize_crs.hpp diff --git a/include/geode/mesh/io/geode/geode_edged_curve_input.hpp b/include/geode/mesh/io/geode/geode_edged_curve_input.hpp index fe4ecdfa4..bedf88969 100644 --- a/include/geode/mesh/io/geode/geode_edged_curve_input.hpp +++ b/include/geode/mesh/io/geode/geode_edged_curve_input.hpp @@ -30,60 +30,4 @@ namespace geode { BITSERY_INPUT_MESH_DIMENSION( EdgedCurve ); - - // template < index_t dimension > - // class OpenGeodeEdgedCurveInput : public EdgedCurveInput< dimension > - // { - // public: - // explicit OpenGeodeEdgedCurveInput( std::string_view filename ) - // : EdgedCurveInput< dimension >( filename ) - // { - // } - - // [[nodiscard]] AdditionalFiles additional_files() const final - // { - // return {}; - // } - - // [[nodiscard]] std::unique_ptr< EdgedCurve< dimension > > read( - // const MeshImpl& /*impl*/ ) final - // { - // std::ifstream file{ to_string( this->filename() ), - // std::ifstream::binary }; - // geode::OpenGeodeMeshException::check_exception( !file.fail(), - // nullptr, geode::OpenGeodeException::TYPE::data, - // "[Bitsery::read] Failed to open file: ", - // to_string( this->filename() ) ); - // TContext context{}; - // BitseryExtensions::register_deserialize_pcontext( - // std::get< 0 >( context ) ); - // Deserializer archive{ context, file }; - // // auto mesh = Mesh::create( impl ); - // std::unique_ptr< EdgedCurve< dimension > > mesh{ - // new OpenGeodeEdgedCurve< dimension >{ BITSERY::constructor } - // }; - // archive.object( - // dynamic_cast< OpenGeodeEdgedCurve< dimension >& >( *mesh ) ); - // const auto& adapter = archive.adapter(); - // geode::OpenGeodeMeshException::check_exception( - // adapter.error() == bitsery::ReaderError::NoError - // && adapter.isCompletedSuccessfully() - // && std::get< 1 >( context ).isValid(), - // nullptr, geode::OpenGeodeException::TYPE::internal, - // "[Bitsery::read] Error while reading file: ", - // this->filename() ); - // return mesh; - // } - - // index_t object_priority() const final - // { - // return 0; - // } - - // Percentage is_loadable() const final - // { - // return Percentage{ 1 }; - // } - // }; - // ALIAS_2D_AND_3D( OpenGeodeEdgedCurveInput ); } // namespace geode diff --git a/include/geode/model/mixin/core/detail/relationships_impl.hpp b/include/geode/model/mixin/core/detail/relationships_impl.hpp index 9d5673876..24e78ae26 100644 --- a/include/geode/model/mixin/core/detail/relationships_impl.hpp +++ b/include/geode/model/mixin/core/detail/relationships_impl.hpp @@ -115,7 +115,6 @@ namespace geode archive.object( impl.uuid2index_ ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); - impl.attribute_id_ = impl.ids_->id(); impl.delete_isolated_vertices(); }, []( Archive& archive, RelationshipsImpl& impl ) { @@ -124,7 +123,6 @@ namespace geode archive.object( impl.uuid2index_ ); archive.ext( impl.ids_, bitsery::ext::StdSmartPtr{} ); - archive.object( impl.attribute_id_ ); impl.delete_isolated_vertices(); } } } ); } @@ -143,7 +141,6 @@ namespace geode std::unique_ptr< Graph > graph_; detail::UuidToIndex uuid2index_; std::shared_ptr< VariableAttribute< ComponentID > > ids_; - geode::uuid attribute_id_; }; } // namespace detail } // namespace geode diff --git a/src/geode/mesh/CMakeLists.txt b/src/geode/mesh/CMakeLists.txt index 3c21a77b4..65c0a5e81 100644 --- a/src/geode/mesh/CMakeLists.txt +++ b/src/geode/mesh/CMakeLists.txt @@ -326,7 +326,7 @@ add_geode_library( "helpers/detail/surface_merger.hpp" "helpers/detail/surface_mesh_validity_fix.hpp" "helpers/detail/vertex_merger.hpp" - "helpers/detail/bitsery_mesh_helper.hpp" + "helpers/detail/initialize_crs.hpp" INTERNAL_HEADERS "core/internal/edges_impl.hpp" "core/internal/facet_edges_impl.hpp" diff --git a/src/geode/mesh/builder/edged_curve_builder.cpp b/src/geode/mesh/builder/edged_curve_builder.cpp index 89a1e5639..ce880405d 100644 --- a/src/geode/mesh/builder/edged_curve_builder.cpp +++ b/src/geode/mesh/builder/edged_curve_builder.cpp @@ -67,10 +67,6 @@ namespace geode "[EdgedCurveBuilder::copy] Cannot copy a mesh into an already " "initialized mesh." ); GraphBuilder::copy( edged_curve ); - // if( edged_curve_.impl_name() == edged_curve.impl_name() ) - // { - // do_copy_points( edged_curve ); - // } for( const auto p : Range{ edged_curve.nb_vertices() } ) { this->set_point( p, edged_curve.point( p ) ); diff --git a/src/geode/mesh/builder/point_set_builder.cpp b/src/geode/mesh/builder/point_set_builder.cpp index 59da047d8..385d952bd 100644 --- a/src/geode/mesh/builder/point_set_builder.cpp +++ b/src/geode/mesh/builder/point_set_builder.cpp @@ -65,10 +65,6 @@ namespace geode "[PointSetBuilder::copy] Cannot copy a mesh into an already " "initialized mesh." ); VertexSetBuilder::copy( point_set ); - // if( point_set_.impl_name() == point_set.impl_name() ) - // { - // do_copy_points( point_set ); - // } for( const auto p : Range{ point_set.nb_vertices() } ) { this->set_point( p, point_set.point( p ) ); diff --git a/src/geode/mesh/builder/surface_mesh_builder.cpp b/src/geode/mesh/builder/surface_mesh_builder.cpp index e76fe5773..657a4a73c 100644 --- a/src/geode/mesh/builder/surface_mesh_builder.cpp +++ b/src/geode/mesh/builder/surface_mesh_builder.cpp @@ -832,11 +832,6 @@ namespace geode surface_mesh_.disable_edges(); } VertexSetBuilder::copy( surface_mesh ); - // if( surface_mesh.impl_name() == surface_mesh_.impl_name() ) - // { - // do_copy_points( surface_mesh ); - // do_copy_polygons( surface_mesh ); - // } copy_polygons( surface_mesh, *this ); if( surface_mesh.are_edges_enabled() ) { diff --git a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp index eb9daa975..355301ab0 100644 --- a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include namespace { diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index a3790d065..af8827abc 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include namespace geode { diff --git a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp index bb8f6c620..d2b040dcd 100644 --- a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp +++ b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp @@ -34,7 +34,7 @@ #include -#include +#include namespace geode { diff --git a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp index 2ec841ff2..2f94bdae8 100644 --- a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include namespace geode { diff --git a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp index 1c8d8603c..78a2668fa 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include namespace { diff --git a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp index 639a2aee5..5818cda16 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include namespace { diff --git a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp index 97fc77078..aeedfc13d 100644 --- a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include namespace geode { diff --git a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp index c134222d5..bdc0f7849 100644 --- a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp +++ b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include namespace geode { diff --git a/src/geode/model/representation/io/brep_input.cpp b/src/geode/model/representation/io/brep_input.cpp index d64823322..5c901ff3b 100644 --- a/src/geode/model/representation/io/brep_input.cpp +++ b/src/geode/model/representation/io/brep_input.cpp @@ -39,36 +39,37 @@ namespace geode BRep load_brep( std::string_view filename ) { constexpr auto TYPE = "BRep"; - // try - // { - auto brep = detail::geode_object_input_impl< BRepInputFactory >( - TYPE, filename ); - auto message = absl::StrCat( TYPE, " has: " ); - detail::add_to_message( message, brep.nb_blocks(), " Blocks, " ); - detail::add_to_message( message, brep.nb_surfaces(), " Surfaces, " ); - detail::add_to_message( message, brep.nb_lines(), " Lines, " ); - detail::add_to_message( message, brep.nb_corners(), " Corners, " ); - detail::add_to_message( - message, brep.nb_model_boundaries(), " ModelBoundaries, " ); - detail::add_to_message( - message, brep.nb_corner_collections(), " CornerCollections, " ); - detail::add_to_message( - message, brep.nb_line_collections(), " LineCollections, " ); - detail::add_to_message( - message, brep.nb_surface_collections(), " SurfaceCollections, " ); - detail::add_to_message( - message, brep.nb_block_collections(), " BlockCollections" ); - Logger::info( message ); - return brep; - // } - // catch( const OpenGeodeException& e ) - // { - // Logger::error( e.what() ); - // print_available_extensions< BRepInputFactory >( TYPE ); - // throw OpenGeodeModelException{ nullptr, - // OpenGeodeException::TYPE::data, - // "Cannot load BRep from file: ", filename }; - // } + try + { + auto brep = detail::geode_object_input_impl< BRepInputFactory >( + TYPE, filename ); + auto message = absl::StrCat( TYPE, " has: " ); + detail::add_to_message( message, brep.nb_blocks(), " Blocks, " ); + detail::add_to_message( + message, brep.nb_surfaces(), " Surfaces, " ); + detail::add_to_message( message, brep.nb_lines(), " Lines, " ); + detail::add_to_message( message, brep.nb_corners(), " Corners, " ); + detail::add_to_message( + message, brep.nb_model_boundaries(), " ModelBoundaries, " ); + detail::add_to_message( + message, brep.nb_corner_collections(), " CornerCollections, " ); + detail::add_to_message( + message, brep.nb_line_collections(), " LineCollections, " ); + detail::add_to_message( message, brep.nb_surface_collections(), + " SurfaceCollections, " ); + detail::add_to_message( + message, brep.nb_block_collections(), " BlockCollections" ); + Logger::info( message ); + return brep; + } + catch( const OpenGeodeException& e ) + { + Logger::error( e.what() ); + print_available_extensions< BRepInputFactory >( TYPE ); + throw OpenGeodeModelException{ nullptr, + OpenGeodeException::TYPE::data, + "Cannot load BRep from file: ", filename }; + } } AdditionalFiles brep_additional_files( std::string_view filename ) @@ -80,16 +81,17 @@ namespace geode Percentage is_brep_loadable( std::string_view filename ) { - // try - // { - const auto input = - detail::geode_object_input_reader< BRepInputFactory >( filename ); - return input->is_loadable(); - // } - // catch( ... ) - // { - // return Percentage{ 0 }; - // } + try + { + const auto input = + detail::geode_object_input_reader< BRepInputFactory >( + filename ); + return input->is_loadable(); + } + catch( ... ) + { + return Percentage{ 0 }; + } } index_t brep_object_priority( std::string_view filename ) diff --git a/tests/common.hpp.in b/tests/common.hpp.in index 787bf04d9..e5fdbdf1b 100644 --- a/tests/common.hpp.in +++ b/tests/common.hpp.in @@ -43,10 +43,17 @@ namespace geode #define OPENGEODE_TEST( name ) \ int main() \ { \ - geode::OpenGeodeBasicLibrary::initialize(); \ - geode::Logger::set_level( geode::Logger::LEVEL::trace ); \ - test(); \ + try \ + { \ + geode::OpenGeodeBasicLibrary::initialize(); \ + geode::Logger::set_level( geode::Logger::LEVEL::trace ); \ + test(); \ \ - geode::Logger::info( "TEST SUCCESS" ); \ - return 0; \ + geode::Logger::info( "TEST SUCCESS" ); \ + return 0; \ + } \ + catch( ... ) \ + { \ + return geode::geode_lippincott(); \ + } \ } \ No newline at end of file diff --git a/tests/mesh/test-edged-curve.cpp b/tests/mesh/test-edged-curve.cpp index a1b9434b0..bfab452bd 100644 --- a/tests/mesh/test-edged-curve.cpp +++ b/tests/mesh/test-edged-curve.cpp @@ -354,10 +354,8 @@ void test() test_io( *edged_curve, absl::StrCat( "test.", edged_curve->native_extension() ) ); - DEBUG( "v12" ); test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v12/test_v12.", edged_curve->native_extension() ) ); - DEBUG( "v17" ); test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", edged_curve->native_extension() ) ); test_permutation( *edged_curve, *builder ); diff --git a/tests/mesh/test-geometrical-operations-on-mesh.cpp b/tests/mesh/test-geometrical-operations-on-mesh.cpp index 8f188695a..2f22b0910 100644 --- a/tests/mesh/test-geometrical-operations-on-mesh.cpp +++ b/tests/mesh/test-geometrical-operations-on-mesh.cpp @@ -47,26 +47,8 @@ std::unique_ptr< geode::TriangulatedSurface3D > create_surface() void test_rescale( geode::TriangulatedSurface3D& surface ) { - DEBUG( "before builder" ); - SDEBUG( surface.point( 0 ) ); - SDEBUG( surface.point( 1 ) ); - SDEBUG( surface.point( 2 ) ); - SDEBUG( surface.point( 3 ) ); - SDEBUG( surface.point( 4 ) ); - auto builder = geode::TriangulatedSurfaceBuilder3D::create( surface ); - SDEBUG( surface.point( 0 ) ); - SDEBUG( surface.point( 1 ) ); - SDEBUG( surface.point( 2 ) ); - SDEBUG( surface.point( 3 ) ); - SDEBUG( surface.point( 4 ) ); geode::rescale_mesh( surface, *builder, { 2, -2, 0.1 } ); - DEBUG( "rescaled" ); - SDEBUG( surface.point( 0 ) ); - SDEBUG( surface.point( 1 ) ); - SDEBUG( surface.point( 2 ) ); - SDEBUG( surface.point( 3 ) ); - SDEBUG( surface.point( 4 ) ); geode::OpenGeodeMeshException::test( surface.point( 0 ).inexact_equal( geode::Point3D{ { 0.2, -0.4, 0.03 } } ), diff --git a/tests/mesh/test-hybrid-solid.cpp b/tests/mesh/test-hybrid-solid.cpp index 2b927fb01..24a0fad53 100644 --- a/tests/mesh/test-hybrid-solid.cpp +++ b/tests/mesh/test-hybrid-solid.cpp @@ -484,24 +484,23 @@ void test() geode::OpenGeodeMeshLibrary::initialize(); auto hybrid_solid = geode::HybridSolid3D::create( geode::OpenGeodeHybridSolid3D::impl_name_static() ); - // hybrid_solid->enable_edges(); - // hybrid_solid->enable_facets(); - // auto builder = geode::HybridSolidBuilder3D::create( *hybrid_solid ); + hybrid_solid->enable_edges(); + hybrid_solid->enable_facets(); + auto builder = geode::HybridSolidBuilder3D::create( *hybrid_solid ); - // test_create_vertices( *hybrid_solid, *builder ); - // test_create_polyhedra( *hybrid_solid, *builder ); - // test_edges( *hybrid_solid ); - // test_facets( *hybrid_solid ); - // test_polyhedron_adjacencies( *hybrid_solid, *builder ); - // test_io( *hybrid_solid, - // absl::StrCat( "test.", hybrid_solid->native_extension() ) ); + test_create_vertices( *hybrid_solid, *builder ); + test_create_polyhedra( *hybrid_solid, *builder ); + test_edges( *hybrid_solid ); + test_facets( *hybrid_solid ); + test_polyhedron_adjacencies( *hybrid_solid, *builder ); + test_io( *hybrid_solid, + absl::StrCat( "test.", hybrid_solid->native_extension() ) ); test_backward_io( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.", hybrid_solid->native_extension() ) ); - DEBUG( "coucou" ); - // test_permutation( *hybrid_solid, *builder ); - // test_delete_polyhedra( *hybrid_solid, *builder ); - // test_clone( *hybrid_solid ); - // test_delete_all( *hybrid_solid, *builder ); + test_permutation( *hybrid_solid, *builder ); + test_delete_polyhedra( *hybrid_solid, *builder ); + test_clone( *hybrid_solid ); + test_delete_all( *hybrid_solid, *builder ); } OPENGEODE_TEST( "hybrid-solid" ) diff --git a/tests/model/test-ray-tracing-helpers.cpp b/tests/model/test-ray-tracing-helpers.cpp index 8ba36af4f..a8a2e4712 100644 --- a/tests/model/test-ray-tracing-helpers.cpp +++ b/tests/model/test-ray-tracing-helpers.cpp @@ -47,7 +47,6 @@ void test() // get the block geode::BRepRayTracing brep_ray_tracing{ brep }; const auto block_id = brep_ray_tracing.block_containing_point( center ); - SDEBUG( block_id.value() ); geode::OpenGeodeModelException::test( block_id.has_value(), "Failed to recover block_containing_point." ); @@ -65,7 +64,6 @@ void test() "Point [", outside.string(), "] should be outside the block." ); // load a section with various surfaces to test 2D - DEBUG( "Loading section" ); auto section = geode::load_section( absl::StrCat( geode::DATA_PATH, "fractures.og_sctn" ) ); geode::Point2D section_center{ { 230., 240. } }; From f549b73f1ca23be85f70ab939ff1aff7ea61c53d Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 19 Jun 2026 16:16:46 +0200 Subject: [PATCH 11/19] fix python --- .../python/src/basic/attribute_manager.cpp | 57 ++++++++++++------- .../io/geode/geode_brep_input.hpp | 2 +- src/geode/basic/attribute_manager.cpp | 6 +- tests/mesh/test-merge-surface.cpp | 1 - 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/bindings/python/src/basic/attribute_manager.cpp b/bindings/python/src/basic/attribute_manager.cpp index 9957236ec..864ef2373 100644 --- a/bindings/python/src/basic/attribute_manager.cpp +++ b/bindings/python/src/basic/attribute_manager.cpp @@ -36,30 +36,49 @@ namespace geode void python_attribute_class( pybind11::class_< AttributeManager >& manager, const std::string& suffix ) { - const auto read_suffix = absl::StrCat( "find_attribute_", suffix ); + const auto read_suffix = absl::StrCat( "read_attribute_", suffix ); manager.def( - read_suffix.c_str(), &AttributeManager::find_attribute< type > ); - const auto constant_suffix = - absl::StrCat( "find_or_create_attribute_constant_", suffix ); - manager.def( constant_suffix.c_str(), + read_suffix.c_str(), &AttributeManager::read_attribute< type > ); + const auto create_constant_suffix = + absl::StrCat( "create_attribute_constant_", suffix ); + manager.def( create_constant_suffix.c_str(), + static_cast< geode::uuid ( AttributeManager::* )( + std::string_view, type ) >( + &AttributeManager::create_attribute< ConstantAttribute, + type > ) ); + const auto find_constant_suffix = + absl::StrCat( "find_attribute_constant_", suffix ); + manager.def( find_constant_suffix.c_str(), static_cast< std::shared_ptr< ConstantAttribute< type > > ( - AttributeManager::* )( std::string_view, type ) >( - &AttributeManager::find_or_create_attribute< ConstantAttribute, + AttributeManager::* )( const geode::uuid& ) >( + &AttributeManager::find_attribute< ConstantAttribute, + type > ) ); + const auto create_variable_suffix = + absl::StrCat( "create_attribute_variable_", suffix ); + manager.def( create_variable_suffix.c_str(), + static_cast< geode::uuid ( AttributeManager::* )( + std::string_view, type ) >( + &AttributeManager::create_attribute< VariableAttribute, type > ) ); - const auto variable_suffix = - absl::StrCat( "find_or_create_attribute_variable_", suffix ); - manager.def( variable_suffix.c_str(), + const auto find_variable_suffix = + absl::StrCat( "find_attribute_variable_", suffix ); + manager.def( find_variable_suffix.c_str(), static_cast< std::shared_ptr< VariableAttribute< type > > ( - AttributeManager::* )( std::string_view, type ) >( - &AttributeManager::find_or_create_attribute< VariableAttribute, + AttributeManager::* )( const geode::uuid& ) >( + &AttributeManager::find_attribute< VariableAttribute, type > ) ); - const auto sparse_suffix = - absl::StrCat( "find_or_create_attribute_sparse_", suffix ); - manager.def( sparse_suffix.c_str(), + const auto create_sparse_suffix = + absl::StrCat( "create_attribute_sparse_", suffix ); + manager.def( create_sparse_suffix.c_str(), + static_cast< geode::uuid ( AttributeManager::* )( std::string_view, + type ) >( &AttributeManager::create_attribute< SparseAttribute, + type > ) ); + const auto find_sparse_suffix = + absl::StrCat( "find_attribute_sparse_", suffix ); + manager.def( find_sparse_suffix.c_str(), static_cast< std::shared_ptr< SparseAttribute< type > > ( - AttributeManager::* )( std::string_view, type ) >( - &AttributeManager::find_or_create_attribute< SparseAttribute, - type > ) ); + AttributeManager::* )( const geode::uuid& ) >( + &AttributeManager::find_attribute< SparseAttribute, type > ) ); } void define_attribute_manager( pybind11::module& module ) @@ -69,7 +88,7 @@ namespace geode manager.def( pybind11::init<>() ) .def( "find_generic_attribute", &AttributeManager::find_generic_attribute ) - .def( "attribute_names", &AttributeManager::attribute_names ) + .def( "attribute_ids", &AttributeManager::attribute_ids ) .def( "attribute_type", &AttributeManager::attribute_type ) .def( "attribute_exists", &AttributeManager::attribute_exists ) .def( "nb_elements", &AttributeManager::nb_elements ) diff --git a/include/geode/model/representation/io/geode/geode_brep_input.hpp b/include/geode/model/representation/io/geode/geode_brep_input.hpp index b77dd3084..7c5aa7606 100644 --- a/include/geode/model/representation/io/geode/geode_brep_input.hpp +++ b/include/geode/model/representation/io/geode/geode_brep_input.hpp @@ -71,7 +71,7 @@ namespace geode { BRepBuilder builder{ brep }; const auto level = Logger::level(); - Logger::set_level( Logger::LEVEL::warn ); + // Logger::set_level( Logger::LEVEL::warn ); async::parallel_invoke( [&builder, &directory] { builder.load_identifier( directory ); diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index 947695a0c..c4e71af31 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -233,7 +233,11 @@ namespace geode std::vector< uuid > ids; for( const auto &[attribute_id, attribute] : attributes_ ) { - if( attribute->name() == name ) + if( !attribute->name().has_value() ) + { + continue; + } + if( attribute->name().value() == name ) { ids.push_back( attribute_id ); } diff --git a/tests/mesh/test-merge-surface.cpp b/tests/mesh/test-merge-surface.cpp index 6c2c0d110..a94338a9b 100644 --- a/tests/mesh/test-merge-surface.cpp +++ b/tests/mesh/test-merge-surface.cpp @@ -142,7 +142,6 @@ void test_import() } geode::NNSearch3D nns( points ); const auto mappings = nns.colocated_index_mapping( geode::GLOBAL_EPSILON ); - DEBUG( mappings.nb_colocated_points() ); geode::OpenGeodeMeshException::test( mappings.nb_colocated_points() == 0, "Should be no more colocated points" ); for( const auto p : geode::Indices{ points } ) From a9482f0304eecbdbe35fe042b6e5004815439ec4 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 19 Jun 2026 17:44:49 +0200 Subject: [PATCH 12/19] fix tests --- .../python/tests/basic/test-py-attribute.py | 65 ++++++++++++------- .../python/tests/mesh/test-py-edged-curve.py | 8 ++- .../mesh/test-py-gradient-computation.py | 17 +++-- .../tests/mesh/test-py-light-regular-grid.py | 24 ++++--- .../python/tests/mesh/test-py-point-set.py | 14 ++-- .../tests/mesh/test-py-polygonal-surface.py | 19 +++--- .../tests/mesh/test-py-polyhedral-solid.py | 26 +++++--- .../python/tests/mesh/test-py-regular-grid.py | 26 +++++--- include/geode/basic/attribute.hpp | 4 +- include/geode/basic/attribute_manager.hpp | 1 + 10 files changed, 126 insertions(+), 78 deletions(-) diff --git a/bindings/python/tests/basic/test-py-attribute.py b/bindings/python/tests/basic/test-py-attribute.py index 672290471..b3bfb87ab 100644 --- a/bindings/python/tests/basic/test-py-attribute.py +++ b/bindings/python/tests/basic/test-py-attribute.py @@ -30,61 +30,80 @@ def test_constant_attribute(manager): - constant_attribute = manager.find_or_create_attribute_constant_bool( + + constant_attribute_id = manager.create_attribute_constant_bool( "bool", True) - - attribute = manager.find_attribute_bool("bool") + constant_attribute = manager.find_attribute_constant_bool(constant_attribute_id) + attribute = manager.read_attribute_bool(constant_attribute_id) if not attribute.value(0): raise ValueError("[Test] Should be equal to True") constant_attribute.set_value(False) if attribute.value(12): raise ValueError("[Test] Should be equal to False") + return constant_attribute_id def test_int_variable_attribute(manager): - variable_attribute = manager.find_or_create_attribute_variable_int( + variable_attribute_id = manager.create_attribute_variable_int( "int", 12) + variable_attribute = manager.find_attribute_variable_int(variable_attribute_id) variable_attribute.set_value(3, 3) if not variable_attribute.is_genericable(): raise ValueError("[Test] Should be genericable") - manager.set_attribute_properties("int",basic.AttributeProperties(True,True)) + manager.set_attribute_properties(variable_attribute_id,basic.AttributeProperties(True,True)) if not variable_attribute.properties().assignable or not variable_attribute.properties().interpolable : raise ValueError("[Test] Should be assignable and interpolable") - attribute = manager.find_attribute_int("int") - if attribute.value(3) != 3: + read_attribute = manager.read_attribute_int(variable_attribute_id) + if variable_attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") - if attribute.value(6) != 12: + if variable_attribute.value(6) != 12: + raise ValueError("[Test] Should be equal to 12") + if read_attribute.value(3) != 3: + raise ValueError("[Test] Should be equal to 3") + if read_attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") variable_attribute.set_value(3, 5) - if attribute.value(3) != 5: + if variable_attribute.value(3) != 5: + raise ValueError("[Test] Should be equal to 5") + if read_attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") def test_double_sparse_attribute(manager): - sparse_attribute = manager.find_or_create_attribute_sparse_double( + sparse_attribute_id = manager.create_attribute_sparse_double( "double", 12) - sparse_attribute.set_value(3, 3) - sparse_attribute.set_value(7, 7) + attribute = manager.find_attribute_sparse_double(sparse_attribute_id) + attribute.set_value(3, 3) + attribute.set_value(7, 7) - attribute = manager.find_attribute_double("double") + read_attribute = manager.read_attribute_double(sparse_attribute_id) if attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") if attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") if attribute.value(7) != 7: raise ValueError("[Test] Should be equal to 7") + if read_attribute.value(3) != 3: + raise ValueError("[Test] Should be equal to 3") + if read_attribute.value(6) != 12: + raise ValueError("[Test] Should be equal to 12") + if read_attribute.value(7) != 7: + raise ValueError("[Test] Should be equal to 7") - sparse_attribute.set_value(3, 5) + attribute.set_value(3, 5) if attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") + if read_attribute.value(3) != 5: + raise ValueError("[Test] Should be equal to 5") + return sparse_attribute_id def test_number_of_attributes(manager, nb): - if len(manager.attribute_names()) != nb: + if len(manager.attribute_ids()) != nb: raise ValueError( "[Test] Not the correct number of attributes in the manager") @@ -99,8 +118,8 @@ def test_delete_attribute_elements(manager): "[Test] Two attribute elements should have been removed") -def test_sparse_attribute_after_element_deletion(manager): - sparse_attribute = manager.find_attribute_double("double") +def test_sparse_attribute_after_element_deletion(manager, double_attribute_id): + sparse_attribute = manager.read_attribute_double(double_attribute_id) if sparse_attribute.value(0) != 12: raise ValueError("Element 0 of sparse attribute should be 12 ") if sparse_attribute.value(5) != 7: @@ -114,17 +133,17 @@ def test_sparse_attribute_after_element_deletion(manager): manager.resize(10) if manager.nb_elements() != 10: raise ValueError("[Test] Manager should have 10 elements") - test_constant_attribute(manager) + bool_attribute_id = test_constant_attribute(manager) test_int_variable_attribute(manager) test_double_sparse_attribute(manager) - test_double_sparse_attribute(manager) + double_attribute_id = test_double_sparse_attribute(manager) test_delete_attribute_elements(manager) - test_sparse_attribute_after_element_deletion(manager) + test_sparse_attribute_after_element_deletion(manager,double_attribute_id) + test_number_of_attributes(manager, 4) + manager.delete_attribute(bool_attribute_id) test_number_of_attributes(manager, 3) - manager.delete_attribute("bool") - test_number_of_attributes(manager, 2) manager.clear_attributes() - test_number_of_attributes(manager, 2) + test_number_of_attributes(manager, 3) manager.resize(10) if manager.nb_elements() != 10: raise ValueError("[Test] Manager should have 10 elements") diff --git a/bindings/python/tests/mesh/test-py-edged-curve.py b/bindings/python/tests/mesh/test-py-edged-curve.py index cb1831f4e..669d2e2b0 100644 --- a/bindings/python/tests/mesh/test-py-edged-curve.py +++ b/bindings/python/tests/mesh/test-py-edged-curve.py @@ -123,8 +123,10 @@ def test_edge_requests(edged_curve, builder): def test_clone(edged_curve): - attribute = edged_curve.edge_attribute_manager( - ).find_or_create_attribute_variable_int("test", 0) + attribute_id = edged_curve.edge_attribute_manager( + ).create_attribute_variable_int("test", 0) + + attribute = edged_curve.edge_attribute_manager().find_attribute_variable_int(attribute_id) attribute.set_value(0, 42) edged_curve2 = edged_curve.clone() @@ -133,7 +135,7 @@ def test_clone(edged_curve): if edged_curve2.nb_edges() != 3: raise ValueError("[Test] EdgedCurve2 should have 3 edge") - attribute2 = edged_curve2.edge_attribute_manager().find_attribute_int("test") + attribute2 = edged_curve2.edge_attribute_manager().read_attribute_int(attribute_id) if attribute2.value(0) != 42: raise ValueError("[Test] EdgedCurve2 attribute should be 42") diff --git a/bindings/python/tests/mesh/test-py-gradient-computation.py b/bindings/python/tests/mesh/test-py-gradient-computation.py index 1b5cd4c31..1bfa67ad5 100644 --- a/bindings/python/tests/mesh/test-py-gradient-computation.py +++ b/bindings/python/tests/mesh/test-py-gradient-computation.py @@ -35,7 +35,8 @@ def test_gradient_grid2D(): builder = mesh.RegularGridBuilder2D.create( grid ) builder.initialize_cartesian_grid( geom.Point2D([ 0, 0 ] ), [ 3, 3 ], 1 ) scalar_function_name = "scalar_function" - attribute = grid.vertex_attribute_manager().find_or_create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute = grid.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 1, 1 ) attribute.set_value( 4, 1 ) attribute.set_value( 6, 1 ) @@ -50,7 +51,7 @@ def test_gradient_grid2D(): attribute.set_value( 13, 2 ) attribute.set_value( 14, 3 ) attribute.set_value( 15, 8 ) - gradient_name = mesh.compute_surface_scalar_function_gradient2D( grid, scalar_function_name ) + gradient_name = mesh.compute_surface_scalar_function_gradient2D( grid, attribute_id ) print("Gradient attribute name: ", gradient_name) mesh.save_regular_grid2D( grid, "grid_with_gradient.og_rgd2d" ) @@ -80,7 +81,8 @@ def test_gradient_triangulated_surface2D(): builder.create_polygon( [ 5, 6, 8 ] ) builder.compute_polygon_adjacencies() scalar_function_name = "scalar_function" - attribute = surface.vertex_attribute_manager().find_or_create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = surface.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute = surface.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 1, 1 ) attribute.set_value( 2, 1 ) attribute.set_value( 3, 1 ) @@ -89,7 +91,7 @@ def test_gradient_triangulated_surface2D(): attribute.set_value( 9, 3 ) attribute.set_value( 7, 2 ) attribute.set_value( 8, 2 ) - gradient_name = mesh.compute_surface_scalar_function_gradient2D( surface, scalar_function_name ) + gradient_name = mesh.compute_surface_scalar_function_gradient2D( surface, attribute_id ) print("Gradient attribute name: ", gradient_name) mesh.save_triangulated_surface2D( surface, "mesh_with_gradient.og_tsf2d" ) @@ -98,7 +100,8 @@ def test_gradient_grid3D(): builder = mesh.RegularGridBuilder3D.create( grid ) builder.initialize_cartesian_grid( geom.Point3D([ 0, 0, 0 ]), [ 2, 2, 2 ], 1 ) scalar_function_name = "scalar_function" - attribute = grid.vertex_attribute_manager().find_or_create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute = grid.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 4, 1 ) attribute.set_value( 10, 1 ) attribute.set_value( 12, 1 ) @@ -125,8 +128,8 @@ def test_gradient_grid3D(): attribute.set_value( 20, 3 ) attribute.set_value( 24, 3 ) attribute.set_value( 26, 3 ) - gradient_name = mesh.compute_solid_scalar_function_gradient3D( grid, scalar_function_name ) - print("Gradient attribute name: ", gradient_name) + gradient_id= mesh.compute_solid_scalar_function_gradient3D( grid, attribute_id ) + print("Gradient attribute name: ", gradient_id) mesh.save_regular_grid3D( grid, "grid_with_gradient.og_rgd3d" ) if __name__ == '__main__': diff --git a/bindings/python/tests/mesh/test-py-light-regular-grid.py b/bindings/python/tests/mesh/test-py-light-regular-grid.py index ef2d98351..97d4a1abe 100644 --- a/bindings/python/tests/mesh/test-py-light-regular-grid.py +++ b/bindings/python/tests/mesh/test-py-light-regular-grid.py @@ -287,22 +287,26 @@ def test_closest_vertex(grid): def test_attribute_3d(grid): - attribute = grid.cell_attribute_manager().find_or_create_attribute_variable_double( + attribute_id = grid.cell_attribute_manager().create_attribute_variable_double( "toto", -1 ) + attribute = grid.cell_attribute_manager().find_attribute_variable_double(attribute_id) attribute.set_value(10, 10) - attribute = grid.cell_attribute_manager().find_attribute_double("toto") + attribute = grid.cell_attribute_manager().read_attribute_double(attribute_id) if attribute.value(0) != -1: raise ValueError("[Test] Wrong attribute value") if attribute.value(10) != 10: raise ValueError("[Test] Wrong attribute value") if attribute.value(grid.nb_cells() - 1) != -1: raise ValueError("[Test] Wrong attribute value") - attribute = ( - grid.grid_vertex_attribute_manager().find_or_create_attribute_variable_double( + attribute_id = ( + grid.grid_vertex_attribute_manager().create_attribute_variable_double( "toto_vertex", 1 ) ) + attribute = grid.grid_vertex_attribute_manager().find_attribute_variable_double( + attribute_id + ) attribute.set_value(10, 10) if attribute.value(0) != 1: raise ValueError("[Test] Wrong attribute value") @@ -314,22 +318,26 @@ def test_attribute_3d(grid): def test_attribute_2d(): grid = mesh.LightRegularGrid2D(geom.Point2D([1.5, 0]), [5, 10], [1.0, 2.0]) - attribute = grid.cell_attribute_manager().find_or_create_attribute_variable_double( + attribute_id = grid.cell_attribute_manager().create_attribute_variable_double( "toto", -1 ) + attribute = grid.cell_attribute_manager().find_attribute_variable_double(attribute_id) attribute.set_value(10, 10) - attribute = grid.cell_attribute_manager().find_attribute_double("toto") + attribute = grid.cell_attribute_manager().read_attribute_double(attribute_id) if attribute.value(0) != -1: raise ValueError("[Test] Wrong attribute value") if attribute.value(10) != 10: raise ValueError("[Test] Wrong attribute value") if attribute.value(grid.nb_cells() - 1) != -1: raise ValueError("[Test] Wrong attribute value") - attribute = ( - grid.grid_vertex_attribute_manager().find_or_create_attribute_variable_double( + attribute_id = ( + grid.grid_vertex_attribute_manager().create_attribute_variable_double( "toto_vertex", 1 ) ) + attribute = grid.grid_vertex_attribute_manager().find_attribute_variable_double( + attribute_id + ) attribute.set_value(10, 10) if attribute.value(0) != 1: raise ValueError("[Test] Wrong attribute value") diff --git a/bindings/python/tests/mesh/test-py-point-set.py b/bindings/python/tests/mesh/test-py-point-set.py index 8d710f872..c16fc5996 100644 --- a/bindings/python/tests/mesh/test-py-point-set.py +++ b/bindings/python/tests/mesh/test-py-point-set.py @@ -58,10 +58,12 @@ def test_bounding_box(point_set): def test_create_vertex_attribute(point_set): manager = point_set.vertex_attribute_manager() - attribute = point_set.vertex_attribute_manager( - ).find_or_create_attribute_constant_bool("test", True) + attribute_id = point_set.vertex_attribute_manager( + ).create_attribute_constant_bool("test", True) + attribute = manager.find_attribute_constant_bool(attribute_id) if attribute.constant_value() != True: raise ValueError("[Test] PointSet attribute value should be true") + return attribute_id def test_delete_vertex(point_set, builder): @@ -80,12 +82,12 @@ def test_io(point_set, filename): new_point_set = mesh.load_point_set3D(filename) -def test_clone(point_set): +def test_clone(point_set, attribute_id): point_set2 = point_set.clone() if point_set2.nb_vertices() != 3: raise ValueError("[Test] PointSet2 should have 3 vertices") - attribute = point_set2.vertex_attribute_manager().find_attribute_bool("test") + attribute = point_set2.vertex_attribute_manager().read_attribute_bool(attribute_id) if attribute.value(0) != True: raise ValueError("[Test] PointSet2 attribute value should be true") @@ -110,9 +112,9 @@ def test_permutation(point_set, builder): builder = mesh.PointSetBuilder3D.create(point_set) test_create_vertices(point_set, builder) test_bounding_box(point_set) - test_create_vertex_attribute(point_set) + test_attribute_id =test_create_vertex_attribute(point_set) test_io(point_set, "test." + point_set.native_extension()) test_permutation(point_set, builder) test_delete_vertex(point_set, builder) - test_clone(point_set) + test_clone(point_set, test_attribute_id) diff --git a/bindings/python/tests/mesh/test-py-polygonal-surface.py b/bindings/python/tests/mesh/test-py-polygonal-surface.py index d959f2806..b603280f7 100644 --- a/bindings/python/tests/mesh/test-py-polygonal-surface.py +++ b/bindings/python/tests/mesh/test-py-polygonal-surface.py @@ -66,10 +66,13 @@ def test_create_polygons(polygonal_surface, builder): def test_create_edge_attribute(polygonal_surface): + attribute_id = polygonal_surface.edges().edge_attribute_manager( + ).create_attribute_variable_uint("test", basic.NO_ID) attribute = polygonal_surface.edges().edge_attribute_manager( - ).find_or_create_attribute_variable_uint("test", basic.NO_ID) + ).find_attribute_variable_uint(attribute_id) for e in range(polygonal_surface.edges().nb_edges()): attribute.set_value(e, e) + return attribute_id def test_polygon_adjacencies(polygonal_surface, builder): @@ -113,7 +116,7 @@ def test_previous_next_on_border(polygonal_surface): raise ValueError("[Test] Next edge on border index is not correct") -def test_delete_polygon(polygonal_surface, builder): +def test_delete_polygon(polygonal_surface, builder, attribute_id): to_delete = [False] * polygonal_surface.nb_polygons() to_delete[0] = True builder.delete_polygons(to_delete) @@ -133,7 +136,7 @@ def test_delete_polygon(polygonal_surface, builder): raise ValueError("[Test] PolygonalSurface should have 6 edges") attribute = polygonal_surface.edges( - ).edge_attribute_manager().find_attribute_uint("test") + ).edge_attribute_manager().read_attribute_uint(attribute_id) for e in range(6): if attribute.value(e) != e: raise ValueError("[Test] Update of edge attributes after " @@ -204,7 +207,7 @@ def test_polygon_vertex_normal(): "[Test] PolygonalSurface polygon vertex normal is not correct") -def test_io(polygonal_surface, filename): +def test_io(polygonal_surface, filename, attribute_id): mesh.save_polygonal_surface3D(polygonal_surface, filename) new_polygonal_surface = mesh.load_polygonal_surface3D(filename) @@ -218,7 +221,7 @@ def test_io(polygonal_surface, filename): raise ValueError( "[Test] Reloaded PolygonalSurface should have 3 polygons") attribute = new_polygonal_surface.edges( - ).edge_attribute_manager().find_attribute_uint("test") + ).edge_attribute_manager().read_attribute_uint(attribute_id) for e in range(new_polygonal_surface.edges().nb_edges()): if attribute.value(e) != e: raise ValueError( @@ -365,7 +368,7 @@ def test_permutation(surface, builder): test_create_vertices(polygonal_surface, builder) test_bounding_box(polygonal_surface) test_create_polygons(polygonal_surface, builder) - test_create_edge_attribute(polygonal_surface) + edge_attribute_id = test_create_edge_attribute(polygonal_surface) test_polygon_adjacencies(polygonal_surface, builder) test_polygon_edges_on_borders(polygonal_surface) test_previous_next_on_border(polygonal_surface) @@ -374,10 +377,10 @@ def test_permutation(surface, builder): test_polygon_normal() test_polygon_vertex_normal() - test_io(polygonal_surface, "test." + polygonal_surface.native_extension()) + test_io(polygonal_surface, "test." + polygonal_surface.native_extension(),edge_attribute_id) test_permutation(polygonal_surface, builder) - test_delete_polygon(polygonal_surface, builder) + test_delete_polygon(polygonal_surface, builder, edge_attribute_id) test_clone(polygonal_surface) test_set_polygon_vertex(polygonal_surface, builder) test_delete_all(polygonal_surface, builder) diff --git a/bindings/python/tests/mesh/test-py-polyhedral-solid.py b/bindings/python/tests/mesh/test-py-polyhedral-solid.py index 1255238b9..4203e2ad8 100644 --- a/bindings/python/tests/mesh/test-py-polyhedral-solid.py +++ b/bindings/python/tests/mesh/test-py-polyhedral-solid.py @@ -72,15 +72,20 @@ def test_create_polyhedra(polyhedral_solid, builder): def test_create_facet_attribute(polyhedral_solid): + attribute_id = polyhedral_solid.facets().facet_attribute_manager( + ).create_attribute_variable_uint("test", basic.NO_ID) attribute = polyhedral_solid.facets().facet_attribute_manager( - ).find_or_create_attribute_variable_uint("test", basic.NO_ID) + ).find_attribute_variable_uint(attribute_id) for f in range(polyhedral_solid.facets().nb_facets()): attribute.set_value(f, f) + return attribute_id def test_create_edge_attribute(polyhedral_solid): + attribute_id = polyhedral_solid.edges().edge_attribute_manager( + ).create_attribute_variable_uint("test", basic.NO_ID) attribute = polyhedral_solid.edges().edge_attribute_manager( - ).find_or_create_attribute_variable_uint("test", basic.NO_ID) + ).find_attribute_variable_uint(attribute_id) for e in range(polyhedral_solid.edges().nb_edges()): vertices = polyhedral_solid.edges().edge_vertices(e) attribute.set_value(e, vertices[0] + vertices[1]) @@ -88,6 +93,7 @@ def test_create_edge_attribute(polyhedral_solid): raise ValueError("[Test] Wrong value for attribute on edge 0") if attribute.value(1) != 3: raise ValueError("[Test] Wrong value for attribute on edge 1") + return attribute_id def test_polyhedron_adjacencies(polyhedral_solid, builder): @@ -135,7 +141,7 @@ def test_polyhedron_adjacencies(polyhedral_solid, builder): raise ValueError("[Test] Polyhedra from facet should contain (2, 3)") -def test_delete_polyhedra(polyhedral_solid, builder): +def test_delete_polyhedra(polyhedral_solid, builder,edge_attribute_id): to_delete = [False] * polyhedral_solid.nb_polyhedra() to_delete[0] = True builder.delete_polyhedra(to_delete) @@ -160,7 +166,7 @@ def test_delete_polyhedra(polyhedral_solid, builder): if polyhedral_solid.edges().nb_edges() != 12: raise ValueError("[Test] PolyhedralSolid should have 12 edges") attribute = polyhedral_solid.edges( - ).edge_attribute_manager().find_attribute_uint("test") + ).edge_attribute_manager().read_attribute_uint(edge_attribute_id) if attribute.value(0) != 1: raise ValueError( "[Test] Wrong value for attribute on edge 0 after polyhedron deletion") @@ -169,7 +175,7 @@ def test_delete_polyhedra(polyhedral_solid, builder): "[Test] Wrong value for attribute on edge 1 after polyhedron deletion") -def test_io(polyhedral_solid, filename): +def test_io(polyhedral_solid, filename, facet_attribute_id): mesh.save_polyhedral_solid3D(polyhedral_solid, filename) new_polyhedral_solid = mesh.load_polyhedral_solid3D(filename) @@ -186,7 +192,7 @@ def test_io(polyhedral_solid, filename): raise ValueError( "[Test] Reloaded PolyhedralSolid should have 3 polyhedra") attribute = new_polyhedral_solid.facets( - ).facet_attribute_manager().find_attribute_uint("test") + ).facet_attribute_manager().read_attribute_uint(facet_attribute_id) for f in range(new_polyhedral_solid.facets().nb_facets()): if attribute.value(f) != f: raise ValueError( @@ -404,13 +410,13 @@ def test_permutation(solid, builder): test_create_vertices(polyhedral_solid, builder) test_create_polyhedra(polyhedral_solid, builder) - test_create_facet_attribute(polyhedral_solid) - test_create_edge_attribute(polyhedral_solid) + facet_attribute_id = test_create_facet_attribute(polyhedral_solid) + edge_attribute_id = test_create_edge_attribute(polyhedral_solid) test_polyhedron_adjacencies(polyhedral_solid, builder) - test_io(polyhedral_solid, "test." + polyhedral_solid.native_extension()) + test_io(polyhedral_solid, "test." + polyhedral_solid.native_extension(),facet_attribute_id) test_permutation(polyhedral_solid, builder) - test_delete_polyhedra(polyhedral_solid, builder) + test_delete_polyhedra(polyhedral_solid, builder,edge_attribute_id) test_clone(polyhedral_solid) test_set_polyhedron_vertex(polyhedral_solid, builder) test_delete_all(polyhedral_solid, builder) diff --git a/bindings/python/tests/mesh/test-py-regular-grid.py b/bindings/python/tests/mesh/test-py-regular-grid.py index 3e60366a3..9fb8b31f8 100644 --- a/bindings/python/tests/mesh/test-py-regular-grid.py +++ b/bindings/python/tests/mesh/test-py-regular-grid.py @@ -246,16 +246,22 @@ def test_closest_vertex(grid): def test_clone(grid): attribute_name = "int_attribute" attribute_name_d = "double_attribute" - attribute = ( - grid.polyhedron_attribute_manager().find_or_create_attribute_variable_int( + attribute_id = ( + grid.polyhedron_attribute_manager().create_attribute_variable_int( attribute_name, 0 ) ) - attribute_d = ( - grid.vertex_attribute_manager().find_or_create_attribute_variable_double( + attribute = grid.polyhedron_attribute_manager().find_attribute_variable_int( + attribute_id + ) + attribute_d_id = ( + grid.vertex_attribute_manager().create_attribute_variable_double( attribute_name_d, 0 ) ) + attribute_d = grid.vertex_attribute_manager().find_attribute_variable_double( + attribute_d_id + ) for c in range(grid.nb_cells()): attribute.set_value(c, 2 * c) for c in range(grid.nb_vertices()): @@ -263,18 +269,18 @@ def test_clone(grid): clone = grid.clone() if clone.grid_point([0, 0, 0]) != grid.grid_point([0, 0, 0]): raise ValueError("[Test] Wrong clone origin") - if not clone.polyhedron_attribute_manager().attribute_exists(attribute_name): + if not clone.polyhedron_attribute_manager().attribute_exists(attribute_id): raise ValueError("[Test] Clone missing attribute") - if not clone.vertex_attribute_manager().attribute_exists(attribute_name_d): + if not clone.vertex_attribute_manager().attribute_exists(attribute_d_id): raise ValueError("[Test] Clone missing attribute") - clone_attribute = clone.polyhedron_attribute_manager().find_attribute_int( - attribute_name + clone_attribute = clone.polyhedron_attribute_manager().read_attribute_int( + attribute_id ) for c in range(clone.nb_cells()): if clone_attribute.value(c) != 2 * c: raise ValueError("[Test] Wrong clone attribute") - clone_attribute_d = clone.vertex_attribute_manager().find_attribute_double( - attribute_name_d + clone_attribute_d = clone.vertex_attribute_manager().read_attribute_double( + attribute_d_id ) for c in range(clone.nb_vertices()): if clone_attribute_d.value(c) != 2 * c: diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index 5e0733b0b..e9035c28e 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -141,8 +140,7 @@ namespace geode archive.object( attribute.properties_ ); std::string old_name; archive.text1b( old_name, old_name.max_size() ); - IdentifierBuilder builder{ attribute }; - builder.set_name( old_name ); + attribute.set_name( old_name ); }, []( Archive& archive, AttributeBase& attribute ) { archive.object( attribute.properties_ ); diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 37d96f243..c8e53023b 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -33,6 +33,7 @@ #include #include +#include #include #include From 23cfdf1b6b423c244f99e2a32213696daa5580df Mon Sep 17 00:00:00 2001 From: BenPinet Date: Mon, 22 Jun 2026 10:24:46 +0200 Subject: [PATCH 13/19] feat(Attributes): add uuid to identify attributes and remove find or create method --- .../python/src/basic/attribute_manager.cpp | 18 ++--- .../python/tests/basic/test-py-attribute.py | 28 ++++---- .../python/tests/mesh/test-py-edged-curve.py | 4 +- .../mesh/test-py-gradient-computation.py | 6 +- .../tests/mesh/test-py-light-regular-grid.py | 12 ++-- .../python/tests/mesh/test-py-point-set.py | 4 +- .../tests/mesh/test-py-polygonal-surface.py | 6 +- .../tests/mesh/test-py-polyhedral-solid.py | 8 +-- .../python/tests/mesh/test-py-regular-grid.py | 8 +-- include/geode/basic/attribute_manager.hpp | 61 ++++++---------- .../geode/mesh/core/internal/texture_impl.hpp | 3 +- src/geode/basic/attribute_manager.cpp | 11 +-- .../mesh/core/geode/geode_edged_curve.cpp | 7 +- .../mesh/core/geode/geode_hybrid_solid.cpp | 7 +- src/geode/mesh/core/geode/geode_point_set.cpp | 7 +- .../core/geode/geode_polygonal_surface.cpp | 7 +- .../core/geode/geode_polyhedral_solid.cpp | 7 +- .../core/geode/geode_regular_grid_solid.cpp | 4 +- .../core/geode/geode_regular_grid_surface.cpp | 4 +- .../core/geode/geode_tetrahedral_solid.cpp | 7 +- .../core/geode/geode_triangulated_surface.cpp | 7 +- src/geode/mesh/helpers/convert_grid.cpp | 2 +- .../helpers/euclidean_distance_transform.cpp | 4 +- .../mesh/helpers/gradient_computation.cpp | 11 +-- .../mixin/core/detail/relationships_impl.cpp | 4 +- src/geode/model/mixin/core/relationships.cpp | 4 +- tests/basic/test-attribute.cpp | 70 +++++++++++-------- tests/image/test-colors.cpp | 6 +- tests/mesh/test-convert-surface.cpp | 8 ++- tests/mesh/test-edged-curve.cpp | 8 +-- tests/mesh/test-generic-mesh-accessor.cpp | 9 +-- tests/mesh/test-gradient-computation.cpp | 6 +- tests/mesh/test-light-regular-grid.cpp | 3 +- tests/mesh/test-point-set.cpp | 8 +-- tests/mesh/test-polygonal-surface.cpp | 14 ++-- tests/mesh/test-polyhedral-solid.cpp | 29 ++++---- tests/mesh/test-regular-grid.cpp | 13 ++-- tests/mesh/test-tetrahedral-solid.cpp | 13 ++-- tests/mesh/test-triangulated-surface.cpp | 11 ++- tests/model/test-relationships.cpp | 3 +- 40 files changed, 234 insertions(+), 218 deletions(-) diff --git a/bindings/python/src/basic/attribute_manager.cpp b/bindings/python/src/basic/attribute_manager.cpp index 864ef2373..04e4a18fb 100644 --- a/bindings/python/src/basic/attribute_manager.cpp +++ b/bindings/python/src/basic/attribute_manager.cpp @@ -36,14 +36,15 @@ namespace geode void python_attribute_class( pybind11::class_< AttributeManager >& manager, const std::string& suffix ) { - const auto read_suffix = absl::StrCat( "read_attribute_", suffix ); - manager.def( - read_suffix.c_str(), &AttributeManager::read_attribute< type > ); + const auto read_suffix = + absl::StrCat( "find_read_only_attribute_", suffix ); + manager.def( read_suffix.c_str(), + &AttributeManager::find_read_only_attribute< type > ); const auto create_constant_suffix = absl::StrCat( "create_attribute_constant_", suffix ); manager.def( create_constant_suffix.c_str(), static_cast< geode::uuid ( AttributeManager::* )( - std::string_view, type ) >( + std::string_view, type, AttributeProperties ) >( &AttributeManager::create_attribute< ConstantAttribute, type > ) ); const auto find_constant_suffix = @@ -57,7 +58,7 @@ namespace geode absl::StrCat( "create_attribute_variable_", suffix ); manager.def( create_variable_suffix.c_str(), static_cast< geode::uuid ( AttributeManager::* )( - std::string_view, type ) >( + std::string_view, type, AttributeProperties ) >( &AttributeManager::create_attribute< VariableAttribute, type > ) ); const auto find_variable_suffix = @@ -70,9 +71,10 @@ namespace geode const auto create_sparse_suffix = absl::StrCat( "create_attribute_sparse_", suffix ); manager.def( create_sparse_suffix.c_str(), - static_cast< geode::uuid ( AttributeManager::* )( std::string_view, - type ) >( &AttributeManager::create_attribute< SparseAttribute, - type > ) ); + static_cast< geode::uuid ( AttributeManager::* )( + std::string_view, type, AttributeProperties ) >( + &AttributeManager::create_attribute< SparseAttribute, + type > ) ); const auto find_sparse_suffix = absl::StrCat( "find_attribute_sparse_", suffix ); manager.def( find_sparse_suffix.c_str(), diff --git a/bindings/python/tests/basic/test-py-attribute.py b/bindings/python/tests/basic/test-py-attribute.py index b3bfb87ab..3f4ee3e4e 100644 --- a/bindings/python/tests/basic/test-py-attribute.py +++ b/bindings/python/tests/basic/test-py-attribute.py @@ -32,9 +32,9 @@ def test_constant_attribute(manager): constant_attribute_id = manager.create_attribute_constant_bool( - "bool", True) + "bool", True, basic.AttributeProperties()) constant_attribute = manager.find_attribute_constant_bool(constant_attribute_id) - attribute = manager.read_attribute_bool(constant_attribute_id) + attribute = manager.find_read_only_attribute_bool(constant_attribute_id) if not attribute.value(0): raise ValueError("[Test] Should be equal to True") @@ -46,7 +46,7 @@ def test_constant_attribute(manager): def test_int_variable_attribute(manager): variable_attribute_id = manager.create_attribute_variable_int( - "int", 12) + "int", 12,basic.AttributeProperties()) variable_attribute = manager.find_attribute_variable_int(variable_attribute_id) variable_attribute.set_value(3, 3) if not variable_attribute.is_genericable(): @@ -56,48 +56,48 @@ def test_int_variable_attribute(manager): if not variable_attribute.properties().assignable or not variable_attribute.properties().interpolable : raise ValueError("[Test] Should be assignable and interpolable") - read_attribute = manager.read_attribute_int(variable_attribute_id) + find_read_only_attribute = manager.find_read_only_attribute_int(variable_attribute_id) if variable_attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") if variable_attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") - if read_attribute.value(3) != 3: + if find_read_only_attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") - if read_attribute.value(6) != 12: + if find_read_only_attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") variable_attribute.set_value(3, 5) if variable_attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") - if read_attribute.value(3) != 5: + if find_read_only_attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") def test_double_sparse_attribute(manager): sparse_attribute_id = manager.create_attribute_sparse_double( - "double", 12) + "double", 12,basic.AttributeProperties()) attribute = manager.find_attribute_sparse_double(sparse_attribute_id) attribute.set_value(3, 3) attribute.set_value(7, 7) - read_attribute = manager.read_attribute_double(sparse_attribute_id) + find_read_only_attribute = manager.find_read_only_attribute_double(sparse_attribute_id) if attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") if attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") if attribute.value(7) != 7: raise ValueError("[Test] Should be equal to 7") - if read_attribute.value(3) != 3: + if find_read_only_attribute.value(3) != 3: raise ValueError("[Test] Should be equal to 3") - if read_attribute.value(6) != 12: + if find_read_only_attribute.value(6) != 12: raise ValueError("[Test] Should be equal to 12") - if read_attribute.value(7) != 7: + if find_read_only_attribute.value(7) != 7: raise ValueError("[Test] Should be equal to 7") attribute.set_value(3, 5) if attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") - if read_attribute.value(3) != 5: + if find_read_only_attribute.value(3) != 5: raise ValueError("[Test] Should be equal to 5") return sparse_attribute_id @@ -119,7 +119,7 @@ def test_delete_attribute_elements(manager): def test_sparse_attribute_after_element_deletion(manager, double_attribute_id): - sparse_attribute = manager.read_attribute_double(double_attribute_id) + sparse_attribute = manager.find_read_only_attribute_double(double_attribute_id) if sparse_attribute.value(0) != 12: raise ValueError("Element 0 of sparse attribute should be 12 ") if sparse_attribute.value(5) != 7: diff --git a/bindings/python/tests/mesh/test-py-edged-curve.py b/bindings/python/tests/mesh/test-py-edged-curve.py index 669d2e2b0..ce2dc1bff 100644 --- a/bindings/python/tests/mesh/test-py-edged-curve.py +++ b/bindings/python/tests/mesh/test-py-edged-curve.py @@ -124,7 +124,7 @@ def test_edge_requests(edged_curve, builder): def test_clone(edged_curve): attribute_id = edged_curve.edge_attribute_manager( - ).create_attribute_variable_int("test", 0) + ).create_attribute_variable_int("test", 0,opengeode_py_basic.AttributeProperties()) attribute = edged_curve.edge_attribute_manager().find_attribute_variable_int(attribute_id) attribute.set_value(0, 42) @@ -135,7 +135,7 @@ def test_clone(edged_curve): if edged_curve2.nb_edges() != 3: raise ValueError("[Test] EdgedCurve2 should have 3 edge") - attribute2 = edged_curve2.edge_attribute_manager().read_attribute_int(attribute_id) + attribute2 = edged_curve2.edge_attribute_manager().find_read_only_attribute_int(attribute_id) if attribute2.value(0) != 42: raise ValueError("[Test] EdgedCurve2 attribute should be 42") diff --git a/bindings/python/tests/mesh/test-py-gradient-computation.py b/bindings/python/tests/mesh/test-py-gradient-computation.py index 1bfa67ad5..26f2345f6 100644 --- a/bindings/python/tests/mesh/test-py-gradient-computation.py +++ b/bindings/python/tests/mesh/test-py-gradient-computation.py @@ -35,7 +35,7 @@ def test_gradient_grid2D(): builder = mesh.RegularGridBuilder2D.create( grid ) builder.initialize_cartesian_grid( geom.Point2D([ 0, 0 ] ), [ 3, 3 ], 1 ) scalar_function_name = "scalar_function" - attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0,opengeode_py_basic.AttributeProperties() ) attribute = grid.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 1, 1 ) attribute.set_value( 4, 1 ) @@ -81,7 +81,7 @@ def test_gradient_triangulated_surface2D(): builder.create_polygon( [ 5, 6, 8 ] ) builder.compute_polygon_adjacencies() scalar_function_name = "scalar_function" - attribute_id = surface.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = surface.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0,opengeode_py_basic.AttributeProperties() ) attribute = surface.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 1, 1 ) attribute.set_value( 2, 1 ) @@ -100,7 +100,7 @@ def test_gradient_grid3D(): builder = mesh.RegularGridBuilder3D.create( grid ) builder.initialize_cartesian_grid( geom.Point3D([ 0, 0, 0 ]), [ 2, 2, 2 ], 1 ) scalar_function_name = "scalar_function" - attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0 ) + attribute_id = grid.vertex_attribute_manager().create_attribute_variable_double( scalar_function_name, 0,opengeode_py_basic.AttributeProperties() ) attribute = grid.vertex_attribute_manager().find_attribute_variable_double( attribute_id ) attribute.set_value( 4, 1 ) attribute.set_value( 10, 1 ) diff --git a/bindings/python/tests/mesh/test-py-light-regular-grid.py b/bindings/python/tests/mesh/test-py-light-regular-grid.py index 97d4a1abe..92dc94e2c 100644 --- a/bindings/python/tests/mesh/test-py-light-regular-grid.py +++ b/bindings/python/tests/mesh/test-py-light-regular-grid.py @@ -288,11 +288,11 @@ def test_closest_vertex(grid): def test_attribute_3d(grid): attribute_id = grid.cell_attribute_manager().create_attribute_variable_double( - "toto", -1 + "toto", -1,geode.AttributeProperties() ) attribute = grid.cell_attribute_manager().find_attribute_variable_double(attribute_id) attribute.set_value(10, 10) - attribute = grid.cell_attribute_manager().read_attribute_double(attribute_id) + attribute = grid.cell_attribute_manager().find_read_only_attribute_double(attribute_id) if attribute.value(0) != -1: raise ValueError("[Test] Wrong attribute value") if attribute.value(10) != 10: @@ -301,7 +301,7 @@ def test_attribute_3d(grid): raise ValueError("[Test] Wrong attribute value") attribute_id = ( grid.grid_vertex_attribute_manager().create_attribute_variable_double( - "toto_vertex", 1 + "toto_vertex", 1,geode.AttributeProperties() ) ) attribute = grid.grid_vertex_attribute_manager().find_attribute_variable_double( @@ -319,11 +319,11 @@ def test_attribute_3d(grid): def test_attribute_2d(): grid = mesh.LightRegularGrid2D(geom.Point2D([1.5, 0]), [5, 10], [1.0, 2.0]) attribute_id = grid.cell_attribute_manager().create_attribute_variable_double( - "toto", -1 + "toto", -1,geode.AttributeProperties() ) attribute = grid.cell_attribute_manager().find_attribute_variable_double(attribute_id) attribute.set_value(10, 10) - attribute = grid.cell_attribute_manager().read_attribute_double(attribute_id) + attribute = grid.cell_attribute_manager().find_read_only_attribute_double(attribute_id) if attribute.value(0) != -1: raise ValueError("[Test] Wrong attribute value") if attribute.value(10) != 10: @@ -332,7 +332,7 @@ def test_attribute_2d(): raise ValueError("[Test] Wrong attribute value") attribute_id = ( grid.grid_vertex_attribute_manager().create_attribute_variable_double( - "toto_vertex", 1 + "toto_vertex", 1,geode.AttributeProperties() ) ) attribute = grid.grid_vertex_attribute_manager().find_attribute_variable_double( diff --git a/bindings/python/tests/mesh/test-py-point-set.py b/bindings/python/tests/mesh/test-py-point-set.py index c16fc5996..ad6a25feb 100644 --- a/bindings/python/tests/mesh/test-py-point-set.py +++ b/bindings/python/tests/mesh/test-py-point-set.py @@ -59,7 +59,7 @@ def test_bounding_box(point_set): def test_create_vertex_attribute(point_set): manager = point_set.vertex_attribute_manager() attribute_id = point_set.vertex_attribute_manager( - ).create_attribute_constant_bool("test", True) + ).create_attribute_constant_bool("test", True,opengeode_py_basic.AttributeProperties()) attribute = manager.find_attribute_constant_bool(attribute_id) if attribute.constant_value() != True: raise ValueError("[Test] PointSet attribute value should be true") @@ -87,7 +87,7 @@ def test_clone(point_set, attribute_id): if point_set2.nb_vertices() != 3: raise ValueError("[Test] PointSet2 should have 3 vertices") - attribute = point_set2.vertex_attribute_manager().read_attribute_bool(attribute_id) + attribute = point_set2.vertex_attribute_manager().find_read_only_attribute_bool(attribute_id) if attribute.value(0) != True: raise ValueError("[Test] PointSet2 attribute value should be true") diff --git a/bindings/python/tests/mesh/test-py-polygonal-surface.py b/bindings/python/tests/mesh/test-py-polygonal-surface.py index b603280f7..9d0ab4bac 100644 --- a/bindings/python/tests/mesh/test-py-polygonal-surface.py +++ b/bindings/python/tests/mesh/test-py-polygonal-surface.py @@ -67,7 +67,7 @@ def test_create_polygons(polygonal_surface, builder): def test_create_edge_attribute(polygonal_surface): attribute_id = polygonal_surface.edges().edge_attribute_manager( - ).create_attribute_variable_uint("test", basic.NO_ID) + ).create_attribute_variable_uint("test", basic.NO_ID,basic.AttributeProperties()) attribute = polygonal_surface.edges().edge_attribute_manager( ).find_attribute_variable_uint(attribute_id) for e in range(polygonal_surface.edges().nb_edges()): @@ -136,7 +136,7 @@ def test_delete_polygon(polygonal_surface, builder, attribute_id): raise ValueError("[Test] PolygonalSurface should have 6 edges") attribute = polygonal_surface.edges( - ).edge_attribute_manager().read_attribute_uint(attribute_id) + ).edge_attribute_manager().find_read_only_attribute_uint(attribute_id) for e in range(6): if attribute.value(e) != e: raise ValueError("[Test] Update of edge attributes after " @@ -221,7 +221,7 @@ def test_io(polygonal_surface, filename, attribute_id): raise ValueError( "[Test] Reloaded PolygonalSurface should have 3 polygons") attribute = new_polygonal_surface.edges( - ).edge_attribute_manager().read_attribute_uint(attribute_id) + ).edge_attribute_manager().find_read_only_attribute_uint(attribute_id) for e in range(new_polygonal_surface.edges().nb_edges()): if attribute.value(e) != e: raise ValueError( diff --git a/bindings/python/tests/mesh/test-py-polyhedral-solid.py b/bindings/python/tests/mesh/test-py-polyhedral-solid.py index 4203e2ad8..83c2c739d 100644 --- a/bindings/python/tests/mesh/test-py-polyhedral-solid.py +++ b/bindings/python/tests/mesh/test-py-polyhedral-solid.py @@ -73,7 +73,7 @@ def test_create_polyhedra(polyhedral_solid, builder): def test_create_facet_attribute(polyhedral_solid): attribute_id = polyhedral_solid.facets().facet_attribute_manager( - ).create_attribute_variable_uint("test", basic.NO_ID) + ).create_attribute_variable_uint("test", basic.NO_ID, basic.AttributeProperties()) attribute = polyhedral_solid.facets().facet_attribute_manager( ).find_attribute_variable_uint(attribute_id) for f in range(polyhedral_solid.facets().nb_facets()): @@ -83,7 +83,7 @@ def test_create_facet_attribute(polyhedral_solid): def test_create_edge_attribute(polyhedral_solid): attribute_id = polyhedral_solid.edges().edge_attribute_manager( - ).create_attribute_variable_uint("test", basic.NO_ID) + ).create_attribute_variable_uint("test", basic.NO_ID, basic.AttributeProperties()) attribute = polyhedral_solid.edges().edge_attribute_manager( ).find_attribute_variable_uint(attribute_id) for e in range(polyhedral_solid.edges().nb_edges()): @@ -166,7 +166,7 @@ def test_delete_polyhedra(polyhedral_solid, builder,edge_attribute_id): if polyhedral_solid.edges().nb_edges() != 12: raise ValueError("[Test] PolyhedralSolid should have 12 edges") attribute = polyhedral_solid.edges( - ).edge_attribute_manager().read_attribute_uint(edge_attribute_id) + ).edge_attribute_manager().find_read_only_attribute_uint(edge_attribute_id) if attribute.value(0) != 1: raise ValueError( "[Test] Wrong value for attribute on edge 0 after polyhedron deletion") @@ -192,7 +192,7 @@ def test_io(polyhedral_solid, filename, facet_attribute_id): raise ValueError( "[Test] Reloaded PolyhedralSolid should have 3 polyhedra") attribute = new_polyhedral_solid.facets( - ).facet_attribute_manager().read_attribute_uint(facet_attribute_id) + ).facet_attribute_manager().find_read_only_attribute_uint(facet_attribute_id) for f in range(new_polyhedral_solid.facets().nb_facets()): if attribute.value(f) != f: raise ValueError( diff --git a/bindings/python/tests/mesh/test-py-regular-grid.py b/bindings/python/tests/mesh/test-py-regular-grid.py index 9fb8b31f8..1f31f73be 100644 --- a/bindings/python/tests/mesh/test-py-regular-grid.py +++ b/bindings/python/tests/mesh/test-py-regular-grid.py @@ -248,7 +248,7 @@ def test_clone(grid): attribute_name_d = "double_attribute" attribute_id = ( grid.polyhedron_attribute_manager().create_attribute_variable_int( - attribute_name, 0 + attribute_name, 0,geode.AttributeProperties() ) ) attribute = grid.polyhedron_attribute_manager().find_attribute_variable_int( @@ -256,7 +256,7 @@ def test_clone(grid): ) attribute_d_id = ( grid.vertex_attribute_manager().create_attribute_variable_double( - attribute_name_d, 0 + attribute_name_d, 0,geode.AttributeProperties() ) ) attribute_d = grid.vertex_attribute_manager().find_attribute_variable_double( @@ -273,13 +273,13 @@ def test_clone(grid): raise ValueError("[Test] Clone missing attribute") if not clone.vertex_attribute_manager().attribute_exists(attribute_d_id): raise ValueError("[Test] Clone missing attribute") - clone_attribute = clone.polyhedron_attribute_manager().read_attribute_int( + clone_attribute = clone.polyhedron_attribute_manager().find_read_only_attribute_int( attribute_id ) for c in range(clone.nb_cells()): if clone_attribute.value(c) != 2 * c: raise ValueError("[Test] Wrong clone attribute") - clone_attribute_d = clone.vertex_attribute_manager().read_attribute_double( + clone_attribute_d = clone.vertex_attribute_manager().find_read_only_attribute_double( attribute_d_id ) for c in range(clone.nb_vertices()): diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index c8e53023b..a2139c147 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -74,8 +74,8 @@ namespace geode * @exception OpenGeodeException if no Attribute found */ template < typename T > - [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > read_attribute( - const geode::uuid& attribute_id ) const + [[nodiscard]] std::shared_ptr< ReadOnlyAttribute< T > > + find_read_only_attribute( const geode::uuid& attribute_id ) const { absl::ReaderMutexLock lock{ mutex() }; auto attribute = @@ -83,7 +83,9 @@ namespace geode find_attribute_base( attribute_id ) ); OpenGeodeBasicException::check_exception( attribute.get(), nullptr, OpenGeodeException::TYPE::data, - "[AttributeManager::find_attribute] Could not find attribute '", + "[AttributeManager::find_read_only_attribute] Could not find " + "attribute " + "with id :'", attribute_id.string(), "'. You have to create an attribute before using it. See " "create_attribute method and derived classes of " @@ -100,7 +102,8 @@ namespace geode find_attribute_base( attribute_id ) ); OpenGeodeBasicException::check_exception( attribute.get(), nullptr, OpenGeodeException::TYPE::data, - "[AttributeManager::find_attribute] Could not find attribute '", + "[AttributeManager::find_attribute] Could not find attribute " + "with id : '", attribute_id.string(), "'. You have to create an attribute before using it. See " "create_attribute method and derived classes of " @@ -121,26 +124,16 @@ namespace geode OpenGeodeBasicException::check_exception( typed_attribute.get() == nullptr, nullptr, OpenGeodeException::TYPE::data, - "[AttributeManager::create_attribute] Attribute '", + "[AttributeManager::create_attribute] Attribute with id '", attribute_id.string(), "' already exists." ); - typed_attribute.reset( - new Attribute< T >{ std::move( default_value ), attribute_name, - std::move( properties ), {} } ); + typed_attribute = std::make_unique< Attribute< T > >( + std::move( default_value ), attribute_name, + std::move( properties ), AttributeBase::AttributeKey{} ); IdentifierBuilder builder{ *typed_attribute }; builder.set_id( attribute_id ); register_attribute( typed_attribute, attribute_id ); } - template < template < typename > class Attribute, typename T > - void create_attribute( std::string_view attribute_name, - const geode::uuid& attribute_id, - T default_value ) - { - return create_attribute< Attribute, T >( attribute_name, - attribute_id, std::move( default_value ), - AttributeProperties{} ); - } - template < template < typename > class Attribute, typename T > [[nodiscard]] geode::uuid create_attribute( std::string_view attribute_name, @@ -153,14 +146,6 @@ namespace geode return attribute_id; } - template < template < typename > class Attribute, typename T > - [[nodiscard]] geode::uuid create_attribute( - std::string_view attribute_name, T default_value ) - { - return create_attribute< Attribute, T >( attribute_name, - std::move( default_value ), AttributeProperties{} ); - } - /*! * Resize all the attributes to the given size * @param[in] size The new attribute size @@ -205,26 +190,26 @@ namespace geode [[nodiscard]] bool has_interpolable_attributes() const; /*! - * Get all the associated attribute names + * Get all the associated attribute ids */ [[nodiscard]] absl::FixedArray< geode::uuid > attribute_ids() const; /*! - * Return true if an attribute matching the given name. - * @param[in] name The attribute name to use + * Return true if an attribute matching the given id. + * @param[in] id The attribute id to use */ [[nodiscard]] bool attribute_exists( const geode::uuid& ) const; /*! - * Delete the attribute matching the given name. - * Do nothing if the name does not exist. - * @param[in] name The attribute name to delete + * Delete the attribute matching the given id. + * Do nothing if the id does not exist. + * @param[in] id The attribute id to delete */ void delete_attribute( const geode::uuid& ); /*! - * Get the typeid name of the attribute type - * @param[in] name The attribute name to use + * Get the typeid id of the attribute type + * @param[in] id The attribute id to use */ [[nodiscard]] std::string_view attribute_type( const geode::uuid& ) const; @@ -265,8 +250,8 @@ namespace geode [[nodiscard]] std::optional< std::string_view > attribute_name( const uuid& ) const; - std::optional< std::vector< uuid > > attribute_ids_with_name( - std::string_view name ) const; + [[nodiscard]] std::optional< std::vector< uuid > > + attribute_ids_matching_name( std::string_view name ) const; void copy( const AttributeManager& attribute_manager ); @@ -275,14 +260,14 @@ namespace geode void import( const AttributeManager& attribute_manager, absl::Span< const index_t > old2new, - uuid attribute_id ); + const uuid& attribute_id ); void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping ); void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping, - uuid attribute_id ); + const uuid& attribute_id ); private: friend class bitsery::Access; diff --git a/include/geode/mesh/core/internal/texture_impl.hpp b/include/geode/mesh/core/internal/texture_impl.hpp index 6e58459cb..2922cfe61 100644 --- a/include/geode/mesh/core/internal/texture_impl.hpp +++ b/include/geode/mesh/core/internal/texture_impl.hpp @@ -94,7 +94,8 @@ namespace geode { const auto texture_id = manager.create_attribute< VariableAttribute, - ElementTextureCoordinates >( name, {} ); + ElementTextureCoordinates >( + name, {}, geode::AttributeProperties{} ); coordinates_ = manager.find_attribute< VariableAttribute, ElementTextureCoordinates >( texture_id ); } diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index c4e71af31..04d7f4f78 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -227,7 +227,7 @@ namespace geode return attributes_.at( id )->name().value_or( "unknown" ); } - std::optional< std::vector< uuid > > attribute_ids_with_name( + std::optional< std::vector< uuid > > attribute_ids_matching_name( std::string_view name ) const { std::vector< uuid > ids; @@ -560,9 +560,10 @@ namespace geode } std::optional< std::vector< geode::uuid > > - AttributeManager::attribute_ids_with_name( std::string_view name ) const + AttributeManager::attribute_ids_matching_name( + std::string_view name ) const { - return impl_->attribute_ids_with_name( name ); + return impl_->attribute_ids_matching_name( name ); } std::optional< std::string_view > AttributeManager::attribute_name( @@ -579,7 +580,7 @@ namespace geode void AttributeManager::import( const AttributeManager &attribute_manager, absl::Span< const index_t > old2new, - geode::uuid attribute_id ) + const geode::uuid &attribute_id ) { impl_->import( *attribute_manager.impl_, old2new, attribute_id, {} ); } @@ -592,7 +593,7 @@ namespace geode void AttributeManager::import( const AttributeManager &attribute_manager, const GenericMapping< index_t > &old2new_mapping, - geode::uuid attribute_id ) + const geode::uuid &attribute_id ) { impl_->import( *attribute_manager.impl_, old2new_mapping, attribute_id, {} ); diff --git a/src/geode/mesh/core/geode/geode_edged_curve.cpp b/src/geode/mesh/core/geode/geode_edged_curve.cpp index ae4e8a3a8..f9a7a81a8 100644 --- a/src/geode/mesh/core/geode/geode_edged_curve.cpp +++ b/src/geode/mesh/core/geode/geode_edged_curve.cpp @@ -118,7 +118,7 @@ namespace geode archive.object( edged_curve.impl_ ); const auto new_point_attribute_id = edged_curve.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -133,8 +133,9 @@ namespace geode archive.object( edged_curve.impl_ ); const auto new_point_attribute_id = edged_curve.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp index 355301ab0..8e75d2c40 100644 --- a/src/geode/mesh/core/geode/geode_hybrid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_hybrid_solid.cpp @@ -637,7 +637,7 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -651,8 +651,9 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_point_set.cpp b/src/geode/mesh/core/geode/geode_point_set.cpp index af8827abc..d176a3214 100644 --- a/src/geode/mesh/core/geode/geode_point_set.cpp +++ b/src/geode/mesh/core/geode/geode_point_set.cpp @@ -96,7 +96,7 @@ namespace geode archive.object( point_set.impl_ ); const auto new_attribute_id = point_set.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -110,8 +110,9 @@ namespace geode archive.object( point_set.impl_ ); const auto new_attribute_id = point_set.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp index d2b040dcd..2e90f41c0 100644 --- a/src/geode/mesh/core/geode/geode_polygonal_surface.cpp +++ b/src/geode/mesh/core/geode/geode_polygonal_surface.cpp @@ -282,7 +282,7 @@ namespace geode archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -297,8 +297,9 @@ namespace geode archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp index 2f94bdae8..44aa7181f 100644 --- a/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_polyhedral_solid.cpp @@ -541,7 +541,7 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -556,8 +556,9 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp index 78a2668fa..a24b3b629 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_solid.cpp @@ -223,7 +223,7 @@ namespace geode archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() - .attribute_ids_with_name( + .attribute_ids_matching_name( internal::PointsImpl< 3 >::POINTS_NAME ) .value() .at( 0 ); @@ -237,7 +237,7 @@ namespace geode archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() - .attribute_ids_with_name( + .attribute_ids_matching_name( internal::PointsImpl< 3 >::POINTS_NAME ) .value() .at( 0 ); diff --git a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp index 5818cda16..e763c5b41 100644 --- a/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp +++ b/src/geode/mesh/core/geode/geode_regular_grid_surface.cpp @@ -201,7 +201,7 @@ namespace geode archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() - .attribute_ids_with_name( + .attribute_ids_matching_name( internal::PointsImpl< 2 >::POINTS_NAME ) .value() .at( 0 ); @@ -215,7 +215,7 @@ namespace geode archive.object( grid.impl_ ); const auto new_point_attribute_id = grid.vertex_attribute_manager() - .attribute_ids_with_name( + .attribute_ids_matching_name( internal::PointsImpl< 2 >::POINTS_NAME ) .value() .at( 0 ); diff --git a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp index aeedfc13d..d0ec55671 100644 --- a/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp +++ b/src/geode/mesh/core/geode/geode_tetrahedral_solid.cpp @@ -241,7 +241,7 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -256,8 +256,9 @@ namespace geode archive.object( solid.impl_ ); const auto new_point_attribute_id = solid.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp index bdc0f7849..04196ccc4 100644 --- a/src/geode/mesh/core/geode/geode_triangulated_surface.cpp +++ b/src/geode/mesh/core/geode/geode_triangulated_surface.cpp @@ -219,7 +219,7 @@ namespace geode archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< + .attribute_ids_matching_name( internal::PointsImpl< dimension >::POINTS_NAME ) .value() .at( 0 ); @@ -235,8 +235,9 @@ namespace geode archive.object( surface.impl_ ); const auto new_point_attribute_id = surface.vertex_attribute_manager() - .attribute_ids_with_name( internal::PointsImpl< - dimension >::POINTS_NAME ) + .attribute_ids_matching_name( + internal::PointsImpl< + dimension >::POINTS_NAME ) .value() .at( 0 ); detail::template initialize_crs< diff --git a/src/geode/mesh/helpers/convert_grid.cpp b/src/geode/mesh/helpers/convert_grid.cpp index 4efbb43a3..f362f3227 100644 --- a/src/geode/mesh/helpers/convert_grid.cpp +++ b/src/geode/mesh/helpers/convert_grid.cpp @@ -54,7 +54,7 @@ namespace geode auto color_attribute_id = grid.cell_attribute_manager() .template create_attribute< VariableAttribute, RGBColor >( - "RGB_data", {} ); + "RGB_data", {}, geode::AttributeProperties{} ); auto color = grid.cell_attribute_manager() .template find_attribute< VariableAttribute, RGBColor >( diff --git a/src/geode/mesh/helpers/euclidean_distance_transform.cpp b/src/geode/mesh/helpers/euclidean_distance_transform.cpp index 395b98e21..ace718e1f 100644 --- a/src/geode/mesh/helpers/euclidean_distance_transform.cpp +++ b/src/geode/mesh/helpers/euclidean_distance_transform.cpp @@ -46,8 +46,8 @@ namespace geode const auto distance_map_id = grid.cell_attribute_manager() .template create_attribute< VariableAttribute, double >( - distance_map_name, - std::numeric_limits< double >::max() ); + distance_map_name, std::numeric_limits< double >::max(), + geode::AttributeProperties{} ); distance_map_ = grid.cell_attribute_manager() .template find_attribute< VariableAttribute, double >( diff --git a/src/geode/mesh/helpers/gradient_computation.cpp b/src/geode/mesh/helpers/gradient_computation.cpp index dfdf6f508..69202df90 100644 --- a/src/geode/mesh/helpers/gradient_computation.cpp +++ b/src/geode/mesh/helpers/gradient_computation.cpp @@ -74,8 +74,9 @@ namespace auto gradient_function_id = mesh_.vertex_attribute_manager() .template create_attribute< geode::VariableAttribute, - geode::Vector< Mesh::dim > >( - gradient_function_name, geode::Vector< Mesh::dim >{} ); + geode::Vector< Mesh::dim > >( gradient_function_name, + geode::Vector< Mesh::dim >{}, + geode::AttributeProperties{} ); auto gradient_function = mesh_.vertex_attribute_manager() .template find_attribute< geode::VariableAttribute, @@ -109,9 +110,9 @@ namespace nullptr, geode::OpenGeodeException::TYPE::data, "[compute_scalar_function_gradient] The attribute linked to " "given id is not scalar." ); - scalar_function_ = - mesh_.vertex_attribute_manager() - .template read_attribute< double >( scalar_function_id ); + scalar_function_ = mesh_.vertex_attribute_manager() + .template find_read_only_attribute< double >( + scalar_function_id ); } bool compute_gradient( diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index aa58d0a0a..6de351111 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -235,7 +235,7 @@ namespace geode void RelationshipsImpl::initialize_attributes() { const auto ids = - graph_->vertex_attribute_manager().attribute_ids_with_name( + graph_->vertex_attribute_manager().attribute_ids_matching_name( "id" ); if( ids.has_value() ) { @@ -247,7 +247,7 @@ namespace geode const auto id = graph_->vertex_attribute_manager() .create_attribute< VariableAttribute, ComponentID >( - "id", ComponentID{} ); + "id", ComponentID{}, AttributeProperties{} ); ids_ = graph_->vertex_attribute_manager() .find_attribute< VariableAttribute, ComponentID >( id ); } diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index 10d30beda..33883af6b 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -242,7 +242,7 @@ namespace geode void initialize_relation_attribute() { const auto ids = - relation_attribute_manager().attribute_ids_with_name( + relation_attribute_manager().attribute_ids_matching_name( "relation_type" ); if( ids.has_value() ) { @@ -255,7 +255,7 @@ namespace geode const auto id = relation_attribute_manager() .create_attribute< VariableAttribute, RelationType >( - "relation_type", NO_ID ); + "relation_type", NO_ID, geode::AttributeProperties{} ); relation_type_ = relation_attribute_manager() .find_attribute< VariableAttribute, RelationType >( id ); diff --git a/tests/basic/test-attribute.cpp b/tests/basic/test-attribute.cpp index 05cab2530..c52bad9fc 100644 --- a/tests/basic/test-attribute.cpp +++ b/tests/basic/test-attribute.cpp @@ -119,7 +119,7 @@ void test_constant_attribute( geode::OpenGeodeBasicException::test( constant_attribute->default_value() == true, "Wrong default value" ); - auto attribute = manager.read_attribute< bool >( attribute_id ); + auto attribute = manager.find_read_only_attribute< bool >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 0 ), "Should be equal to true" ); geode::OpenGeodeBasicException::test( @@ -135,7 +135,7 @@ void test_foo_constant_attribute( geode::AttributeManager& manager, const geode::uuid& attribute_id ) { manager.create_attribute< geode::ConstantAttribute, Foo >( - "foo", attribute_id, Foo{} ); + "foo", attribute_id, Foo{}, geode::AttributeProperties{} ); auto constant_attribute = manager.find_attribute< geode::ConstantAttribute, Foo >( attribute_id ); constant_attribute->modify_value( []( Foo& foo ) { @@ -188,7 +188,8 @@ void test_int_variable_attribute( variable_attribute->default_value() == 12, "Wrong default value" ); variable_attribute->set_value( 3, 3 ); - const auto attribute = manager.read_attribute< int >( attribute_id ); + const auto attribute = + manager.find_read_only_attribute< int >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 3 ) == 3, "Int variable value 3 should be equal to 3" ); geode::OpenGeodeBasicException::test( attribute->value( 6 ) == 12, @@ -203,7 +204,7 @@ void test_foo_sparse_attribute( geode::AttributeManager& manager, const geode::uuid& attribute_id ) { manager.create_attribute< geode::SparseAttribute, Foo >( - "foo", attribute_id, Foo{} ); + "foo", attribute_id, Foo{}, geode::AttributeProperties{} ); auto sparse_attribute = manager.find_attribute< geode::SparseAttribute, Foo >( attribute_id ); sparse_attribute->modify_value( 3, []( Foo& foo ) { @@ -237,7 +238,7 @@ void test_double_sparse_attribute( manager.assign_attribute_value( 3, 2 ); manager.interpolate_attribute_value( { { 1, 7 }, { 0.5, 0.3 } }, 4 ); - auto attribute = manager.read_attribute< double >( attribute_id ); + auto attribute = manager.find_read_only_attribute< double >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 2 ) == 3, "Double sparse value 2 should be equal to 3" ); geode::OpenGeodeBasicException::test( attribute->value( 3 ) == 3, @@ -274,7 +275,8 @@ void test_double_array_attribute( geode::AttributeManager& manager ) manager.interpolate_attribute_value( { { 1, 7 }, { 0.5, 0.3 } }, 4 ); auto attribute = - manager.read_attribute< std::array< double, 3 > >( attribute_id ); + manager.find_read_only_attribute< std::array< double, 3 > >( + attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 2 )[0] == 1., "Value [2,0] Should be equal to 1., not ", attribute->value( 2 )[0] ); geode::OpenGeodeBasicException::test( attribute->value( 2 )[1] == 2., @@ -328,7 +330,8 @@ void test_bool_variable_attribute( variable_attribute->default_value() == false, "Wrong default value" ); variable_attribute->set_value( 3, true ); - const auto attribute = manager.read_attribute< bool >( attribute_id ); + const auto attribute = + manager.find_read_only_attribute< bool >( attribute_id ); geode::OpenGeodeBasicException::test( attribute->value( 3 ), "Should be equal to true" ); @@ -369,8 +372,9 @@ void check_one_attribute_values( geode::AttributeManager& manager, geode::AttributeManager& reloaded_manager, const geode::uuid& attribute_id ) { - const auto in_att = manager.read_attribute< T >( attribute_id ); - const auto out_att = reloaded_manager.read_attribute< T >( attribute_id ); + const auto in_att = manager.find_read_only_attribute< T >( attribute_id ); + const auto out_att = + reloaded_manager.find_read_only_attribute< T >( attribute_id ); for( auto i : geode::Range{ manager.nb_elements() } ) { geode::OpenGeodeBasicException::test( @@ -496,7 +500,7 @@ void test_sparse_attribute_after_element_deletion( geode::AttributeManager& manager, const geode::uuid& double_attribute_id ) { const auto sparse_attribute = - manager.read_attribute< double >( double_attribute_id ); + manager.find_read_only_attribute< double >( double_attribute_id ); geode::OpenGeodeBasicException::test( sparse_attribute->value( 0 ) == 12, "Element 0 of sparse attribute should be 12 " ); geode::OpenGeodeBasicException::test( sparse_attribute->value( 3 ) == 3, @@ -511,7 +515,8 @@ geode::uuid test_generic_value( geode::AttributeManager& manager, const geode::uuid& foo_sparse_id, const geode::uuid& double_attribute_id ) { - const auto& foo_attr = manager.read_attribute< Foo >( foo_sparse_id ); + const auto& foo_attr = + manager.find_read_only_attribute< Foo >( foo_sparse_id ); geode::OpenGeodeBasicException::test( foo_attr->is_genericable(), "Foo attribute should be genericable" ); geode::OpenGeodeBasicException::test( foo_attr->generic_value( 3 ) == 15.4f, @@ -519,13 +524,13 @@ geode::uuid test_generic_value( geode::AttributeManager& manager, "15.4" ); const auto& double_attr = - manager.read_attribute< double >( double_attribute_id ); + manager.find_read_only_attribute< double >( double_attribute_id ); geode::OpenGeodeBasicException::test( double_attr->generic_value( 7 ) == 7, "Generic value for element 7 of double attribute should be 7" ); auto array_attr_id = manager.create_attribute< geode::VariableAttribute, - std::array< double, 2 > >( - "array_double_2", std::array< double, 2 >() ); + std::array< double, 2 > >( "array_double_2", std::array< double, 2 >(), + geode::AttributeProperties{} ); auto array_attr = manager.find_attribute< geode::VariableAttribute, std::array< double, 2 > >( array_attr_id ); array_attr->set_value( 2, { 3.1, 1.3 } ); @@ -578,10 +583,12 @@ void test_import_manager( geode::AttributeManager& manager, manager3.import( manager, old2new ); test_attribute_types( manager3, bool_variable_attribute_id ); test_number_of_attributes( manager3, 8 ); - auto array_attr = manager.read_attribute< std::array< double, 2 > >( - array_double_attribute_id ); - auto array_attr2 = manager3.read_attribute< std::array< double, 2 > >( - array_double_attribute_id ); + auto array_attr = + manager.find_read_only_attribute< std::array< double, 2 > >( + array_double_attribute_id ); + auto array_attr2 = + manager3.find_read_only_attribute< std::array< double, 2 > >( + array_double_attribute_id ); geode::OpenGeodeBasicException::test( array_attr->value( 2 ) == array_attr2->value( 4 ), "Error in attribute import value." ); @@ -605,7 +612,7 @@ void test_multi_import_manager() from1.resize( 10 ); auto attr1_from1_id = from1.create_attribute< geode::VariableAttribute, geode::index_t >( - " variable", 42 ); + " variable", 42, geode::AttributeProperties{} ); auto attr1_from1 = from1.find_attribute< geode::VariableAttribute, geode::index_t >( attr1_from1_id ); @@ -615,12 +622,12 @@ void test_multi_import_manager() } auto attr2_from1_id = from1.create_attribute< geode::ConstantAttribute, double >( - "constant", 1.0 ); + "constant", 1.0, geode::AttributeProperties{} ); auto attr2_from1 = from1.find_attribute< geode::ConstantAttribute, double >( attr2_from1_id ); auto attr3_from1_id = from1.create_attribute< geode::SparseAttribute, std::string >( - "sparse", "default" ); + "sparse", "default", geode::AttributeProperties{} ); auto attr3_from1 = from1.find_attribute< geode::SparseAttribute, std::string >( attr3_from1_id ); @@ -629,7 +636,7 @@ void test_multi_import_manager() geode::AttributeManager from2; from2.resize( 10 ); from2.create_attribute< geode::VariableAttribute, geode::index_t >( - " variable", attr1_from1_id, 42 ); + " variable", attr1_from1_id, 42, geode::AttributeProperties{} ); auto attr1_from2 = from2.find_attribute< geode::VariableAttribute, geode::index_t >( attr1_from1_id ); @@ -638,11 +645,11 @@ void test_multi_import_manager() attr1_from2->set_value( i, from2.nb_elements() - i ); } from2.create_attribute< geode::ConstantAttribute, double >( - "constant", attr2_from1_id, 2.0 ); + "constant", attr2_from1_id, 2.0, geode::AttributeProperties{} ); auto attr2_from2 = from2.find_attribute< geode::ConstantAttribute, double >( attr2_from1_id ); - from2.create_attribute< geode::SparseAttribute, std::string >( - "sparse", attr3_from1_id, "another_default" ); + from2.create_attribute< geode::SparseAttribute, std::string >( "sparse", + attr3_from1_id, "another_default", geode::AttributeProperties{} ); auto attr3_from2 = from2.find_attribute< geode::SparseAttribute, std::string >( attr3_from1_id ); @@ -677,10 +684,11 @@ void test_multi_import_manager() "default", "default", "another_default", "two", "another_default", "another_default", "another_default" }; const auto result_variable = - to.read_attribute< geode::index_t >( attr1_from1_id ); - const auto result_constant = to.read_attribute< double >( attr2_from1_id ); + to.find_read_only_attribute< geode::index_t >( attr1_from1_id ); + const auto result_constant = + to.find_read_only_attribute< double >( attr2_from1_id ); const auto result_sparse = - to.read_attribute< std::string >( attr3_from1_id ); + to.find_read_only_attribute< std::string >( attr3_from1_id ); for( const auto i : geode::LRange( from2.nb_elements() ) ) { @@ -703,7 +711,8 @@ void test_permutation( geode::AttributeManager& manager, std::vector< geode::index_t > permutation{ 2, 1, 4, 6, 7, 8, 5, 9, 3, 0 }; manager.permute_elements( permutation ); - const auto int_attribute = manager.read_attribute< int >( int_att_id ); + const auto int_attribute = + manager.find_read_only_attribute< int >( int_att_id ); geode::OpenGeodeBasicException::test( int_attribute->value( 3 ) == 12, "Attribute value 3 should be equal to 12" ); geode::OpenGeodeBasicException::test( int_attribute->value( 0 ) == 5, @@ -711,7 +720,8 @@ void test_permutation( geode::AttributeManager& manager, geode::OpenGeodeBasicException::test( int_attribute->value( 8 ) == 5, "Attribute value 8 should be equal to 5" ); - auto double_attribute = manager.read_attribute< double >( double_att_id ); + auto double_attribute = + manager.find_read_only_attribute< double >( double_att_id ); geode::OpenGeodeBasicException::test( double_attribute->value( 2 ) == 12, "Attribute value 2 should be equal to 3, not ", double_attribute->value( 2 ) ); diff --git a/tests/image/test-colors.cpp b/tests/image/test-colors.cpp index 3416dd56c..cc0356728 100644 --- a/tests/image/test-colors.cpp +++ b/tests/image/test-colors.cpp @@ -48,15 +48,15 @@ void test_color_attribute() manager.resize( 1 ); const auto rgb_attribute_id = manager.create_attribute< geode::VariableAttribute, geode::RGBColor >( - "rgb_color", geode::RGBColor{} ); + "rgb_color", geode::RGBColor{}, geode::AttributeProperties{} ); auto rgb_attribute = manager.find_attribute< geode::VariableAttribute, geode::RGBColor >( rgb_attribute_id ); rgb_attribute->set_value( 0, { 3, 254, 68 } ); const auto greyscale_attribute_id = manager.create_attribute< geode::VariableAttribute, - geode::GreyscaleColor >( - "greyscale_color", geode::GreyscaleColor{} ); + geode::GreyscaleColor >( "greyscale_color", geode::GreyscaleColor{}, + geode::AttributeProperties{} ); auto greyscale_attribute = manager.find_attribute< geode::VariableAttribute, geode::GreyscaleColor >( greyscale_attribute_id ); greyscale_attribute->set_value( 0, geode::GreyscaleColor{ 67 } ); diff --git a/tests/mesh/test-convert-surface.cpp b/tests/mesh/test-convert-surface.cpp index 9d85262ca..9c2823fc6 100644 --- a/tests/mesh/test-convert-surface.cpp +++ b/tests/mesh/test-convert-surface.cpp @@ -118,7 +118,8 @@ void convert_grid_to_surface() auto test_attribute_id = old_regular_grid_surface->vertex_attribute_manager() .create_attribute< geode::VariableAttribute, geode::Point2D >( - "test", geode::Point2D{ { 0., 0. } } ); + "test", geode::Point2D{ { 0., 0. } }, + geode::AttributeProperties{} ); auto test_attribute = old_regular_grid_surface->vertex_attribute_manager() .find_attribute< geode::VariableAttribute, geode::Point2D >( @@ -128,8 +129,9 @@ void convert_grid_to_surface() *old_regular_grid ) .value(); old_regular_grid_surface2->vertex_attribute_manager() - .create_attribute< geode::VariableAttribute, geode::Point2D >( - "test", test_attribute_id, geode::Point2D{ { 0., 0. } } ); + .create_attribute< geode::VariableAttribute, geode::Point2D >( "test", + test_attribute_id, geode::Point2D{ { 0., 0. } }, + geode::AttributeProperties{} ); auto test_attribute2 = old_regular_grid_surface2->vertex_attribute_manager() .find_attribute< geode::VariableAttribute, geode::Point2D >( diff --git a/tests/mesh/test-edged-curve.cpp b/tests/mesh/test-edged-curve.cpp index bfab452bd..8e2c41f4b 100644 --- a/tests/mesh/test-edged-curve.cpp +++ b/tests/mesh/test-edged-curve.cpp @@ -311,9 +311,9 @@ void test_edge_requests( const geode::EdgedCurve3D& edged_curve, void test_clone( const geode::EdgedCurve3D& edged_curve ) { - auto attribute_id = - edged_curve.edge_attribute_manager() - .create_attribute< geode::VariableAttribute, int >( "edge", 0 ); + auto attribute_id = edged_curve.edge_attribute_manager() + .create_attribute< geode::VariableAttribute, int >( + "edge", 0, geode::AttributeProperties{} ); auto attribute = edged_curve.edge_attribute_manager() .find_attribute< geode::VariableAttribute, int >( attribute_id ); @@ -328,7 +328,7 @@ void test_clone( const geode::EdgedCurve3D& edged_curve ) edged_curve2.nb_edges() == 3, "EdgedCurve2 should have 3 edge" ); const auto attribute2 = - edged_curve2.edge_attribute_manager().read_attribute< int >( + edged_curve2.edge_attribute_manager().find_read_only_attribute< int >( attribute_id ); geode::OpenGeodeMeshException::test( attribute2->value( 0 ) == 42, "EdgedCurve2 attribute should be 42" ); diff --git a/tests/mesh/test-generic-mesh-accessor.cpp b/tests/mesh/test-generic-mesh-accessor.cpp index d7e30df06..2753fd0ca 100644 --- a/tests/mesh/test-generic-mesh-accessor.cpp +++ b/tests/mesh/test-generic-mesh-accessor.cpp @@ -53,7 +53,7 @@ std::unique_ptr< geode::EdgedCurve3D > create_edged_curve( builder->create_edge( 0, 2 ); edged_curve->edge_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "edge", attribute_id, 2 ); + "edge", attribute_id, 2, geode::AttributeProperties{} ); auto attribute = edged_curve->edge_attribute_manager() .find_attribute< geode::VariableAttribute, geode::index_t >( @@ -76,7 +76,7 @@ std::unique_ptr< geode::TriangulatedSurface2D > create_surface( builder->compute_polygon_adjacencies(); surface->polygon_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "surface", attribute_id, 2 ); + "surface", attribute_id, 2, geode::AttributeProperties{} ); auto attribute = surface->polygon_attribute_manager() .find_attribute< geode::VariableAttribute, geode::index_t >( @@ -100,7 +100,7 @@ std::unique_ptr< geode::TetrahedralSolid3D > create_solid( builder->compute_polyhedron_adjacencies(); solid->polyhedron_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "solid", attribute_id, 2 ); + "solid", attribute_id, 2, geode::AttributeProperties{} ); auto attribute = solid->polyhedron_attribute_manager() .find_attribute< geode::VariableAttribute, geode::index_t >( @@ -135,7 +135,8 @@ void test_basic_accessor( const Mesh& mesh, "Wrong size of element vertices container" ); const auto attribute = accessor.element_attribute_manager() - .template read_attribute< geode::index_t >( attribute_id ); + .template find_read_only_attribute< geode::index_t >( + attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == 2 && attribute->value( 1 ) == 5, "Wrong values of the element attributes." ); diff --git a/tests/mesh/test-gradient-computation.cpp b/tests/mesh/test-gradient-computation.cpp index 4c55ef1d6..483b74016 100644 --- a/tests/mesh/test-gradient-computation.cpp +++ b/tests/mesh/test-gradient-computation.cpp @@ -51,7 +51,7 @@ void test_gradient_grid2D() auto attribute_id = grid->vertex_attribute_manager() .create_attribute< geode::VariableAttribute, double >( - "scalar_function", 0 ); + "scalar_function", 0, geode::AttributeProperties{} ); auto attribute = grid->vertex_attribute_manager() .find_attribute< geode::VariableAttribute, double >( attribute_id ); @@ -104,7 +104,7 @@ void test_gradient_triangulated_surface2D() auto attribute_id = surface->vertex_attribute_manager() .create_attribute< geode::VariableAttribute, double >( - "scalar_function", 0 ); + "scalar_function", 0, geode::AttributeProperties{} ); auto attribute = surface->vertex_attribute_manager() .find_attribute< geode::VariableAttribute, double >( attribute_id ); @@ -133,7 +133,7 @@ void test_gradient_grid3D() auto attribute_id = grid->vertex_attribute_manager() .create_attribute< geode::VariableAttribute, double >( - "scalar_function", 0 ); + "scalar_function", 0, geode::AttributeProperties{} ); auto attribute = grid->vertex_attribute_manager() .find_attribute< geode::VariableAttribute, double >( attribute_id ); diff --git a/tests/mesh/test-light-regular-grid.cpp b/tests/mesh/test-light-regular-grid.cpp index 818be70ec..ed559a51e 100644 --- a/tests/mesh/test-light-regular-grid.cpp +++ b/tests/mesh/test-light-regular-grid.cpp @@ -334,7 +334,8 @@ void test_attribute( const geode::LightRegularGrid3D& grid ) { auto attribute_id = grid.cell_attribute_manager() - .create_attribute< geode::VariableAttribute, double >( "test", -1 ); + .create_attribute< geode::VariableAttribute, double >( + "test", -1, geode::AttributeProperties{} ); auto attribute = grid.cell_attribute_manager() .find_attribute< geode::VariableAttribute, double >( attribute_id ); diff --git a/tests/mesh/test-point-set.cpp b/tests/mesh/test-point-set.cpp index e7cc4ee54..dc2f85ba0 100644 --- a/tests/mesh/test-point-set.cpp +++ b/tests/mesh/test-point-set.cpp @@ -84,9 +84,9 @@ void test_bounding_box( const geode::PointSet3D& point_set ) geode::uuid test_create_vertex_attribute( const geode::PointSet3D& point_set ) { - auto attribute_id = - point_set.vertex_attribute_manager() - .create_attribute< geode::ConstantAttribute, bool >( "bool", true ); + auto attribute_id = point_set.vertex_attribute_manager() + .create_attribute< geode::ConstantAttribute, bool >( + "bool", true, geode::AttributeProperties{} ); const auto attribute = point_set.vertex_attribute_manager() .find_attribute< geode::ConstantAttribute, bool >( attribute_id ); @@ -143,7 +143,7 @@ void test_clone( point_set2->nb_vertices() == 3, "PointSet2 should have 3 vertices" ); const auto attribute = - point_set2->vertex_attribute_manager().read_attribute< bool >( + point_set2->vertex_attribute_manager().find_read_only_attribute< bool >( attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == true, "PointSet2 attribute value should be true" ); diff --git a/tests/mesh/test-polygonal-surface.cpp b/tests/mesh/test-polygonal-surface.cpp index 440d3ba2d..c706d11ea 100644 --- a/tests/mesh/test-polygonal-surface.cpp +++ b/tests/mesh/test-polygonal-surface.cpp @@ -74,7 +74,7 @@ geode::uuid test_create_vertex_attribute( auto attribute_id = polygonal_surface.vertex_attribute_manager() .create_attribute< geode::VariableAttribute, geode::PolygonEdge >( - "test", geode::PolygonEdge{} ); + "test", geode::PolygonEdge{}, geode::AttributeProperties{} ); auto attribute = polygonal_surface.vertex_attribute_manager() .find_attribute< geode::VariableAttribute, geode::PolygonEdge >( @@ -232,7 +232,7 @@ geode::uuid test_create_edge_attribute( polygonal_surface.edges() .edge_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "edges", geode::NO_ID ); + "edges", geode::NO_ID, geode::AttributeProperties{} ); auto attribute = polygonal_surface.edges() .edge_attribute_manager() @@ -378,7 +378,7 @@ void test_delete_polygon( const geode::PolygonalSurface3D& polygonal_surface, const auto attribute = polygonal_surface.edges() .edge_attribute_manager() - .read_attribute< geode::index_t >( edge_attribute_id ); + .find_read_only_attribute< geode::index_t >( edge_attribute_id ); for( const auto e : geode::Range{ 6 } ) { geode::OpenGeodeMeshException::test( attribute->value( e ) == e, @@ -508,7 +508,7 @@ void test_io( const geode::PolygonalSurface3D& polygonal_surface, const auto attribute = new_polygonal_surface->edges() .edge_attribute_manager() - .read_attribute< geode::index_t >( edge_attribute_id ); + .find_read_only_attribute< geode::index_t >( edge_attribute_id ); for( const auto e : geode::Range{ new_polygonal_surface->edges().nb_edges() } ) { @@ -562,9 +562,9 @@ void test_clone( const geode::PolygonalSurface3D& polygonal_surface, geode::OpenGeodeMeshException::test( polygonal_surface2.nb_polygons() == 2, "PolygonalSurface2 should have 2 polygons" ); - const auto attribute2 = - polygonal_surface2.vertex_attribute_manager() - .read_attribute< geode::PolygonEdge >( vertex_attribute_id ); + const auto attribute2 = polygonal_surface2.vertex_attribute_manager() + .find_read_only_attribute< geode::PolygonEdge >( + vertex_attribute_id ); std::vector< geode::PolygonEdge > att_answer{ { 4, 0 }, { 2, 0 }, { 6, 0 }, { 1, 0 }, { 5, 0 }, { 0, 0 }, { 3, 0 } }; for( const auto v : geode::Range{ polygonal_surface2.nb_vertices() } ) diff --git a/tests/mesh/test-polyhedral-solid.cpp b/tests/mesh/test-polyhedral-solid.cpp index 5463982f0..feeb9a0cb 100644 --- a/tests/mesh/test-polyhedral-solid.cpp +++ b/tests/mesh/test-polyhedral-solid.cpp @@ -134,7 +134,7 @@ geode::uuid test_create_facet_attribute( polyhedral_solid.facets() .facet_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "facet_attribute", geode::NO_ID ); + "facet_attribute", geode::NO_ID, geode::AttributeProperties{} ); auto attribute = polyhedral_solid.facets() .facet_attribute_manager() @@ -154,7 +154,7 @@ geode::uuid test_create_edge_attribute( polyhedral_solid.edges() .edge_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "test", geode::NO_ID ); + "test", geode::NO_ID, geode::AttributeProperties{} ); auto attribute = polyhedral_solid.edges() .edge_attribute_manager() @@ -383,9 +383,10 @@ void test_delete_polyhedra( const geode::PolyhedralSolid3D& polyhedral_solid, geode::OpenGeodeMeshException::test( polyhedral_solid.edges().nb_edges() == 12, "PolyhedralSolid should have 12 edges" ); - auto attribute = polyhedral_solid.edges() - .edge_attribute_manager() - .read_attribute< geode::index_t >( edge_attribute_id ); + auto attribute = + polyhedral_solid.edges() + .edge_attribute_manager() + .find_read_only_attribute< geode::index_t >( edge_attribute_id ); geode::OpenGeodeMeshException::test( attribute->value( 0 ) == 1, "Wrong value for attribute on edge 0 after vertex deletion" ); geode::OpenGeodeMeshException::test( attribute->value( 1 ) == 3, @@ -430,7 +431,7 @@ void test_io( const geode::PolyhedralSolid3D& polyhedral_solid, auto attribute = new_polyhedral_solid->facets() .facet_attribute_manager() - .read_attribute< geode::index_t >( facet_attribute_id ); + .find_read_only_attribute< geode::index_t >( facet_attribute_id ); for( auto f : geode::Range{ new_polyhedral_solid->facets().nb_facets() } ) { geode::OpenGeodeMeshException::test( attribute->value( f ) == f, @@ -540,10 +541,11 @@ void test_normals() geode::uuid test_create_vertex_attribute( const geode::PolyhedralSolid3D& polyhedral_solid ) { - auto attribute_id = polyhedral_solid.vertex_attribute_manager() - .create_attribute< geode::VariableAttribute, - geode::PolyhedronFacetVertex >( - "test", geode::PolyhedronFacetVertex{} ); + auto attribute_id = + polyhedral_solid.vertex_attribute_manager() + .create_attribute< geode::VariableAttribute, + geode::PolyhedronFacetVertex >( "test", + geode::PolyhedronFacetVertex{}, geode::AttributeProperties{} ); auto attribute = polyhedral_solid.vertex_attribute_manager() .find_attribute< geode::VariableAttribute, geode::PolyhedronFacetVertex >( attribute_id ); @@ -569,9 +571,10 @@ void test_clone( const geode::PolyhedralSolid3D& polyhedral_solid, geode::OpenGeodeMeshException::test( polyhedral_solid2.nb_polyhedra() == 2, "PolyhedralSolid2 should have 2 polyhedra" ); - const auto attribute2 = polyhedral_solid2.vertex_attribute_manager() - .read_attribute< geode::PolyhedronFacetVertex >( - vertex_attribute_id ); + const auto attribute2 = + polyhedral_solid2.vertex_attribute_manager() + .find_read_only_attribute< geode::PolyhedronFacetVertex >( + vertex_attribute_id ); std::vector< geode::PolyhedronFacetVertex > att_answer{ { { 4, 0 }, 1 }, { { 2, 0 }, 1 }, { { 6, 0 }, 1 }, { { 1, 0 }, 1 }, { { 5, 0 }, 1 }, { { 0, 0 }, 1 }, { { 7, 0 }, 1 }, { { 3, 0 }, 1 } }; diff --git a/tests/mesh/test-regular-grid.cpp b/tests/mesh/test-regular-grid.cpp index 8fbc7fc77..ed208d9a6 100644 --- a/tests/mesh/test-regular-grid.cpp +++ b/tests/mesh/test-regular-grid.cpp @@ -353,16 +353,17 @@ void test_closest_vertex( const geode::RegularGrid3D& grid ) void test_clone( const geode::RegularGrid3D& grid ) { - auto attribute_id = grid.polyhedron_attribute_manager() - .create_attribute< geode::VariableAttribute, int >( - "int_attribute", 0 ); + auto attribute_id = + grid.polyhedron_attribute_manager() + .create_attribute< geode::VariableAttribute, int >( + "int_attribute", 0, geode::AttributeProperties{} ); auto attribute = grid.polyhedron_attribute_manager() .find_attribute< geode::VariableAttribute, int >( attribute_id ); auto attribute_d_id = grid.vertex_attribute_manager() .create_attribute< geode::VariableAttribute, double >( - "double_attribute", 0 ); + "double_attribute", 0, geode::AttributeProperties{} ); auto attribute_d = grid.vertex_attribute_manager() .find_attribute< geode::VariableAttribute, double >( attribute_d_id ); @@ -423,7 +424,7 @@ void test_clone( const geode::RegularGrid3D& grid ) clone->vertex_attribute_manager().attribute_exists( attribute_d_id ), "Clone missing attribute" ); const auto clone_attribute = - clone->polyhedron_attribute_manager().read_attribute< int >( + clone->polyhedron_attribute_manager().find_read_only_attribute< int >( attribute_id ); for( const auto c : geode::TRange< int >{ clone->nb_polyhedra() } ) { @@ -431,7 +432,7 @@ void test_clone( const geode::RegularGrid3D& grid ) clone_attribute->value( c ) == 2 * c, "Wrong clone attribute" ); } const auto clone_attribute_d = - clone->vertex_attribute_manager().read_attribute< double >( + clone->vertex_attribute_manager().find_read_only_attribute< double >( attribute_d_id ); for( const auto c : geode::TRange< int >{ clone->nb_vertices() } ) { diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index a5fe19129..b7bcc9bd8 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -343,7 +343,7 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) solid.facets() .facet_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "facet_id", 0 ); + "facet_id", 0, geode::AttributeProperties{} ); auto attr_from = solid.facets() .facet_attribute_manager() @@ -357,7 +357,7 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) solid.edges() .edge_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "edge_id", 0 ); + "edge_id", 0, geode::AttributeProperties{} ); auto attr_edge_from = solid.edges() .edge_attribute_manager() @@ -372,9 +372,10 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) geode::OpenGeodeTetrahedralSolid3D solid4{ std::move( *dynamic_cast< geode::OpenGeodeTetrahedralSolid3D* >( solid2.get() ) ) }; - const auto attr_to = solid4.facets() - .facet_attribute_manager() - .read_attribute< geode::index_t >( attr_from_id ); + const auto attr_to = + solid4.facets() + .facet_attribute_manager() + .find_read_only_attribute< geode::index_t >( attr_from_id ); for( const auto f : geode::Range{ solid.facets().nb_facets() } ) { geode::OpenGeodeMeshException::test( @@ -392,7 +393,7 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) const auto attr_edge_to = solid4.edges() .edge_attribute_manager() - .read_attribute< geode::index_t >( attr_edge_from_id ); + .find_read_only_attribute< geode::index_t >( attr_edge_from_id ); for( const auto e : geode::Range{ solid.edges().nb_edges() } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index 9c1043d48..1215cb29e 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -239,13 +239,11 @@ void test_io( void test_backward_io( const std::string& filename ) { - DEBUG( "test_backward_io" ); const auto surface = geode::load_triangulated_surface< 3 >( filename ); geode::OpenGeodeMeshException::test( surface->nb_vertices() == 5, "Backward TriangulatedSurface should have 5 vertices" ); geode::OpenGeodeMeshException::test( surface->nb_polygons() == 3, "Backward TriangulatedSurface should have 3 polygons" ); - SDEBUG( surface->point( 0 ) ); geode::OpenGeodeMeshException::test( surface->point( 0 ) == geode::Point3D{ { 0.1, 0.2, 0.3 } }, "Backward TriangulatedSurface should have point ( 0.1, 0.2, 0.3 ) at " @@ -268,7 +266,7 @@ void test_clone( const geode::TriangulatedSurface3D& surface ) surface.edges() .edge_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "edge_id", 0 ); + "edge_id", 0, geode::AttributeProperties{} ); auto attr_from = surface.edges() .edge_attribute_manager() @@ -288,9 +286,10 @@ void test_clone( const geode::TriangulatedSurface3D& surface ) "TriangulatedSurface2 should have 5 edges" ); geode::OpenGeodeMeshException::test( surface2.nb_polygons() == 2, "TriangulatedSurface2 should have 2 polygons" ); - auto attr_to = surface2.edges() - .edge_attribute_manager() - .read_attribute< geode::index_t >( attr_from_id ); + auto attr_to = + surface2.edges() + .edge_attribute_manager() + .find_read_only_attribute< geode::index_t >( attr_from_id ); for( const auto e : geode::Range{ surface.edges().nb_edges() } ) { geode::OpenGeodeMeshException::test( diff --git a/tests/model/test-relationships.cpp b/tests/model/test-relationships.cpp index 334c97547..35753cfd7 100644 --- a/tests/model/test-relationships.cpp +++ b/tests/model/test-relationships.cpp @@ -169,7 +169,8 @@ void test_attributes( const geode::Relationships& relations, "Wrong relation uuids from index" ); auto relation_att_id = relations.relation_attribute_manager() - .create_attribute< geode::VariableAttribute, int >( "int", 0 ); + .create_attribute< geode::VariableAttribute, int >( + "int", 0, geode::AttributeProperties{} ); const auto relation_att = relations.relation_attribute_manager() .find_attribute< geode::VariableAttribute, int >( relation_att_id ); From 3194d1b23290671446227e394f822ba5f99d28b9 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Mon, 22 Jun 2026 10:54:16 +0200 Subject: [PATCH 14/19] feat(Attribute): attribute are now identified with uuid. BREAKING CHANGE: attribute are now identified with uuid instead of strings which changes a lot of input parameters for attribute mananger methods. Also find_or_create_attribute was divided into two differents methods find_attribute and create_attribute --- .../geode/model/representation/io/geode/geode_brep_input.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/geode/model/representation/io/geode/geode_brep_input.hpp b/include/geode/model/representation/io/geode/geode_brep_input.hpp index 7c5aa7606..b77dd3084 100644 --- a/include/geode/model/representation/io/geode/geode_brep_input.hpp +++ b/include/geode/model/representation/io/geode/geode_brep_input.hpp @@ -71,7 +71,7 @@ namespace geode { BRepBuilder builder{ brep }; const auto level = Logger::level(); - // Logger::set_level( Logger::LEVEL::warn ); + Logger::set_level( Logger::LEVEL::warn ); async::parallel_invoke( [&builder, &directory] { builder.load_identifier( directory ); From 4a07b925492f3636a7476554fa430a2c12d1b3d3 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Tue, 23 Jun 2026 12:36:06 +0200 Subject: [PATCH 15/19] fixes for geosciences --- include/geode/basic/attribute.hpp | 2 ++ .../geode/geode_vertex_set_builder.hpp | 3 -- .../attribute_coordinate_reference_system.hpp | 2 ++ .../tetrahedral_solid_point_function.hpp | 11 ++++--- .../tetrahedral_solid_scalar_function.hpp | 15 ++++++---- .../triangulated_surface_point_function.hpp | 11 ++++--- .../triangulated_surface_scalar_function.hpp | 7 +++-- .../geode/geode_vertex_set_builder.cpp | 2 +- src/geode/mesh/builder/solid_mesh_builder.cpp | 8 +++-- .../attribute_coordinate_reference_system.cpp | 6 ++++ .../tetrahedral_solid_point_function.cpp | 27 ++++++++++------- .../tetrahedral_solid_scalar_function.cpp | 27 ++++++++++------- .../triangulated_surface_point_function.cpp | 27 ++++++++++------- .../triangulated_surface_scalar_function.cpp | 26 +++++++++++------ tests/mesh/test-triangulated-surface.cpp | 5 ++++ tests/model/test-brep.cpp | 29 +++++++++++++++++-- 16 files changed, 143 insertions(+), 65 deletions(-) diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index e9035c28e..3ef6851e1 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -144,6 +144,8 @@ namespace geode }, []( Archive& archive, AttributeBase& attribute ) { archive.object( attribute.properties_ ); + archive.ext( attribute, + bitsery::ext::BaseClass< Identifier >{} ); } } } ); } diff --git a/include/geode/mesh/builder/geode/geode_vertex_set_builder.hpp b/include/geode/mesh/builder/geode/geode_vertex_set_builder.hpp index bf676c631..15446f63f 100644 --- a/include/geode/mesh/builder/geode/geode_vertex_set_builder.hpp +++ b/include/geode/mesh/builder/geode/geode_vertex_set_builder.hpp @@ -59,8 +59,5 @@ namespace geode void do_permute_vertices( absl::Span< const index_t > permutation, absl::Span< const index_t > old2new ) final; - - private: - [[maybe_unused]] OpenGeodeVertexSet& geode_vertex_set_; }; } // namespace geode diff --git a/include/geode/mesh/core/attribute_coordinate_reference_system.hpp b/include/geode/mesh/core/attribute_coordinate_reference_system.hpp index 589149287..604f9ec9e 100644 --- a/include/geode/mesh/core/attribute_coordinate_reference_system.hpp +++ b/include/geode/mesh/core/attribute_coordinate_reference_system.hpp @@ -67,6 +67,8 @@ namespace geode [[nodiscard]] index_t nb_points() const; + [[nodiscard]] uuid attribute_id() const; + protected: AttributeCoordinateReferenceSystem(); diff --git a/include/geode/mesh/helpers/tetrahedral_solid_point_function.hpp b/include/geode/mesh/helpers/tetrahedral_solid_point_function.hpp index f2b150fd7..e35b346e3 100644 --- a/include/geode/mesh/helpers/tetrahedral_solid_point_function.hpp +++ b/include/geode/mesh/helpers/tetrahedral_solid_point_function.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include @@ -59,13 +60,13 @@ namespace geode /*! * Finds an object function that already exists in the given - * TetrahedralSolid, from its given name. - * Throws an exception if no attribute with the same name exists. + * TetrahedralSolid, from its given uuid. + * Throws an exception if no attribute with the same uuid exists. */ [[nodiscard]] static TetrahedralSolidPointFunction< dimension, point_dimension > find( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); void set_value( index_t vertex_index, Point< point_dimension > value ); @@ -75,10 +76,12 @@ namespace geode [[nodiscard]] Point< point_dimension > value( const Point< dimension >& point, index_t tetrahedron_id ) const; + [[nodiscard]] uuid attribute_function_id() const; + private: TetrahedralSolidPointFunction( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); TetrahedralSolidPointFunction( const TetrahedralSolid< dimension >& solid, diff --git a/include/geode/mesh/helpers/tetrahedral_solid_scalar_function.hpp b/include/geode/mesh/helpers/tetrahedral_solid_scalar_function.hpp index 1e0cffe70..9584d2557 100644 --- a/include/geode/mesh/helpers/tetrahedral_solid_scalar_function.hpp +++ b/include/geode/mesh/helpers/tetrahedral_solid_scalar_function.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include @@ -57,12 +58,12 @@ namespace geode /*! * Finds an object function that already exists in the given - * TetrahedralSolid, from its given name. - * Throws an exception if no attribute with the same name exists. + * TetrahedralSolid, from its given id. + * Throws an exception if no attribute with the same id exists. */ [[nodiscard]] static TetrahedralSolidScalarFunction< dimension > find( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); void set_value( index_t vertex_index, double value ); @@ -71,15 +72,17 @@ namespace geode [[nodiscard]] double value( const Point< dimension >& point, index_t tetrahedron_id ) const; + [[nodiscard]] uuid attribute_function_id() const; + private: TetrahedralSolidScalarFunction( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ); + std::string_view function_name, + double value ); TetrahedralSolidScalarFunction( const TetrahedralSolid< dimension >& solid, - std::string_view function_name, - double value ); + const uuid& function_id ); private: IMPLEMENTATION_MEMBER( impl_ ); diff --git a/include/geode/mesh/helpers/triangulated_surface_point_function.hpp b/include/geode/mesh/helpers/triangulated_surface_point_function.hpp index ddb81b749..df25323ec 100644 --- a/include/geode/mesh/helpers/triangulated_surface_point_function.hpp +++ b/include/geode/mesh/helpers/triangulated_surface_point_function.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include @@ -57,13 +58,13 @@ namespace geode /*! * Finds an object function that already exists in the given - * TriangulatedSurface, from its given name. - * Throws an exception if no attribute with the same name exists. + * TriangulatedSurface, from its given id. + * Throws an exception if no attribute with the same id exists. */ [[nodiscard]] static TriangulatedSurfacePointFunction< dimension, point_dimension > find( const TriangulatedSurface< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); void set_value( index_t vertex_index, Point< point_dimension > value ); @@ -73,10 +74,12 @@ namespace geode [[nodiscard]] Point< point_dimension > value( const Point< dimension >& point, index_t tetrahedron_id ) const; + [[nodiscard]] uuid attribute_function_id() const; + private: TriangulatedSurfacePointFunction( const TriangulatedSurface< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); TriangulatedSurfacePointFunction( const TriangulatedSurface< dimension >& solid, diff --git a/include/geode/mesh/helpers/triangulated_surface_scalar_function.hpp b/include/geode/mesh/helpers/triangulated_surface_scalar_function.hpp index c7bed50f6..dbe19724b 100644 --- a/include/geode/mesh/helpers/triangulated_surface_scalar_function.hpp +++ b/include/geode/mesh/helpers/triangulated_surface_scalar_function.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include @@ -60,7 +61,7 @@ namespace geode */ [[nodiscard]] static TriangulatedSurfaceScalarFunction< dimension > find( const TriangulatedSurface< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); void set_value( index_t vertex_index, double value ); @@ -69,10 +70,12 @@ namespace geode [[nodiscard]] double value( const Point< dimension >& point, index_t tetrahedron_id ) const; + [[nodiscard]] uuid attribute_function_id() const; + private: TriangulatedSurfaceScalarFunction( const TriangulatedSurface< dimension >& solid, - std::string_view function_name ); + const uuid& function_id ); TriangulatedSurfaceScalarFunction( const TriangulatedSurface< dimension >& solid, diff --git a/src/geode/mesh/builder/geode/geode_vertex_set_builder.cpp b/src/geode/mesh/builder/geode/geode_vertex_set_builder.cpp index 9094efe40..50ab836db 100644 --- a/src/geode/mesh/builder/geode/geode_vertex_set_builder.cpp +++ b/src/geode/mesh/builder/geode/geode_vertex_set_builder.cpp @@ -37,7 +37,7 @@ namespace geode OpenGeodeVertexSetBuilder::OpenGeodeVertexSetBuilder( OpenGeodeVertexSet& mesh ) - : VertexSetBuilder( mesh ), geode_vertex_set_( mesh ) + : VertexSetBuilder( mesh ) { } diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index 1b25101e8..9762e3d00 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -231,10 +233,10 @@ namespace template < geode::index_t dimension > void copy_polyhedra( const geode::SolidMesh< dimension >& solid, - const geode::SolidMesh< dimension >& solid_to_build, geode::SolidMeshBuilder< dimension >& builder ) { - if( solid_to_build.nb_polyhedra() != 0 ) + if( solid.impl_name() + == geode::OpenGeodeRegularGrid< dimension >::impl_name_static() ) { return; } @@ -964,9 +966,9 @@ namespace geode } VertexSetBuilder::copy( solid_mesh ); copy_points( solid_mesh, *this ); + copy_polyhedra( solid_mesh, *this ); solid_mesh_.polyhedron_attribute_manager().copy( solid_mesh.polyhedron_attribute_manager() ); - copy_polyhedra( solid_mesh, solid_mesh_, *this ); if( solid_mesh.are_edges_enabled() ) { solid_mesh_.copy_edges( solid_mesh, {} ); diff --git a/src/geode/mesh/core/attribute_coordinate_reference_system.cpp b/src/geode/mesh/core/attribute_coordinate_reference_system.cpp index 52386627b..812ce1871 100644 --- a/src/geode/mesh/core/attribute_coordinate_reference_system.cpp +++ b/src/geode/mesh/core/attribute_coordinate_reference_system.cpp @@ -108,6 +108,12 @@ namespace geode return impl_->attribute_name(); } + template < index_t dimension > + uuid AttributeCoordinateReferenceSystem< dimension >::attribute_id() const + { + return impl_->attribute_id(); + } + template < index_t dimension > index_t AttributeCoordinateReferenceSystem< dimension >::nb_points() const { diff --git a/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp b/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp index 74f140763..49153f16a 100644 --- a/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp +++ b/src/geode/mesh/helpers/tetrahedral_solid_point_function.cpp @@ -56,14 +56,9 @@ namespace geode } Impl( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) + const uuid& function_id ) : solid_( solid ) { - const auto function_id = - solid_.vertex_attribute_manager() - .template create_attribute< VariableAttribute, - Point< point_dimension > >( function_name, - Point< point_dimension >(), { false, true } ); function_attribute_ = solid_.vertex_attribute_manager() .template find_attribute< VariableAttribute, @@ -98,6 +93,11 @@ namespace geode return point_value; } + uuid attribute_function_id() const + { + return function_attribute_->id(); + } + private: const TetrahedralSolid< dimension >& solid_; std::shared_ptr< VariableAttribute< Point< point_dimension > > > @@ -127,8 +127,8 @@ namespace geode TetrahedralSolidPointFunction< dimension, point_dimension >:: TetrahedralSolidPointFunction( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) - : impl_{ solid, function_name } + const uuid& function_id ) + : impl_{ solid, function_id } { } @@ -150,9 +150,9 @@ namespace geode TetrahedralSolidPointFunction< dimension, point_dimension > TetrahedralSolidPointFunction< dimension, point_dimension >::find( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) + const uuid& function_id ) { - return { solid, function_name }; + return { solid, function_id }; } template < index_t dimension, index_t point_dimension > @@ -178,6 +178,13 @@ namespace geode return impl_->value( point, tetrahedron_id ); } + template < index_t dimension, index_t point_dimension > + uuid TetrahedralSolidPointFunction< dimension, + point_dimension >::attribute_function_id() const + { + return impl_->attribute_function_id(); + } + template class opengeode_mesh_api TetrahedralSolidPointFunction< 3, 3 >; template class opengeode_mesh_api TetrahedralSolidPointFunction< 3, 2 >; template class opengeode_mesh_api TetrahedralSolidPointFunction< 3, 1 >; diff --git a/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp b/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp index cb8ef104c..c269ab994 100644 --- a/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp +++ b/src/geode/mesh/helpers/tetrahedral_solid_scalar_function.cpp @@ -54,13 +54,9 @@ namespace geode } Impl( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) + const uuid& function_id ) : solid_( solid ) { - const auto function_id = - solid_.vertex_attribute_manager() - .template create_attribute< VariableAttribute, double >( - function_name, 0, { false, true } ); function_attribute_ = solid_.vertex_attribute_manager() .template find_attribute< VariableAttribute, double >( @@ -95,6 +91,11 @@ namespace geode return point_value; } + uuid attribute_function_id() const + { + return function_attribute_->id(); + } + private: const TetrahedralSolid< dimension >& solid_; std::shared_ptr< VariableAttribute< double > > function_attribute_; @@ -115,9 +116,8 @@ namespace geode template < index_t dimension > TetrahedralSolidScalarFunction< dimension >::TetrahedralSolidScalarFunction( - const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) - : impl_{ solid, function_name } + const TetrahedralSolid< dimension >& solid, const uuid& function_id ) + : impl_{ solid, function_id } { } @@ -139,9 +139,9 @@ namespace geode TetrahedralSolidScalarFunction< dimension > TetrahedralSolidScalarFunction< dimension >::find( const TetrahedralSolid< dimension >& solid, - std::string_view function_name ) + const uuid& function_id ) { - return { solid, function_name }; + return { solid, function_id }; } template < index_t dimension > @@ -165,5 +165,12 @@ namespace geode return impl_->value( point, tetrahedron_id ); } + template < index_t dimension > + uuid TetrahedralSolidScalarFunction< dimension >::attribute_function_id() + const + { + return impl_->attribute_function_id(); + } + template class opengeode_mesh_api TetrahedralSolidScalarFunction< 3 >; } // namespace geode \ No newline at end of file diff --git a/src/geode/mesh/helpers/triangulated_surface_point_function.cpp b/src/geode/mesh/helpers/triangulated_surface_point_function.cpp index deb85f94e..191877bae 100644 --- a/src/geode/mesh/helpers/triangulated_surface_point_function.cpp +++ b/src/geode/mesh/helpers/triangulated_surface_point_function.cpp @@ -56,14 +56,9 @@ namespace geode } Impl( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) + const uuid& function_id ) : surface_( surface ) { - const auto function_id = - surface_.vertex_attribute_manager() - .template create_attribute< VariableAttribute, - Point< point_dimension > >( function_name, - Point< point_dimension >(), { false, true } ); function_attribute_ = surface_.vertex_attribute_manager() .template find_attribute< VariableAttribute, @@ -98,6 +93,11 @@ namespace geode return point_value; } + uuid attribute_function_id() const + { + return function_attribute_->id(); + } + private: const TriangulatedSurface< dimension >& surface_; std::shared_ptr< VariableAttribute< Point< point_dimension > > > @@ -127,8 +127,8 @@ namespace geode TriangulatedSurfacePointFunction< dimension, point_dimension >:: TriangulatedSurfacePointFunction( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) - : impl_{ surface, function_name } + const uuid& function_id ) + : impl_{ surface, function_id } { } @@ -150,9 +150,9 @@ namespace geode TriangulatedSurfacePointFunction< dimension, point_dimension > TriangulatedSurfacePointFunction< dimension, point_dimension >::find( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) + const uuid& function_id ) { - return { surface, function_name }; + return { surface, function_id }; } template < index_t dimension, index_t point_dimension > @@ -179,6 +179,13 @@ namespace geode return impl_->value( point, triangle_id ); } + template < index_t dimension, index_t point_dimension > + uuid TriangulatedSurfacePointFunction< dimension, + point_dimension >::attribute_function_id() const + { + return impl_->attribute_function_id(); + } + template class opengeode_mesh_api TriangulatedSurfacePointFunction< 2, 2 >; template class opengeode_mesh_api TriangulatedSurfacePointFunction< 2, 1 >; template class opengeode_mesh_api TriangulatedSurfacePointFunction< 3, 3 >; diff --git a/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp b/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp index 87089b36b..596cee2b4 100644 --- a/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp +++ b/src/geode/mesh/helpers/triangulated_surface_scalar_function.cpp @@ -55,13 +55,9 @@ namespace geode } Impl( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) + const uuid& function_id ) : surface_( surface ) { - const auto function_id = - surface_.vertex_attribute_manager() - .template create_attribute< VariableAttribute, double >( - function_name, 0, { false, true } ); function_attribute_ = surface_.vertex_attribute_manager() .template find_attribute< VariableAttribute, double >( @@ -96,6 +92,11 @@ namespace geode return point_value; } + uuid attribute_function_id() const + { + return function_attribute_->id(); + } + private: const TriangulatedSurface< dimension >& surface_; std::shared_ptr< VariableAttribute< double > > function_attribute_; @@ -121,8 +122,8 @@ namespace geode TriangulatedSurfaceScalarFunction< dimension >:: TriangulatedSurfaceScalarFunction( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) - : impl_{ surface, function_name } + const uuid& function_id ) + : impl_{ surface, function_id } { } @@ -144,9 +145,9 @@ namespace geode TriangulatedSurfaceScalarFunction< dimension > TriangulatedSurfaceScalarFunction< dimension >::find( const TriangulatedSurface< dimension >& surface, - std::string_view function_name ) + const uuid& function_id ) { - return { surface, function_name }; + return { surface, function_id }; } template < index_t dimension > @@ -170,6 +171,13 @@ namespace geode return impl_->value( point, triangle_id ); } + template < index_t dimension > + uuid TriangulatedSurfaceScalarFunction< dimension >::attribute_function_id() + const + { + return impl_->attribute_function_id(); + } + template class opengeode_mesh_api TriangulatedSurfaceScalarFunction< 2 >; template class opengeode_mesh_api TriangulatedSurfaceScalarFunction< 3 >; } // namespace geode \ No newline at end of file diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index 1215cb29e..fbf52c0e6 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -225,6 +225,11 @@ void test_io( { geode::save_triangulated_surface( surface, filename ); const auto relaod = geode::load_triangulated_surface< 3 >( filename ); + const auto point_attributes = + relaod->vertex_attribute_manager().attribute_ids_matching_name( + "points" ); + geode::OpenGeodeMeshException::test( point_attributes.has_value(), + "TriangulatedSurface should have points attribute" ); geode_unused( relaod ); const auto surface2 = geode::load_triangulated_surface< 3 >( geode::OpenGeodeTriangulatedSurface3D::impl_name_static(), filename ); diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index e58db87df..22a38e9e5 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -1220,7 +1220,7 @@ void test_clone( const geode::BRep& brep ) brep2.nb_blocks() == 2, "BRep should have 2 blocks" ); geode::OpenGeodeModelException::test( brep2.nb_model_boundaries() == 6, "BRep should have 6 model boundaries" ); - + DEBUG( "test_clone" ); for( const auto& corner : brep.corners() ) { const auto& new_corner = brep2.corner( @@ -1287,6 +1287,22 @@ void test_clone( const geode::BRep& brep ) found, "All Surfaces incidences are not correct" ); } } + DEBUG( brep2.nb_blocks() ); + for( const auto& block : brep2.blocks() ) + { + const auto& block_mesh = block.mesh(); + DEBUG( block_mesh.nb_polyhedra() ); + for( const auto p : geode::Range{ block_mesh.nb_polyhedra() } ) + { + DEBUG( p ); + for( const auto v : + geode::LRange{ block_mesh.nb_polyhedron_vertices( p ) } ) + { + DEBUG( v ); + DEBUG( block_mesh.polyhedron_vertex( { p, v } ) ); + } + } + } for( const auto& model_boundary : brep.model_boundaries() ) { const auto& new_model_boundary = brep2.model_boundary( @@ -1607,11 +1623,18 @@ void test() test_block_collection_ranges( model, block_uuid, block_collection_uuid ); test_clone( model ); test_steal_mesh( model ); - + DEBUG( "io" ); const auto file_io = absl::StrCat( "test.", model.native_extension() ); geode::save_brep( model, file_io ); - + DEBUG( "start load" ); auto model2 = geode::load_brep( file_io ); + for( const auto& surface : model2.surfaces() ) + { + const auto& mesh = surface.mesh(); + const auto scalar_attributes = + mesh.vertex_attribute_manager().attribute_ids_matching_name( + "curvature_min" ); + } test_compare_brep( model, model2 ); test_registry( model2, 4, 6, 9, 5, 1, 5, 2, 2, 2, 1, 3 ); From d174e81fef143a7103e31d3201efa4d07dd839ef Mon Sep 17 00:00:00 2001 From: BenPinet Date: Tue, 23 Jun 2026 16:41:22 +0200 Subject: [PATCH 16/19] python fixes --- bindings/python/src/basic/attribute_manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/python/src/basic/attribute_manager.cpp b/bindings/python/src/basic/attribute_manager.cpp index 04e4a18fb..34ee8c867 100644 --- a/bindings/python/src/basic/attribute_manager.cpp +++ b/bindings/python/src/basic/attribute_manager.cpp @@ -101,7 +101,9 @@ namespace geode .def( "delete_attribute", &AttributeManager::delete_attribute ) .def( "set_attribute_properties", &AttributeManager::set_attribute_properties ) - .def( "delete_elements", &AttributeManager::delete_elements ); + .def( "delete_elements", &AttributeManager::delete_elements ) + .def( "attribute_ids_matching_name", + &AttributeManager::attribute_ids_matching_name ); python_attribute_class< bool >( manager, "bool" ); python_attribute_class< int >( manager, "int" ); python_attribute_class< unsigned int >( manager, "uint" ); From 740b3e5361a607bce73077211acd7c7062a7eb54 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Wed, 24 Jun 2026 14:23:12 +0200 Subject: [PATCH 17/19] fix copy --- src/geode/mesh/builder/solid_mesh_builder.cpp | 15 +++++++++++ .../mesh/builder/surface_mesh_builder.cpp | 11 ++++++++ tests/mesh/test-tetrahedral-solid.cpp | 26 +++++++++++++++++++ tests/mesh/test-triangulated-surface.cpp | 26 +++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/src/geode/mesh/builder/solid_mesh_builder.cpp b/src/geode/mesh/builder/solid_mesh_builder.cpp index 9762e3d00..a7ed1aa0b 100644 --- a/src/geode/mesh/builder/solid_mesh_builder.cpp +++ b/src/geode/mesh/builder/solid_mesh_builder.cpp @@ -284,6 +284,21 @@ namespace polyhedron.value(), v ); } } + for( const auto p : geode::Range{ solid.nb_polyhedra() } ) + { + for( const auto f : + geode::LRange{ solid.nb_polyhedron_facets( p ) } ) + { + const auto polyhedron_adjacent = + solid.polyhedron_adjacent( geode::PolyhedronFacet{ p, f } ); + if( polyhedron_adjacent ) + { + builder.set_polyhedron_adjacent( + geode::PolyhedronFacet{ p, f }, + polyhedron_adjacent.value() ); + } + } + } } template < geode::index_t dimension > diff --git a/src/geode/mesh/builder/surface_mesh_builder.cpp b/src/geode/mesh/builder/surface_mesh_builder.cpp index 657a4a73c..cbc59fe5e 100644 --- a/src/geode/mesh/builder/surface_mesh_builder.cpp +++ b/src/geode/mesh/builder/surface_mesh_builder.cpp @@ -301,6 +301,17 @@ namespace polygon.value(), v ); } } + for( const auto p : geode::Range{ surface.nb_polygons() } ) + { + for( const auto e : geode::LRange{ surface.nb_polygon_edges( p ) } ) + { + const geode::PolygonEdge edge{ p, e }; + if( const auto adj = surface.polygon_adjacent( edge ) ) + { + builder.set_polygon_adjacent( edge, adj.value() ); + } + } + } } template < geode::index_t dimension > diff --git a/tests/mesh/test-tetrahedral-solid.cpp b/tests/mesh/test-tetrahedral-solid.cpp index b7bcc9bd8..02fa6b5bc 100644 --- a/tests/mesh/test-tetrahedral-solid.cpp +++ b/tests/mesh/test-tetrahedral-solid.cpp @@ -376,6 +376,25 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) solid4.facets() .facet_attribute_manager() .find_read_only_attribute< geode::index_t >( attr_from_id ); + for( const auto v : geode::Range{ solid4.nb_vertices() } ) + { + geode::OpenGeodeMeshException::test( + solid4.point( v ) == solid.point( v ), + "Wrong cloned mesh point coordinates." ); + } + for( const auto p : geode::Range{ solid4.nb_polyhedra() } ) + { + for( const auto f : geode::LRange{ 4 } ) + { + for( const auto v : geode::LRange{ 3 } ) + { + geode::OpenGeodeMeshException::test( + solid4.polyhedron_facet_vertex( { { p, f }, v } ) + == solid.polyhedron_facet_vertex( { { p, f }, v } ), + "polyhedron_facet_vertex should match" ); + } + } + } for( const auto f : geode::Range{ solid.facets().nb_facets() } ) { geode::OpenGeodeMeshException::test( @@ -390,6 +409,13 @@ void test_clone( const geode::TetrahedralSolid3D& solid ) "Error in facet vertices transfer during cloning" ); } } + for( const auto v : geode::Range{ solid4.nb_vertices() } ) + { + geode::OpenGeodeMeshException::test( + solid.polyhedra_around_vertex( v ) + == solid4.polyhedra_around_vertex( v ), + "Polyhedra around vertex should match during cloning" ); + } const auto attr_edge_to = solid4.edges() .edge_attribute_manager() diff --git a/tests/mesh/test-triangulated-surface.cpp b/tests/mesh/test-triangulated-surface.cpp index fbf52c0e6..e06072701 100644 --- a/tests/mesh/test-triangulated-surface.cpp +++ b/tests/mesh/test-triangulated-surface.cpp @@ -282,6 +282,32 @@ void test_clone( const geode::TriangulatedSurface3D& surface ) attr_from->set_value( e, e ); } auto surface_clone = surface.clone(); + for( const auto v : geode::Range{ surface_clone->nb_vertices() } ) + { + geode::OpenGeodeMeshException::test( + surface.polygons_around_vertex( v ) + == surface_clone->polygons_around_vertex( v ), + "Polyhedra around vertex should match during cloning" ); + } + for( const auto v : geode::Range{ surface_clone->nb_vertices() } ) + { + geode::OpenGeodeMeshException::test( + surface_clone->point( v ) == surface.point( v ), + "Wrong cloned mesh point coordinates." ); + } + for( const auto p : geode::Range{ surface_clone->nb_polygons() } ) + { + for( const auto e : geode::LRange{ 3 } ) + { + for( const auto v : geode::LRange{ 2 } ) + { + geode::OpenGeodeMeshException::test( + surface_clone->polygon_edge_vertex( { p, e }, v ) + == surface.polygon_edge_vertex( { p, e }, v ), + "polyhedron_facet_vertex should match" ); + } + } + } geode::OpenGeodeTriangulatedSurface3D surface2{ std::move( *dynamic_cast< geode::OpenGeodeTriangulatedSurface3D* >( surface_clone.get() ) ) }; From fe21d43a77d431b1c0d68b6733c28b12f54652f0 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Thu, 25 Jun 2026 10:47:16 +0200 Subject: [PATCH 18/19] fix vertices identifier --- include/geode/basic/constant_attribute.hpp | 3 ++ include/geode/basic/sparse_attribute.hpp | 3 ++ include/geode/basic/variable_attribute.hpp | 3 ++ .../model/mixin/core/vertex_identifier.cpp | 34 +++++++++++++--- tests/model/test-brep.cpp | 39 ++++++++++++++++--- 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/include/geode/basic/constant_attribute.hpp b/include/geode/basic/constant_attribute.hpp index 7a9eed7c3..05eeba76a 100644 --- a/include/geode/basic/constant_attribute.hpp +++ b/include/geode/basic/constant_attribute.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -159,6 +160,8 @@ namespace geode new ConstantAttribute< T >{ value_, this->name().value(), this->properties() } }; + IdentifierBuilder builder{ *attribute }; + builder.set_id( this->id() ); return attribute; } diff --git a/include/geode/basic/sparse_attribute.hpp b/include/geode/basic/sparse_attribute.hpp index c258d115d..1a2a0189d 100644 --- a/include/geode/basic/sparse_attribute.hpp +++ b/include/geode/basic/sparse_attribute.hpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -200,6 +201,8 @@ namespace geode new SparseAttribute< T >{ default_value_, this->name().value(), this->properties() } }; + IdentifierBuilder builder{ *attribute }; + builder.set_id( this->id() ); attribute->values_ = values_; return attribute; } diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index 72a881b70..f46e65b6a 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -179,6 +180,8 @@ namespace geode new VariableAttribute< T >{ default_value_, this->name().value(), this->properties() } }; + IdentifierBuilder builder{ *attribute }; + builder.set_id( this->id() ); attribute->values_ = values_; return attribute; } diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index adae22d5a..38063012a 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -185,6 +185,18 @@ namespace geode const auto& mesh = component.mesh(); if( it == vertex2unique_vertex_.end() ) { + // find attribute + const auto unique_vertices_ids = + mesh.vertex_attribute_manager().attribute_ids_matching_name( + unique_vertices_name ); + if( unique_vertices_ids.has_value() ) + { + vertex2unique_vertex_.emplace( component.id(), + mesh.vertex_attribute_manager() + .template find_attribute< VariableAttribute, + index_t >( unique_vertices_ids.value()[0] ) ); + } + const auto unique_vertices_attribute_id = mesh.vertex_attribute_manager() .template create_attribute< VariableAttribute, @@ -419,9 +431,11 @@ namespace geode archive.object( impl.unique_vertices_ ); archive.ext( impl.component_vertices_, bitsery::ext::StdSmartPtr{} ); - archive.ext( impl.vertex2unique_vertex_, - bitsery::ext::StdMap{ - impl.vertex2unique_vertex_.max_size() }, + absl::flat_hash_map< uuid, + std::shared_ptr< VariableAttribute< index_t > > > + old_map; + archive.ext( old_map, + bitsery::ext::StdMap{ old_map.max_size() }, []( Archive& archive2, uuid& id, std::shared_ptr< VariableAttribute< index_t > >& attribute ) { @@ -440,9 +454,12 @@ namespace geode archive.object( impl.unique_vertices_ ); archive.ext( impl.component_vertices_, bitsery::ext::StdSmartPtr{} ); - archive.ext( impl.vertex2unique_vertex_, - bitsery::ext::StdMap{ - impl.vertex2unique_vertex_.max_size() }, + absl::flat_hash_map< uuid, + std::shared_ptr< + VariableAttribute< index_t > > > + old_map; + archive.ext( old_map, + bitsery::ext::StdMap{ old_map.max_size() }, []( Archive& archive2, uuid& id, std::shared_ptr< VariableAttribute< index_t > >& attribute ) { @@ -450,6 +467,11 @@ namespace geode archive2.ext( attribute, bitsery::ext::StdSmartPtr{} ); } ); + }, + []( Archive& archive, Impl& impl ) { + archive.object( impl.unique_vertices_ ); + archive.ext( impl.component_vertices_, + bitsery::ext::StdSmartPtr{} ); } } } ); } diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index 22a38e9e5..af474aa33 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -1478,8 +1478,9 @@ void test_registry( const geode::BRep& brep, void test_backward_io() { - const auto brep = geode::load_brep( + auto brep = geode::load_brep( absl::StrCat( geode::DATA_PATH, "dangling.og_brep" ) ); + geode::BRepBuilder brep_builder{ brep }; for( const auto& block : brep.blocks() ) { geode::OpenGeodeModelException::test( block.id() == block.mesh().id(), @@ -1503,9 +1504,21 @@ void test_backward_io() "[Backward_IO] Brep corner should have the same uuid as its " "mesh." ); } + for( const auto& surface : brep.surfaces() ) + { + auto vertex_index = + brep_builder.surface_mesh_builder( surface.id() )->create_vertex(); + DEBUG( vertex_index ); + DEBUG( brep.unique_vertex( { surface.component_id(), vertex_index } ) ); + geode::OpenGeodeModelException::test( + brep.unique_vertex( { surface.component_id(), vertex_index } ) + == geode::NO_ID, + "[Backward_IO] Incorrect brep unique_vertex_id." ); + } test_registry( brep, 4, 13, 17, 7, 1, 0, 0, 0, 0, 0, 0 ); auto brep_v17 = geode::load_brep( absl::StrCat( geode::DATA_PATH, "backward_io/v17/v17.og_brep" ) ); + geode::BRepBuilder brep_builder_v17{ brep_v17 }; for( const auto& block : brep_v17.blocks() ) { geode::OpenGeodeModelException::test( block.id() == block.mesh().id(), @@ -1529,6 +1542,16 @@ void test_backward_io() "[Backward_IO] Brep corner should have the same uuid as its " "mesh." ); } + for( const auto& surface : brep_v17.surfaces() ) + { + auto vertex_index = + brep_builder_v17.surface_mesh_builder( surface.id() ) + ->create_vertex(); + geode::OpenGeodeModelException::test( + brep_v17.unique_vertex( { surface.component_id(), vertex_index } ) + == geode::NO_ID, + "[Backward_IO] Incorrect brep unique_vertex_id." ); + } test_registry( brep_v17, 4, 6, 9, 5, 1, 5, 2, 2, 2, 1, 3 ); } @@ -1628,12 +1651,18 @@ void test() geode::save_brep( model, file_io ); DEBUG( "start load" ); auto model2 = geode::load_brep( file_io ); + geode::BRepBuilder model2_builder{ model2 }; for( const auto& surface : model2.surfaces() ) { - const auto& mesh = surface.mesh(); - const auto scalar_attributes = - mesh.vertex_attribute_manager().attribute_ids_matching_name( - "curvature_min" ); + auto vertex_index = model2_builder.surface_mesh_builder( surface.id() ) + ->create_vertex(); + DEBUG( vertex_index ); + DEBUG( + model2.unique_vertex( { surface.component_id(), vertex_index } ) ); + geode::OpenGeodeModelException::test( + model2.unique_vertex( { surface.component_id(), vertex_index } ) + == geode::NO_ID, + "[Backward_IO] Incorrect model2 unique_vertex_id." ); } test_compare_brep( model, model2 ); test_registry( model2, 4, 6, 9, 5, 1, 5, 2, 2, 2, 1, 3 ); From c794ab8ae92ebe0c9169b4338134eefb787020ee Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 26 Jun 2026 13:49:07 +0200 Subject: [PATCH 19/19] fix load vertex identifier --- .../builder/vertex_identifier_builder.hpp | 6 ++ .../model/mixin/core/vertex_identifier.hpp | 7 ++ .../builder/detail/register.hpp | 13 ++- src/geode/mesh/builder/vertex_set_builder.cpp | 3 + .../model/mixin/core/vertex_identifier.cpp | 95 +++++++++++-------- 5 files changed, 82 insertions(+), 42 deletions(-) diff --git a/include/geode/model/mixin/builder/vertex_identifier_builder.hpp b/include/geode/model/mixin/builder/vertex_identifier_builder.hpp index 1aa562050..9ca87c805 100644 --- a/include/geode/model/mixin/builder/vertex_identifier_builder.hpp +++ b/include/geode/model/mixin/builder/vertex_identifier_builder.hpp @@ -47,6 +47,12 @@ namespace geode vertex_identifier_.register_mesh_component( component, {} ); } + template < typename MeshComponent > + void load_mesh_component( const MeshComponent& component ) + { + vertex_identifier_.load_mesh_component( component, {} ); + } + /*! * Remove a component from the VertexIdentifier and delete corresponding * information (i.e. the attribute on component mesh). diff --git a/include/geode/model/mixin/core/vertex_identifier.hpp b/include/geode/model/mixin/core/vertex_identifier.hpp index 2381e989a..df64563ee 100644 --- a/include/geode/model/mixin/core/vertex_identifier.hpp +++ b/include/geode/model/mixin/core/vertex_identifier.hpp @@ -143,6 +143,13 @@ namespace geode void register_mesh_component( const MeshComponent& component, BuilderKey /*key*/ ); + /*! + * Add a component in the VertexIdentifier + */ + template < typename MeshComponent > + void load_mesh_component( + const MeshComponent& component, BuilderKey /*key*/ ); + /*! * Remove a component from the VertexIdentifier and delete corresponding * information (i.e. the attribute on component mesh). diff --git a/include/geode/model/representation/builder/detail/register.hpp b/include/geode/model/representation/builder/detail/register.hpp index e933cc818..933ac63e0 100644 --- a/include/geode/model/representation/builder/detail/register.hpp +++ b/include/geode/model/representation/builder/detail/register.hpp @@ -38,6 +38,15 @@ namespace geode component.component_type(), component.id() ); } + template < typename ModelBuilder, typename MeshComponent > + void add_loaded_mesh_component( + ModelBuilder& builder, const MeshComponent& component ) + { + builder.load_mesh_component( component ); + builder.add_mesh_component( + component.component_type(), component.id() ); + } + template < typename ModelBuilder, typename MeshComponent > void remove_mesh_component( ModelBuilder& builder, const MeshComponent& component ) @@ -76,14 +85,14 @@ namespace geode { for( const auto& component : model.First::components() ) { - detail::add_mesh_component( builder, component ); + detail::add_loaded_mesh_component( builder, component ); } } else { for( const auto& component : model.First::components() ) { - detail::add_mesh_component( builder, component ); + detail::add_loaded_mesh_component( builder, component ); } register_mesh_components< Model, MeshComponents... >( model, builder ); diff --git a/src/geode/mesh/builder/vertex_set_builder.cpp b/src/geode/mesh/builder/vertex_set_builder.cpp index 1193c9499..06d991c7b 100644 --- a/src/geode/mesh/builder/vertex_set_builder.cpp +++ b/src/geode/mesh/builder/vertex_set_builder.cpp @@ -75,9 +75,12 @@ namespace geode index_t VertexSetBuilder::create_vertices( index_t nb ) { + DEBUG( "create_vertices" ); const auto first_added_vertex = vertex_set_.nb_vertices(); + DEBUG( vertex_set_.vertex_attribute_manager().nb_elements() ); vertex_set_.vertex_attribute_manager().resize( first_added_vertex + nb ); + DEBUG( vertex_set_.vertex_attribute_manager().nb_elements() ); do_create_vertices( nb ); return first_added_vertex; } diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index 38063012a..667fc02fa 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -181,51 +181,44 @@ namespace geode template < typename MeshComponent > void register_component( const MeshComponent& component ) { - auto it = vertex2unique_vertex_.find( component.id() ); const auto& mesh = component.mesh(); - if( it == vertex2unique_vertex_.end() ) - { - // find attribute - const auto unique_vertices_ids = - mesh.vertex_attribute_manager().attribute_ids_matching_name( - unique_vertices_name ); - if( unique_vertices_ids.has_value() ) - { - vertex2unique_vertex_.emplace( component.id(), - mesh.vertex_attribute_manager() - .template find_attribute< VariableAttribute, - index_t >( unique_vertices_ids.value()[0] ) ); - } - - const auto unique_vertices_attribute_id = - mesh.vertex_attribute_manager() - .template create_attribute< VariableAttribute, - index_t >( unique_vertices_name, NO_ID, - { false, false, false } ); + const auto unique_vertices_attribute_id = + mesh.vertex_attribute_manager() + .template create_attribute< VariableAttribute, index_t >( + unique_vertices_name, NO_ID, { false, false, false } ); + const auto [_, inserted] = vertex2unique_vertex_.emplace( component.id(), mesh.vertex_attribute_manager() .template find_attribute< VariableAttribute, index_t >( unique_vertices_attribute_id ) ); - } - else - { - auto attribute = vertex2unique_vertex_.at( component.id() ); - attribute->set_properties( { false, false, false } ); - try - { - for( const auto v : Range{ mesh.nb_vertices() } ) - { - attribute->set_value( v, it->second->value( v ) ); - } - } - catch( const std::out_of_range& ) - { - Logger::warn( - "Registering MeshComponent: ", component.id().string(), - " in VertexIdentifier, wrong number of vertices." ); - } - it->second = std::move( attribute ); - } + OpenGeodeModelException::check_exception( inserted, + component.component_id(), OpenGeodeException::TYPE::data, + "[VertexIdentifier::register_component] Component ", + component.id().string(), " is already registered." ); + } + + template < typename MeshComponent > + void load_component( const MeshComponent& component ) + { + const auto& mesh = component.mesh(); + const auto unique_vertices_ids = + mesh.vertex_attribute_manager().attribute_ids_matching_name( + unique_vertices_name ); + DEBUG( unique_vertices_ids.has_value() ); + OpenGeodeModelException::check_exception( + unique_vertices_ids.has_value(), nullptr, + OpenGeodeException::TYPE::data, + "[VertexIdentifier::load_component] Unique vertices " + "attribute not found." ); + const auto [_, inserted] = + vertex2unique_vertex_.emplace( component.id(), + mesh.vertex_attribute_manager() + .template find_attribute< VariableAttribute, index_t >( + unique_vertices_ids.value().front() ) ); + OpenGeodeModelException::check_exception( inserted, + component.component_id(), OpenGeodeException::TYPE::data, + "[VertexIdentifier::load_component] Component ", + component.id().string(), " is already registered." ); } template < typename MeshComponent > @@ -560,6 +553,13 @@ namespace geode unique_vertex_id, component_id ); } + template < typename MeshComponent > + void VertexIdentifier::load_mesh_component( + const MeshComponent& component, BuilderKey /*key*/ ) + { + impl_->load_component( component ); + } + template < typename MeshComponent > void VertexIdentifier::register_mesh_component( const MeshComponent& component, BuilderKey /*key*/ ) @@ -628,6 +628,21 @@ namespace geode return impl_->delete_isolated_vertices(); } + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Corner2D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Corner3D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Line2D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Line3D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Surface2D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Surface3D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::load_mesh_component( + const Block3D&, BuilderKey /*key*/ ); + template void opengeode_model_api VertexIdentifier::register_mesh_component( const Corner2D&, BuilderKey /*key*/ ); template void opengeode_model_api VertexIdentifier::register_mesh_component(