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