Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1999-03-08 |
2 | // Created by: Fabrice SERVANT | |
3 | // Copyright (c) 1999-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 | |
17 | #include <IntPolyh_Point.ixx> | |
18 | ||
19 | #include <stdio.h> | |
20 | ||
21 | ||
55ab6ed6 P |
22 | //======================================================================= |
23 | //function : IntPolyh_Point | |
24 | //purpose : | |
25 | //======================================================================= | |
26 | IntPolyh_Point::IntPolyh_Point() | |
27 | : | |
28 | x(0),y(0),z(0),u(0),v(0),POC(1), | |
29 | myDegenerated(Standard_False) | |
30 | { | |
7fd59977 | 31 | } |
32 | ||
55ab6ed6 P |
33 | //======================================================================= |
34 | //function : IntPolyh_Point | |
35 | //purpose : | |
36 | //======================================================================= | |
7fd59977 | 37 | IntPolyh_Point::IntPolyh_Point(const Standard_Real _x, |
38 | const Standard_Real _y, | |
39 | const Standard_Real _z, | |
40 | const Standard_Real _u, | |
55ab6ed6 P |
41 | const Standard_Real _v) |
42 | : | |
43 | POC(1), | |
44 | myDegenerated(Standard_False) | |
45 | { | |
7fd59977 | 46 | x=_x; y=_y; z=_z; u=_u; v=_v; |
47 | } | |
55ab6ed6 P |
48 | //======================================================================= |
49 | //function : X | |
50 | //purpose : | |
51 | //======================================================================= | |
52 | Standard_Real IntPolyh_Point::X() const | |
53 | { | |
54 | return x; | |
55 | } | |
56 | //======================================================================= | |
57 | //function : Y | |
58 | //purpose : | |
59 | //======================================================================= | |
60 | Standard_Real IntPolyh_Point::Y() const | |
61 | { | |
62 | return y; | |
63 | } | |
64 | //======================================================================= | |
65 | //function : Z | |
66 | //purpose : | |
67 | //======================================================================= | |
68 | Standard_Real IntPolyh_Point::Z() const | |
69 | { | |
70 | return z; | |
71 | } | |
72 | //======================================================================= | |
73 | //function : U | |
74 | //purpose : | |
75 | //======================================================================= | |
76 | Standard_Real IntPolyh_Point::U() const | |
77 | { | |
78 | return u; | |
79 | } | |
80 | //======================================================================= | |
81 | //function : V | |
82 | //purpose : | |
83 | //======================================================================= | |
84 | Standard_Real IntPolyh_Point::V() const | |
85 | { | |
86 | return v; | |
87 | } | |
88 | //======================================================================= | |
89 | //function : PartOfCommon | |
90 | //purpose : | |
91 | //======================================================================= | |
92 | Standard_Integer IntPolyh_Point::PartOfCommon() const | |
93 | { | |
94 | return POC; | |
95 | } | |
96 | //======================================================================= | |
97 | //function : Set | |
98 | //purpose : | |
99 | //======================================================================= | |
100 | void IntPolyh_Point::Set(const Standard_Real _x, | |
101 | const Standard_Real _y, | |
102 | const Standard_Real _z, | |
103 | const Standard_Real _u, | |
104 | const Standard_Real _v, | |
105 | const Standard_Integer II) | |
106 | { | |
107 | x=_x; | |
108 | y=_y; | |
109 | z=_z; | |
110 | u=_u; | |
111 | v=_v; | |
112 | POC=II; | |
113 | } | |
114 | //======================================================================= | |
115 | //function : Equal | |
116 | //purpose : | |
117 | //======================================================================= | |
118 | void IntPolyh_Point::Equal(const IntPolyh_Point &Pt) | |
119 | { | |
7fd59977 | 120 | x = Pt.x; |
121 | y = Pt.y; | |
122 | z = Pt.z; | |
123 | u = Pt.u; | |
124 | v = Pt.v; | |
125 | } | |
55ab6ed6 P |
126 | //======================================================================= |
127 | //function : SetX | |
128 | //purpose : | |
129 | //======================================================================= | |
130 | void IntPolyh_Point::SetX(const Standard_Real _x) | |
131 | { | |
132 | x=_x; | |
133 | } | |
134 | //======================================================================= | |
135 | //function : SetY | |
136 | //purpose : | |
137 | //======================================================================= | |
138 | void IntPolyh_Point::SetY(const Standard_Real _y) | |
139 | { | |
140 | y=_y; | |
141 | } | |
142 | //======================================================================= | |
143 | //function : SetZ | |
144 | //purpose : | |
145 | //======================================================================= | |
146 | void IntPolyh_Point::SetZ(const Standard_Real _z) | |
147 | { | |
148 | z=_z; | |
149 | } | |
150 | //======================================================================= | |
151 | //function : SetU | |
152 | //purpose : | |
153 | //======================================================================= | |
154 | void IntPolyh_Point::SetU(const Standard_Real _u) | |
155 | { | |
156 | u=_u; | |
157 | } | |
158 | //======================================================================= | |
159 | //function : SetV | |
160 | //purpose : | |
161 | //======================================================================= | |
162 | void IntPolyh_Point::SetV(const Standard_Real _v) | |
163 | { | |
164 | v=_v; | |
165 | } | |
166 | //======================================================================= | |
167 | //function : SetPartOfCommon | |
168 | //purpose : | |
169 | //======================================================================= | |
170 | void IntPolyh_Point::SetPartOfCommon(const Standard_Integer ii) | |
171 | { | |
172 | POC=ii; | |
173 | } | |
7fd59977 | 174 | |
7fd59977 | 175 | |
55ab6ed6 P |
176 | //======================================================================= |
177 | //function : Middle | |
178 | //purpose : | |
179 | //======================================================================= | |
7fd59977 | 180 | void IntPolyh_Point::Middle(const Handle(Adaptor3d_HSurface)& MySurface, |
181 | const IntPolyh_Point & Point1, | |
182 | const IntPolyh_Point & Point2){ | |
183 | u = (Point1.U()+Point2.U())*0.5; | |
184 | v = (Point1.V()+Point2.V())*0.5; | |
185 | ||
186 | gp_Pnt PtXYZ = (MySurface)->Value(u, v); | |
187 | ||
188 | x=PtXYZ.X(); | |
189 | y=PtXYZ.Y(); | |
190 | z=PtXYZ.Z(); | |
191 | } | |
55ab6ed6 P |
192 | //======================================================================= |
193 | //function : Add | |
194 | //purpose : | |
195 | //======================================================================= | |
196 | IntPolyh_Point IntPolyh_Point::Add(const IntPolyh_Point &P1)const | |
197 | { | |
7fd59977 | 198 | IntPolyh_Point res; |
55ab6ed6 | 199 | // |
7fd59977 | 200 | res.SetX(x+P1.X()); |
201 | res.SetY(y+P1.Y()); | |
202 | res.SetZ(z+P1.Z()); | |
203 | res.SetU(u+P1.U()); | |
204 | res.SetV(v+P1.V()); | |
55ab6ed6 | 205 | return res; |
7fd59977 | 206 | } |
207 | ||
55ab6ed6 P |
208 | //======================================================================= |
209 | //function : Sub | |
210 | //purpose : | |
211 | //======================================================================= | |
212 | IntPolyh_Point IntPolyh_Point::Sub(const IntPolyh_Point &P1)const | |
213 | { | |
7fd59977 | 214 | IntPolyh_Point res; |
55ab6ed6 | 215 | // |
7fd59977 | 216 | res.SetX(x-P1.X()); |
217 | res.SetY(y-P1.Y()); | |
218 | res.SetZ(z-P1.Z()); | |
219 | res.SetU(u-P1.U()); | |
220 | res.SetV(v-P1.V()); | |
55ab6ed6 | 221 | return res; |
7fd59977 | 222 | } |
55ab6ed6 P |
223 | //======================================================================= |
224 | //function : Divide | |
225 | //purpose : | |
226 | //======================================================================= | |
227 | IntPolyh_Point IntPolyh_Point::Divide(const Standard_Real RR)const | |
228 | { | |
7fd59977 | 229 | IntPolyh_Point res; |
55ab6ed6 | 230 | // |
7fd59977 | 231 | if (Abs(RR)>10.0e-20) { |
232 | res.SetX(x/RR); | |
233 | res.SetY(y/RR); | |
234 | res.SetZ(z/RR); | |
235 | res.SetU(u/RR); | |
236 | res.SetV(v/RR); | |
237 | } | |
238 | else { | |
239 | printf("Division par zero RR=%f\n",RR); | |
7fd59977 | 240 | } |
55ab6ed6 | 241 | return res; |
7fd59977 | 242 | } |
55ab6ed6 P |
243 | //======================================================================= |
244 | //function : Multiplication | |
245 | //purpose : | |
246 | //======================================================================= | |
247 | IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const | |
248 | { | |
7fd59977 | 249 | IntPolyh_Point res; |
55ab6ed6 | 250 | // |
7fd59977 | 251 | res.SetX(x*RR); |
252 | res.SetY(y*RR); | |
253 | res.SetZ(z*RR); | |
254 | res.SetU(u*RR); | |
255 | res.SetV(v*RR); | |
55ab6ed6 | 256 | return res; |
7fd59977 | 257 | } |
55ab6ed6 P |
258 | //======================================================================= |
259 | //function : SquareModulus | |
260 | //purpose : | |
261 | //======================================================================= | |
262 | Standard_Real IntPolyh_Point::SquareModulus()const | |
263 | { | |
7fd59977 | 264 | Standard_Real res=x*x+y*y+z*z; |
55ab6ed6 | 265 | return res; |
7fd59977 | 266 | } |
267 | ||
55ab6ed6 P |
268 | //======================================================================= |
269 | //function : SquareDistance | |
270 | //purpose : | |
271 | //======================================================================= | |
272 | Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const | |
273 | { | |
7fd59977 | 274 | Standard_Real res=(x-P2.x)*(x-P2.x)+(y-P2.y)*(y-P2.y)+(z-P2.z)*(z-P2.z); |
55ab6ed6 | 275 | return res; |
7fd59977 | 276 | } |
55ab6ed6 P |
277 | //======================================================================= |
278 | //function : Dot | |
279 | //purpose : | |
280 | //======================================================================= | |
281 | Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const | |
282 | { | |
7fd59977 | 283 | Standard_Real t=x*b.x+y*b.y+z*b.z; |
55ab6ed6 | 284 | return t; |
7fd59977 | 285 | } |
55ab6ed6 P |
286 | //======================================================================= |
287 | //function : Cross | |
288 | //purpose : | |
289 | //======================================================================= | |
7fd59977 | 290 | void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){ |
291 | x=a.y*b.z-a.z*b.y; | |
292 | y=a.z*b.x-a.x*b.z; | |
293 | z=a.x*b.y-a.y*b.x; | |
7fd59977 | 294 | } |
55ab6ed6 P |
295 | //======================================================================= |
296 | //function : Dump | |
297 | //purpose : | |
298 | //======================================================================= | |
299 | void IntPolyh_Point::Dump() const | |
300 | { | |
7fd59977 | 301 | printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",x,y,z,u,v); |
302 | } | |
55ab6ed6 P |
303 | //======================================================================= |
304 | //function : Dump | |
305 | //purpose : | |
306 | //======================================================================= | |
307 | void IntPolyh_Point::Dump(const Standard_Integer i) const | |
308 | { | |
309 | printf("\nPoint(%3d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg poc=%3d\n", | |
310 | i,x,y,z,u,v,POC); | |
311 | } | |
312 | //modified by NIZNHY-PKV Fri Jan 20 12:13:03 2012f | |
313 | //======================================================================= | |
314 | //function : SetDegenerated | |
315 | //purpose : | |
316 | //======================================================================= | |
317 | void IntPolyh_Point::SetDegenerated(const Standard_Boolean theFlag) | |
318 | { | |
319 | myDegenerated=theFlag; | |
320 | } | |
321 | //======================================================================= | |
322 | //function : Degenerated | |
323 | //purpose : | |
324 | //======================================================================= | |
325 | Standard_Boolean IntPolyh_Point::Degenerated()const | |
326 | { | |
327 | return myDegenerated; | |
7fd59977 | 328 | } |
329 | ||
330 | ||
331 | ||
332 | ||
333 | ||
334 | ||
335 |