Skip to content

Commit da2bd8b

Browse files
authored
Merge pull request #1185 from Geode-solutions/fix/filter-model-component-on-active
fix(Model): apply filter components only on active components
2 parents aa15606 + 22cb51a commit da2bd8b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/geode/model/helpers/model_component_filter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace
5757
std::vector< geode::ComponentID >& removed_components )
5858
{
5959
for( const auto& surface_uuid : find_components_to_delete(
60-
model, model.surfaces(), model.nb_surfaces() ) )
60+
model, model.active_surfaces(), model.nb_active_surfaces() ) )
6161
{
6262
filter.remove_surface( model.surface( surface_uuid ) );
6363
removed_components.emplace_back(
@@ -71,7 +71,7 @@ namespace
7171
std::vector< geode::ComponentID >& removed_components )
7272
{
7373
for( const auto& line_uuid : find_components_to_delete(
74-
model, model.lines(), model.nb_lines() ) )
74+
model, model.active_lines(), model.nb_active_lines() ) )
7575
{
7676
filter.remove_line( model.line( line_uuid ) );
7777
removed_components.emplace_back(
@@ -85,7 +85,7 @@ namespace
8585
std::vector< geode::ComponentID >& removed_components )
8686
{
8787
for( const auto& corner_uuid : find_components_to_delete(
88-
model, model.corners(), model.nb_corners() ) )
88+
model, model.active_corners(), model.nb_active_corners() ) )
8989
{
9090
filter.remove_corner( model.corner( corner_uuid ) );
9191
removed_components.emplace_back(

tests/model/test-model-component-filter.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <geode/basic/logger.hpp>
2626

2727
#include <geode/model/helpers/model_component_filter.hpp>
28+
#include <geode/model/representation/builder/brep_builder.hpp>
2829
#include <geode/model/representation/core/brep.hpp>
2930
#include <geode/model/representation/io/brep_input.hpp>
3031

@@ -62,6 +63,32 @@ void check_brep_dangling( const geode::BRep& brep )
6263
" Blocks, should have 1 Block" );
6364
}
6465

66+
void check_brep_dangling_with_inactive_surface( const geode::BRep& brep )
67+
{
68+
OPENGEODE_EXCEPTION( brep.nb_corners() == 8,
69+
"[Test] Filtered dangling model has ", brep.nb_corners(),
70+
" Corners, should have 8 Corners" );
71+
OPENGEODE_EXCEPTION( brep.nb_lines() == 12,
72+
"[Test] Filtered dangling model has ", brep.nb_lines(),
73+
" Lines, should have 12 Lines" );
74+
OPENGEODE_EXCEPTION( brep.nb_surfaces() == 7,
75+
"[Test] Filtered dangling model with inactive surface has ",
76+
brep.nb_surfaces(), " Surfaces, should have 7 Surfaces" );
77+
OPENGEODE_EXCEPTION( brep.nb_active_surfaces() == 6,
78+
"[Test] Filtered dangling model with inactive surface has ",
79+
brep.nb_active_surfaces(), " Surfaces, should have 6 Surfaces" );
80+
OPENGEODE_EXCEPTION( brep.nb_blocks() == 1,
81+
"[Test] Filtered dangling model has ", brep.nb_blocks(),
82+
" Blocks, should have 1 Block" );
83+
}
84+
85+
void add_inactive_surface( geode::BRep& brep )
86+
{
87+
geode::BRepBuilder builder{ brep };
88+
const auto new_surface_id = builder.add_surface();
89+
builder.set_surface_active( new_surface_id, false );
90+
}
91+
6592
void test()
6693
{
6794
geode::OpenGeodeModelLibrary::initialize();
@@ -74,6 +101,9 @@ void test()
74101
absl::StrCat( geode::DATA_PATH, "dangling.og_brep" ) );
75102
geode::filter_brep_components_with_regards_to_blocks( brep2 );
76103
check_brep_dangling( brep2 );
104+
add_inactive_surface( brep2 );
105+
geode::filter_brep_components_with_regards_to_blocks( brep2 );
106+
check_brep_dangling_with_inactive_surface( brep2 );
77107
}
78108

79109
OPENGEODE_TEST( "model-filter" )

0 commit comments

Comments
 (0)