0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / ChFi2d / ChFi2d_AnaFilletAlgo.cxx
index a3448ac..f6cc1b4 100644 (file)
@@ -2,8 +2,8 @@
 //
 // 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 version 2.1 as published
+// 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.
@@ -80,8 +80,25 @@ static Standard_Boolean IsEqual(const gp_Pnt2d& p1, const gp_Pnt2d& p2)
 // An empty constructor.
 // Use the method Init() to initialize the class.
 ChFi2d_AnaFilletAlgo::ChFi2d_AnaFilletAlgo()
+: segment1(Standard_False),
+  x11(0.0),
+  y11(0.0),
+  x12(0.0),
+  y12(0.0),
+  xc1(0.0),
+  yc1(0.0),
+  radius1(0.0),
+  cw1(Standard_False),
+  segment2(Standard_False),
+  x21(0.0),
+  y21(0.0),
+  x22(0.0),
+  y22(0.0),
+  xc2(0.0),
+  yc2(0.0),
+  radius2(0.0),
+  cw2(Standard_False)
 {
-
 }
 
 // An constructor.
@@ -89,7 +106,26 @@ ChFi2d_AnaFilletAlgo::ChFi2d_AnaFilletAlgo()
 // - segment
 // - arc of circle.
 ChFi2d_AnaFilletAlgo::ChFi2d_AnaFilletAlgo(const TopoDS_Wire& theWire, 
-                                           const gp_Pln& thePlane)
+                                           const gp_Pln&      thePlane)
+: plane(thePlane),
+  segment1(Standard_False),
+  x11(0.0),
+  y11(0.0),
+  x12(0.0),
+  y12(0.0),
+  xc1(0.0),
+  yc1(0.0),
+  radius1(0.0),
+  cw1(Standard_False),
+  segment2(Standard_False),
+  x21(0.0),
+  y21(0.0),
+  x22(0.0),
+  y22(0.0),
+  xc2(0.0),
+  yc2(0.0),
+  radius2(0.0),
+  cw2(Standard_False)
 {
   Init(theWire, thePlane);
 }
@@ -101,6 +137,25 @@ ChFi2d_AnaFilletAlgo::ChFi2d_AnaFilletAlgo(const TopoDS_Wire& theWire,
 ChFi2d_AnaFilletAlgo::ChFi2d_AnaFilletAlgo(const TopoDS_Edge& theEdge1, 
                                            const TopoDS_Edge& theEdge2,
                                            const gp_Pln& thePlane)
+: plane(thePlane),
+  segment1(Standard_False),
+  x11(0.0),
+  y11(0.0),
+  x12(0.0),
+  y12(0.0),
+  xc1(0.0),
+  yc1(0.0),
+  radius1(0.0),
+  cw1(Standard_False),
+  segment2(Standard_False),
+  x21(0.0),
+  y21(0.0),
+  x22(0.0),
+  y22(0.0),
+  xc2(0.0),
+  yc2(0.0),
+  radius2(0.0),
+  cw2(Standard_False)
 {
   // Make a wire consisting of two edges.
   Init(theEdge1, theEdge2, thePlane);
@@ -398,47 +453,56 @@ Standard_Boolean ChFi2d_AnaFilletAlgo::Perform(const Standard_Real radius)
 
       // Limit the neighbours.
       // Left neighbour.
+      gp_Pnt p1, p2;
       shrinke1.Nullify();
+      if (e1.Orientation() == TopAbs_FORWARD)
+      {
+        p1 = AC1.Value(AC1.FirstParameter());
+        p2 = pstart;
+      }
+      else
+      {
+        p1 = pstart;
+        p2 = AC1.Value(AC1.LastParameter());
+      }
       if (segment1)
       {
         BRepBuilderAPI_MakeEdge mkSegment1;
-        if (e1.Orientation() == TopAbs_FORWARD)
-          mkSegment1.Init(AC1.Curve().Curve(), AC1.FirstParameter(), AC1.LastParameter() - start);
-        else
-          mkSegment1.Init(AC1.Curve().Curve(), AC1.FirstParameter() + start, AC1.LastParameter());
+        mkSegment1.Init(AC1.Curve().Curve(), p1, p2);
         if (mkSegment1.IsDone())
           shrinke1 = mkSegment1.Edge();
       }
       else
       {
         BRepBuilderAPI_MakeEdge mkCirc1;
-        if (e1.Orientation() == TopAbs_FORWARD)
-          mkCirc1.Init(AC1.Curve().Curve(), AC1.FirstParameter(), AC1.LastParameter() - start);
-        else
-          mkCirc1.Init(AC1.Curve().Curve(), AC1.FirstParameter() + start, AC1.LastParameter());
+        mkCirc1.Init(AC1.Curve().Curve(), p1, p2);
         if (mkCirc1.IsDone())
           shrinke1 = mkCirc1.Edge();
       }
-
+      
       // Right neighbour.
       shrinke2.Nullify();
+      if (e1.Orientation() == TopAbs_FORWARD)
+      {
+        p1 = pend;
+        p2 = AC2.Value(AC2.LastParameter());
+      }
+      else
+      {
+        p1 = AC2.Value(AC2.FirstParameter());
+        p2 = pend;
+      }
       if (segment2)
       {
         BRepBuilderAPI_MakeEdge mkSegment2;
-        if (e2.Orientation() == TopAbs_FORWARD)
-          mkSegment2.Init(AC2.Curve().Curve(), AC2.FirstParameter() + end, AC2.LastParameter());
-        else
-          mkSegment2.Init(AC2.Curve().Curve(), AC2.FirstParameter(), AC2.LastParameter() - end);
+        mkSegment2.Init(AC2.Curve().Curve(), p1, p2);
         if (mkSegment2.IsDone())
           shrinke2 = mkSegment2.Edge();
       }
       else
       {
         BRepBuilderAPI_MakeEdge mkCirc2;
-        if (e2.Orientation() == TopAbs_FORWARD)
-          mkCirc2.Init(AC2.Curve().Curve(), AC2.FirstParameter() + end, AC2.LastParameter());
-        else
-          mkCirc2.Init(AC2.Curve().Curve(), AC2.FirstParameter(), AC2.LastParameter() - end);
+        mkCirc2.Init(AC2.Curve().Curve(), p1, p2);
         if (mkCirc2.IsDone())
           shrinke2 = mkCirc2.Edge();
       }
@@ -694,12 +758,12 @@ Standard_Boolean ChFi2d_AnaFilletAlgo::ArcFilletSegment(const Standard_Real radi
 
   // Make a line parallel to segment and
   // passing near the "near" point.
-  gp_Vec2d d2(v2);
-  gp_Lin2d line(p22, -d2);
-  d2.Rotate(M_PI_2);
-  line.Translate(radius * d2);
+  gp_Vec2d aD2Vec(v2);
+  gp_Lin2d line(p22, -aD2Vec);
+  aD2Vec.Rotate(M_PI_2);
+  line.Translate(radius * aD2Vec);
   if (line.Distance(nearPoint) > radius)
-    line.Translate(-2.0 * radius * d2);
+    line.Translate(-2.0 * radius * aD2Vec);
 
   // Make a circle of radius of the arc +/- fillet radius.
   gp_Ax2d axes(pc1, gp::DX2d());