]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
IPAL22863 TC6.5.0: Projection_1D2D gives exception
authoreap <eap@opencascade.com>
Mon, 23 Apr 2012 10:13:52 +0000 (10:13 +0000)
committereap <eap@opencascade.com>
Mon, 23 Apr 2012 10:13:52 +0000 (10:13 +0000)
Replace TopTools_DataMapOfShapeShape with
StdMeshers_ShapeShapeBiDirectionMap which includes 2
TopTools_DataMapOfShapeShape's, one per a mapping direction

src/StdMeshers/StdMeshers_ProjectionUtils.cxx
src/StdMeshers/StdMeshers_ProjectionUtils.hxx
src/StdMeshers/StdMeshers_Projection_1D.cxx
src/StdMeshers/StdMeshers_Projection_1D2D.cxx
src/StdMeshers/StdMeshers_Projection_2D.cxx
src/StdMeshers/StdMeshers_RadialPrism_3D.cxx

index 94714a25551a3949b4e0ef4e0074b86071a504e8..c029af6c15e6860e7e37d75ae77a9fa0cdc6a61f 100644 (file)
@@ -418,9 +418,9 @@ namespace {
 //=======================================================================
 /*!
  * \brief Looks for association of all sub-shapes of two shapes
- * \param theShape1 - shape 1
+ * \param theShape1 - target shape
  * \param theMesh1 - mesh built on shape 1
- * \param theShape2 - shape 2
+ * \param theShape2 - source shape
  * \param theMesh2 - mesh built on shape 2
  * \param theAssociation - association map to be filled that may
  *                         contain association of one or two pairs of vertices
@@ -474,13 +474,11 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
     return FindSubShapeAssociation(group1, theMesh1, group2, theMesh2, theMap );
   }
 
-  bool bidirect = ( !theShape1.IsSame( theShape2 ));
-
   // ============
   // 2) Is partner?
   // ============
   bool partner = theShape1.IsPartner( theShape2 );
-  TopTools_DataMapIteratorOfDataMapOfShapeShape vvIt( theMap );
+  TopTools_DataMapIteratorOfDataMapOfShapeShape vvIt( theMap._map1to2 );
   for ( ; partner && vvIt.More(); vvIt.Next() )
     partner = vvIt.Key().IsPartner( vvIt.Value() );
 
@@ -492,7 +490,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
     TShapePairsList::iterator s1_s2 = shapesQueue.begin();
     for ( ; s1_s2 != shapesQueue.end(); ++s1_s2 )
     {
-      InsertAssociation( s1_s2->first, s1_s2->second, theMap, bidirect);
+      InsertAssociation( s1_s2->first, s1_s2->second, theMap );
       TopoDS_Iterator s1It( s1_s2->first), s2It( s1_s2->second );
       for ( ; s1It.More(); s1It.Next(), s2It.Next() )
         shapesQueue.push_back( make_pair( s1It.Value(), s2It.Value() ));
@@ -521,8 +519,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
       int i1 = 0, i2 = 0;
       if ( theMap.IsBound( VV1[ i1 ] )) i1 = 1;
       if ( theMap.IsBound( VV2[ i2 ] )) i2 = 1;
-      InsertAssociation( VV1[ i1 ], VV2[ i2 ], theMap, bidirect);
-      InsertAssociation( theShape1, theShape2, theMap, bidirect );
+      InsertAssociation( VV1[ i1 ], VV2[ i2 ], theMap );
+      InsertAssociation( theShape1, theShape2, theMap );
       return true;
     }
       // ----------------------------------------------------------------------
@@ -561,12 +559,12 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
       list< TopoDS_Edge >::iterator eIt2 = edges2.begin();
       for ( ; eIt1 != edges1.end(); ++eIt1, ++eIt2 )
       {
-        InsertAssociation( *eIt1, *eIt2, theMap, bidirect);
+        InsertAssociation( *eIt1, *eIt2, theMap );
         VV1[0] = TopExp::FirstVertex( *eIt1, true );
         VV2[0] = TopExp::FirstVertex( *eIt2, true );
-        InsertAssociation( VV1[0], VV2[0], theMap, bidirect);
+        InsertAssociation( VV1[0], VV2[0], theMap );
       }
-      InsertAssociation( theShape1, theShape2, theMap, bidirect );
+      InsertAssociation( theShape1, theShape2, theMap );
       return true;
     }
       // ----------------------------------------------------------------------
@@ -647,7 +645,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
       TopExp::Vertices( edge1, VV1[0], VV1[1], true );
       TopExp::Vertices( edge2, VV2[0], VV2[1], true );
       F2 = FF2[ 0 ]; // (F2 !)
-      if ( !VV1[ 0 ].IsSame( theMap( VV2[ 0 ]))) {
+      if ( !VV1[ 0 ].IsSame( theMap( VV2[ 0 ], /*is2=*/true))) {
         edge2.Reverse();
         if ( FF2[ 1 ].IsNull() )
           F2.Reverse();
@@ -674,7 +672,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
         list< TopoDS_Edge > edges1, edges2;
         int nbE = FindFaceAssociation( face1, VV1, face2, VV2, edges1, edges2 );
         if ( !nbE ) RETURN_BAD_RESULT("FindFaceAssociation() failed");
-        InsertAssociation( face1, face2, theMap, bidirect); // assoc faces
+        InsertAssociation( face1, face2, theMap ); // assoc faces
         MESSAGE("Assoc FACE " << theMesh1->GetMeshDS()->ShapeToIndex( face1 )<<
                 " to "        << theMesh2->GetMeshDS()->ShapeToIndex( face2 ));
         if ( nbE == 2 && (edge1.IsSame( edges1.front())) != (edge2.IsSame( edges2.front())))
@@ -686,12 +684,12 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
         for ( ; eIt1 != edges1.end(); ++eIt1, ++eIt2 )
         {
           if ( !boundEdges.Add( *eIt1 )) continue; // already associated
-          InsertAssociation( *eIt1, *eIt2, theMap, bidirect);  // assoc edges
+          InsertAssociation( *eIt1, *eIt2, theMap );  // assoc edges
           MESSAGE("Assoc edge " << theMesh1->GetMeshDS()->ShapeToIndex( *eIt1 )<<
                   " to "        << theMesh2->GetMeshDS()->ShapeToIndex( *eIt2 ));
           VV1[0] = TopExp::FirstVertex( *eIt1, true );
           VV2[0] = TopExp::FirstVertex( *eIt2, true );
-          InsertAssociation( VV1[0], VV2[0], theMap, bidirect); // assoc vertices
+          InsertAssociation( VV1[0], VV2[0], theMap ); // assoc vertices
           MESSAGE("Assoc vertex " << theMesh1->GetMeshDS()->ShapeToIndex( VV1[0] )<<
                   " to "          << theMesh2->GetMeshDS()->ShapeToIndex( VV2[0] ));
 
@@ -704,7 +702,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
           }
         }
       }
-      InsertAssociation( theShape1, theShape2, theMap, bidirect );
+      InsertAssociation( theShape1, theShape2, theMap );
       return true;
     }
       // ----------------------------------------------------------------------
@@ -826,7 +824,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
               TShapeShapeMap tmpMap;
               ok = FindSubShapeAssociation( comp[0], theMesh1, comp[1], theMesh2, tmpMap );
               if ( ok ) {
-                TopTools_DataMapIteratorOfDataMapOfShapeShape mapIt( tmpMap );
+                TopTools_DataMapIteratorOfDataMapOfShapeShape mapIt( tmpMap._map1to2 );
                 for ( ; mapIt.More(); mapIt.Next() )
                   theMap.Bind( mapIt.Key(), mapIt.Value());
               }
@@ -885,13 +883,13 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
             TopoDS_Edge e1 = TopoDS::Edge( edges1.First() );
             v2e[0].UnBind( V[0] );
             v2e[1].UnBind( V[1] );
-            InsertAssociation( e0, e1, theMap, bidirect );
+            InsertAssociation( e0, e1, theMap );
             MESSAGE("Assoc edge " << theMesh1->GetMeshDS()->ShapeToIndex( e0 )<<
                     " to "        << theMesh2->GetMeshDS()->ShapeToIndex( e1 ));
             V[0] = GetNextVertex( e0, V[0] );
             V[1] = GetNextVertex( e1, V[1] );
             if ( !V[0].IsNull() ) {
-              InsertAssociation( V[0], V[1], theMap, bidirect );
+              InsertAssociation( V[0], V[1], theMap );
               MESSAGE("Assoc vertex " << theMesh1->GetMeshDS()->ShapeToIndex( V[0] )<<
                       " to "          << theMesh2->GetMeshDS()->ShapeToIndex( V[1] ));
             }
@@ -917,9 +915,9 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
             } else {
               v1n = v1e1; e1b = edges1.First(); e1n = edges1.Last();
             }
-            InsertAssociation( e0b, e1b, theMap, bidirect );
-            InsertAssociation( e0n, e1n, theMap, bidirect );
-            InsertAssociation( v0n, v1n, theMap, bidirect );
+            InsertAssociation( e0b, e1b, theMap );
+            InsertAssociation( e0n, e1n, theMap );
+            InsertAssociation( v0n, v1n, theMap );
             MESSAGE("Assoc edge " << theMesh1->GetMeshDS()->ShapeToIndex( e0b )<<
                     " to "        << theMesh2->GetMeshDS()->ShapeToIndex( e1b ));
             MESSAGE("Assoc edge " << theMesh1->GetMeshDS()->ShapeToIndex( e0n )<<
@@ -963,14 +961,14 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
         TopoDS_Vertex VV1[2], VV2[2];
         TopExp::Vertices( edge1,   VV1[0], VV1[1], true );
         TopExp::Vertices( prpEdge, VV2[0], VV2[1], true );
-        InsertAssociation( VV1[ 0 ], VV2[ 0 ], theMap, bidirect);
-        InsertAssociation( VV1[ 1 ], VV2[ 1 ], theMap, bidirect);
+        InsertAssociation( VV1[ 0 ], VV2[ 0 ], theMap );
+        InsertAssociation( VV1[ 1 ], VV2[ 1 ], theMap );
         if ( VV1[0].IsSame( VV1[1] ) || // one of edges is closed
              VV2[0].IsSame( VV2[1] ) )
         {
-          InsertAssociation( edge1, prpEdge, theMap, bidirect); // insert with a proper orientation
+          InsertAssociation( edge1, prpEdge, theMap ); // insert with a proper orientation
         }
-        InsertAssociation( theShape1, theShape2, theMap, bidirect );
+        InsertAssociation( theShape1, theShape2, theMap );
         return true; // done
       }
     }
@@ -978,10 +976,10 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
          SMESH_MesherHelper::IsClosedEdge( edge2 ))
     {
       // TODO: find out a proper orientation (is it possible?)
-      InsertAssociation( edge1, edge2, theMap, bidirect); // insert with a proper orientation
+      InsertAssociation( edge1, edge2, theMap ); // insert with a proper orientation
       InsertAssociation( TopExp::FirstVertex(edge1), TopExp::FirstVertex(edge2),
-                         theMap, bidirect);
-      InsertAssociation( theShape1, theShape2, theMap, bidirect );
+                         theMap );
+      InsertAssociation( theShape1, theShape2, theMap );
       return true; // done
     }
     break; // try by vertex closeness
@@ -1031,12 +1029,12 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
         list< TopoDS_Edge >::iterator eIt2 = edges2.begin();
         for ( ; eIt1 != edges1.end(); ++eIt1, ++eIt2 )
         {
-          InsertAssociation( *eIt1, *eIt2, theMap, bidirect);
+          InsertAssociation( *eIt1, *eIt2, theMap );
           VV1[0] = TopExp::FirstVertex( *eIt1, true );
           VV2[0] = TopExp::FirstVertex( *eIt2, true );
-          InsertAssociation( VV1[0], VV2[0], theMap, bidirect);
+          InsertAssociation( VV1[0], VV2[0], theMap );
         }
-        InsertAssociation( theShape1, theShape2, theMap, bidirect );
+        InsertAssociation( theShape1, theShape2, theMap );
         return true;
       }
     }
@@ -1099,8 +1097,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
         }
       }
       if ( !VV1[1].IsNull() ) {
-        InsertAssociation( VV1[0], VV2[0], theMap, bidirect);
-        InsertAssociation( VV1[1], VV2[1], theMap, bidirect);
+        InsertAssociation( VV1[0], VV2[0], theMap );
+        InsertAssociation( VV1[1], VV2[1], theMap );
         return FindSubShapeAssociation( theShape1, theMesh1, theShape2, theMesh2, theMap);
       }
     }
@@ -1121,9 +1119,9 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
     RETURN_BAD_RESULT("Different nb of vertices");
 
   if ( vMap1.Extent() == 1 ) {
-    InsertAssociation( vMap1(1), vMap2(1), theMap, bidirect);
+    InsertAssociation( vMap1(1), vMap2(1), theMap );
     if ( theShape1.ShapeType() == TopAbs_EDGE ) {
-      InsertAssociation( theShape1, theShape2, theMap, bidirect );
+      InsertAssociation( theShape1, theShape2, theMap );
       return true;
     }
     return FindSubShapeAssociation( theShape1, theMesh1, theShape2, theMesh2, theMap);
@@ -1147,8 +1145,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
       }
       if ( edgeFound )
       {
-        InsertAssociation( VV1[0], VV1[0], theMap, bidirect );
-        InsertAssociation( VV1[1], VV1[1], theMap, bidirect );
+        InsertAssociation( VV1[0], VV1[0], theMap );
+        InsertAssociation( VV1[1], VV1[1], theMap );
         if (FindSubShapeAssociation( theShape1, theMesh1, theShape2, theMesh2, theMap ))
           return true;
       }
@@ -1203,14 +1201,14 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the
     }
   }
 
-  InsertAssociation( VV1[ 0 ], VV2[ 0 ], theMap, bidirect);
-  InsertAssociation( VV1[ 1 ], VV2[ 1 ], theMap, bidirect);
+  InsertAssociation( VV1[ 0 ], VV2[ 0 ], theMap );
+  InsertAssociation( VV1[ 1 ], VV2[ 1 ], theMap );
   MESSAGE("Initial assoc VERT " << theMesh1->GetMeshDS()->ShapeToIndex( VV1[ 0 ] )<<
           " to "                << theMesh2->GetMeshDS()->ShapeToIndex( VV2[ 0 ] )<<
           "\nand         VERT " << theMesh1->GetMeshDS()->ShapeToIndex( VV1[ 1 ] )<<
           " to "                << theMesh2->GetMeshDS()->ShapeToIndex( VV2[ 1 ] ));
   if ( theShape1.ShapeType() == TopAbs_EDGE ) {
-    InsertAssociation( theShape1, theShape2, theMap, bidirect );
+    InsertAssociation( theShape1, theShape2, theMap );
     return true;
   }
 
@@ -1378,30 +1376,29 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face&    face1,
 //=======================================================================
 
 void StdMeshers_ProjectionUtils::InitVertexAssociation( const SMESH_Hypothesis* theHyp,
-                                                        TShapeShapeMap &        theAssociationMap,
-                                                        const TopoDS_Shape&     theTargetShape)
+                                                        TShapeShapeMap &        theAssociationMap)
 {
   string hypName = theHyp->GetName();
   if ( hypName == "ProjectionSource1D" ) {
     const StdMeshers_ProjectionSource1D * hyp =
       static_cast<const StdMeshers_ProjectionSource1D*>( theHyp );
     if ( hyp->HasVertexAssociation() )
-      InsertAssociation( hyp->GetSourceVertex(),hyp->GetTargetVertex(),theAssociationMap);
+      InsertAssociation( hyp->GetTargetVertex(),hyp->GetSourceVertex(),theAssociationMap );
   }
   else if ( hypName == "ProjectionSource2D" ) {
     const StdMeshers_ProjectionSource2D * hyp =
       static_cast<const StdMeshers_ProjectionSource2D*>( theHyp );
     if ( hyp->HasVertexAssociation() ) {
-      InsertAssociation( hyp->GetSourceVertex(1),hyp->GetTargetVertex(1),theAssociationMap);
-      InsertAssociation( hyp->GetSourceVertex(2),hyp->GetTargetVertex(2),theAssociationMap);
+      InsertAssociation( hyp->GetTargetVertex(1),hyp->GetSourceVertex(1),theAssociationMap);
+      InsertAssociation( hyp->GetTargetVertex(2),hyp->GetSourceVertex(2),theAssociationMap);
     }
   }
   else if ( hypName == "ProjectionSource3D" ) {
     const StdMeshers_ProjectionSource3D * hyp =
       static_cast<const StdMeshers_ProjectionSource3D*>( theHyp );
     if ( hyp->HasVertexAssociation() ) {
-      InsertAssociation( hyp->GetSourceVertex(1),hyp->GetTargetVertex(1),theAssociationMap);
-      InsertAssociation( hyp->GetSourceVertex(2),hyp->GetTargetVertex(2),theAssociationMap);
+      InsertAssociation( hyp->GetTargetVertex(1),hyp->GetSourceVertex(1),theAssociationMap);
+      InsertAssociation( hyp->GetTargetVertex(2),hyp->GetSourceVertex(2),theAssociationMap);
     }
   }
 }
@@ -1409,24 +1406,21 @@ void StdMeshers_ProjectionUtils::InitVertexAssociation( const SMESH_Hypothesis*
 //=======================================================================
 /*!
  * \brief Inserts association theShape1 <-> theShape2 to TShapeShapeMap
- * \param theShape1 - shape 1
- * \param theShape2 - shape 2
+ * \param theShape1 - target shape
+ * \param theShape2 - source shape
  * \param theAssociationMap - association map 
  * \retval bool - true if there was no association for these shapes before
  */
 //=======================================================================
 
-bool StdMeshers_ProjectionUtils::InsertAssociation( const TopoDS_Shape& theShape1,
-                                                    const TopoDS_Shape& theShape2,
-                                                    TShapeShapeMap &    theAssociationMap,
-                                                    const bool          theBidirectional)
+bool StdMeshers_ProjectionUtils::InsertAssociation( const TopoDS_Shape& theShape1, // tgt
+                                                    const TopoDS_Shape& theShape2, // src
+                                                    TShapeShapeMap &    theAssociationMap)
 {
   if ( !theShape1.IsNull() && !theShape2.IsNull() ) {
     SHOW_SHAPE(theShape1,"Assoc ");
     SHOW_SHAPE(theShape2," to ");
     bool isNew = ( theAssociationMap.Bind( theShape1, theShape2 ));
-    if ( theBidirectional )
-      theAssociationMap.Bind( theShape2, theShape1 );
     return isNew;
   }
   else {
@@ -1647,9 +1641,9 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
     TopoDS_Edge e2 = TopoDS::Edge( eE.Current() );
     eE.Next();
     // edge 1
-    if ( !assocMap.IsBound( e2 ))
+    if ( !assocMap.IsBound( e2, /*is2nd=*/true ))
       RETURN_BAD_RESULT("Association not found for edge " << meshDS2->ShapeToIndex( e2 ));
-    TopoDS_Edge e1 = TopoDS::Edge( assocMap( e2 ));
+    TopoDS_Edge e1 = TopoDS::Edge( assocMap( e2, /*is2nd=*/true ));
     if ( !helper1.IsSubShape( e1, face1 ))
       RETURN_BAD_RESULT("Wrong association, edge " << meshDS1->ShapeToIndex( e1 ) <<
                         " isn't a sub-shape of face " << meshDS1->ShapeToIndex( face1 ));
@@ -1691,9 +1685,9 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
 
   // get 2 matching vertices
   TopoDS_Vertex V2 = TopExp::FirstVertex( TopoDS::Edge( edge2 ));
-  if ( !assocMap.IsBound( V2 ))
+  if ( !assocMap.IsBound( V2, /*is2nd=*/true ))
     RETURN_BAD_RESULT("Association not found for vertex " << meshDS2->ShapeToIndex( V2 ));
-  TopoDS_Vertex V1 = TopoDS::Vertex( assocMap( V2 ));
+  TopoDS_Vertex V1 = TopoDS::Vertex( assocMap( V2, /*is2nd=*/true ));
 
   // nodes on vertices
   const SMDS_MeshNode* vNode1 = SMESH_Algo::VertexNode( V1, meshDS1 );
@@ -1742,9 +1736,9 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
   {
     // get 2 other matching vertices
     V2 = TopExp::LastVertex( TopoDS::Edge( edge2 ));
-    if ( !assocMap.IsBound( V2 ))
+    if ( !assocMap.IsBound( V2, /*is2nd=*/true ))
       RETURN_BAD_RESULT("Association not found for vertex " << meshDS2->ShapeToIndex( V2 ));
-    V1 = TopoDS::Vertex( assocMap( V2 ));
+    V1 = TopoDS::Vertex( assocMap( V2, /*is2nd=*/true ));
 
     // nodes on vertices
     eNode1[0] = SMESH_Algo::VertexNode( V1, meshDS1 );
@@ -1896,9 +1890,9 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
 
     // associate matching nodes on the last vertices
     V2 = TopExp::LastVertex( TopoDS::Edge( edge2 ));
-    if ( !assocMap.IsBound( V2 ))
+    if ( !assocMap.IsBound( V2, /*is2nd=*/true ))
       RETURN_BAD_RESULT("Association not found for vertex " << meshDS2->ShapeToIndex( V2 ));
-    V1 = TopoDS::Vertex( assocMap( V2 ));
+    V1 = TopoDS::Vertex( assocMap( V2, /*is2nd=*/true ));
     vNode1 = SMESH_Algo::VertexNode( V1, meshDS1 );
     vNode2 = SMESH_Algo::VertexNode( V2, meshDS2 );
     if ( !vNode1 ) RETURN_BAD_RESULT("No node on vertex #" << meshDS1->ShapeToIndex( V1 ));
index 9c8f824618359cf5904a227c3e371a4d0ac1a940..685536a4dca7305eb2513b32d8682966c2dcf6cc 100644 (file)
@@ -45,6 +45,29 @@ class SMESH_Hypothesis;
 class SMESH_subMesh;
 class TopTools_IndexedDataMapOfShapeListOfShape;
 
+/*!
+ * \brief Struct used instead of a sole TopTools_DataMapOfShapeShape to avoid
+ *        problems with bidirectional bindings
+ */
+struct StdMeshers_ShapeShapeBiDirectionMap
+{
+  TopTools_DataMapOfShapeShape _map1to2, _map2to1;
+
+  // convension: s1 - target, s2 - source
+  bool Bind( const TopoDS_Shape& s1, const TopoDS_Shape& s2 )
+  { _map1to2.Bind( s1, s2 ); return _map2to1.Bind( s2, s1 ); }
+  bool IsBound( const TopoDS_Shape& s, const bool isShape2=false ) const 
+  { return (isShape2 ? _map2to1 : _map1to2).IsBound( s ); }
+  bool IsEmpty() const { return _map1to2.IsEmpty(); }
+  int Extent() const { return _map1to2.Extent(); }
+  void Clear() { _map1to2.Clear(); _map2to1.Clear(); }
+  const TopoDS_Shape& operator()( const TopoDS_Shape& s, const bool isShape2=false ) const
+  { // if we get a Standard_NoSuchObject here, it means that the calling code
+    // passes incorrect isShape2
+    return (isShape2 ? _map2to1 : _map1to2)( s );
+  }
+};
+
 /*!
  * \brief Class encapsulating methods common to Projection algorithms
  */
@@ -52,7 +75,7 @@ class StdMeshers_ProjectionUtils
 {
  public:
 
-  typedef TopTools_DataMapOfShapeShape                         TShapeShapeMap;
+  typedef StdMeshers_ShapeShapeBiDirectionMap                  TShapeShapeMap;
   typedef TopTools_IndexedDataMapOfShapeListOfShape            TAncestorMap;
   typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
 
@@ -96,21 +119,19 @@ class StdMeshers_ProjectionUtils
     * \param theTargetShape - the shape theHyp assigned to
    */
   static void InitVertexAssociation( const SMESH_Hypothesis* theHyp,
-                                     TShapeShapeMap &        theAssociationMap,
-                                     const TopoDS_Shape&     theTargetShape);
+                                     TShapeShapeMap &        theAssociationMap);
 
   /*!
    * \brief Inserts association theShape1 <-> theShape2 to TShapeShapeMap
-    * \param theShape1 - shape 1
-    * \param theShape2 - shape 2
+    * \param theShape1 - target shape
+    * \param theShape2 - source shape
     * \param theAssociationMap - association map 
     * \param theBidirectional - if false, inserts theShape1 -> theShape2 association
     * \retval bool - true if there was no association for these shapes before
    */
-  static bool InsertAssociation( const TopoDS_Shape& theShape1,
-                                 const TopoDS_Shape& theShape2,
-                                 TShapeShapeMap &    theAssociationMap,
-                                 const bool          theBidirectional=true);
+  static bool InsertAssociation( const TopoDS_Shape& theShape1, // target
+                                 const TopoDS_Shape& theShape2, // source
+                                 TShapeShapeMap &    theAssociationMap);
 
   /*!
    * \brief Finds an edge by its vertices in a main shape of the mesh
index 5b8f2a8511d98613c0c550fbb20a219d5b001b8e..778b57c0e605d36495fe5dd7b72b1b9f3ff2921a 100644 (file)
@@ -217,7 +217,7 @@ bool StdMeshers_Projection_1D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
   TopoDS_Shape srcShape = _sourceHypo->GetSourceEdge().Oriented(TopAbs_FORWARD);
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap, tgtEdge );
+  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
   if ( !TAssocTool::FindSubShapeAssociation( tgtEdge, tgtMesh, srcShape, srcMesh,
                                              shape2ShapeMap) ||
        !shape2ShapeMap.IsBound( tgtEdge ))
@@ -401,7 +401,7 @@ bool StdMeshers_Projection_1D::Evaluate(SMESH_Mesh& theMesh,
   TopoDS_Shape srcShape = _sourceHypo->GetSourceEdge().Oriented(TopAbs_FORWARD);
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap, tgtEdge );
+  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
   if ( !TAssocTool::FindSubShapeAssociation( tgtEdge, tgtMesh, srcShape, srcMesh,
                                              shape2ShapeMap) ||
        !shape2ShapeMap.IsBound( tgtEdge ))
index 49d94142e7337546163dc6354105eb697b7ce82d..0857b9f19cff2911641ebaef60a99d66e7350eb8 100644 (file)
@@ -196,7 +196,7 @@ bool StdMeshers_Projection_1D2D::Evaluate(SMESH_Mesh&         theMesh,
 
   typedef StdMeshers_ProjectionUtils SPU;
   SPU::TShapeShapeMap shape2ShapeMap;
-  SPU::InitVertexAssociation( _sourceHypo, shape2ShapeMap, theShape );
+  SPU::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
   if ( !SPU::FindSubShapeAssociation( theShape, &theMesh, srcFace, srcMesh, shape2ShapeMap))
     return error(COMPERR_BAD_SHAPE,"Topology of source and target faces seems different" );
 
index 8255b7486251ce48018e87c346af8bc8fec574a6..77a8d7559b54e880e4ba34ac3a74327eaf206de1 100644 (file)
@@ -428,7 +428,7 @@ namespace {
           // find corresponding point on target shape
           pOK = false;
           gp_Pnt tgtP;
-          const TopoDS_Shape& tgtShape = shape2ShapeMap( srcSM->GetSubShape() );
+          const TopoDS_Shape& tgtShape = shape2ShapeMap( srcSM->GetSubShape(), /*isSrc=*/true );
           if ( tgtShape.ShapeType() == TopAbs_VERTEX )
           {
             tgtP = BRep_Tool::Pnt( TopoDS::Vertex( tgtShape ));
@@ -480,7 +480,7 @@ namespace {
 
     for ( TopExp_Explorer srcEdge( srcFace, TopAbs_EDGE); srcEdge.More(); srcEdge.Next() )
     {
-      const TopoDS_Shape& tgtEdge = shape2ShapeMap( srcEdge.Current() );
+      const TopoDS_Shape& tgtEdge = shape2ShapeMap( srcEdge.Current(), /*isSrc=*/true );
 
       map< double, const SMDS_MeshNode* > srcNodes, tgtNodes;
       if ( !SMESH_Algo::GetSortedNodesOnEdge( srcMesh->GetMeshDS(),
@@ -611,7 +611,7 @@ namespace {
       TopTools_IndexedMapOfShape edgeMap; // to detect seam edges
       for ( int iE = 0; iE < srcWire->NbEdges(); ++iE )
       {
-        tgtEdges.push_back( TopoDS::Edge( shape2ShapeMap( srcWire->Edge( iE ))));
+        tgtEdges.push_back( TopoDS::Edge( shape2ShapeMap( srcWire->Edge( iE ), /*isSrc=*/true)));
         // reverse a seam edge encountered for the second time
         const int oldExtent = edgeMap.Extent();
         edgeMap.Add( tgtEdges.back() );
@@ -734,14 +734,14 @@ namespace {
           }
           case SMDS_TOP_EDGE: {
             TopoDS_Shape srcEdge = srcHelper.GetSubShapeByNode( srcNode, srcHelper.GetMeshDS() );
-            TopoDS_Shape tgtEdge = shape2ShapeMap( srcEdge );
+            TopoDS_Shape tgtEdge = shape2ShapeMap( srcEdge, /*isSrc=*/true );
             double U = srcHelper.GetNodeU( TopoDS::Edge( srcEdge ), srcNode );
             tgtMeshDS->SetNodeOnEdge( n, TopoDS::Edge( tgtEdge ), U);
             break;
           }
           case SMDS_TOP_VERTEX: {
             TopoDS_Shape srcV = srcHelper.GetSubShapeByNode( srcNode, srcHelper.GetMeshDS() );
-            TopoDS_Shape tgtV = shape2ShapeMap( srcV );
+            TopoDS_Shape tgtV = shape2ShapeMap( srcV, /*isSrc=*/true );
             tgtMeshDS->SetNodeOnVertex( n, TopoDS::Vertex( tgtV ));
             break;
           }
@@ -790,7 +790,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
   TopoDS_Shape srcShape = _sourceHypo->GetSourceFace().Oriented(TopAbs_FORWARD);
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap, tgtFace );
+  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
   if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcShape, srcMesh,
                                              shape2ShapeMap)  ||
        !shape2ShapeMap.IsBound( tgtFace ))
@@ -881,9 +881,9 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
     TopoDS_Vertex srcV1 = TopoDS::Vertex( mapper.GetSubShape( 1 ));
     if ( srcV1.IsNull() )
       RETURN_BAD_RESULT("Mesh is not bound to the face");
-    if ( !shape2ShapeMap.IsBound( srcV1 ))
+    if ( !shape2ShapeMap.IsBound( srcV1, /*isSrc=*/true ))
       RETURN_BAD_RESULT("Not associated vertices, srcV1 " << srcV1.TShape().operator->() );
-    TopoDS_Vertex tgtV1 = TopoDS::Vertex( shape2ShapeMap( srcV1 ));
+    TopoDS_Vertex tgtV1 = TopoDS::Vertex( shape2ShapeMap( srcV1, /*isSrc=*/true ));
 
     if ( !SMESH_MesherHelper::IsSubShape( srcV1, srcFace ))
       RETURN_BAD_RESULT("Wrong srcV1 " << srcV1.TShape().operator->());
@@ -1087,7 +1087,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
   // Check elements orientation
   // ---------------------------
 
-  TopoDS_Face face = tgtFace;
+  TopoDS_Face face = TopoDS::Face( theShape );
   if ( !theMesh.IsMainShape( tgtFace ))
   {
     // find the main shape
@@ -1157,7 +1157,7 @@ bool StdMeshers_Projection_2D::Evaluate(SMESH_Mesh&         theMesh,
   TopoDS_Shape srcShape = _sourceHypo->GetSourceFace().Oriented(TopAbs_FORWARD);
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap, tgtFace );
+  TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
   if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcShape, srcMesh,
                                              shape2ShapeMap)  ||
        !shape2ShapeMap.IsBound( tgtFace ))
index 28b82a5311b0fe0fc8c15b040b8d19f9cca58405..6ae4ac7873760e900178b83489e59f021251ef4c 100644 (file)
@@ -176,8 +176,8 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a
   // ----------------------------------
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
-                                             innerShell, &aMesh,
+  if ( !TAssocTool::FindSubShapeAssociation( innerShell, &aMesh,
+                                             outerShell, &aMesh,
                                              shape2ShapeMap) )
     return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
 
@@ -193,11 +193,11 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a
     // Corresponding sub-shapes
     TopoDS_Face outFace = TopoDS::Face( exp.Current() );
     TopoDS_Face inFace;
-    if ( !shape2ShapeMap.IsBound( outFace )) {
+    if ( !shape2ShapeMap.IsBound( outFace, /*isOut=*/true )) {
       return error(SMESH_Comment("Corresponding inner face not found for face #" )
                    << meshDS->ShapeToIndex( outFace ));
     } else {
-      inFace = TopoDS::Face( shape2ShapeMap( outFace ));
+      inFace = TopoDS::Face( shape2ShapeMap( outFace, /*isOut=*/true ));
     }
 
     // Find matching nodes of in and out faces