+
+ //================================================================================
+ /*!
+ * \brief Return EDGEs dividing one box side
+ */
+ //================================================================================
+
+ bool getInternalEdges( SMESH_Mesh& mesh,
+ const TopoDS_Shape& shape,
+ const TopTools_MapOfShape& cornerVV,
+ TopTools_MapOfShape& internEE)
+ {
+ TopTools_IndexedMapOfShape subEE, subFF;
+ TopExp::MapShapes( shape, TopAbs_EDGE, subEE );
+ TopExp::MapShapes( shape, TopAbs_FACE, subFF );
+
+ TopoDS_Vertex VV[2];
+ TopTools_MapOfShape subChecked/*, ridgeEE*/;
+ TopTools_MapIteratorOfMapOfShape vIt( cornerVV );
+ for ( ; vIt.More(); vIt.Next() )
+ {
+ TopoDS_Shape V0 = vIt.Key();
+ // walk from one corner VERTEX to another along ridge EDGEs
+ PShapeIteratorPtr riIt = SMESH_MesherHelper::GetAncestors( V0, mesh, TopAbs_EDGE );
+ while ( const TopoDS_Shape* riE = riIt->next() )
+ {
+ if ( !subEE.Contains( *riE ) || !subChecked.Add( *riE ))
+ continue;
+ TopoDS_Edge ridgeE = TopoDS::Edge( *riE );
+ while ( !ridgeE.IsNull() )
+ {
+ TopExp::Vertices( ridgeE, VV[0], VV[1] );
+ TopoDS_Shape V1 = VV[ V0.IsSame( VV[0] )];
+ if ( cornerVV.Contains( V1 ) )
+ break; // ridgeE reached a corner VERTEX
+
+ // detect internal EDGEs among those sharing V1. There can be 2, 3 or 4 EDGEs and
+ // number of internal EDGEs is N-2
+ TopoDS_Shape nextRidgeE;
+ PShapeIteratorPtr eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
+ while ( const TopoDS_Shape* E = eIt->next() )
+ {
+ if ( E->IsSame( ridgeE ) || !subEE.Contains( *E ) || !subChecked.Add( *E ))
+ continue;
+ // look for FACEs sharing both E and ridgeE
+ PShapeIteratorPtr fIt = SMESH_MesherHelper::GetAncestors( *E, mesh, TopAbs_FACE );
+ while ( const TopoDS_Shape* F = fIt->next() )
+ {
+ if ( !SMESH_MesherHelper::IsSubShape( ridgeE, *F ))
+ continue;
+ if ( isContinuousMesh( ridgeE, TopoDS::Edge( *E ), TopoDS::Face( *F ), mesh ))
+ {
+ nextRidgeE = *E;
+ }
+ else
+ {
+ internEE.Add( *E );
+ }
+ break;
+ }
+ }
+ // look for the next ridge EDGE ending at V1
+ if ( nextRidgeE.IsNull() )
+ {
+ eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
+ while ( const TopoDS_Shape* E = eIt->next() )
+ if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) && subEE.Contains( *E ))
+ {
+ nextRidgeE = *E;
+ break;
+ }
+ }
+ ridgeE = TopoDS::Edge( nextRidgeE );
+ V0 = V1;
+
+ if ( ridgeE.IsNull() )
+ return false;
+ } // check EDGEs around the last VERTEX of ridgeE
+ } // loop on ridge EDGEs around a corner VERTEX
+ } // loop on on corner VERTEXes
+
+ return true;
+ } // getInternalEdges()
+} // namespace