0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / ChFi2d / ChFi2d_Builder.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 05d3088..e0e4e31
-// File:       ChFi2d_Builder.cxx
-// Created:    Fri Jul  7 16:39:57 1995
-// Author:     Philippe DERVIEUX
-//             <phd@tlefon>
-// Modified:   Tue Oct 15 10:12:02 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              correction in BuildFilletEdge (PRO3529 : computation of dist)
-// Modified:   Tue Oct 22 09:23:11 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              correction in BuildFilletEdge (PRO5827 : computation of vec1)
-// Modified:   Tue Oct 22 09:23:11 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              new status in ComputeFillet for degenerated edges (PRO4896)
-// Modified:   Thu Dec  5 16:25:44 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              correction in BuildFilletEdge (PRO4896 : NewExtr1, NewExtr2)
-// Modified:   Tue Apr 22 16:25:44 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              correction in BuildFilletEdge (ID140047 : inside)
-// Modified:   Fri Oct 24 10:47:52 1997
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              distinction point de tangence --> on arrete
-//                         point de rebroussement --> on continue
-//              (PRO10404 : Ve3, Ve4)
-// Modified:   Tue Oct 28 11:55:53 1997
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
-//              construction de filletEdge avec les parametres U1 et Vv1
-//              au lieu des vertex (PRO10434)
-// Modified:   Tue Apr  7 14:35:58 1998
-// Author:     Joelle CHAUVET
-//             <jct@sgi64>
-//              construction de filletEdge avec les parametres U1 et Vv1
-//              ET les vertex NewExtr1, NewExtr2 sinon pb sur qq aretes
-//              degenerees (GER60069 + controle de PRO10434)
-// Modified:   Mon Jun 22 13:32:25 1998
-// Author:     Joelle CHAUVET
-//             <jct@sgi64>
-//              verification de la validite des parametres (PRO13078 partiel)
-// Modified:   Fri Sep 25 09:38:04 1998
-// Author:     Joelle CHAUVET
-//             <jct@sgi64>
-//              status = ChFi2d_NotAuthorized si les aretes ne sont pas
-//              des droites ou des cercles; fonction IsLineOrCircle
-//              (BUC60288)
+// Created on: 1995-07-07
+// Created by: Joelle CHAUVET
+// Copyright (c) 1995-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.
 
 
-
-#include <ChFi2d.hxx>
-#include <ChFi2d_Builder.ixx>
-
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepLib.hxx>
 #include <BRepLib_MakeEdge.hxx>
 #include <BRepLib_MakeFace.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
-
+#include <ChFi2d.hxx>
+#include <ChFi2d_Builder.hxx>
 #include <ElCLib.hxx>
-
 #include <GccEnt_Position.hxx>
-
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-
-
-#include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2d_Circle.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_Line.hxx>
-
-#include <Geom2dInt_GInter.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2dGcc_Circ2d2TanRad.hxx>
 #include <Geom2dGcc_QualifiedCurve.hxx>
-
-#include <IntRes2d_IntersectionPoint.hxx>
-
+#include <Geom2dInt_GInter.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <gp_Circ2d.hxx>
 #include <gp_Pln.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
-#include <gp_Circ2d.hxx>
 #include <gp_Vec2d.hxx>
-
+#include <IntRes2d_IntersectionPoint.hxx>
 #include <Precision.hxx>
-
 #include <TopAbs_Orientation.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopLoc_Location.hxx>
-#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
 #include <TopoDS_Wire.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 
 static Standard_Boolean IsIssuedFrom(const TopoDS_Edge& E,
                                     const TopTools_IndexedMapOfShape& Map,
@@ -623,10 +575,6 @@ TopoDS_Edge ChFi2d_Builder::BuildNewEdge(const TopoDS_Edge& E1,
   TopoDS_Edge anEdge = makeEdge;
   anEdge.Orientation(E1.Orientation());
 //  anEdge.Location(E1.Location());
-#ifdef DEB
-  BRepLib_EdgeError error = 
-#endif
-    makeEdge.Error();
   return anEdge;
 }
 
@@ -768,10 +716,9 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
   //    The first arc is found.                                        +
   //========================================================================
 
-  TopAbs_Orientation O1,O2;
-  TopAbs_Orientation OE1,OE2;
+  TopAbs_Orientation O1;
+  TopAbs_Orientation OE1;
   OE1 = E1.Orientation();
-  OE2 = E2.Orientation();
   E1.Orientation(TopAbs_FORWARD);
   E2.Orientation(TopAbs_FORWARD);
   TopoDS_Shape aLocalShape = E1.EmptyCopied();
@@ -799,12 +746,10 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
   if (V3.IsSame(V)) {
     param3 = BRep_Tool::Parameter(V3,E2);
     param4 = BRep_Tool::Parameter(V4,E2);
-    O2 = V4.Orientation();
   }
   else {
     param3 = BRep_Tool::Parameter(V4,E2);
     param4 = BRep_Tool::Parameter(V3,E2);
-    O2 = V3.Orientation();
   }
   
   //========================================================================
@@ -975,13 +920,13 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
         inside = (PPU2<param3 && PPU2>param4) || (PPU2<param4 && PPU2>param3);
         //  case of arc of circle passing on the sewing
         if ( ( basisC2->DynamicType() == STANDARD_TYPE(Geom2d_Circle) ) && 
-            ( (2*PI<param3 && 2*PI>param4) || (2*PI<param4 && 2*PI>param3) ) ) {
+            ( (2*M_PI<param3 && 2*M_PI>param4) || (2*M_PI<param4 && 2*M_PI>param3) ) ) {
         //  cas param3<param4
-          inside = (param3<PPU2 && PPU2<2*PI) 
-                     || (0<=PPU2 && PPU2<param4-2*PI);
+          inside = (param3<PPU2 && PPU2<2*M_PI) 
+                     || (0<=PPU2 && PPU2<param4-2*M_PI);
         //  cas param4<param3
-          inside = inside || (param4<PPU2 && PPU2<2*PI) 
-                               || (0<=PPU2 && PPU2<param3-2*PI);
+          inside = inside || (param4<PPU2 && PPU2<2*M_PI) 
+                               || (0<=PPU2 && PPU2<param3-2*M_PI);
         }
        if ( inside && dist < dist1) {
          numsol = nsol;
@@ -1000,28 +945,34 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
     Fillet.Tangency2(numsol,Vv1,Vv2,Ptg2);
 
     // check the validity of parameters
-    inside = (U2<param1 && U2>param2) || (U2<param2 && U2>param1);
+    //// modified by jgv, 08.08.2011 for bug 0022695 ////
+    //inside = (U2<param1 && U2>param2) || (U2<param2 && U2>param1);
+    inside = (U2 < param1 && U2 >= param2) || (U2 <= param2 && U2 > param1);
+    /////////////////////////////////////////////////////
     if ( (basisC1->DynamicType() == STANDARD_TYPE(Geom2d_Circle))
-      &&  ( (2*PI<param1 && 2*PI>param2) || (2*PI<param2 && 2*PI>param1) ) ) {
+      &&  ( (2*M_PI<param1 && 2*M_PI>param2) || (2*M_PI<param2 && 2*M_PI>param1) ) ) {
       // arc of circle containing the circle origin
       //  case param1<param2
-      inside = (param1<U2 && U2<2*PI) || (0<=U2 && U2<param2-2*PI);
+      inside = (param1<U2 && U2<2*M_PI) || (0<=U2 && U2<param2-2*M_PI);
       //  case param2<param1
-      inside = inside || (param2<U2 && U2<2*PI) || (0<=U2 && U2<param1-2*PI);
+      inside = inside || (param2<U2 && U2<2*M_PI) || (0<=U2 && U2<param1-2*M_PI);
     }
     if (!inside) {
       status = ChFi2d_ComputationError;
       return filletEdge;
     }
 
-    inside = (Vv2<param3 && Vv2>param4) || (Vv2<param4 && Vv2>param3);
+    //// modified by jgv, 08.08.2011 for bug 0022695 ////
+    //inside = (Vv2<param3 && Vv2>param4) || (Vv2<param4 && Vv2>param3);
+    inside = (Vv2 < param3 && Vv2 >= param4) || (Vv2 <= param4 && Vv2 > param3);
+    /////////////////////////////////////////////////////
     if ( (basisC2->DynamicType() == STANDARD_TYPE(Geom2d_Circle))
-      &&  ( (2*PI<param3 && 2*PI>param4) || (2*PI<param4 && 2*PI>param3) ) ) {
+      &&  ( (2*M_PI<param3 && 2*M_PI>param4) || (2*M_PI<param4 && 2*M_PI>param3) ) ) {
     // arc of circle containing the circle origin
       //  cas param3<param4
-      inside = (param3<Vv2 && Vv2<2*PI) || (0<=Vv2 && Vv2<param4-2*PI);
+      inside = (param3<Vv2 && Vv2<2*M_PI) || (0<=Vv2 && Vv2<param4-2*M_PI);
       //  cas param4<param3
-      inside = inside || (param4<Vv2 && Vv2<2*PI) || (0<=Vv2 && Vv2<param3-2*PI);
+      inside = inside || (param4<Vv2 && Vv2<2*M_PI) || (0<=Vv2 && Vv2<param3-2*M_PI);
     }
     if (!inside) {
       status = ChFi2d_ComputationError;
@@ -1090,13 +1041,12 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
     if (OE1 == TopAbs_REVERSED) {
       vec1.Reverse();
     } // if (OE1 ...
-    Standard_Real cross = vec1*vec;
-    Standard_Boolean Sense = cross > 0.;
-    if (U1 > Vv1 && U1 > 2.*PI) {
-      ElCLib::AdjustPeriodic(0.,2.*PI,Precision::Confusion(),U1,Vv1);
+    Standard_Boolean Sense = ( vec1*vec ) > 0.;
+    if (U1 > Vv1 && U1 > 2.*M_PI) {
+      ElCLib::AdjustPeriodic(0.,2.*M_PI,Precision::Confusion(),U1,Vv1);
     } // if (U1 ... 
-    if (O1 == TopAbs_FORWARD && OE1 == TopAbs_FORWARD ||
-       O1 == TopAbs_REVERSED && OE1 == TopAbs_REVERSED ) {
+    if ( (O1 == TopAbs_FORWARD && OE1 == TopAbs_FORWARD) ||
+         (O1 == TopAbs_REVERSED && OE1 == TopAbs_REVERSED) ) {
       filletEdge = BRepLib_MakeEdge(circle, refSurf,
                                    NewExtr1, NewExtr2, U1, Vv1);
     } // if (O1 == ...
@@ -1106,8 +1056,8 @@ TopoDS_Edge ChFi2d_Builder::BuildFilletEdge(const TopoDS_Vertex& V,
     } // else ...
     if (!Sense) {
       TopAbs_Orientation S1 = filletEdge.Orientation();
-      if (O1 == TopAbs_FORWARD && OE1 == TopAbs_FORWARD ||
-         O1 == TopAbs_REVERSED && OE1 == TopAbs_REVERSED ) {
+      if ((O1 == TopAbs_FORWARD && OE1 == TopAbs_FORWARD) ||
+          (O1 == TopAbs_REVERSED && OE1 == TopAbs_REVERSED) ) {
        filletEdge = BRepLib_MakeEdge(circle, refSurf, 
                                      NewExtr2, NewExtr1, Vv1, U1);
       }