Salome HOME
Fix valgrind error: Mismatched free() / delete / delete []
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_GetInPlace_3.cxx
index 793cb306f39e50ded714e411b5f86a5cc718f452..9726a4f3b3ee72c791ca942452ae5f586c8acced 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// File:       GEOMAlgo_GetInPlaceIterator.cxx
+// File:        GEOMAlgo_GetInPlaceIterator.cxx
 // Created:
-// Author:     Peter KURNEV
+// Author:      Peter KURNEV
 
 #include <GEOMAlgo_GetInPlace.hxx>
 
-#include <NMTTools_CoupleOfShape.hxx>
+#include <GEOMAlgo_CoupleOfShapes.hxx>
 
 static
   Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
-                                const TopAbs_ShapeEnum aType2);
+                                 const TopAbs_ShapeEnum aType2);
 
 //=======================================================================
 //function :
@@ -62,7 +62,7 @@ void GEOMAlgo_GetInPlaceIterator::Clear()
 //function : AppendPair
 //purpose  :
 //=======================================================================
-void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS)
+void GEOMAlgo_GetInPlaceIterator::AppendPair(const GEOMAlgo_CoupleOfShapes& theCS)
 {
   Standard_Integer iX;
   TopAbs_ShapeEnum aType1, aType2;
@@ -75,6 +75,16 @@ void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS
   iX=TypeToInteger(aType1, aType2);
   if (iX>=0) {
     myLists[iX].Append(theCS);
+  } else {
+    // Add inverted pair of shapes.
+    iX=TypeToInteger(aType2, aType1);
+
+    if (iX>=0) {
+      GEOMAlgo_CoupleOfShapes aCSInv;
+
+      aCSInv.SetShapes(aS2, aS1);
+      myLists[iX].Append(aCSInv);
+    }
   }
 }
 //=======================================================================
@@ -82,7 +92,7 @@ void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS
 //purpose  :
 //=======================================================================
 void GEOMAlgo_GetInPlaceIterator::Initialize(const TopAbs_ShapeEnum aType1,
-                                            const TopAbs_ShapeEnum aType2)
+                                             const TopAbs_ShapeEnum aType2)
 {
   Standard_Integer iX;
   //
@@ -114,7 +124,7 @@ void GEOMAlgo_GetInPlaceIterator::Next()
 // function: Value
 // purpose:
 //=======================================================================
-const NMTTools_CoupleOfShape& GEOMAlgo_GetInPlaceIterator::Value()const
+const GEOMAlgo_CoupleOfShapes& GEOMAlgo_GetInPlaceIterator::Value()const
 {
   return myIterator.Value();
 }
@@ -123,7 +133,7 @@ const NMTTools_CoupleOfShape& GEOMAlgo_GetInPlaceIterator::Value()const
 //purpose  :
 //=======================================================================
 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
-                              const TopAbs_ShapeEnum aType2)
+                               const TopAbs_ShapeEnum aType2)
 {
   Standard_Integer iRet;
   //