Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1992-01-02 |
2 | // Created by: Remi GILET | |
3 | // Copyright (c) 1992-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
7fd59977 | 17 | |
18 | #include <ElCLib.hxx> | |
42cf5bc1 | 19 | #include <GccAna_Circ2d2TanOn.hxx> |
20 | #include <GccEnt_BadQualifier.hxx> | |
21 | #include <GccEnt_QualifiedCirc.hxx> | |
22 | #include <GccEnt_QualifiedLin.hxx> | |
7fd59977 | 23 | #include <gp_Ax2d.hxx> |
42cf5bc1 | 24 | #include <gp_Circ2d.hxx> |
25 | #include <gp_Dir2d.hxx> | |
26 | #include <gp_Lin2d.hxx> | |
27 | #include <gp_Pnt2d.hxx> | |
7fd59977 | 28 | #include <IntAna2d_AnaIntersection.hxx> |
29 | #include <IntAna2d_IntPoint.hxx> | |
42cf5bc1 | 30 | #include <Standard_OutOfRange.hxx> |
31 | #include <StdFail_NotDone.hxx> | |
7fd59977 | 32 | |
33 | //========================================================================= | |
0d969553 Y |
34 | // Creation of a circle passing by : 2 points Point1 and Point2. + |
35 | // Centered on : 1 straight line OnLine. + | |
36 | // with a Tolerance of precision : Tolerance. + | |
7fd59977 | 37 | // + |
0d969553 Y |
38 | // Create L1 straight line of points equidistant from Point1 and Point2. + |
39 | // Then create solutions cirsol such as : + | |
40 | // cirsol is all circle with center at the intersections of + | |
41 | // L1 with OnLine and the radius the distance between Point1 and the point + | |
42 | // calculated above. + | |
7fd59977 | 43 | //========================================================================= |
7fd59977 | 44 | GccAna_Circ2d2TanOn:: |
45 | GccAna_Circ2d2TanOn (const gp_Pnt2d& Point1 , | |
46 | const gp_Pnt2d& Point2 , | |
47 | const gp_Lin2d& OnLine , | |
48 | const Standard_Real Tolerance ): | |
49 | cirsol(1,2) , | |
50 | qualifier1(1,2) , | |
51 | qualifier2(1,2), | |
52 | TheSame1(1,2) , | |
53 | TheSame2(1,2) , | |
54 | pnttg1sol(1,2) , | |
55 | pnttg2sol(1,2) , | |
56 | pntcen(1,2) , | |
57 | par1sol(1,2) , | |
58 | par2sol(1,2) , | |
59 | pararg1(1,2) , | |
60 | pararg2(1,2) , | |
61 | parcen3(1,2) | |
62 | { | |
63 | TheSame1.Init(0); | |
64 | TheSame2.Init(0); | |
65 | WellDone = Standard_False; | |
66 | NbrSol = 0; | |
67 | ||
68 | gp_Dir2d dirx(1.,0.); | |
69 | Standard_Real dist = Point1.Distance(Point2); | |
70 | if (dist < Abs(Tolerance)) { WellDone = Standard_True; } | |
71 | else { | |
72 | gp_Lin2d L1(gp_Pnt2d((Point1.XY()+Point2.XY())/2.0), | |
73 | gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X())); | |
74 | IntAna2d_AnaIntersection Intp(L1,OnLine); | |
75 | if (Intp.IsDone()) { | |
76 | if (!Intp.IsEmpty()) { | |
77 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { | |
78 | NbrSol++; | |
79 | gp_Ax2d axe(Intp.Point(i).Value(),dirx); | |
80 | cirsol(NbrSol)=gp_Circ2d(axe,Point1.Distance(Intp.Point(i).Value())); | |
81 | // ==================================================================== | |
82 | qualifier1(NbrSol) = GccEnt_noqualifier; | |
83 | qualifier2(NbrSol) = GccEnt_noqualifier; | |
84 | pnttg1sol(NbrSol) = Point1; | |
85 | pnttg2sol(NbrSol) = Point2; | |
86 | pntcen(NbrSol) = cirsol(NbrSol).Location(); | |
87 | pararg1(NbrSol) = 0.; | |
88 | pararg2(NbrSol) = 0.; | |
89 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol)); | |
90 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol)); | |
91 | parcen3(NbrSol)=ElCLib::Parameter(OnLine,pntcen(NbrSol)); | |
92 | } | |
93 | } | |
94 | WellDone = Standard_True; | |
95 | } | |
96 | } | |
97 | } | |
98 | ||
99 | ||
100 | ||
101 | ||
102 | ||
103 |