1 // Created on: 1993-07-23
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified: Wed Oct 23 09:17:47 1996
18 // check ponctuallity (PRO4896)
20 #include <BRepLib_MakeEdge.ixx>
21 #include <BRepLib.hxx>
22 #include <BRep_Tool.hxx>
23 #include <BRep_Builder.hxx>
25 #include <Geom_Line.hxx>
26 #include <Geom_Circle.hxx>
27 #include <Geom_Ellipse.hxx>
28 #include <Geom_Parabola.hxx>
29 #include <Geom_Hyperbola.hxx>
30 #include <Geom_TrimmedCurve.hxx>
31 #include <Geom2d_TrimmedCurve.hxx>
32 #include <GeomAdaptor_Curve.hxx>
33 #include <Geom2dAdaptor_HCurve.hxx>
34 #include <GeomAdaptor_HSurface.hxx>
35 #include <Adaptor3d_CurveOnSurface.hxx>
36 #include <Extrema_ExtPC.hxx>
39 #include <Precision.hxx>
42 //=======================================================================
44 //purpose : project a vertex on a curve
45 //=======================================================================
47 static Standard_Boolean Project(const Handle(Geom_Curve)& C,
48 const TopoDS_Vertex& V,
51 Standard_Real Eps2 = BRep_Tool::Tolerance(V);
54 gp_Pnt P = BRep_Tool::Pnt(V);
55 GeomAdaptor_Curve GAC(C);
57 // Afin de faire les extremas, on verifie les distances en bout
60 P1 = GAC.Value(GAC.FirstParameter());
61 P2 = GAC.Value(GAC.LastParameter());
62 D1 = P1.SquareDistance(P);
63 D2 = P2.SquareDistance(P);
64 if ( (D1 < D2) && (D1 <= Eps2) ) {
65 p = GAC.FirstParameter();
68 else if ( (D2 < D1) && (D2 <= Eps2) ) {
69 p = GAC.LastParameter();
73 // Sinon, on calcule les extremas.
75 Extrema_ExtPC extrema(P,GAC);
76 if (extrema.IsDone()) {
77 Standard_Integer i, index = 0, n = extrema.NbExt();
78 Standard_Real Dist2 = RealLast(), dist2min;
80 for (i = 1; i <= n; i++) {
81 dist2min = extrema.SquareDistance(i);
82 if (dist2min < Dist2) {
90 p = (extrema.Point(index)).Parameter();
95 return Standard_False;
99 //=======================================================================
101 //purpose : project a vertex on a curve on surface
102 //=======================================================================
104 static Standard_Boolean Project(const Handle(Geom2d_Curve)& C,
105 const Handle(Geom_Surface)& S,
106 const TopoDS_Vertex& V,
109 gp_Pnt P = BRep_Tool::Pnt(V);
110 Standard_Real Eps2 = BRep_Tool::Tolerance(V);
113 Handle(Geom2dAdaptor_HCurve) HG2AHC = new Geom2dAdaptor_HCurve();
115 Handle(GeomAdaptor_HSurface) HGAHS = new GeomAdaptor_HSurface();
117 Adaptor3d_CurveOnSurface ACOS(HG2AHC,HGAHS);
121 P1 = ACOS.Value(ACOS.FirstParameter());
122 P2 = ACOS.Value(ACOS.LastParameter());
123 D1 = P1.SquareDistance(P);
124 D2 = P2.SquareDistance(P);
125 if ( (D1 < D2) && (D1 <= Eps2) ) {
126 p = ACOS.FirstParameter();
127 return Standard_True;
129 else if ( (D2 < D1) && (D2 <= Eps2) ) {
130 p = ACOS.LastParameter();
131 return Standard_True;
135 Extrema_ExtPC extrema(P,ACOS);
137 if (extrema.IsDone()) {
138 Standard_Integer i, index = 0, n = extrema.NbExt();
139 Standard_Real Dist2 = RealLast(), dist2min;
141 for (i = 1; i <= n; i++) {
142 dist2min = extrema.SquareDistance(i);
143 if (dist2min < Dist2) {
150 Extrema_POnCurv POC = extrema.Point(index);
151 if (P.SquareDistance(POC.Value()) <= Precision::SquareConfusion()) {
153 return Standard_True;
157 return Standard_False;
160 //=======================================================================
161 //function : BRepLib_MakeEdge
163 //=======================================================================
165 BRepLib_MakeEdge::BRepLib_MakeEdge()
168 //=======================================================================
169 //function : BRepLib_MakeEdge
171 //=======================================================================
173 BRepLib_MakeEdge::BRepLib_MakeEdge(const TopoDS_Vertex& V1,
174 const TopoDS_Vertex& V2)
176 gp_Pnt P1 = BRep_Tool::Pnt(V1);
177 gp_Pnt P2 = BRep_Tool::Pnt(V2);
178 Standard_Real l = P1.Distance(P2);
179 if (l <= gp::Resolution()) {
180 myError = BRepLib_LineThroughIdenticPoints;
183 gp_Lin L(P1,gp_Vec(P1,P2));
184 Handle(Geom_Line) GL = new Geom_Line(L);
189 //=======================================================================
190 //function : BRepLib_MakeEdge
192 //=======================================================================
194 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Pnt& P1,
197 Standard_Real l = P1.Distance(P2);
198 if (l <= gp::Resolution()) {
199 myError = BRepLib_LineThroughIdenticPoints;
202 gp_Lin L(P1,gp_Vec(P1,P2));
203 Handle(Geom_Line) GL = new Geom_Line(L);
208 //=======================================================================
209 //function : BRepLib_MakeEdge
211 //=======================================================================
213 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L)
215 Handle(Geom_Line) GL = new Geom_Line(L);
220 //=======================================================================
221 //function : BRepLib_MakeEdge
223 //=======================================================================
225 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
226 const Standard_Real p1,
227 const Standard_Real p2)
229 Handle(Geom_Line) GL = new Geom_Line(L);
234 //=======================================================================
235 //function : BRepLib_MakeEdge
237 //=======================================================================
239 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
243 Handle(Geom_Line) GL = new Geom_Line(L);
248 //=======================================================================
249 //function : BRepLib_MakeEdge
251 //=======================================================================
253 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
254 const TopoDS_Vertex& V1,
255 const TopoDS_Vertex& V2)
257 Handle(Geom_Line) GL = new Geom_Line(L);
262 //=======================================================================
263 //function : BRepLib_MakeEdge
265 //=======================================================================
267 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C)
269 Handle(Geom_Circle) GC = new Geom_Circle(C);
274 //=======================================================================
275 //function : BRepLib_MakeEdge
277 //=======================================================================
279 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
280 const Standard_Real p1,
281 const Standard_Real p2)
283 Handle(Geom_Circle) GC = new Geom_Circle(C);
288 //=======================================================================
289 //function : BRepLib_MakeEdge
291 //=======================================================================
293 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
297 Handle(Geom_Circle) GC = new Geom_Circle(C);
302 //=======================================================================
303 //function : BRepLib_MakeEdge
305 //=======================================================================
307 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
308 const TopoDS_Vertex& V1,
309 const TopoDS_Vertex& V2)
311 Handle(Geom_Circle) GC = new Geom_Circle(C);
316 //=======================================================================
317 //function : BRepLib_MakeEdge
319 //=======================================================================
321 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E)
323 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
328 //=======================================================================
329 //function : BRepLib_MakeEdge
331 //=======================================================================
333 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
334 const Standard_Real p1,
335 const Standard_Real p2)
337 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
342 //=======================================================================
343 //function : BRepLib_MakeEdge
345 //=======================================================================
347 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
351 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
356 //=======================================================================
357 //function : BRepLib_MakeEdge
359 //=======================================================================
361 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
362 const TopoDS_Vertex& V1,
363 const TopoDS_Vertex& V2)
365 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
370 //=======================================================================
371 //function : BRepLib_MakeEdge
373 //=======================================================================
375 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H)
377 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
382 //=======================================================================
383 //function : BRepLib_MakeEdge
385 //=======================================================================
387 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
388 const Standard_Real p1,
389 const Standard_Real p2)
391 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
396 //=======================================================================
397 //function : BRepLib_MakeEdge
399 //=======================================================================
401 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
405 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
410 //=======================================================================
411 //function : BRepLib_MakeEdge
413 //=======================================================================
415 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
416 const TopoDS_Vertex& V1,
417 const TopoDS_Vertex& V2)
419 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
424 //=======================================================================
425 //function : BRepLib_MakeEdge
427 //=======================================================================
429 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P)
431 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
436 //=======================================================================
437 //function : BRepLib_MakeEdge
439 //=======================================================================
441 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
442 const Standard_Real p1,
443 const Standard_Real p2)
445 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
450 //=======================================================================
451 //function : BRepLib_MakeEdge
453 //=======================================================================
455 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
459 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
464 //=======================================================================
465 //function : BRepLib_MakeEdge
467 //=======================================================================
469 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
470 const TopoDS_Vertex& V1,
471 const TopoDS_Vertex& V2)
473 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
478 //=======================================================================
479 //function : BRepLib_MakeEdge
481 //=======================================================================
483 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L)
489 //=======================================================================
490 //function : BRepLib_MakeEdge
492 //=======================================================================
494 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
495 const Standard_Real p1,
496 const Standard_Real p2)
502 //=======================================================================
503 //function : BRepLib_MakeEdge
505 //=======================================================================
507 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
514 //=======================================================================
515 //function : BRepLib_MakeEdge
517 //=======================================================================
519 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
520 const TopoDS_Vertex& V1,
521 const TopoDS_Vertex& V2)
527 //=======================================================================
528 //function : BRepLib_MakeEdge
530 //=======================================================================
532 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
535 const Standard_Real p1,
536 const Standard_Real p2)
542 //=======================================================================
543 //function : BRepLib_MakeEdge
545 //=======================================================================
547 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
548 const TopoDS_Vertex& V1,
549 const TopoDS_Vertex& V2,
550 const Standard_Real p1,
551 const Standard_Real p2)
558 //=======================================================================
559 //function : BRepLib_MakeEdge
561 //=======================================================================
563 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
564 const Handle(Geom_Surface)& S)
570 //=======================================================================
571 //function : BRepLib_MakeEdge
573 //=======================================================================
575 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
576 const Handle(Geom_Surface)& S,
577 const Standard_Real p1,
578 const Standard_Real p2)
584 //=======================================================================
585 //function : BRepLib_MakeEdge
587 //=======================================================================
589 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
590 const Handle(Geom_Surface)& S,
597 //=======================================================================
598 //function : BRepLib_MakeEdge
600 //=======================================================================
602 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
603 const Handle(Geom_Surface)& S,
604 const TopoDS_Vertex& V1,
605 const TopoDS_Vertex& V2)
611 //=======================================================================
612 //function : BRepLib_MakeEdge
614 //=======================================================================
616 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
617 const Handle(Geom_Surface)& S,
620 const Standard_Real p1,
621 const Standard_Real p2)
623 Init(L,S,P1,P2,p1,p2);
627 //=======================================================================
628 //function : BRepLib_MakeEdge
630 //=======================================================================
632 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
633 const Handle(Geom_Surface)& S,
634 const TopoDS_Vertex& V1,
635 const TopoDS_Vertex& V2,
636 const Standard_Real p1,
637 const Standard_Real p2)
639 Init(L,S,V1,V2,p1,p2);
643 //=======================================================================
646 //=======================================================================
648 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C)
650 Init(C,C->FirstParameter(),C->LastParameter());
654 //=======================================================================
657 //=======================================================================
659 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
660 const Standard_Real p1,
661 const Standard_Real p2)
670 //=======================================================================
673 //=======================================================================
675 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
679 Standard_Real Tol = BRepLib::Precision();
683 B.MakeVertex(V1,P1,Tol);
684 if (P1.Distance(P2) < Tol)
687 B.MakeVertex(V2,P2,Tol);
693 //=======================================================================
696 //=======================================================================
698 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
699 const TopoDS_Vertex& V1,
700 const TopoDS_Vertex& V2)
702 // try projecting the vertices on the curve
707 p1 = C->FirstParameter();
709 if (!Project(C,V1,p1)) {
710 myError = BRepLib_PointProjectionFailed;
714 p2 = C->LastParameter();
716 if (!Project(C,V2,p2)) {
717 myError = BRepLib_PointProjectionFailed;
725 //=======================================================================
728 //=======================================================================
730 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
733 const Standard_Real p1,
734 const Standard_Real p2)
736 Standard_Real Tol = BRepLib::Precision();
740 B.MakeVertex(V1,P1,Tol);
741 if (P1.Distance(P2) < Tol)
744 B.MakeVertex(V2,P2,Tol);
750 //=======================================================================
752 //purpose : this one really makes the job ...
753 //=======================================================================
755 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
756 const TopoDS_Vertex& VV1,
757 const TopoDS_Vertex& VV2,
758 const Standard_Real pp1,
759 const Standard_Real pp2)
761 // kill trimmed curves
762 Handle(Geom_Curve) C = CC;
763 Handle(Geom_TrimmedCurve) CT = Handle(Geom_TrimmedCurve)::DownCast(C);
764 while (!CT.IsNull()) {
765 C = CT->BasisCurve();
766 CT = Handle(Geom_TrimmedCurve)::DownCast(C);
770 Standard_Real p1 = pp1;
771 Standard_Real p2 = pp2;
772 Standard_Real cf = C->FirstParameter();
773 Standard_Real cl = C->LastParameter();
774 Standard_Real epsilon = Precision::PConfusion();
775 Standard_Boolean periodic = C->IsPeriodic();
776 GeomAdaptor_Curve aCA(C);
781 ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2);
794 Standard_Real x = p1;
800 if ((cf - p1 > epsilon) || (p2 - cl > epsilon)) {
801 myError = BRepLib_ParameterOutOfRange;
805 // check ponctuallity
806 if ((p2-p1) <= gp::Resolution()) {
807 myError = BRepLib_LineThroughIdenticPoints;
812 // compute points on the curve
813 Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
814 Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
816 if (!p1inf) P1 = aCA.Value(p1);
817 if (!p2inf) P2 = aCA.Value(p2);
819 Standard_Real preci = BRepLib::Precision();
822 // check for closed curve
823 Standard_Boolean closed = Standard_False;
824 Standard_Boolean degenerated = Standard_False;
825 if (!p1inf && !p2inf)
826 closed = (P1.Distance(P2) <= preci);
828 // check if the vertices are on the curve
830 if (V1.IsNull() && V2.IsNull()) {
831 B.MakeVertex(V1,P1,preci);
834 else if (V1.IsNull())
836 else if (V2.IsNull())
839 if (!V1.IsSame(V2)) {
840 myError = BRepLib_DifferentPointsOnClosedCurve;
843 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
844 Max(preci,BRep_Tool::Tolerance(V1))) {
845 myError = BRepLib_DifferentPointsOnClosedCurve;
850 gp_Pnt PM = aCA.Value((p1+p2)/2);
851 if (P1.Distance(PM) < preci)
852 degenerated = Standard_True;
861 myError = BRepLib_PointWithInfiniteParameter;
867 B.MakeVertex(V1,P1,preci);
869 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
870 Max(preci,BRep_Tool::Tolerance(V1))) {
871 myError = BRepLib_DifferentsPointAndParameter;
878 myError = BRepLib_PointWithInfiniteParameter;
884 B.MakeVertex(V2,P2,preci);
886 else if (P2.Distance(BRep_Tool::Pnt(V2)) >
887 Max(preci,BRep_Tool::Tolerance(V2))){
888 myError = BRepLib_DifferentsPointAndParameter;
894 V1.Orientation(TopAbs_FORWARD);
895 V2.Orientation(TopAbs_REVERSED);
899 TopoDS_Edge& E = TopoDS::Edge(myShape);
900 B.MakeEdge(E,C,preci);
908 B.Degenerated(E, degenerated);
910 myError = BRepLib_EdgeDone;
914 //=======================================================================
917 //=======================================================================
919 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
920 const Handle(Geom_Surface)& S)
922 Init(C,S,C->FirstParameter(),C->LastParameter());
926 //=======================================================================
929 //=======================================================================
931 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
932 const Handle(Geom_Surface)& S,
933 const Standard_Real p1,
934 const Standard_Real p2)
939 Init(C,S,V1,V2,p1,p2);
943 //=======================================================================
946 //=======================================================================
948 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
949 const Handle(Geom_Surface)& S,
953 Standard_Real Tol = BRepLib::Precision();
957 B.MakeVertex(V1,P1,Tol);
958 if (P1.Distance(P2) < Tol)
961 B.MakeVertex(V2,P2,Tol);
967 //=======================================================================
970 //=======================================================================
972 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
973 const Handle(Geom_Surface)& S,
974 const TopoDS_Vertex& V1,
975 const TopoDS_Vertex& V2)
977 // try projecting the vertices on the curve
982 p1 = C->FirstParameter();
984 if (!Project(C,S,V1,p1)) {
985 myError = BRepLib_PointProjectionFailed;
989 p2 = C->LastParameter();
991 if (!Project(C,S,V2,p2)) {
992 myError = BRepLib_PointProjectionFailed;
996 Init(C,S,V1,V2,p1,p2);
1000 //=======================================================================
1003 //=======================================================================
1005 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
1006 const Handle(Geom_Surface)& S,
1009 const Standard_Real p1,
1010 const Standard_Real p2)
1012 Standard_Real Tol = BRepLib::Precision();
1015 TopoDS_Vertex V1,V2;
1016 B.MakeVertex(V1,P1,Tol);
1017 if (P1.Distance(P2) < Tol)
1020 B.MakeVertex( V2, P2, Tol);
1022 Init(C,S,V1,V2,p1,p2);
1026 //=======================================================================
1028 //purpose : this one really makes the job ...
1029 //=======================================================================
1031 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& CC,
1032 const Handle(Geom_Surface)& S,
1033 const TopoDS_Vertex& VV1,
1034 const TopoDS_Vertex& VV2,
1035 const Standard_Real pp1,
1036 const Standard_Real pp2)
1038 // kill trimmed curves
1039 Handle(Geom2d_Curve) C = CC;
1040 Handle(Geom2d_TrimmedCurve) CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
1041 while (!CT.IsNull()) {
1042 C = CT->BasisCurve();
1043 CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
1047 Standard_Real p1 = pp1;
1048 Standard_Real p2 = pp2;
1049 Standard_Real cf = C->FirstParameter();
1050 Standard_Real cl = C->LastParameter();
1051 Standard_Real epsilon = Precision::PConfusion();
1052 Standard_Boolean periodic = C->IsPeriodic();
1055 TopoDS_Vertex V1,V2;
1056 Standard_Boolean reverse = Standard_False;
1060 ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2);
1073 Standard_Real x = p1;
1076 reverse = Standard_True;
1080 if ((cf - p1 > epsilon) || (p2 - cl > epsilon)) {
1081 myError = BRepLib_ParameterOutOfRange;
1086 // compute points on the curve
1087 Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
1088 Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
1092 P2d1 = C->Value(p1);
1093 P1 = S->Value(P2d1.X(),P2d1.Y());
1096 P2d2 = C->Value(p2);
1097 P2 = S->Value(P2d2.X(),P2d2.Y());
1100 Standard_Real preci = BRepLib::Precision();
1103 // check for closed curve
1104 Standard_Boolean closed = Standard_False;
1105 if (!p1inf && !p2inf)
1106 closed = (P1.Distance(P2) <= preci);
1108 // check if the vertices are on the curve
1110 if (V1.IsNull() && V2.IsNull()) {
1111 B.MakeVertex(V1,P1,preci);
1114 else if (V1.IsNull())
1116 else if (V2.IsNull())
1119 if (!V1.IsSame(V2)) {
1120 myError = BRepLib_DifferentPointsOnClosedCurve;
1123 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
1124 Max(preci,BRep_Tool::Tolerance(V1))) {
1125 myError = BRepLib_DifferentPointsOnClosedCurve;
1131 else { // not closed
1135 myError = BRepLib_PointWithInfiniteParameter;
1141 B.MakeVertex(V1,P1,preci);
1143 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
1144 Max(preci,BRep_Tool::Tolerance(V1))) {
1145 myError = BRepLib_DifferentsPointAndParameter;
1152 myError = BRepLib_PointWithInfiniteParameter;
1158 B.MakeVertex(V2,P2,preci);
1160 else if (P2.Distance(BRep_Tool::Pnt(V2)) >
1161 Max(preci,BRep_Tool::Tolerance(V2))){
1162 myError = BRepLib_DifferentsPointAndParameter;
1168 V1.Orientation(TopAbs_FORWARD);
1169 V2.Orientation(TopAbs_REVERSED);
1173 TopoDS_Edge& E = TopoDS::Edge(myShape);
1175 B.UpdateEdge(E,C,S,TopLoc_Location(),preci);
1186 E.Orientation(TopAbs_REVERSED);
1188 myError = BRepLib_EdgeDone;
1192 //=======================================================================
1195 //=======================================================================
1197 BRepLib_EdgeError BRepLib_MakeEdge::Error() const
1202 //=======================================================================
1205 //=======================================================================
1207 const TopoDS_Edge& BRepLib_MakeEdge::Edge()const
1209 return TopoDS::Edge(Shape());
1213 //=======================================================================
1214 //function : Vertex1
1216 //=======================================================================
1218 const TopoDS_Vertex& BRepLib_MakeEdge::Vertex1()const
1225 //=======================================================================
1226 //function : Vertex2
1228 //=======================================================================
1230 const TopoDS_Vertex& BRepLib_MakeEdge::Vertex2()const
1238 //=======================================================================
1239 //function : operator
1241 //=======================================================================
1243 BRepLib_MakeEdge::operator TopoDS_Edge() const