From ac3ebed32c8d63840e0a7a48a0116962999b4f9c Mon Sep 17 00:00:00 2001 From: MelchiorSchuh Date: Mon, 22 Apr 2024 16:14:18 +0200 Subject: [PATCH 1/2] fix(ImplicitModel): Create attributes only if block is meshed. --- .../core/implicit_cross_section.cpp | 19 ++++---------- .../core/implicit_structural_model.cpp | 26 +++++++++++-------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/geode/geosciences/implicit/representation/core/implicit_cross_section.cpp b/src/geode/geosciences/implicit/representation/core/implicit_cross_section.cpp index c54a9951..436b9459 100644 --- a/src/geode/geosciences/implicit/representation/core/implicit_cross_section.cpp +++ b/src/geode/geosciences/implicit/representation/core/implicit_cross_section.cpp @@ -56,15 +56,16 @@ namespace geode void initialize_implicit_query_trees( const ImplicitCrossSection& model ) { - implicit_attributes_.reserve( model.nb_surfaces() ); instantiate_implicit_attribute_on_surfaces( model ); surface_mesh_aabb_trees_.reserve( model.nb_surfaces() ); + surface_distance_to_triangles_.reserve( model.nb_surfaces() ); for( const auto& surface : model.surfaces() ) { surface_mesh_aabb_trees_.try_emplace( surface.id() ); + surface_distance_to_triangles_.try_emplace( surface.id(), + DistanceToTriangle2D{ + surface.mesh< TriangulatedSurface2D >() } ); } - surface_distance_to_triangles_.reserve( model.nb_surfaces() ); - build_model_distance_to_mesh_elements( model ); } double implicit_value( @@ -210,6 +211,7 @@ namespace geode void instantiate_implicit_attribute_on_surfaces( const ImplicitCrossSection& model ) { + implicit_attributes_.reserve( model.nb_surfaces() ); for( const auto& surface : model.surfaces() ) { OPENGEODE_EXCEPTION( @@ -268,17 +270,6 @@ namespace geode } private: - void build_model_distance_to_mesh_elements( - const ImplicitCrossSection& model ) - { - for( const auto& surface : model.surfaces() ) - { - surface_distance_to_triangles_.try_emplace( surface.id(), - DistanceToTriangle2D{ - surface.mesh< TriangulatedSurface2D >() } ); - } - } - absl::optional< bool > increasing_stack_isovalues() const { for( const auto& unit : horizons_stack_.stratigraphic_units() ) diff --git a/src/geode/geosciences/implicit/representation/core/implicit_structural_model.cpp b/src/geode/geosciences/implicit/representation/core/implicit_structural_model.cpp index 8f352f63..54ba083e 100644 --- a/src/geode/geosciences/implicit/representation/core/implicit_structural_model.cpp +++ b/src/geode/geosciences/implicit/representation/core/implicit_structural_model.cpp @@ -54,15 +54,20 @@ namespace geode void initialize_implicit_query_trees( const ImplicitStructuralModel& model ) { - implicit_attributes_.reserve( model.nb_blocks() ); instantiate_implicit_attribute_on_blocks( model ); block_mesh_aabb_trees_.reserve( model.nb_blocks() ); + block_distance_to_tetras_.reserve( model.nb_blocks() ); for( const auto& block : model.blocks() ) { + if( !block_is_meshed( block ) ) + { + continue; + } block_mesh_aabb_trees_.try_emplace( block.id() ); + block_distance_to_tetras_.try_emplace( + block.id(), DistanceToTetrahedron3D{ + block.mesh< TetrahedralSolid3D >() } ); } - block_distance_to_tetras_.reserve( model.nb_blocks() ); - build_model_distance_to_mesh_elements( model ); } double implicit_value( const Block3D& block, index_t vertex_id ) const @@ -205,8 +210,13 @@ namespace geode void instantiate_implicit_attribute_on_blocks( const ImplicitStructuralModel& model ) { + implicit_attributes_.reserve( model.nb_blocks() ); for( const auto& block : model.blocks() ) { + if( !block_is_meshed( block ) ) + { + continue; + } OPENGEODE_EXCEPTION( ( block.mesh().type_name() == TetrahedralSolid3D::type_name_static() ), @@ -260,15 +270,9 @@ namespace geode } private: - void build_model_distance_to_mesh_elements( - const ImplicitStructuralModel& model ) + bool block_is_meshed( const Block3D& block ) { - for( const auto& block : model.blocks() ) - { - block_distance_to_tetras_.try_emplace( - block.id(), DistanceToTetrahedron3D{ - block.mesh< TetrahedralSolid3D >() } ); - } + return block.mesh().nb_polyhedra() != 0; } absl::optional< bool > increasing_stack_isovalues() const From 0b36f296da21fa189524a989113cc247398d12f2 Mon Sep 17 00:00:00 2001 From: MelchiorSchuh Date: Mon, 22 Apr 2024 14:15:18 +0000 Subject: [PATCH 2/2] Apply prepare changes --- bindings/python/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/requirements.txt b/bindings/python/requirements.txt index bd3fad3d..571ba2e0 100644 --- a/bindings/python/requirements.txt +++ b/bindings/python/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile bindings/python/requirements.in +# pip-compile --pre bindings/python/requirements.in # -opengeode-core==14.*,>=14.19.0 +opengeode-core==14.*,>=14.19.1 # via -r bindings/python/requirements.in