From: eap Date: Fri, 17 Apr 2015 15:55:19 +0000 (+0300) Subject: 22264: EDF 2648 GEOM: Propagate edges automatic orientation X-Git-Tag: V7_6_0rc1~31 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=5c372c165941502d85392e1502980931d0109c8f 22264: EDF 2648 GEOM: Propagate edges automatic orientation PB: chains are built incorrectly in a compound of solids + Fix and optimize LyingOnGeom --- diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index a5739224f..267fc2a28 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -68,6 +68,7 @@ #include #include +#include /* AUXILIARY METHODS @@ -4506,12 +4507,22 @@ void LyingOnGeom::init() myIsSubshape = false; } else { - TopTools_IndexedMapOfShape aMap; - TopExp::MapShapes(aMainShape, aMap); - myIsSubshape = IsSubShape(aMap, myShape); + myIsSubshape = myMeshDS->IsGroupOfSubShapes( myShape ); } - if (!myIsSubshape) + if (myIsSubshape) + { + TopTools_IndexedMapOfShape shapes; + TopExp::MapShapes( myShape, shapes ); + mySubShapesIDs.Clear(); + for ( int i = 1; i <= shapes.Extent(); ++i ) + { + int subID = myMeshDS->ShapeToIndex( shapes( i )); + if ( subID > 0 ) + mySubShapesIDs.Add( subID ); + } + } + else { myElementsOnShapePtr.reset(new ElementsOnShape()); myElementsOnShapePtr->SetTolerance(myTolerance); @@ -4531,43 +4542,22 @@ bool LyingOnGeom::IsSatisfy( long theId ) return myElementsOnShapePtr->IsSatisfy(theId); } - // Case of submesh - if( myType == SMDSAbs_Node ) - { - if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) ) - { - const SMDS_PositionPtr& aPosition = aNode->GetPosition(); - SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition(); - switch( aTypeOfPosition ) - { - case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX ); - case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE ); - case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE ); - case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL ); - } - } - } - else + // Case of sub-mesh + + const SMDS_MeshElement* elem = + ( myType == SMDSAbs_Node ) ? myMeshDS->FindNode( theId ) : myMeshDS->FindElement( theId ); + + if ( mySubShapesIDs.Contains( elem->getshapeId() )) + return true; + + if ( elem->GetType() != SMDSAbs_Node ) { - if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) ) + SMDS_ElemIteratorPtr nodeItr = elem->nodesIterator(); + while ( nodeItr->more() ) { - if( myType == SMDSAbs_All ) - { - return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) || - Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) || - Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| - Contains( myMeshDS,myShape,anElem,TopAbs_SOLID ); - } - else if( myType == anElem->GetType() ) - { - switch( myType ) - { - case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ); - case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE ); - case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| - Contains( myMeshDS,myShape,anElem,TopAbs_SOLID ); - } - } + const SMDS_MeshElement* aNode = nodeItr->next(); + if ( mySubShapesIDs.Contains( aNode->getshapeId() )) + return true; } } @@ -4613,34 +4603,30 @@ bool LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS, TopAbs_ShapeEnum theFindShapeEnum, TopAbs_ShapeEnum theAvoidShapeEnum ) { - if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum)) - return true; - - TopTools_IndexedMapOfShape aSubShapes; - TopExp::MapShapes( theShape, aSubShapes ); - - for (int i = 1; i <= aSubShapes.Extent(); i++) - { - const TopoDS_Shape& aShape = aSubShapes.FindKey(i); - - if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){ - if( aSubMesh->Contains( theElem ) ) - return true; - - SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes(); - while ( aNodeIt->more() ) - { - const SMDS_MeshNode* aNode = static_cast(aNodeIt->next()); - SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator(); - while ( anElemIt->more() ) - { - const SMDS_MeshElement* anElement = static_cast(anElemIt->next()); - if (anElement == theElem) - return true; - } - } - } - } + // if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum)) + // return true; + + // TopTools_MapOfShape aSubShapes; + // TopExp_Explorer exp( theShape, theFindShapeEnum, theAvoidShapeEnum ); + // for ( ; exp.More(); exp.Next() ) + // { + // const TopoDS_Shape& aShape = exp.Current(); + // if ( !aSubShapes.Add( aShape )) continue; + + // if ( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape )) + // { + // if ( aSubMesh->Contains( theElem )) + // return true; + + // SMDS_ElemIteratorPtr nodeItr = theElem->nodesIterator(); + // while ( nodeItr->more() ) + // { + // const SMDS_MeshElement* aNode = nodeItr->next(); + // if ( aSubMesh->Contains( aNode )) + // return true; + // } + // } + // } return false; } diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index cf3a7cd98..41448b1f6 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -974,6 +973,7 @@ namespace SMESH{ virtual void init(); TopoDS_Shape myShape; + TColStd_MapOfInteger mySubShapesIDs; const SMESHDS_Mesh* myMeshDS; SMDSAbs_ElementType myType; bool myIsSubshape; diff --git a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx index 9f9dbd002..3369aaa95 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx @@ -237,8 +237,11 @@ bool StdMeshersGUI_PropagationHelperWdg::buildChains() NCollection_DataMap< TGeomID, TWiresOfEdge > wiresOfEdge( egdeIDs.count() ); TopExp_Explorer wire; + TopTools_MapOfShape faceMap; for ( TopExp_Explorer face( shape, TopAbs_FACE ); face.More(); face.Next() ) { + if ( !faceMap.Add( face.Current() )) continue; + wire.Init( face.Current(), TopAbs_WIRE ); TopoDS_Shape W = wire.Current().Oriented( TopAbs_FORWARD );