0032539: Modeling Algorithms - Parallelize BRepExtrema_DistShapeShape algorithm
[occt.git] / src / BRepExtrema / BRepExtrema_DistanceSS.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 74d439b..7cbd701
@@ -1,7 +1,18 @@
-// File:    BRepExtrema_DistanceSS.cxx
-// Created: Mon Apr 22 17:03:37 1996
-// Author:     Maria PUMBORIOS
-// Author:  Herve LOUESSARD 
+// Created on: 1996-04-22
+// Created by: Herve LOUESSARD 
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 // Modified: Sergey ZERCHANINOV
 
 //------------------------------------------------------------------------------
 static Standard_Boolean TRI_SOLUTION (const BRepExtrema_SeqOfSolution& SeqSol, const gp_Pnt& Pt)
 {
-  const Standard_Integer Nbsol = SeqSol.Length();
-  for (Standard_Integer i = 1; i <= Nbsol; i++)
+  for (BRepExtrema_SeqOfSolution::iterator anIt = SeqSol.begin(); anIt != SeqSol.end(); anIt++)
   {
-    const Standard_Real dst = SeqSol.Value(i).Point().Distance(Pt);
-    if (dst <= Precision::Confusion()) return Standard_False;
+    const Standard_Real dst = anIt->Point().Distance(Pt);
+    if (dst <= Precision::Confusion())
+    {
+      return Standard_False;
+    }
   }
   return Standard_True;
 }  
@@ -72,15 +85,16 @@ static void MIN_SOLUTION (const BRepExtrema_SeqOfSolution& SeqSol1,
                           BRepExtrema_SeqOfSolution& seqSol1,
                           BRepExtrema_SeqOfSolution& seqSol2)
 {
-  const Standard_Integer nbSol = SeqSol1.Length();
-  for (Standard_Integer i = 1; i <= nbSol; i++)
+  for (BRepExtrema_SeqOfSolution::iterator anIt1 = SeqSol1.begin(), anIt2 = SeqSol2.begin(); 
+       anIt1 != SeqSol1.end(); 
+       anIt1++, anIt2++)
   {
-    const Standard_Real dst1 = SeqSol1.Value(i).Dist();
+    const Standard_Real dst1 = anIt1->Dist();
     if (fabs(dst1 - DstRef) < Eps)
-       {         
-      seqSol1.Append(SeqSol1.Value(i));
-      seqSol2.Append(SeqSol2.Value(i));
-       }
+         {       
+      seqSol1.Append(*anIt1);
+      seqSol2.Append(*anIt2);
+         }
   }
 }
 
@@ -104,7 +118,7 @@ static void TRIM_INFINIT_EDGE(const TopoDS_Edge& S1, const TopoDS_Edge& S2, Topo
       Precision::IsInfinite(aLast2))
     return;
   
-  Standard_Real Umin, Umax;
+  Standard_Real Umin = 0., Umax = 0.;
   Standard_Boolean bUmin, bUmax;
   bUmin = bUmax = Standard_False;
 
@@ -243,7 +257,7 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
   const Standard_Boolean bRestrict = BRep_Tool::NaturalRestriction(aF);
 
   Standard_Real U1, V1, U2, V2;
-  Standard_Real Umin, Umax, Vmin, Vmax;
+  Standard_Real Umin = RealLast(), Umax = RealFirst(), Vmin = RealLast(), Vmax = RealFirst();
   Standard_Boolean bUmin, bUmax, bVmin, bVmax;
   bUmin = bUmax = bVmin = bVmax = Standard_False;
   Standard_Boolean bIsTrim = Standard_False;
@@ -529,6 +543,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& S1, const TopoDS_Shape&
           Perform( V1, F2, B1, B2 );
           break;
         }
+        default:
+          break;
       }
       break;
     }
@@ -569,6 +585,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& S1, const TopoDS_Shape&
           Perform( E1, F2, B1, B2 );
           break;
         }
+        default:
+          break;
       }
       break;
     }
@@ -601,9 +619,13 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& S1, const TopoDS_Shape&
           Perform( F1, F2, B1, B2 );
           break;
         }
+        default:
+          break;
       }
       break;
     }
+    default:
+      break;
   }
 }
 
@@ -826,7 +848,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Vertex&
       if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin-myDstRef) < myEps))
       {
         Standard_Real U,V;
-        gp_Pnt Pt,P1=BRep_Tool::Pnt(S2);
+        gp_Pnt Pt,P2=BRep_Tool::Pnt(S2);
         BRepClass_FaceClassifier classifier;
         const Standard_Real tol = BRep_Tool::Tolerance(S1);
  
@@ -846,8 +868,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Vertex&
                 if (myDstRef > Dstmin)
                   myDstRef=Dstmin;
                 myModif=Standard_True;
-                const BRepExtrema_SolutionElem Sol1(Dstmin,P1,BRepExtrema_IsInFace,S1,U,V);
-                const BRepExtrema_SolutionElem Sol2(Dstmin,Pt,BRepExtrema_IsVertex,S2);
+                const BRepExtrema_SolutionElem Sol1(Dstmin,Pt,BRepExtrema_IsInFace,S1,U,V);
+                const BRepExtrema_SolutionElem Sol2(Dstmin,P2,BRepExtrema_IsVertex,S2);
                 SeqSolShape1.Append(Sol1);
                 SeqSolShape2.Append(Sol2);               
               }
@@ -1035,13 +1057,13 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S
         TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(aPnt);
 
         BRepExtrema_ExtPF ExtPF(V1,S2);
-        const Standard_Integer NbExtrema = ExtPF.IsDone()? ExtPF.NbExt() : 0;
-        if ( NbExtrema > 0 )
+        const Standard_Integer NbExtremaPF = ExtPF.IsDone()? ExtPF.NbExt() : 0;
+        if (NbExtremaPF > 0 )
         {
           // Search minimum distance Dstmin
           Standard_Integer ii;
           Standard_Real Dstmin = ExtPF.SquareDistance(1);
-          for (ii = 2; ii <= NbExtrema; ii++)
+          for (ii = 2; ii <= NbExtremaPF; ii++)
           {
             const Standard_Real sDst = ExtPF.SquareDistance(ii);
             if (sDst<Dstmin)
@@ -1051,7 +1073,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S
 
           if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin-myDstRef) < myEps))
           {
-            for (ii = 1; ii <= NbExtrema; ii++)
+            for (ii = 1; ii <= NbExtremaPF; ii++)
             { 
               if (fabs(Dstmin-sqrt(ExtPF.SquareDistance(ii)))<myEps)
               { 
@@ -1180,13 +1202,13 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S
         TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(aPnt);
 
         BRepExtrema_ExtPF ExtPF(V1,S1);
-        const Standard_Integer NbExtrema = ExtPF.IsDone()? ExtPF.NbExt() : 0;
-        if ( NbExtrema > 0 )
+        const Standard_Integer NbExtremaPF = ExtPF.IsDone()? ExtPF.NbExt() : 0;
+        if (NbExtremaPF > 0 )
         {
           // Search minimum distance Dstmin
           Standard_Integer ii;
           Standard_Real Dstmin = ExtPF.SquareDistance(1);
-          for (ii = 2; ii <= NbExtrema; ii++)
+          for (ii = 2; ii <= NbExtremaPF; ii++)
           {
             const Standard_Real sDst = ExtPF.SquareDistance(ii);
             if (sDst<Dstmin)
@@ -1196,7 +1218,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S
 
           if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin-myDstRef) < myEps))
           {
-            for (ii = 1; ii <= NbExtrema; ii++)
+            for (ii = 1; ii <= NbExtremaPF; ii++)
             { 
               if (fabs(Dstmin-sqrt(ExtPF.SquareDistance(ii)))<myEps)
               {