Skip to content

Commit

Permalink
Merge pull request #113 from Geode-solutions/fix/test_if_block_is_mes…
Browse files Browse the repository at this point in the history
…hed_before_attribute_instantiation

fix(ImplicitModel): Create attributes only if block is meshed.
  • Loading branch information
panquez authored Apr 23, 2024
2 parents 611128d + 0b36f29 commit 2768857
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
4 changes: 2 additions & 2 deletions bindings/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() ),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2768857

Please sign in to comment.