0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepLib / BRepLib_MakeEdge.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 0077ae7..e8b9985
@@ -1,39 +1,59 @@
-// File:       BRepLib_MakeEdge.cxx
-// Created:    Fri Jul 23 15:51:46 1993
-// Author:     Remi LEQUETTE
-//             <rle@nonox>
+// Created on: 1993-07-23
+// Created by: Joelle CHAUVET
+// Copyright (c) 1993-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:   Wed Oct 23 09:17:47 1996
-// Author:     Joelle CHAUVET
-//             <jct@sgi38>
 //             check ponctuallity (PRO4896)
 
-#include <BRepLib_MakeEdge.ixx>
-#include <BRepLib.hxx>
-#include <BRep_Tool.hxx>
+#include <Adaptor3d_CurveOnSurface.hxx>
 #include <BRep_Builder.hxx>
-#include <TopoDS.hxx>
-#include <Geom_Line.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepLib.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <ElCLib.hxx>
+#include <Extrema_ExtPC.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
 #include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
 #include <Geom_Ellipse.hxx>
-#include <Geom_Parabola.hxx>
 #include <Geom_Hyperbola.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Parabola.hxx>
+#include <Geom_Surface.hxx>
 #include <Geom_TrimmedCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
 #include <GeomAdaptor_Curve.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
 #include <GeomAdaptor_HSurface.hxx>
-#include <Adaptor3d_CurveOnSurface.hxx>
-#include <Extrema_ExtPC.hxx>
 #include <gp.hxx>
-#include <ElCLib.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Elips.hxx>
+#include <gp_Hypr.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Parab.hxx>
+#include <gp_Pnt.hxx>
 #include <Precision.hxx>
-
+#include <StdFail_NotDone.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
 
 //=======================================================================
 //function : Project
 //purpose  : project a vertex on a curve
 //=======================================================================
-
 static Standard_Boolean Project(const Handle(Geom_Curve)& C,
                                const TopoDS_Vertex& V,
                                Standard_Real& p)
@@ -138,7 +158,7 @@ static Standard_Boolean Project(const Handle(Geom2d_Curve)& C,
     
     if (index != 0) {
       Extrema_POnCurv POC = extrema.Point(index);
-      if (P.SquareDistance(POC.Value()) <= Precision::Confusion() * Precision::Confusion()) {
+      if (P.SquareDistance(POC.Value()) <= Precision::SquareConfusion()) {
        p = POC.Parameter();
        return Standard_True;
       }
@@ -763,7 +783,7 @@ void  BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
   Standard_Real cl = C->LastParameter();
   Standard_Real epsilon = Precision::PConfusion();
   Standard_Boolean periodic = C->IsPeriodic();
-
+  GeomAdaptor_Curve aCA(C);
 
   TopoDS_Vertex V1,V2;
   if (periodic) {
@@ -803,14 +823,15 @@ void  BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
   Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
   Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
   gp_Pnt P1,P2;
-  if (!p1inf) P1 = C->Value(p1);
-  if (!p2inf) P2 = C->Value(p2);
+  if (!p1inf) P1 = aCA.Value(p1);
+  if (!p2inf) P2 = aCA.Value(p2);
 
   Standard_Real preci = BRepLib::Precision();
   BRep_Builder B;
 
   // check for closed curve
   Standard_Boolean closed = Standard_False;
+  Standard_Boolean degenerated = Standard_False;
   if (!p1inf && !p2inf)
     closed = (P1.Distance(P2) <= preci);
 
@@ -826,13 +847,19 @@ void  BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
       V2 = V1;
     else {
       if (!V1.IsSame(V2)) {
-       myError = BRepLib_DifferentPointsOnClosedCurve;
-       return;
+        myError = BRepLib_DifferentPointsOnClosedCurve;
+        return;
       }
       else if (P1.Distance(BRep_Tool::Pnt(V1)) > 
-              Max(preci,BRep_Tool::Tolerance(V1))) {
-       myError = BRepLib_DifferentPointsOnClosedCurve;
-       return;
+        Max(preci,BRep_Tool::Tolerance(V1))) {
+        myError = BRepLib_DifferentPointsOnClosedCurve;
+        return;
+      }
+      else
+      {
+        gp_Pnt PM = aCA.Value((p1+p2)/2);
+        if (P1.Distance(PM) < preci)
+          degenerated = Standard_True;
       }
     }
   }
@@ -888,6 +915,7 @@ void  BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
     B.Add(E,V2);
   }
   B.Range(E,p1,p2);
+  B.Degenerated(E, degenerated);
 
   myError = BRepLib_EdgeDone;
   Done();