-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathGeom2d_Arc.cxx
187 lines (168 loc) · 3.67 KB
/
Geom2d_Arc.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* \file Geom2d_Arc.cxx
* \brief Implementation file for the class Geom2d_Arc
* \author <a href="mailto:[email protected]?subject=Geom2d_Arc.cxx">Sergei Maslov</a>
*/
#include "Geom2d_Arc.hxx"
IMPLEMENT_STANDARD_RTTIEXT(Geom2d_Arc, Geom2d_Circle)
/**
* \fn Geom2d_Arc(const gp_Circ2d& C)
* \brief Constructs a Geom2d_Arc
* \param C const gp_Circ2d&
*/
Geom2d_Arc::Geom2d_Arc(const gp_Circ2d& C)
:Geom2d_Circle(C)
{
myFirstParam = 0.0;
myLastParam = 2*M_PI;
}
/**
* \fn Geom2d_Arc(const gp_Ax2d& Ax2d,const Standard_Real R)
* \brief Constructs a Geom2d_Arc
* \param Ax2d const gp_Ax2d&
* \param R const Standard_Real
*/
Geom2d_Arc::Geom2d_Arc(const gp_Ax2d& Ax2d,const Standard_Real R)
:Geom2d_Circle(Ax2d,R)
{
myFirstParam = 0.0;
myLastParam = 2*M_PI;
}
/**
* \fn ~Geom2d_Arc()
* \brief destructor
*/
Geom2d_Arc::~Geom2d_Arc()
{
}
/**
* \fn SetParam(const gp_Pnt2d& start,const gp_Pnt2d& mid,const gp_Pnt2d& end)
* \brief set parameters
* \param start const gp_Pnt2d&
* \param mid const gp_Pnt2d&
* \param end const gp_Pnt2d&
*/
void Geom2d_Arc::SetParam(const gp_Pnt2d& start,const gp_Pnt2d& mid,const gp_Pnt2d& end)
{
myFirstParam = ElCLib::Parameter(Circ2d(),start);
myLastParam = ElCLib::Parameter(Circ2d(),end);
Standard_Real u = ElCLib::Parameter(Circ2d(),mid);
CheckParam();
if( (myFirstParam < u) && (u < myLastParam) ||
(myFirstParam < u + 2* M_PI) && (u + 2* M_PI < myLastParam) );
else
{
Standard_Real u;
if(myLastParam > 2*M_PI)
{
myLastParam -= 2*M_PI;
u = myFirstParam;
}
else u = myFirstParam + 2*M_PI;
myFirstParam = myLastParam;
myLastParam = u;
}
}
/**
* \fn SetFirstParam(const Standard_Real u1)
* \brief set first parameter
* \return void
* \param u1 const Standard_Real
*/
void Geom2d_Arc::SetFirstParam(const Standard_Real u1)
{
myFirstParam = u1;
CheckParam();
}
/**
* \fn SetFirstParam(const gp_Pnt2d& p1)
* \brief set first parameter
* \return void
* \param p1 const gp_Pnt2d&
*/
void Geom2d_Arc::SetFirstParam(const gp_Pnt2d& p1)
{
myFirstParam = ElCLib::Parameter(Circ2d(),p1);
CheckParam();
}
/**
* \fn SetLastParam(const Standard_Real u2)
* \brief set last parameter
* \return void
* \param u2 const Standard_Real
*/
void Geom2d_Arc::SetLastParam(const Standard_Real u2)
{
myLastParam = u2;
CheckParam();
}
/**
* \fn SetLastParam(const gp_Pnt2d& p2)
* \brief set last parameter
* \return void
* \param p2 const gp_Pnt2d&
*/
void Geom2d_Arc::SetLastParam(const gp_Pnt2d& p2)
{
myLastParam = ElCLib::Parameter(Circ2d(),p2);
CheckParam();
}
/**
* \fn FirstParameter()
* \brief get first parameter
* \return Standard_Real const
*/
Standard_Real Geom2d_Arc::FirstParameter() const
{
return myFirstParam;
}
/**
* \fn LastParameter()
* \brief get last parameter
* \return Standard_Real const
*/
Standard_Real Geom2d_Arc::LastParameter() const
{
return myLastParam;
}
/**
* \fn FirstPnt()
* \brief get first 2d point
* \return gp_Pnt2d const
*/
gp_Pnt2d Geom2d_Arc::FirstPnt() const
{
return ElCLib::Value(myFirstParam,Circ2d());
}
/**
* \fn LastPnt()
* \brief get last 2d point
* \return gp_Pnt2d const
*/
gp_Pnt2d Geom2d_Arc::LastPnt() const
{
return ElCLib::Value(myLastParam,Circ2d());
}
/**
* \fn MiddlePnt()
* \brief get middle 2d point
* \return gp_Pnt2d const
*/
gp_Pnt2d Geom2d_Arc::MiddlePnt() const
{
return ElCLib::Value((myLastParam + myFirstParam) / 2, Circ2d());
}
/**
* \fn CheckParam()
* \brief set correct parameters
* \return void
*/
void Geom2d_Arc::CheckParam()
{
while(myFirstParam > 2*M_PI)
myFirstParam-= 2*M_PI;
while(myLastParam > 2*M_PI || (myLastParam - myFirstParam )> 2*M_PI)
myLastParam -= 2*M_PI;
while(myFirstParam > myLastParam)
myLastParam += 2*M_PI;
}