Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Convert): solve wrong transfer of ModelBoundaries during model co… #897

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions src/geode/model/helpers/convert_brep_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace
section_slice0_mapping_ =
std::move( std::get< 1 >( slice0_conversion_output ) );
brep_ = std::move( std::get< 0 >( slice0_conversion_output ) );
add_surfaces_in_model_boundaries();

auto slice1_conversion_output = convert_section_into_brep(
section_, options.axis_to_extrude, options.max_coordinate );
Expand All @@ -113,6 +114,29 @@ namespace
geode::BRepConcatener brep_concatener{ brep_ };
slice1_brep_mapping_ = brep_concatener.concatenate(
std::get< 0 >( slice1_conversion_output ) );
add_surfaces_in_model_boundaries();
}

void add_surfaces_in_model_boundaries()
{
const auto model_boundary_id = brep_builder_.add_model_boundary();
bool surface_added{ false };
const auto& model_boundary =
brep_.model_boundary( model_boundary_id );
for( const auto& surface : brep_.surfaces() )
{
if( brep_.nb_collections( surface.id() ) > 0 )
{
continue;
}
brep_builder_.add_surface_in_model_boundary(
surface, model_boundary );
surface_added = true;
}
if( !surface_added )
{
brep_builder_.remove_model_boundary( model_boundary );
}
}

geode::uuid section_slice0_brep_mapping(
Expand Down Expand Up @@ -171,13 +195,33 @@ namespace

void create_surfaces()
{
absl::flat_hash_map< geode::uuid, geode::uuid >
panquez marked this conversation as resolved.
Show resolved Hide resolved
lines_to_model_boundaries;
for( const auto& model_boundary : section_.model_boundaries() )
{
const auto new_id = brep_builder_.add_model_boundary();
brep_builder_.set_model_boundary_name(
new_id, model_boundary.name() );
for( const auto& item :
section_.model_boundary_items( model_boundary ) )
{
lines_to_model_boundaries[item.id()] = new_id;
}
}
for( const auto& line : section_.lines() )
{
extrude_line( line );
const auto surface_id = extrude_line( line );
if( lines_to_model_boundaries.contains( line.id() ) )
{
brep_builder_.add_surface_in_model_boundary(
brep_.surface( surface_id ),
brep_.model_boundary(
lines_to_model_boundaries.at( line.id() ) ) );
}
}
}

void extrude_line( const geode::Line2D& section_line )
geode::uuid extrude_line( const geode::Line2D& section_line )
{
const auto& line_slice0 = brep_.line( section_slice0_brep_mapping(
geode::Line3D::component_type_static(), section_line.id() ) );
Expand Down Expand Up @@ -208,6 +252,7 @@ namespace
surface_builder->create_polygon( pointids );
}
surface_builder->compute_polygon_adjacencies();
return surface.id();
}

geode::index_t find_or_create_surface_vertex( const geode::Line3D& line,
Expand Down Expand Up @@ -471,6 +516,12 @@ namespace geode
BRepBuilder builder{ brep };
auto mappings =
copy_components< Section, BRepBuilder >( section, builder );
// Remove wrong transfer of Model Boundaries
mappings.remove( ModelBoundary3D::component_type_static() );
for( const auto& model_boundary : brep.model_boundaries() )
{
builder.remove_model_boundary( model_boundary );
}
for( const auto& corner : section.corners() )
{
builder.update_corner_mesh(
Expand Down
Loading