- if ( GEOMBase::GetShape(mainShape, aShape)) {
- isValidMesh = true;
- TopExp_Explorer exp( aShape, TopAbs_SOLID );
- myHasSolids = exp.More();
- for ( ; exp.More(); exp.Next())
- nb3dShapes++;
- for ( exp.Init( aShape, TopAbs_SHELL, TopAbs_SOLID ); exp.More(); exp.Next())
- nb3dShapes++;
+ if ( GEOMBase::GetShape(mainShape, aShape))
+ {
+ TopAbs_ShapeEnum types[4] = { TopAbs_EDGE, TopAbs_FACE, TopAbs_SHELL, TopAbs_SOLID };
+ for ( int dim = 4; dim > 0; --dim ) {
+ TopAbs_ShapeEnum type = types[ dim - 1 ];
+ TopAbs_ShapeEnum avoid = ( type == TopAbs_SHELL ) ? TopAbs_SOLID : TopAbs_SHAPE;
+ TopExp_Explorer exp( aShape, type, avoid );
+ for ( ; nbShapes[ type ] < 2 && exp.More(); exp.Next() )
+ ++nbShapes[ type ];
+ if ( nbShapes[ type ] > 1 ) {
+ shapeDim = dim;
+ break;
+ }
+ }