424cd6bb |
1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
42cf5bc1 |
15 | |
16 | #include <BRepGProp_Domain.hxx> |
17 | #include <BRepGProp_Face.hxx> |
9bd59d1c |
18 | #include <BRepGProp_Gauss.hxx> |
42cf5bc1 |
19 | #include <BRepGProp_Vinert.hxx> |
20 | #include <gp_Pln.hxx> |
21 | #include <gp_Pnt.hxx> |
424cd6bb |
22 | |
9bd59d1c |
23 | //======================================================================= |
24 | //function : BRepGProp_Vinert |
25 | //purpose : Constructor |
26 | //======================================================================= |
27 | BRepGProp_Vinert::BRepGProp_Vinert() |
424cd6bb |
28 | { |
424cd6bb |
29 | } |
30 | |
9bd59d1c |
31 | //======================================================================= |
32 | //function : BRepGProp_Vinert |
33 | //purpose : |
34 | //======================================================================= |
35 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
36 | const gp_Pnt& theLocation, |
37 | const Standard_Real theEps) |
424cd6bb |
38 | { |
9bd59d1c |
39 | SetLocation(theLocation); |
40 | Perform(theSurface, theEps); |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : BRepGProp_Vinert |
45 | //purpose : |
46 | //======================================================================= |
47 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
48 | BRepGProp_Domain& theDomain, |
49 | const gp_Pnt& theLocation, |
50 | const Standard_Real theEps) |
424cd6bb |
51 | { |
9bd59d1c |
52 | SetLocation(theLocation); |
53 | Perform(theSurface, theDomain, theEps); |
424cd6bb |
54 | } |
55 | |
9bd59d1c |
56 | //======================================================================= |
57 | //function : BRepGProp_Vinert |
58 | //purpose : |
59 | //======================================================================= |
60 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
61 | BRepGProp_Domain& theDomain, |
62 | const gp_Pnt& theLocation) |
424cd6bb |
63 | { |
9bd59d1c |
64 | SetLocation(theLocation); |
65 | Perform(theSurface, theDomain); |
424cd6bb |
66 | } |
67 | |
9bd59d1c |
68 | //======================================================================= |
69 | //function : BRepGProp_Vinert |
70 | //purpose : |
71 | //======================================================================= |
72 | BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface, |
73 | const gp_Pnt& theLocation) |
424cd6bb |
74 | { |
9bd59d1c |
75 | SetLocation(theLocation); |
76 | Perform(theSurface); |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : BRepGProp_Vinert |
81 | //purpose : |
82 | //======================================================================= |
83 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
84 | const gp_Pnt& theOrigin, |
85 | const gp_Pnt& theLocation, |
86 | const Standard_Real theEps) |
87 | { |
88 | SetLocation(theLocation); |
89 | Perform(theSurface, theOrigin, theEps); |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : BRepGProp_Vinert |
94 | //purpose : |
95 | //======================================================================= |
96 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
97 | BRepGProp_Domain& theDomain, |
98 | const gp_Pnt& theOrigin, |
99 | const gp_Pnt& theLocation, |
100 | const Standard_Real theEps) |
101 | { |
102 | SetLocation(theLocation); |
103 | Perform(theSurface, theDomain, theOrigin, theEps); |
424cd6bb |
104 | } |
105 | |
9bd59d1c |
106 | //======================================================================= |
107 | //function : BRepGProp_Vinert |
108 | //purpose : |
109 | //======================================================================= |
110 | BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface, |
111 | const gp_Pnt& theOrigin, |
112 | const gp_Pnt& theLocation) |
113 | { |
114 | SetLocation(theLocation); |
115 | Perform(theSurface, theOrigin); |
116 | } |
117 | |
118 | //======================================================================= |
119 | //function : BRepGProp_Vinert |
120 | //purpose : |
121 | //======================================================================= |
122 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
123 | BRepGProp_Domain& theDomain, |
124 | const gp_Pnt& theOrigin, |
125 | const gp_Pnt& theLocation) |
126 | { |
127 | SetLocation(theLocation); |
128 | Perform(theSurface, theDomain, theOrigin); |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : BRepGProp_Vinert |
133 | //purpose : |
134 | //======================================================================= |
135 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
136 | const gp_Pln& thePlane, |
137 | const gp_Pnt& theLocation, |
138 | const Standard_Real theEps) |
424cd6bb |
139 | { |
9bd59d1c |
140 | SetLocation(theLocation); |
141 | Perform(theSurface, thePlane, theEps); |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : BRepGProp_Vinert |
146 | //purpose : |
147 | //======================================================================= |
148 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
149 | BRepGProp_Domain& theDomain, |
150 | const gp_Pln& thePlane, |
151 | const gp_Pnt& theLocation, |
152 | const Standard_Real theEps) |
153 | { |
154 | SetLocation(theLocation); |
155 | Perform(theSurface, theDomain, thePlane, theEps); |
424cd6bb |
156 | } |
157 | |
9bd59d1c |
158 | //======================================================================= |
159 | //function : BRepGProp_Vinert |
160 | //purpose : |
161 | //======================================================================= |
162 | BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface, |
163 | const gp_Pln& thePlane, |
164 | const gp_Pnt& theLocation) |
424cd6bb |
165 | { |
9bd59d1c |
166 | SetLocation(theLocation); |
167 | Perform(theSurface, thePlane); |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : BRepGProp_Vinert |
172 | //purpose : |
173 | //======================================================================= |
174 | BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface, |
175 | BRepGProp_Domain& theDomain, |
176 | const gp_Pln& thePlane, |
177 | const gp_Pnt& theLocation) |
178 | { |
179 | SetLocation(theLocation); |
180 | Perform(theSurface, theDomain, thePlane); |
424cd6bb |
181 | } |
182 | |
9bd59d1c |
183 | //======================================================================= |
184 | //function : SetLocation |
185 | //purpose : |
186 | //======================================================================= |
187 | void BRepGProp_Vinert::SetLocation(const gp_Pnt& theLocation) |
424cd6bb |
188 | { |
9bd59d1c |
189 | loc = theLocation; |
424cd6bb |
190 | } |
191 | |
9bd59d1c |
192 | //======================================================================= |
193 | //function : Perform |
194 | //purpose : |
195 | //======================================================================= |
196 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
197 | const Standard_Real theEps) |
198 | { |
199 | BRepGProp_Domain anEmptyDomain; |
200 | return Perform(theSurface, anEmptyDomain, theEps); |
424cd6bb |
201 | } |
202 | |
9bd59d1c |
203 | //======================================================================= |
204 | //function : |
205 | //purpose : |
206 | //======================================================================= |
207 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
208 | BRepGProp_Domain& theDomain, |
209 | const Standard_Real theEps) |
210 | { |
211 | const Standard_Real aCoeff[] = {0.0, 0.0, 0.0}; |
212 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
424cd6bb |
213 | |
9bd59d1c |
214 | return myEpsilon = |
215 | aGauss.Compute(theSurface, theDomain, loc, theEps, |
216 | aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
217 | } |
218 | |
9bd59d1c |
219 | //======================================================================= |
220 | //function : Perform |
221 | //purpose : |
222 | //======================================================================= |
223 | void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface) |
224 | { |
225 | const Standard_Real aCoeff[] = {0.0, 0.0, 0.0}; |
226 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
424cd6bb |
227 | |
9bd59d1c |
228 | myEpsilon = 1.0; |
229 | aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
230 | } |
231 | |
9bd59d1c |
232 | //======================================================================= |
233 | //function : Perform |
234 | //purpose : |
235 | //======================================================================= |
236 | void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
237 | BRepGProp_Domain& theDomain) |
238 | { |
239 | const Standard_Real aCoeff[] = {0.0, 0.0, 0.0}; |
240 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
424cd6bb |
241 | |
9bd59d1c |
242 | myEpsilon = 1.0; |
243 | aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
244 | } |
245 | |
9bd59d1c |
246 | //======================================================================= |
247 | //function : Perform |
248 | //purpose : |
249 | //======================================================================= |
250 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
251 | const gp_Pnt& theOrigin, |
252 | const Standard_Real theEps) |
253 | { |
254 | BRepGProp_Domain anEmptyDomain; |
255 | return Perform(theSurface, anEmptyDomain, theOrigin, theEps); |
256 | } |
257 | |
258 | //======================================================================= |
259 | //function : Perform |
260 | //purpose : |
261 | //======================================================================= |
262 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
263 | BRepGProp_Domain& theDomain, |
264 | const gp_Pnt& theOrigin, |
265 | const Standard_Real theEps) |
266 | { |
267 | const Standard_Real aCoeff[] = |
268 | { |
269 | theOrigin.X() - loc.X(), |
270 | theOrigin.Y() - loc.Y(), |
271 | theOrigin.Z() - loc.Z() |
272 | }; |
424cd6bb |
273 | |
9bd59d1c |
274 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
424cd6bb |
275 | |
9bd59d1c |
276 | return myEpsilon = |
277 | aGauss.Compute(theSurface, theDomain, loc, theEps, |
278 | aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
279 | } |
280 | |
9bd59d1c |
281 | //======================================================================= |
282 | //function : Perform |
283 | //purpose : |
284 | //======================================================================= |
285 | void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface, |
286 | const gp_Pnt& theOrigin) |
287 | { |
288 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
289 | const Standard_Real aCoeff[] = |
290 | { |
291 | theOrigin.X() - loc.X(), |
292 | theOrigin.Y() - loc.Y(), |
293 | theOrigin.Z() - loc.Z() |
294 | }; |
424cd6bb |
295 | |
9bd59d1c |
296 | myEpsilon = 1.0; |
297 | aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
298 | } |
299 | |
9bd59d1c |
300 | //======================================================================= |
301 | //function : Perform |
302 | //purpose : |
303 | //======================================================================= |
304 | void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
305 | BRepGProp_Domain& theDomain, |
306 | const gp_Pnt& theOrigin) |
307 | { |
308 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
309 | const Standard_Real aCoeff[] = |
310 | { |
311 | theOrigin.X() - loc.X(), |
312 | theOrigin.Y() - loc.Y(), |
313 | theOrigin.Z() - loc.Z() |
314 | }; |
424cd6bb |
315 | |
9bd59d1c |
316 | myEpsilon = 1.0; |
317 | aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia); |
424cd6bb |
318 | } |
319 | |
9bd59d1c |
320 | //======================================================================= |
321 | //function : |
322 | //purpose : |
323 | //======================================================================= |
324 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
325 | const gp_Pln& thePlane, |
326 | const Standard_Real theEps) |
327 | { |
328 | BRepGProp_Domain anEmptyDomain; |
329 | return Perform(theSurface, anEmptyDomain, thePlane, theEps); |
330 | } |
331 | |
332 | //======================================================================= |
333 | //function : Perform |
334 | //purpose : |
335 | //======================================================================= |
336 | Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
337 | BRepGProp_Domain& theDomain, |
338 | const gp_Pln& thePlane, |
339 | const Standard_Real theEps) |
340 | { |
341 | Standard_Real aCoeff[4]; |
342 | thePlane.Coefficients(aCoeff[0], aCoeff[1], aCoeff[2], aCoeff[3]); |
343 | aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X() |
344 | - aCoeff[1] * loc.Y() |
345 | - aCoeff[2] * loc.Z(); |
424cd6bb |
346 | |
9bd59d1c |
347 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
424cd6bb |
348 | |
9bd59d1c |
349 | return myEpsilon = |
350 | aGauss.Compute(theSurface, theDomain, loc, theEps, |
351 | aCoeff, Standard_False, dim, g, inertia); |
424cd6bb |
352 | } |
353 | |
9bd59d1c |
354 | //======================================================================= |
355 | //function : Perform |
356 | //purpose : |
357 | //======================================================================= |
358 | void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface, |
359 | const gp_Pln& thePlane) |
360 | { |
361 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
362 | Standard_Real aCoeff[4]; |
424cd6bb |
363 | |
9bd59d1c |
364 | thePlane.Coefficients (aCoeff[0], |
365 | aCoeff[1], |
366 | aCoeff[2], |
367 | aCoeff[3]); |
424cd6bb |
368 | |
9bd59d1c |
369 | aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X() |
370 | - aCoeff[1] * loc.Y() |
371 | - aCoeff[2] * loc.Z(); |
424cd6bb |
372 | |
424cd6bb |
373 | myEpsilon = 1.0; |
9bd59d1c |
374 | aGauss.Compute(theSurface, loc, aCoeff, Standard_False, dim, g, inertia); |
424cd6bb |
375 | } |
376 | |
9bd59d1c |
377 | //======================================================================= |
378 | //function : Perform |
379 | //purpose : |
380 | //======================================================================= |
381 | void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface, |
382 | BRepGProp_Domain& theDomain, |
383 | const gp_Pln& thePlane) |
384 | { |
385 | BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert); |
386 | Standard_Real aCoeff[4]; |
424cd6bb |
387 | |
9bd59d1c |
388 | thePlane.Coefficients (aCoeff[0], |
389 | aCoeff[1], |
390 | aCoeff[2], |
391 | aCoeff[3]); |
424cd6bb |
392 | |
9bd59d1c |
393 | aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X() |
394 | - aCoeff[1] * loc.Y() |
395 | - aCoeff[2] * loc.Z(); |
424cd6bb |
396 | |
424cd6bb |
397 | myEpsilon = 1.0; |
9bd59d1c |
398 | aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_False, dim, g, inertia); |
424cd6bb |
399 | } |
400 | |
9bd59d1c |
401 | //======================================================================= |
402 | //function : GetEpsilon |
403 | //purpose : |
404 | //======================================================================= |
405 | Standard_Real BRepGProp_Vinert::GetEpsilon() |
406 | { |
424cd6bb |
407 | return myEpsilon; |
408 | } |