MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / loadModelStructure

Method loadModelStructure

source/MRIOExtras/MRStep.cpp:221–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219 }
220
221 [[nodiscard]] Expected<void> loadModelStructure( STEPControl_Reader& reader, [[maybe_unused]] const ProgressCallback& callback )
222 {
223 MR_TIMER;
224
225 {
226 MR_NAMED_TIMER( "transfer roots" );
227
228#if MODERN_PROGRESS_INDICATION_SUPPORTED
229 ProgressIndicator progress( subprogress( callback, 0.00f, 0.80f ) );
230 reader.TransferRoots( progress.Start() );
231#else
232 reader.TransferRoots();
233#endif
234 }
235
236 if ( !reportProgress( callback, 0.80f ) )
237 return unexpectedOperationCanceled();
238
239 std::deque<TopoDS_Shape> shapes;
240 for ( auto shi = 1; shi <= reader.NbShapes(); ++shi )
241 {
242 const auto shape = reader.Shape( shi );
243
244 // search for closed shapes
245 size_t solidCount = 0;
246 for ( auto explorer = TopExp_Explorer( shape, TopAbs_SOLID ); explorer.More(); explorer.Next() )
247 {
248 shapes.emplace_back( explorer.Current() );
249 ++solidCount;
250 }
251 // search for non-closed shapes
252 size_t shellCount = 0;
253 for ( auto explorer = TopExp_Explorer( shape, TopAbs_SHELL, TopAbs_SOLID ); explorer.More(); explorer.Next() )
254 {
255 shapes.emplace_back( explorer.Current() );
256 ++shellCount;
257 }
258
259 // import the whole shape if it doesn't consist of solids or shells
260 if ( solidCount + shellCount == 0 )
261 shapes.emplace_back( shape );
262 }
263
264 rootObj_ = std::make_shared<Object>();
265 rootObj_->select( true );
266
267 for ( const auto& shape : shapes )
268 {
269 const auto& location = shape.Location();
270 const auto xf = AffineXf3f( toXf( location.Transformation() ) );
271
272 auto objMesh = std::make_shared<ObjectMesh>();
273 objMesh->setMesh( std::make_shared<Mesh>() );
274 objMesh->setXf( xf );
275 objMesh->select( true );
276 rootObj_->addChild( objMesh );
277
278 meshTriangulationContexts_.emplace_back( shape, objMesh, std::nullopt, std::nullopt );

Callers 2

fromStepImplFunction · 0.80
fromSceneStepFileImplFunction · 0.80

Calls 12

subprogressFunction · 0.85
reportProgressFunction · 0.85
toXfFunction · 0.85
setMeshMethod · 0.80
addChildMethod · 0.80
selectMethod · 0.45
setXfMethod · 0.45
MainMethod · 0.45
pushMethod · 0.45
ValueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected