Salome HOME
Fix valgrind error: Mismatched free() / delete / delete []
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_AlgoTools.cxx
index 3505101d41a07de78cc5de04f6a7adbeccedded6..b9fb15a9e0c146651dbd398d12eaa34f1f76f746 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  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
@@ -25,8 +25,6 @@
 
 #include <GEOMAlgo_AlgoTools.hxx>
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Dir2d.hxx>
@@ -93,15 +91,15 @@ static
                 Standard_Integer& iCnt);
 static
   void CopySource(const TopoDS_Shape& aS,
-                 TopTools_IndexedDataMapOfShapeShape& aMapSS,
-                 TopoDS_Shape& aSC);
+    TopTools_IndexedDataMapOfShapeShape& aMapSS,
+    TopoDS_Shape& aSC);
 
 //=======================================================================
 //function : CopyShape
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
-                                  TopoDS_Shape& aSC)
+       TopoDS_Shape& aSC)
 {
   TopTools_IndexedDataMapOfShapeShape aMapSS;
   //
@@ -112,8 +110,8 @@ void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
-                                  TopoDS_Shape& aSC,
-                                  TopTools_IndexedDataMapOfShapeShape& aMapSS)
+       TopoDS_Shape& aSC,
+       TopTools_IndexedDataMapOfShapeShape& aMapSS)
 {
   CopySource(aS, aMapSS, aSC);
 }
@@ -172,9 +170,9 @@ void CopySource(const TopoDS_Shape& aS,
 //purpose  : 
 //=======================================================================
 void GEOMAlgo_AlgoTools::FaceNormal (const TopoDS_Face& aF,
-                                    const Standard_Real U,
-                                    const Standard_Real V,
-                                    gp_Vec& aN)
+         const Standard_Real U,
+         const Standard_Real V,
+         gp_Vec& aN)
 {
   gp_Pnt aPnt ;
   gp_Vec aD1U, aD1V;
@@ -197,12 +195,7 @@ Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
   (const TopoDS_Edge& aEold,
    const TopoDS_Edge& aEnew,
    const TopoDS_Face& aF,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aCtx
-#else
-   const Handle(BOPInt_Context)& aCtx
-#endif
-   )
+   const Handle(IntTools_Context)& aCtx)
 {
   Standard_Boolean bIsClosed, bUClosed, bHasOld;
   Standard_Integer iRet, aNbPoints;
@@ -222,7 +215,6 @@ Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
     return iRet;
   }
   //
-#if OCC_VERSION_LARGE > 0x06070100
   // Try to copy PCurve from old edge to the new one.
   iRet = BOPTools_AlgoTools2D::AttachExistingPCurve(aEold, aEnew, aF, aCtx);
 
@@ -233,7 +225,6 @@ Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
     // The PCurve is attached successfully.
     return iRet;
   }
-#endif
   //
   BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aEnew, aF);
   aC2D=BRep_Tool::CurveOnSurface(aEnew, aF, aT1, aT2);
@@ -343,7 +334,7 @@ Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
 // purpose:
 //=======================================================================
 void GEOMAlgo_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType,
-                                      TopoDS_Shape& theC)
+           TopoDS_Shape& theC)
 {
   BRep_Builder aBB;
   //
@@ -412,9 +403,9 @@ Standard_Boolean GEOMAlgo_AlgoTools::IsUPeriodic(const  Handle(Geom_Surface) &aS
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
-                                                  const TopoDS_Face& aF,
-                                                  const Standard_Real aUMin,
-                                                  const Standard_Real aUMax)
+         const TopoDS_Face& aF,
+         const Standard_Real aUMin,
+         const Standard_Real aUMax)
 {
   Standard_Real aT1, aT2, aTx, aUx, aTol;
   gp_Pnt2d aP2D;
@@ -446,12 +437,7 @@ void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
 Standard_Boolean GEOMAlgo_AlgoTools::IsSplitToReverse
   (const TopoDS_Edge& aEF1,
    const TopoDS_Edge& aEF2,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aContext
-#else
-   const Handle(BOPInt_Context)& aContext
-#endif
-   )
+   const Handle(IntTools_Context)& aContext)
 {
   Standard_Boolean aFlag;
   Standard_Real aT1, aT2, aScPr, a, b;
@@ -496,12 +482,7 @@ Standard_Boolean GEOMAlgo_AlgoTools::ProjectPointOnShape
   (const gp_Pnt& aP1,
    const TopoDS_Shape& aS,
    gp_Pnt& aP2,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aCtx
-#else
-   const Handle(BOPInt_Context)& aCtx
-#endif
-   )
+   const Handle(IntTools_Context)& aCtx)
 {
   Standard_Boolean bIsDone = Standard_False;
   Standard_Real aT2;
@@ -559,7 +540,7 @@ Standard_Boolean GEOMAlgo_AlgoTools::ProjectPointOnShape
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
-                                    gp_Pnt& aP3D)
+         gp_Pnt& aP3D)
 {
   Standard_Real aTx, aT1, aT2;
   //
@@ -572,8 +553,8 @@ void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
-                                    const Standard_Real aT,
-                                    gp_Pnt& aP3D)
+         const Standard_Real aT,
+         gp_Pnt& aP3D)
 {
   Standard_Real aT1, aT2;
   Handle(Geom_Curve) aC3D;
@@ -586,9 +567,9 @@ void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
-                                    const Standard_Real aU,
-                                    const Standard_Real aV,
-                                    gp_Pnt& aP3D)
+         const Standard_Real aU,
+         const Standard_Real aV,
+         gp_Pnt& aP3D)
 {
   Handle(Geom_Surface) aS;
   //
@@ -600,7 +581,7 @@ void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
-                                    gp_Pnt& aP3D)
+         gp_Pnt& aP3D)
 {
   Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax;
   //
@@ -616,7 +597,7 @@ void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
 //purpose  :
 //=======================================================================
 void GEOMAlgo_AlgoTools::PointOnShape(const TopoDS_Shape& aS,
-                                     gp_Pnt& aP3D)
+          gp_Pnt& aP3D)
 {
   TopAbs_ShapeEnum aType;
   //
@@ -648,12 +629,7 @@ Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
    const TopTools_ListOfShape& aLE,
    const Standard_Real aTol,
    TopTools_ListOfShape& aLESD,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aCtx
-#else
-   const Handle(BOPInt_Context)& aCtx
-#endif
-   )
+   const Handle(IntTools_Context)& aCtx)
 {
   Standard_Boolean bIsDone;
   Standard_Real aTol2, aD2;
@@ -692,12 +668,7 @@ Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
   (const TopTools_ListOfShape& aLE,
    const Standard_Real aTol,
    TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aCtx
-#else
-   const Handle(BOPInt_Context)& aCtx
-#endif
-   )
+   const Handle(IntTools_Context)& aCtx)
 {
   Standard_Integer aNbE, aNbEProcessed, aNbESD, iErr;
   TopTools_ListOfShape aLESD;
@@ -713,7 +684,7 @@ Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
     return 0; // Nothing to do
   }
   //
-  while(1) {
+  for(;;) {
     aNbEProcessed=aMProcessed.Extent();
     if (aNbEProcessed==aNbE) {
       break;
@@ -765,12 +736,7 @@ Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
 Standard_Integer GEOMAlgo_AlgoTools::RefineSDShapes
   (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE,
    const Standard_Real aTol,
-#if OCC_VERSION_LARGE > 0x06070100
-   const Handle(IntTools_Context)& aCtx
-#else
-   const Handle(BOPInt_Context)& aCtx
-#endif
-   )
+   const Handle(IntTools_Context)& aCtx)
 {
   Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd;
   TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd;
@@ -922,8 +888,8 @@ void GetCount(const TopoDS_Shape& aS,
 //purpose  :
 //=======================================================================
 Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
-                                              gp_Pnt& theP,
-                                              gp_Pnt2d& theP2D)
+                                               gp_Pnt& theP,
+                                               gp_Pnt2d& theP2D)
 {
   Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
   Standard_Integer iErr, aIx, aNbDomains, i;
@@ -948,8 +914,8 @@ Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
   //
   Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
   Geom2dHatch_Hatcher aHatcher(aIntr,
-                              aTolHatch2D, aTolHatch3D,
-                              Standard_True, Standard_False);
+          aTolHatch2D, aTolHatch3D,
+          Standard_True, Standard_False);
   //
   iErr=0;
   aEpsT=1.e-12;
@@ -1004,30 +970,33 @@ Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
   }
   //
   // 4.
+  aVx=aVMin;
   aNbDomains=aHatcher.NbDomains(aIx);
-  for (i=1; i<=aNbDomains; ++i) {
-    const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
-    bHasFirstPoint=aDomain.HasFirstPoint();
-    if (!bHasFirstPoint) {
-      iErr=5;
-      return iErr;
-    }
-    //
-    aV1=aDomain.FirstPoint().Parameter();
-    //
-    bHasSecondPoint=aDomain.HasSecondPoint();
-    if (!bHasSecondPoint) {
-      iErr=6;
-      return iErr;
-    }
-    //
-    aV2=aDomain.SecondPoint().Parameter();
-    //
-    aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
-    //
-    break;
+  if (!aNbDomains) {
+    iErr=5;
+    return iErr;
+  }
+  //
+  i=1;
+  const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
+  bHasFirstPoint=aDomain.HasFirstPoint();
+  if (!bHasFirstPoint) {
+    iErr=5;
+    return iErr;
+  }
+  //
+  aV1=aDomain.FirstPoint().Parameter();
+  //
+  bHasSecondPoint=aDomain.HasSecondPoint();
+  if (!bHasSecondPoint) {
+    iErr=6;
+    return iErr;
   }
   //
+  aV2=aDomain.SecondPoint().Parameter();
+  //
+  aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
+  //
   aS->D0(aUx, aVx, aPx);
   //
   theP2D.SetCoord(aUx, aVx);