Salome HOME
0022686: [CEA 1268] Explode a shape into edges sorted in a row from a starting point
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IMeasureOperations.cxx
index bc7111cb27d006521c9a71ee61b97dc727e89b92..0cf9dd339f55ad7e1832c97600e10b5826e43e0c 100644 (file)
@@ -41,7 +41,6 @@
 #include <BOPCol_ListOfShape.hxx>
 #include <BOPDS_DS.hxx>
 #include <BOPDS_MapOfPassKey.hxx>
-#include <BRep_Builder.hxx>
 #include <BRepBndLib.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
@@ -65,7 +64,6 @@
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
-#include <TopoDS_Compound.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
@@ -123,7 +121,7 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape
   int geom_type = theShape->GetType();
 
   // check if it's advanced shape
-  if ( geom_type > ADVANCED_BASE ) {
+  if ( geom_type > USER_TYPE ) {
     SetErrorCode(OK);
     return SK_ADVANCED;
   }
@@ -744,9 +742,7 @@ void GEOMImpl_IMeasureOperations::GetPosition
   }
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
 
     gp_Ax3 anAx3 = GEOMUtils::GetPosition(aShape);
 
@@ -800,9 +796,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
 
   //Compute the CentreOfMass value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Measure driver failed to compute centre of mass");
       return NULL;
@@ -854,9 +848,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
 
   //Compute
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Vertex by index driver failed.");
       return NULL;
@@ -913,9 +905,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal
 
   //Compute the Normale value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Measure driver failed to compute normake of face");
       return NULL;
@@ -965,9 +955,7 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha
   //Compute the parameters
   GProp_GProps LProps, SProps;
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     BRepGProp::LinearProperties(aShape, LProps);
     theLength = LProps.Mass();
 
@@ -1021,9 +1009,7 @@ void GEOMImpl_IMeasureOperations::GetInertia
   GProp_GProps System;
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (aShape.ShapeType() == TopAbs_VERTEX ||
         aShape.ShapeType() == TopAbs_EDGE ||
         aShape.ShapeType() == TopAbs_WIRE) {
@@ -1089,9 +1075,7 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox
   Bnd_Box B;
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     BRepBuilderAPI_Copy aCopyTool (aShape);
     if (!aCopyTool.IsDone()) {
       SetErrorCode("GetBoundingBox Error: Bad shape detected");
@@ -1157,9 +1141,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetBoundingBox
 
   //Compute the BoundingBox value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Measure driver failed to compute a bounding box");
       return NULL;
@@ -1216,9 +1198,7 @@ void GEOMImpl_IMeasureOperations::GetTolerance
   FaceMax = EdgeMax = VertMax = -RealLast();
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) {
       TopoDS_Face Face = TopoDS::Face(ExF.Current());
       T = BRep_Tool::Tolerance(Face);
@@ -1279,9 +1259,7 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object)     theShape,
   //Compute the parameters
   bool isValid = false;
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     BRepCheck_Analyzer ana (aShape, theIsCheckGeom);
     if (ana.IsValid()) {
       isValid = true;
@@ -1543,8 +1521,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
   if (aShape.IsNull()) return isGood;
 
   // 0. Prepare data
-  BRep_Builder aBB;
-  TopoDS_Compound aCS;
   TopoDS_Shape aScopy;
   //
   GEOMAlgo_AlgoTools::CopyShape(aShape, aScopy);
@@ -1553,9 +1529,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
   TopTools_IndexedMapOfShape anIndices;
   TopExp::MapShapes(aScopy, anIndices);
 
-  aBB.MakeCompound(aCS);
-  aBB.Add(aCS, aScopy);
-
   BOPCol_ListOfShape aLCS;
   aLCS.Append(aScopy);
   //
@@ -1565,9 +1538,6 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
   // 1. Launch the checker
   aCSI.Perform();
   Standard_Integer iErr = aCSI.ErrorStatus();
-  if (iErr) {
-    return false; // Error
-  }
 
   isGood = true;
   //
@@ -1596,7 +1566,10 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
     isGood = false;
   }
 
-  SetErrorCode(OK);
+  if (!iErr) {
+    SetErrorCode(OK);
+  }
+
   return isGood;
 }
 
@@ -1680,9 +1653,7 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object)
   Astr = Astr + " Number of sub-shapes : \n";
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     int iType, nbTypes [TopAbs_SHAPE];
     for (iType = 0; iType < TopAbs_SHAPE; ++iType)
       nbTypes[iType] = 0;
@@ -1875,9 +1846,7 @@ GEOMImpl_IMeasureOperations::GetMinDistance (Handle(GEOM_Object) theShape1,
 
   //Compute the parameters
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
 
     gp_Pnt aPnt1, aPnt2;
 
@@ -1927,9 +1896,7 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object)
 
   // Compute the extremities
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
 
     // skl 30.06.2008
     // additional workaround for bugs 19899, 19908 and 19910 from Mantis
@@ -2003,9 +1970,7 @@ void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape
   }
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
     theX = aPnt.X();
     theY = aPnt.Y();
@@ -2055,9 +2020,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine
   }
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     TopoDS_Edge E1 = TopoDS::Edge(aLine1);
     TopoDS_Edge E2 = TopoDS::Edge(aLine2);
 
@@ -2133,9 +2096,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Objec
   }
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     TopoDS_Edge aE1 = TopoDS::Edge(aVec1);
     TopoDS_Edge aE2 = TopoDS::Edge(aVec2);
 
@@ -2195,9 +2156,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam
 
   //Compute curvature
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     GeomLProp_CLProps Prop = GeomLProp_CLProps
       (aCurve, aP, 2, Precision::Confusion());
     aRes = fabs(Prop.Curvature());
@@ -2249,9 +2208,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint
 
   //Compute curvature
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     GeomAPI_ProjectPointOnCurve PPCurve(aPoint, aCurve, aFP, aLP);
     if(PPCurve.NbPoints()>0) {
       GeomLProp_CLProps Prop = GeomLProp_CLProps
@@ -2292,9 +2249,7 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures
   if (aSurf.IsNull()) return aRes;
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     GeomLProp_SLProps Prop = GeomLProp_SLProps
       (aSurf, theUParam, theVParam, 2, Precision::Confusion());
     if(Prop.IsCurvatureDefined()) {