Salome HOME
Fix valgrind error: Mismatched free() / delete / delete []
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ClsfBox.cxx
index dbc3eec1cc92bb917a6e9da4aefc8ef2dc1162a7..7c6b9f5c6b5adcf888b1c82cee5979b52fc60f7b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  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
 //
 #include <GEOMAlgo_ClsfBox.hxx>
 
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Ax3.hxx>
+
 #include <GeomAbs_SurfaceType.hxx>
-#include <GEOMAlgo_SurfaceTools.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
 #include <TopAbs_ShapeEnum.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopExp.hxx>
+
 #include <TopoDS_Face.hxx>
 #include <TopoDS.hxx>
-#include <Geom_Surface.hxx>
+
 #include <BRep_Tool.hxx>
-#include <Geom_Plane.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Ax1.hxx>
-#include <Geom_Plane.hxx>
 
-IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <GEOMAlgo_SurfaceTools.hxx>
+
 IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
 
 //=======================================================================
@@ -128,17 +131,22 @@ IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
     }
     //
     if(aOr==TopAbs_REVERSED) {
-      gp_Ax1 aAx1;
+      gp_Ax3 aPos;
       gp_Pln aPln;
       gp_Pnt aP;
       gp_Dir aD;
       Handle(Geom_Plane) aSR;
       //
       aPln=myGAS[i-1].Plane();
-      aAx1=aPln.Axis();
-      aP=aAx1.Location();
-      aD=aAx1.Direction();
-      aD.Reverse();
+      aPos=aPln.Position();
+      aP=aPos.Location();
+      aD=aPos.Direction();
+
+      // Is aPos is not direct, aD is already a reversed direction.
+      if (aPos.Direct()) {
+        aD.Reverse();
+      }
+
       aSR=new Geom_Plane(aP, aD);
       myGAS[i-1].Load(aSR);
     }