Skip to content

Commit

Permalink
STEP: Import missing non-closed shells (MIC#3789) (MeshInspector#2509)
Browse files Browse the repository at this point in the history
* STEP: Import missing shells

* Clarify code
  • Loading branch information
oitel authored Apr 2, 2024
1 parent a8184e5 commit fb25877
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions source/MRMesh/MRMeshLoadStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,35 @@ struct StepLoader
if ( !reportProgress( callback, 0.80f ) )
return;

std::deque<TopoDS_Shape> solids;
std::deque<TopoDS_Shape> shapes;
for ( auto shi = 1; shi <= reader.NbShapes(); ++shi )
{
const auto shape = reader.Shape( shi );

// search for closed shapes
size_t solidCount = 0;
for ( auto explorer = TopExp_Explorer( shape, TopAbs_SOLID ); explorer.More(); explorer.Next() )
{
solids.emplace_back( explorer.Current() );
shapes.emplace_back( explorer.Current() );
++solidCount;
}
// search for non-closed shapes
size_t shellCount = 0;
for ( auto explorer = TopExp_Explorer( shape, TopAbs_SHELL, TopAbs_SOLID ); explorer.More(); explorer.Next() )
{
shapes.emplace_back( explorer.Current() );
++shellCount;
}

// import the whole shape if it doesn't consist of solids
if ( solidCount == 0 )
solids.emplace_back( shape );
// import the whole shape if it doesn't consist of solids or shells
if ( solidCount + shellCount == 0 )
shapes.emplace_back( shape );
}

rootObj_ = std::make_shared<Object>();
rootObj_->select( true );

for ( const auto& shape : solids )
for ( const auto& shape : shapes )
{
const auto& location = shape.Location();
const auto xf = AffineXf3f( toXf( location.Transformation() ) );
Expand Down

0 comments on commit fb25877

Please sign in to comment.