Salome HOME
Fix compilation error and some warnings
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IMeasureOperations.cxx
index 6cebe14bc5f862e7511d442db4d62130683f91f4..d6f255812028b4b13e2e8cd0e36ecfb8e00aa17a 100644 (file)
@@ -20,8 +20,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <GEOMImpl_IMeasureOperations.hxx>
 #include <GEOMImpl_IMeasure.hxx>
 #include <GEOMImpl_MeasureDriver.hxx>
 // OCCT Includes
 #include <Bnd_Box.hxx>
 #include <BOPAlgo_CheckerSI.hxx>
-#include <BOPCol_ListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
 #include <BOPDS_DS.hxx>
-#include <BOPDS_MapOfPassKey.hxx>
+#include <BOPDS_MapOfPair.hxx>
+#include <BOPDS_Pair.hxx>
 #include <BRepBndLib.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 #include <BRepExtrema_DistShapeShape.hxx>
 #include <BRepExtrema_ShapeProximity.hxx>
-#if OCC_VERSION_LARGE > 0x06090000
 #include <BRepExtrema_SelfIntersection.hxx>
 #include <BRepExtrema_MapOfIntegerPackedMapOfInteger.hxx>
-#endif
 #include <BRepGProp.hxx>
 #include <BRepTools.hxx>
 #include <BRep_Tool.hxx>
@@ -141,17 +138,19 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape
   GEOMAlgo_ShapeInfoFiller aSF;
   aSF.SetShape(aShape);
   aSF.Perform();
+
   Standard_Integer iErr = aSF.ErrorStatus();
+
   if (iErr) {
     SetErrorCode("Error in GEOMAlgo_ShapeInfoFiller");
     return SK_NO_SHAPE;
   }
   const GEOMAlgo_ShapeInfo& anInfo = aSF.Info();
 
-  // specific processing for some "advandced" objects
+  // specific processing for some "advanced" objects
   switch ( geom_type ) {
   case GEOM_MARKER:
-    // local coordinate systen
+    // local coordinate system
     // (+) geompy.kind.LCS  xc yc zc xx xy xz yx yy yz zx zy zz
 
     TopoDS_Face aFace = TopoDS::Face( aShape );
@@ -737,6 +736,7 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape
       theDoubles->Append(aP.Z());
     }
     break;
+  default:;
   }
 
   SetErrorCode(OK);
@@ -785,9 +785,8 @@ void GEOMImpl_IMeasureOperations::GetPosition
     aDirZ.Coord(Zx, Zy, Zz);
     aDirX.Coord(Xx, Xy, Xz);
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return;
   }
 
@@ -832,9 +831,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -884,9 +882,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -941,9 +938,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -965,6 +961,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal
  */
 //=============================================================================
 void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape,
+                                                      const Standard_Real theTolerance,
                                                       Standard_Real& theLength,
                                                       Standard_Real& theSurfArea,
                                                       Standard_Real& theVolume)
@@ -984,27 +981,26 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha
 
   //Compute the parameters
   GProp_GProps LProps, SProps;
-  Standard_Real anEps = 1.e-6;
+  Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6;
   try {
     OCC_CATCH_SIGNALS;
-    BRepGProp::LinearProperties(aShape, LProps);
+    BRepGProp::LinearProperties(aShape, LProps, Standard_True);
     theLength = LProps.Mass();
 
-    BRepGProp::SurfaceProperties(aShape, SProps, anEps);
+    BRepGProp::SurfaceProperties(aShape, SProps, anEps, Standard_True);
     theSurfArea = SProps.Mass();
 
     theVolume = 0.0;
     if (aShape.ShapeType() < TopAbs_SHELL) {
       for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) {
         GProp_GProps VProps;
-        BRepGProp::VolumeProperties(Exp.Current(), VProps, anEps);
+        BRepGProp::VolumeProperties(Exp.Current(), VProps, anEps, Standard_True);
         theVolume += VProps.Mass();
       }
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return;
   }
 
@@ -1044,12 +1040,12 @@ void GEOMImpl_IMeasureOperations::GetInertia
     if (aShape.ShapeType() == TopAbs_VERTEX ||
         aShape.ShapeType() == TopAbs_EDGE ||
         aShape.ShapeType() == TopAbs_WIRE) {
-      BRepGProp::LinearProperties(aShape, System);
+      BRepGProp::LinearProperties(aShape, System, Standard_True);
     } else if (aShape.ShapeType() == TopAbs_FACE ||
                aShape.ShapeType() == TopAbs_SHELL) {
-      BRepGProp::SurfaceProperties(aShape, System);
+      BRepGProp::SurfaceProperties(aShape, System, Standard_True);
     } else {
-      BRepGProp::VolumeProperties(aShape, System);
+      BRepGProp::VolumeProperties(aShape, System, Standard_True);
     }
     gp_Mat I = System.MatrixOfInertia();
 
@@ -1068,9 +1064,8 @@ void GEOMImpl_IMeasureOperations::GetInertia
     GProp_PrincipalProps Pr = System.PrincipalProperties();
     Pr.Moments(Ix,Iy,Iz);
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return;
   }
 
@@ -1129,9 +1124,8 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox
 
     B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return;
   }
 
@@ -1178,9 +1172,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetBoundingBox
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1255,9 +1248,8 @@ void GEOMImpl_IMeasureOperations::GetTolerance
         VertMin = T;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return;
   }
 
@@ -1298,9 +1290,8 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)     theShape,
       FillErrors(ana, aShape, theErrors);
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return false;
   }
 
@@ -1560,7 +1551,7 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
   TopTools_IndexedMapOfShape anIndices;
   TopExp::MapShapes(aScopy, anIndices);
 
-  BOPCol_ListOfShape aLCS;
+  TopTools_ListOfShape aLCS;
   aLCS.Append(aScopy);
   //
   BOPAlgo_CheckerSI aCSI; // checker of self-interferences
@@ -1569,22 +1560,22 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
 
   // 1. Launch the checker
   aCSI.Perform();
-  Standard_Integer iErr = aCSI.ErrorStatus();
+  Standard_Boolean iErr = aCSI.HasErrors();
 
   //
   Standard_Integer aNbS, n1, n2;
-  BOPDS_MapIteratorMapOfPassKey aItMPK;
+  BOPDS_MapIteratorOfMapOfPair aItMPK;
   //
   // 2. Take the shapes from DS
   const BOPDS_DS& aDS = aCSI.DS();
   aNbS=aDS.NbShapes();
   //
   // 3. Get the pairs of interfered shapes
-  const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
+  const BOPDS_MapOfPair& aMPK=aDS.Interferences();
   aItMPK.Initialize(aMPK);
   for (; aItMPK.More(); aItMPK.Next()) {
-    const BOPDS_PassKey& aPK=aItMPK.Value();
-    aPK.Ids(n1, n2);
+    const BOPDS_Pair& aPK=aItMPK.Value();
+    aPK.Indices(n1, n2);
     //
     if (n1 > aNbS || n2 > aNbS){
       return false; // Error
@@ -1610,7 +1601,7 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
 //=============================================================================
 bool GEOMImpl_IMeasureOperations::CheckSelfIntersectionsFast
                          (Handle(GEOM_Object) theShape,
-                         float theDeflection, double theTolerance,
+                          float theDeflection, double theTolerance,
                           Handle(TColStd_HSequenceOfInteger)& theIntersections)
 {
   SetErrorCode(KO);
@@ -1639,7 +1630,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersectionsFast
   TopTools_IndexedMapOfShape anIndices;
   TopExp::MapShapes(aScopy, anIndices);
 
-#if OCC_VERSION_LARGE > 0x06090000
   // Checker of fast interferences
   BRepExtrema_SelfIntersection aTool(aScopy, (theTolerance <= 0.) ? 0.0 : theTolerance);
 
@@ -1667,7 +1657,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersectionsFast
 
   if (aTool.IsDone())
     SetErrorCode(OK);
-#endif
 
   return theIntersections->IsEmpty();
 }
@@ -1759,7 +1748,7 @@ bool GEOMImpl_IMeasureOperations::FastIntersect (Handle(GEOM_Object) theShape1,
   TopExp::MapShapes(aScopy1, anIndices1);
   TopExp::MapShapes(aScopy2, anIndices2);
 
-  BOPCol_ListOfShape aLCS1, aLCS2;
+  TopTools_ListOfShape aLCS1, aLCS2;
   aLCS1.Append(aScopy1); aLCS2.Append(aScopy2);
   //
   BRepExtrema_ShapeProximity aBSP; // checker of fast interferences
@@ -1770,21 +1759,13 @@ bool GEOMImpl_IMeasureOperations::FastIntersect (Handle(GEOM_Object) theShape1,
   aBSP.Perform();
  
   // 2. Get sets of IDs of overlapped faces
-#if OCC_VERSION_LARGE > 0x06090000
   for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt1 (aBSP.OverlapSubShapes1()); anIt1.More(); anIt1.Next())
-#else
-  for (BRepExtrema_OverlappedSubShapes::Iterator anIt1 (aBSP.OverlapSubShapes1()); anIt1.More(); anIt1.Next())
-#endif
   {
     const TopoDS_Shape& aS1 = aBSP.GetSubShape1(anIt1.Key());
     theIntersections1->Append(anIndices1.FindIndex(aS1));
   }
   
-#if OCC_VERSION_LARGE > 0x06090000
   for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt2 (aBSP.OverlapSubShapes2()); anIt2.More(); anIt2.Next())
-#else
-  for (BRepExtrema_OverlappedSubShapes::Iterator anIt2 (aBSP.OverlapSubShapes2()); anIt2.More(); anIt2.Next())
-#endif
   {
     const TopoDS_Shape& aS2 = aBSP.GetSubShape2(anIt2.Key());
     theIntersections2->Append(anIndices2.FindIndex(aS2));
@@ -1901,7 +1882,7 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object)
           aListOfShape.Append(s);
           nbTypes[s.ShapeType()]++;
           if ((sp.ShapeType() == TopAbs_COMPOUND) || (sp.ShapeType() == TopAbs_COMPSOLID)) {
-           nbFlatType[s.ShapeType()]++;
+            nbFlatType[s.ShapeType()]++;
           }
         }
       }
@@ -1920,22 +1901,21 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object)
     if ((aShape.ShapeType() == TopAbs_COMPOUND) || (aShape.ShapeType() == TopAbs_COMPSOLID)){
       Astr = Astr + " --------------------- \n Flat content : \n";
       if (nbFlatType[TopAbs_VERTEX] > 0)
-       Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbFlatType[TopAbs_VERTEX]) + "\n";
+        Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbFlatType[TopAbs_VERTEX]) + "\n";
       if (nbFlatType[TopAbs_EDGE] > 0)
-       Astr = Astr + " EDGE : " + TCollection_AsciiString(nbFlatType[TopAbs_EDGE]) + "\n";
+        Astr = Astr + " EDGE : " + TCollection_AsciiString(nbFlatType[TopAbs_EDGE]) + "\n";
       if (nbFlatType[TopAbs_WIRE] > 0)
-       Astr = Astr + " WIRE : " + TCollection_AsciiString(nbFlatType[TopAbs_WIRE]) + "\n";
+        Astr = Astr + " WIRE : " + TCollection_AsciiString(nbFlatType[TopAbs_WIRE]) + "\n";
       if (nbFlatType[TopAbs_FACE] > 0)
-       Astr = Astr + " FACE : " + TCollection_AsciiString(nbFlatType[TopAbs_FACE]) + "\n";
+        Astr = Astr + " FACE : " + TCollection_AsciiString(nbFlatType[TopAbs_FACE]) + "\n";
       if (nbFlatType[TopAbs_SHELL] > 0)
-       Astr = Astr + " SHELL : " + TCollection_AsciiString(nbFlatType[TopAbs_SHELL]) + "\n";
+        Astr = Astr + " SHELL : " + TCollection_AsciiString(nbFlatType[TopAbs_SHELL]) + "\n";
       if (nbFlatType[TopAbs_SOLID] > 0)
-       Astr = Astr + " SOLID : " + TCollection_AsciiString(nbFlatType[TopAbs_SOLID]) + "\n";
+        Astr = Astr + " SOLID : " + TCollection_AsciiString(nbFlatType[TopAbs_SOLID]) + "\n";
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return Astr;
   }
 
@@ -2011,7 +1991,7 @@ GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object)        theShape
                    project.NbPoints() > 0 &&
                    project.LowerDistance() <= tolerance )
               {
-                Quantity_Parameter u, v;
+                Standard_Real u, v;
                 project.LowerDistanceParameters(u, v);
                 gp_Pnt2d uv( u, v );
                 BRepClass_FaceClassifier FC ( face, uv, tolerance );
@@ -2106,9 +2086,8 @@ GEOMImpl_IMeasureOperations::GetMinDistance (Handle(GEOM_Object) theShape1,
       return MinDist;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return MinDist;
   }
 
@@ -2182,9 +2161,8 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object)
       }
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return nbSolutions;
   }
 
@@ -2225,10 +2203,9 @@ void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape
 
     SetErrorCode(OK);
   }
-  catch (Standard_Failure)
+  catch (Standard_Failure& aFail)
   {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode( aFail->GetMessageString() );
+    SetErrorCode( aFail.GetMessageString() );
   }
 }
 
@@ -2298,10 +2275,9 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine
 
     SetErrorCode(OK);
   }
-  catch (Standard_Failure)
+  catch (Standard_Failure& aFail)
   {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+    SetErrorCode(aFail.GetMessageString());
   }
 
   return anAngle;
@@ -2363,10 +2339,9 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Objec
 
     SetErrorCode(OK);
   }
-  catch (Standard_Failure)
+  catch (Standard_Failure& aFail)
   {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+    SetErrorCode(aFail.GetMessageString());
   }
 
   return anAngle;
@@ -2409,9 +2384,8 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam
     aRes = fabs(Prop.Curvature());
     SetErrorCode(OK);
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return aRes;
   }
 
@@ -2464,9 +2438,8 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint
       SetErrorCode(OK);
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return aRes;
   }
 
@@ -2516,9 +2489,8 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures
       SetErrorCode(OK);
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return aRes;
   }