0024213: bopargcheck complains on sphere
[occt.git] / src / BOPAlgo / BOPAlgo_ArgumentAnalyzer.cxx
index 87a55ca..fe1d2e2 100644 (file)
@@ -304,7 +304,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
   Standard_Boolean bSelfInt;
 
   for(ii = 0; ii < 2; ii++) {
-    TopoDS_Shape aS = (ii == 0) ? myShape1 : myShape2;
+    const TopoDS_Shape& aS = (ii == 0) ? myShape1 : myShape2;
 
     if(aS.IsNull())
       continue;
@@ -333,7 +333,6 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
     Standard_Integer aNb[6] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), 
                                aVFs.Extent(), aEFs.Extent(), aFFs.Extent()};
     //
-    Standard_Integer ind = 0;
     for (Standard_Integer aTypeInt = 0; aTypeInt < 6; ++aTypeInt) {
       for (Standard_Integer i = 0; i < aNb[aTypeInt]; ++i) {
         BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) : 
@@ -348,6 +347,13 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
           continue;
         }
         //
+        if (aTypeInt == 4) {
+          BOPDS_InterfEF& aEF=aEFs(i);
+          if (aEF.CommonPart().Type()==TopAbs_SHAPE) {
+            continue;
+          }
+        }
+        //
         const TopoDS_Shape& aS1 = theDS->Shape(nI1);
         const TopoDS_Shape& aS2 = theDS->Shape(nI2);
         //
@@ -425,7 +431,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
   aCtx = new BOPInt_Context;
   
   for(i = 0; i < 2; i++) {
-    TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2;
+    const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2;
 
     if(aS.IsNull())
       continue;
@@ -433,13 +439,16 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
     TopExp_Explorer anExp(aS, TopAbs_EDGE);
 
     for(; anExp.More(); anExp.Next()) {
-      TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());
+      const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&anExp.Current();
+      if (BRep_Tool::Degenerated(anEdge)) {
+        continue;
+      }
 
       if(BOPTools_AlgoTools::IsMicroEdge(anEdge, aCtx)) {
         Standard_Boolean bKeepResult = Standard_True;
         
         if(myOperation == BOPAlgo_SECTION) {
-          TopoDS_Shape anOtherS = (i == 0) ? myShape2 : myShape1;
+          const TopoDS_Shape& anOtherS = (i == 0) ? myShape2 : myShape1;
           
           if(!anOtherS.IsNull()) {
             aDist.LoadS2(anOtherS);
@@ -449,7 +458,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
             TopExp_Explorer anExpV(anEdge, TopAbs_VERTEX);
             
             for(; anExpV.More(); anExpV.Next()) {
-              TopoDS_Shape aV = anExpV.Current();
+              const TopoDS_Shape& aV = anExpV.Current();
               
               aDist.LoadS1(aV);
               aDist.Perform();
@@ -457,20 +466,20 @@ void BOPAlgo_ArgumentAnalyzer::TestSmallEdge()
               if(aDist.IsDone()) {
                 
                 for(ii = 1; ii <= aDist.NbSolution(); ii++) {
-                  Standard_Real aTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(aV));
-                  TopoDS_Shape aSupportShape = aDist.SupportOnShape2(ii);
+                  Standard_Real aTolerance = BRep_Tool::Tolerance(*(TopoDS_Vertex*)&aV);
+                  const TopoDS_Shape& aSupportShape = aDist.SupportOnShape2(ii);
                   
                   switch(aSupportShape.ShapeType()) {
                   case TopAbs_VERTEX: {
-                    aTolerance += BRep_Tool::Tolerance(TopoDS::Vertex(aSupportShape));
+                    aTolerance += BRep_Tool::Tolerance(*(TopoDS_Vertex*)&(aSupportShape));
                     break;
                   }
                   case TopAbs_EDGE: {
-                    aTolerance += BRep_Tool::Tolerance(TopoDS::Edge(aSupportShape));
+                    aTolerance += BRep_Tool::Tolerance(*(TopoDS_Edge*)&(aSupportShape));
                     break;
                   }
                   case TopAbs_FACE: {
-                    aTolerance += BRep_Tool::Tolerance(TopoDS::Face(aSupportShape));
+                    aTolerance += BRep_Tool::Tolerance(*(TopoDS_Face*)&(aSupportShape));
                     break;
                   }
                   default:
@@ -527,7 +536,7 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace()
   Standard_Integer i = 0;
 
   for(i = 0; i < 2; i++) {
-    TopoDS_Shape aS = (i == 0) ? myShape1 : myShape2;
+    const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2;
 
     if(aS.IsNull())
       continue;
@@ -536,7 +545,7 @@ void BOPAlgo_ArgumentAnalyzer::TestRebuildFace()
     BOPCol_ListOfShape aLS;
 
     for(; anExp.More(); anExp.Next()) {
-      TopoDS_Face aFace = TopoDS::Face(anExp.Current());
+      const TopoDS_Face& aFace = *(TopoDS_Face*)&(anExp.Current());
 
       TopoDS_Face aFF = aFace;
       aFF.Orientation(TopAbs_FORWARD);
@@ -649,7 +658,7 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
   BOPCol_MapOfShape aMap1, aMap2;
 
   for(; anExp1.More(); anExp1.Next()) {
-    TopoDS_Shape aS1 = anExp1.Current();
+    const TopoDS_Shape& aS1 = anExp1.Current();
 
     if(aMap1.Contains(aS1))
       continue;
@@ -658,7 +667,7 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
   }
 
   for(; anExp2.More(); anExp2.Next()) {
-    TopoDS_Shape aS2 = anExp2.Current();
+    const TopoDS_Shape& aS2 = anExp2.Current();
     if(aMap2.Contains(aS2))
       continue;
     aSeq2.Append(aS2);
@@ -672,18 +681,18 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
       anArrayOfFlag.SetValue(i, j, Standard_False);
 
   for(i = 1; i <= aSeq1.Length(); i++) {
-    TopoDS_Shape aS1 = aSeq1.Value(i);
+    const TopoDS_Shape& aS1 = aSeq1.Value(i);
     BOPCol_ListOfShape aListOfS2;
     Standard_Integer nbs = 0;
 
     for(j = 1; j <= aSeq2.Length(); j++) {
-      TopoDS_Shape aS2 = aSeq2.Value(j);
+      const TopoDS_Shape& aS2 = aSeq2.Value(j);
       Standard_Boolean bIsEqual = Standard_False;
 
       if(theType == TopAbs_VERTEX) {
 
-        TopoDS_Vertex aV1 = TopoDS::Vertex(aS1);
-        TopoDS_Vertex aV2 = TopoDS::Vertex(aS2);
+        const TopoDS_Vertex& aV1 = *(TopoDS_Vertex*)&(aS1);
+        const TopoDS_Vertex& aV2 = *(TopoDS_Vertex*)&(aS2);
         gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
         gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
         Standard_Real aDist = aP1.Distance(aP2);
@@ -695,8 +704,8 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
       else if(theType == TopAbs_EDGE) {
         Standard_Integer aDiscretize = 30;
         Standard_Real    aDeflection = 0.01;
-        TopoDS_Edge aE1 = TopoDS::Edge(aS1);
-        TopoDS_Edge aE2 = TopoDS::Edge(aS2);
+        const TopoDS_Edge& aE1 = *(TopoDS_Edge*)&(aS1);
+        const TopoDS_Edge& aE2 = *(TopoDS_Edge*)&(aS2);
         
         IntTools_EdgeEdge aEE;
         aEE.SetEdge1 (aE1);
@@ -761,12 +770,12 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
   }
 
   for(i = 1; i <= aSeq2.Length(); i++) {
-    TopoDS_Shape aS2 = aSeq2.Value(i);
+    const TopoDS_Shape& aS2 = aSeq2.Value(i);
     BOPCol_ListOfShape aListOfS1;
     Standard_Integer nbs = 0;
 
     for(j = 1; j <= aSeq1.Length(); j++) {
-      TopoDS_Shape aS1 = aSeq1.Value(j);
+      const TopoDS_Shape& aS1 = aSeq1.Value(j);
 
       if(anArrayOfFlag.Value(j, i)) {
         aListOfS1.Append(aS1);