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 <Adaptor3d_CurveOnSurface.hxx>
21 #include <BRep_Builder.hxx>
22 #include <BRep_Tool.hxx>
23 #include <BRepLib.hxx>
24 #include <BRepLib_MakeEdge.hxx>
26 #include <Extrema_ExtPC.hxx>
27 #include <Geom2d_Curve.hxx>
28 #include <Geom2d_TrimmedCurve.hxx>
29 #include <Geom2dAdaptor_HCurve.hxx>
30 #include <Geom_Circle.hxx>
31 #include <Geom_Curve.hxx>
32 #include <Geom_Ellipse.hxx>
33 #include <Geom_Hyperbola.hxx>
34 #include <Geom_Line.hxx>
35 #include <Geom_Parabola.hxx>
36 #include <Geom_Surface.hxx>
37 #include <Geom_TrimmedCurve.hxx>
38 #include <GeomAdaptor_Curve.hxx>
39 #include <GeomAdaptor_HSurface.hxx>
41 #include <gp_Circ.hxx>
42 #include <gp_Elips.hxx>
43 #include <gp_Hypr.hxx>
45 #include <gp_Parab.hxx>
47 #include <Precision.hxx>
48 #include <StdFail_NotDone.hxx>
50 #include <TopoDS_Edge.hxx>
51 #include <TopoDS_Vertex.hxx>
53 //=======================================================================
55 //purpose : project a vertex on a curve
56 //=======================================================================
57 static Standard_Boolean Project(const Handle(Geom_Curve)& C,
58 const TopoDS_Vertex& V,
61 Standard_Real Eps2 = BRep_Tool::Tolerance(V);
64 gp_Pnt P = BRep_Tool::Pnt(V);
65 GeomAdaptor_Curve GAC(C);
67 // Afin de faire les extremas, on verifie les distances en bout
70 P1 = GAC.Value(GAC.FirstParameter());
71 P2 = GAC.Value(GAC.LastParameter());
72 D1 = P1.SquareDistance(P);
73 D2 = P2.SquareDistance(P);
74 if ( (D1 < D2) && (D1 <= Eps2) ) {
75 p = GAC.FirstParameter();
78 else if ( (D2 < D1) && (D2 <= Eps2) ) {
79 p = GAC.LastParameter();
83 // Sinon, on calcule les extremas.
85 Extrema_ExtPC extrema(P,GAC);
86 if (extrema.IsDone()) {
87 Standard_Integer i, index = 0, n = extrema.NbExt();
88 Standard_Real Dist2 = RealLast(), dist2min;
90 for (i = 1; i <= n; i++) {
91 dist2min = extrema.SquareDistance(i);
92 if (dist2min < Dist2) {
100 p = (extrema.Point(index)).Parameter();
101 return Standard_True;
105 return Standard_False;
109 //=======================================================================
111 //purpose : project a vertex on a curve on surface
112 //=======================================================================
114 static Standard_Boolean Project(const Handle(Geom2d_Curve)& C,
115 const Handle(Geom_Surface)& S,
116 const TopoDS_Vertex& V,
119 gp_Pnt P = BRep_Tool::Pnt(V);
120 Standard_Real Eps2 = BRep_Tool::Tolerance(V);
123 Handle(Geom2dAdaptor_HCurve) HG2AHC = new Geom2dAdaptor_HCurve();
125 Handle(GeomAdaptor_HSurface) HGAHS = new GeomAdaptor_HSurface();
127 Adaptor3d_CurveOnSurface ACOS(HG2AHC,HGAHS);
131 P1 = ACOS.Value(ACOS.FirstParameter());
132 P2 = ACOS.Value(ACOS.LastParameter());
133 D1 = P1.SquareDistance(P);
134 D2 = P2.SquareDistance(P);
135 if ( (D1 < D2) && (D1 <= Eps2) ) {
136 p = ACOS.FirstParameter();
137 return Standard_True;
139 else if ( (D2 < D1) && (D2 <= Eps2) ) {
140 p = ACOS.LastParameter();
141 return Standard_True;
145 Extrema_ExtPC extrema(P,ACOS);
147 if (extrema.IsDone()) {
148 Standard_Integer i, index = 0, n = extrema.NbExt();
149 Standard_Real Dist2 = RealLast(), dist2min;
151 for (i = 1; i <= n; i++) {
152 dist2min = extrema.SquareDistance(i);
153 if (dist2min < Dist2) {
160 Extrema_POnCurv POC = extrema.Point(index);
161 if (P.SquareDistance(POC.Value()) <= Precision::SquareConfusion()) {
163 return Standard_True;
167 return Standard_False;
170 //=======================================================================
171 //function : BRepLib_MakeEdge
173 //=======================================================================
175 BRepLib_MakeEdge::BRepLib_MakeEdge()
178 //=======================================================================
179 //function : BRepLib_MakeEdge
181 //=======================================================================
183 BRepLib_MakeEdge::BRepLib_MakeEdge(const TopoDS_Vertex& V1,
184 const TopoDS_Vertex& V2)
186 gp_Pnt P1 = BRep_Tool::Pnt(V1);
187 gp_Pnt P2 = BRep_Tool::Pnt(V2);
188 Standard_Real l = P1.Distance(P2);
189 if (l <= gp::Resolution()) {
190 myError = BRepLib_LineThroughIdenticPoints;
193 gp_Lin L(P1,gp_Vec(P1,P2));
194 Handle(Geom_Line) GL = new Geom_Line(L);
199 //=======================================================================
200 //function : BRepLib_MakeEdge
202 //=======================================================================
204 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Pnt& P1,
207 Standard_Real l = P1.Distance(P2);
208 if (l <= gp::Resolution()) {
209 myError = BRepLib_LineThroughIdenticPoints;
212 gp_Lin L(P1,gp_Vec(P1,P2));
213 Handle(Geom_Line) GL = new Geom_Line(L);
218 //=======================================================================
219 //function : BRepLib_MakeEdge
221 //=======================================================================
223 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L)
225 Handle(Geom_Line) GL = new Geom_Line(L);
230 //=======================================================================
231 //function : BRepLib_MakeEdge
233 //=======================================================================
235 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
236 const Standard_Real p1,
237 const Standard_Real p2)
239 Handle(Geom_Line) GL = new Geom_Line(L);
244 //=======================================================================
245 //function : BRepLib_MakeEdge
247 //=======================================================================
249 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
253 Handle(Geom_Line) GL = new Geom_Line(L);
258 //=======================================================================
259 //function : BRepLib_MakeEdge
261 //=======================================================================
263 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Lin& L,
264 const TopoDS_Vertex& V1,
265 const TopoDS_Vertex& V2)
267 Handle(Geom_Line) GL = new Geom_Line(L);
272 //=======================================================================
273 //function : BRepLib_MakeEdge
275 //=======================================================================
277 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C)
279 Handle(Geom_Circle) GC = new Geom_Circle(C);
284 //=======================================================================
285 //function : BRepLib_MakeEdge
287 //=======================================================================
289 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
290 const Standard_Real p1,
291 const Standard_Real p2)
293 Handle(Geom_Circle) GC = new Geom_Circle(C);
298 //=======================================================================
299 //function : BRepLib_MakeEdge
301 //=======================================================================
303 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
307 Handle(Geom_Circle) GC = new Geom_Circle(C);
312 //=======================================================================
313 //function : BRepLib_MakeEdge
315 //=======================================================================
317 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Circ& C,
318 const TopoDS_Vertex& V1,
319 const TopoDS_Vertex& V2)
321 Handle(Geom_Circle) GC = new Geom_Circle(C);
326 //=======================================================================
327 //function : BRepLib_MakeEdge
329 //=======================================================================
331 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E)
333 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
338 //=======================================================================
339 //function : BRepLib_MakeEdge
341 //=======================================================================
343 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
344 const Standard_Real p1,
345 const Standard_Real p2)
347 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
352 //=======================================================================
353 //function : BRepLib_MakeEdge
355 //=======================================================================
357 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
361 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
366 //=======================================================================
367 //function : BRepLib_MakeEdge
369 //=======================================================================
371 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Elips& E,
372 const TopoDS_Vertex& V1,
373 const TopoDS_Vertex& V2)
375 Handle(Geom_Ellipse) GE = new Geom_Ellipse(E);
380 //=======================================================================
381 //function : BRepLib_MakeEdge
383 //=======================================================================
385 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H)
387 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
392 //=======================================================================
393 //function : BRepLib_MakeEdge
395 //=======================================================================
397 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
398 const Standard_Real p1,
399 const Standard_Real p2)
401 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
406 //=======================================================================
407 //function : BRepLib_MakeEdge
409 //=======================================================================
411 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
415 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
420 //=======================================================================
421 //function : BRepLib_MakeEdge
423 //=======================================================================
425 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Hypr& H,
426 const TopoDS_Vertex& V1,
427 const TopoDS_Vertex& V2)
429 Handle(Geom_Hyperbola) GH = new Geom_Hyperbola(H);
434 //=======================================================================
435 //function : BRepLib_MakeEdge
437 //=======================================================================
439 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P)
441 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
446 //=======================================================================
447 //function : BRepLib_MakeEdge
449 //=======================================================================
451 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
452 const Standard_Real p1,
453 const Standard_Real p2)
455 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
460 //=======================================================================
461 //function : BRepLib_MakeEdge
463 //=======================================================================
465 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
469 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
474 //=======================================================================
475 //function : BRepLib_MakeEdge
477 //=======================================================================
479 BRepLib_MakeEdge::BRepLib_MakeEdge(const gp_Parab& P,
480 const TopoDS_Vertex& V1,
481 const TopoDS_Vertex& V2)
483 Handle(Geom_Parabola) GP = new Geom_Parabola(P);
488 //=======================================================================
489 //function : BRepLib_MakeEdge
491 //=======================================================================
493 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L)
499 //=======================================================================
500 //function : BRepLib_MakeEdge
502 //=======================================================================
504 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
505 const Standard_Real p1,
506 const Standard_Real p2)
512 //=======================================================================
513 //function : BRepLib_MakeEdge
515 //=======================================================================
517 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
524 //=======================================================================
525 //function : BRepLib_MakeEdge
527 //=======================================================================
529 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
530 const TopoDS_Vertex& V1,
531 const TopoDS_Vertex& V2)
537 //=======================================================================
538 //function : BRepLib_MakeEdge
540 //=======================================================================
542 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
545 const Standard_Real p1,
546 const Standard_Real p2)
552 //=======================================================================
553 //function : BRepLib_MakeEdge
555 //=======================================================================
557 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom_Curve)& L,
558 const TopoDS_Vertex& V1,
559 const TopoDS_Vertex& V2,
560 const Standard_Real p1,
561 const Standard_Real p2)
568 //=======================================================================
569 //function : BRepLib_MakeEdge
571 //=======================================================================
573 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
574 const Handle(Geom_Surface)& S)
580 //=======================================================================
581 //function : BRepLib_MakeEdge
583 //=======================================================================
585 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
586 const Handle(Geom_Surface)& S,
587 const Standard_Real p1,
588 const Standard_Real p2)
594 //=======================================================================
595 //function : BRepLib_MakeEdge
597 //=======================================================================
599 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
600 const Handle(Geom_Surface)& S,
607 //=======================================================================
608 //function : BRepLib_MakeEdge
610 //=======================================================================
612 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
613 const Handle(Geom_Surface)& S,
614 const TopoDS_Vertex& V1,
615 const TopoDS_Vertex& V2)
621 //=======================================================================
622 //function : BRepLib_MakeEdge
624 //=======================================================================
626 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
627 const Handle(Geom_Surface)& S,
630 const Standard_Real p1,
631 const Standard_Real p2)
633 Init(L,S,P1,P2,p1,p2);
637 //=======================================================================
638 //function : BRepLib_MakeEdge
640 //=======================================================================
642 BRepLib_MakeEdge::BRepLib_MakeEdge(const Handle(Geom2d_Curve)& L,
643 const Handle(Geom_Surface)& S,
644 const TopoDS_Vertex& V1,
645 const TopoDS_Vertex& V2,
646 const Standard_Real p1,
647 const Standard_Real p2)
649 Init(L,S,V1,V2,p1,p2);
653 //=======================================================================
656 //=======================================================================
658 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C)
660 Init(C,C->FirstParameter(),C->LastParameter());
664 //=======================================================================
667 //=======================================================================
669 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
670 const Standard_Real p1,
671 const Standard_Real p2)
680 //=======================================================================
683 //=======================================================================
685 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
689 Standard_Real Tol = BRepLib::Precision();
693 B.MakeVertex(V1,P1,Tol);
694 if (P1.Distance(P2) < Tol)
697 B.MakeVertex(V2,P2,Tol);
703 //=======================================================================
706 //=======================================================================
708 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
709 const TopoDS_Vertex& V1,
710 const TopoDS_Vertex& V2)
712 // try projecting the vertices on the curve
717 p1 = C->FirstParameter();
719 if (!Project(C,V1,p1)) {
720 myError = BRepLib_PointProjectionFailed;
724 p2 = C->LastParameter();
726 if (!Project(C,V2,p2)) {
727 myError = BRepLib_PointProjectionFailed;
735 //=======================================================================
738 //=======================================================================
740 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& C,
743 const Standard_Real p1,
744 const Standard_Real p2)
746 Standard_Real Tol = BRepLib::Precision();
750 B.MakeVertex(V1,P1,Tol);
751 if (P1.Distance(P2) < Tol)
754 B.MakeVertex(V2,P2,Tol);
760 //=======================================================================
762 //purpose : this one really makes the job ...
763 //=======================================================================
765 void BRepLib_MakeEdge::Init(const Handle(Geom_Curve)& CC,
766 const TopoDS_Vertex& VV1,
767 const TopoDS_Vertex& VV2,
768 const Standard_Real pp1,
769 const Standard_Real pp2)
771 // kill trimmed curves
772 Handle(Geom_Curve) C = CC;
773 Handle(Geom_TrimmedCurve) CT = Handle(Geom_TrimmedCurve)::DownCast(C);
774 while (!CT.IsNull()) {
775 C = CT->BasisCurve();
776 CT = Handle(Geom_TrimmedCurve)::DownCast(C);
780 Standard_Real p1 = pp1;
781 Standard_Real p2 = pp2;
782 Standard_Real cf = C->FirstParameter();
783 Standard_Real cl = C->LastParameter();
784 Standard_Real epsilon = Precision::PConfusion();
785 Standard_Boolean periodic = C->IsPeriodic();
786 GeomAdaptor_Curve aCA(C);
791 ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2);
804 Standard_Real x = p1;
810 if ((cf - p1 > epsilon) || (p2 - cl > epsilon)) {
811 myError = BRepLib_ParameterOutOfRange;
815 // check ponctuallity
816 if ((p2-p1) <= gp::Resolution()) {
817 myError = BRepLib_LineThroughIdenticPoints;
822 // compute points on the curve
823 Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
824 Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
826 if (!p1inf) P1 = aCA.Value(p1);
827 if (!p2inf) P2 = aCA.Value(p2);
829 Standard_Real preci = BRepLib::Precision();
832 // check for closed curve
833 Standard_Boolean closed = Standard_False;
834 Standard_Boolean degenerated = Standard_False;
835 if (!p1inf && !p2inf)
836 closed = (P1.Distance(P2) <= preci);
838 // check if the vertices are on the curve
840 if (V1.IsNull() && V2.IsNull()) {
841 B.MakeVertex(V1,P1,preci);
844 else if (V1.IsNull())
846 else if (V2.IsNull())
849 if (!V1.IsSame(V2)) {
850 myError = BRepLib_DifferentPointsOnClosedCurve;
853 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
854 Max(preci,BRep_Tool::Tolerance(V1))) {
855 myError = BRepLib_DifferentPointsOnClosedCurve;
860 gp_Pnt PM = aCA.Value((p1+p2)/2);
861 if (P1.Distance(PM) < preci)
862 degenerated = Standard_True;
871 myError = BRepLib_PointWithInfiniteParameter;
877 B.MakeVertex(V1,P1,preci);
879 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
880 Max(preci,BRep_Tool::Tolerance(V1))) {
881 myError = BRepLib_DifferentsPointAndParameter;
888 myError = BRepLib_PointWithInfiniteParameter;
894 B.MakeVertex(V2,P2,preci);
896 else if (P2.Distance(BRep_Tool::Pnt(V2)) >
897 Max(preci,BRep_Tool::Tolerance(V2))){
898 myError = BRepLib_DifferentsPointAndParameter;
904 V1.Orientation(TopAbs_FORWARD);
905 V2.Orientation(TopAbs_REVERSED);
909 TopoDS_Edge& E = TopoDS::Edge(myShape);
910 B.MakeEdge(E,C,preci);
918 B.Degenerated(E, degenerated);
920 myError = BRepLib_EdgeDone;
924 //=======================================================================
927 //=======================================================================
929 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
930 const Handle(Geom_Surface)& S)
932 Init(C,S,C->FirstParameter(),C->LastParameter());
936 //=======================================================================
939 //=======================================================================
941 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
942 const Handle(Geom_Surface)& S,
943 const Standard_Real p1,
944 const Standard_Real p2)
949 Init(C,S,V1,V2,p1,p2);
953 //=======================================================================
956 //=======================================================================
958 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
959 const Handle(Geom_Surface)& S,
963 Standard_Real Tol = BRepLib::Precision();
967 B.MakeVertex(V1,P1,Tol);
968 if (P1.Distance(P2) < Tol)
971 B.MakeVertex(V2,P2,Tol);
977 //=======================================================================
980 //=======================================================================
982 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
983 const Handle(Geom_Surface)& S,
984 const TopoDS_Vertex& V1,
985 const TopoDS_Vertex& V2)
987 // try projecting the vertices on the curve
992 p1 = C->FirstParameter();
994 if (!Project(C,S,V1,p1)) {
995 myError = BRepLib_PointProjectionFailed;
999 p2 = C->LastParameter();
1001 if (!Project(C,S,V2,p2)) {
1002 myError = BRepLib_PointProjectionFailed;
1006 Init(C,S,V1,V2,p1,p2);
1010 //=======================================================================
1013 //=======================================================================
1015 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& C,
1016 const Handle(Geom_Surface)& S,
1019 const Standard_Real p1,
1020 const Standard_Real p2)
1022 Standard_Real Tol = BRepLib::Precision();
1025 TopoDS_Vertex V1,V2;
1026 B.MakeVertex(V1,P1,Tol);
1027 if (P1.Distance(P2) < Tol)
1030 B.MakeVertex( V2, P2, Tol);
1032 Init(C,S,V1,V2,p1,p2);
1036 //=======================================================================
1038 //purpose : this one really makes the job ...
1039 //=======================================================================
1041 void BRepLib_MakeEdge::Init(const Handle(Geom2d_Curve)& CC,
1042 const Handle(Geom_Surface)& S,
1043 const TopoDS_Vertex& VV1,
1044 const TopoDS_Vertex& VV2,
1045 const Standard_Real pp1,
1046 const Standard_Real pp2)
1048 // kill trimmed curves
1049 Handle(Geom2d_Curve) C = CC;
1050 Handle(Geom2d_TrimmedCurve) CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
1051 while (!CT.IsNull()) {
1052 C = CT->BasisCurve();
1053 CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
1057 Standard_Real p1 = pp1;
1058 Standard_Real p2 = pp2;
1059 Standard_Real cf = C->FirstParameter();
1060 Standard_Real cl = C->LastParameter();
1061 Standard_Real epsilon = Precision::PConfusion();
1062 Standard_Boolean periodic = C->IsPeriodic();
1065 TopoDS_Vertex V1,V2;
1066 Standard_Boolean reverse = Standard_False;
1070 ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2);
1083 Standard_Real x = p1;
1086 reverse = Standard_True;
1090 if ((cf - p1 > epsilon) || (p2 - cl > epsilon)) {
1091 myError = BRepLib_ParameterOutOfRange;
1096 // compute points on the curve
1097 Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
1098 Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
1102 P2d1 = C->Value(p1);
1103 P1 = S->Value(P2d1.X(),P2d1.Y());
1106 P2d2 = C->Value(p2);
1107 P2 = S->Value(P2d2.X(),P2d2.Y());
1110 Standard_Real preci = BRepLib::Precision();
1113 // check for closed curve
1114 Standard_Boolean closed = Standard_False;
1115 if (!p1inf && !p2inf)
1116 closed = (P1.Distance(P2) <= preci);
1118 // check if the vertices are on the curve
1120 if (V1.IsNull() && V2.IsNull()) {
1121 B.MakeVertex(V1,P1,preci);
1124 else if (V1.IsNull())
1126 else if (V2.IsNull())
1129 if (!V1.IsSame(V2)) {
1130 myError = BRepLib_DifferentPointsOnClosedCurve;
1133 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
1134 Max(preci,BRep_Tool::Tolerance(V1))) {
1135 myError = BRepLib_DifferentPointsOnClosedCurve;
1141 else { // not closed
1145 myError = BRepLib_PointWithInfiniteParameter;
1151 B.MakeVertex(V1,P1,preci);
1153 else if (P1.Distance(BRep_Tool::Pnt(V1)) >
1154 Max(preci,BRep_Tool::Tolerance(V1))) {
1155 myError = BRepLib_DifferentsPointAndParameter;
1162 myError = BRepLib_PointWithInfiniteParameter;
1168 B.MakeVertex(V2,P2,preci);
1170 else if (P2.Distance(BRep_Tool::Pnt(V2)) >
1171 Max(preci,BRep_Tool::Tolerance(V2))){
1172 myError = BRepLib_DifferentsPointAndParameter;
1178 V1.Orientation(TopAbs_FORWARD);
1179 V2.Orientation(TopAbs_REVERSED);
1183 TopoDS_Edge& E = TopoDS::Edge(myShape);
1185 B.UpdateEdge(E,C,S,TopLoc_Location(),preci);
1196 E.Orientation(TopAbs_REVERSED);
1198 myError = BRepLib_EdgeDone;
1202 //=======================================================================
1205 //=======================================================================
1207 BRepLib_EdgeError BRepLib_MakeEdge::Error() const
1212 //=======================================================================
1215 //=======================================================================
1217 const TopoDS_Edge& BRepLib_MakeEdge::Edge()const
1219 return TopoDS::Edge(Shape());
1223 //=======================================================================
1224 //function : Vertex1
1226 //=======================================================================
1228 const TopoDS_Vertex& BRepLib_MakeEdge::Vertex1()const
1235 //=======================================================================
1236 //function : Vertex2
1238 //=======================================================================
1240 const TopoDS_Vertex& BRepLib_MakeEdge::Vertex2()const
1248 //=======================================================================
1249 //function : operator
1251 //=======================================================================
1253 BRepLib_MakeEdge::operator TopoDS_Edge() const