1 -- Created on: 2005-12-21
2 -- Created by: Sergey KHROMOV
3 -- Copyright (c) 2005-2014 OPEN CASCADE SAS
5 -- This file is part of Open CASCADE Technology software library.
7 -- This library is free software; you can redistribute it and / or modify it
8 -- under the terms of the GNU Lesser General Public version 2.1 as published
9 -- by the Free Software Foundation, with special exception defined in the file
10 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 -- distribution for complete text of the license and disclaimer of any warranty.
13 -- Alternatively, this file may be used under the terms of Open CASCADE
14 -- commercial license or contractual agreement.
16 generic class VGPropsGK from GProp (Arc as any;
17 Face as any; -- as FaceTool(Arc)
18 Domain as any -- as DomainTool(Arc)
20 inherits GProps from GProp
22 ---Purpose: Computes the global properties of a geometric solid
23 -- (3D closed region of space) delimited with :
24 -- - a point and a surface
25 -- - a plane and a surface
27 -- The surface can be :
28 -- - a surface limited with its parametric values U-V,
29 -- (naturally restricted)
30 -- - a surface limited in U-V space with its boundary
33 -- The surface's requirements to evaluate the global
34 -- properties are defined in the template FaceTool class from
37 -- The adaptive 2D algorithm of Gauss-Kronrod integration of
38 -- double integral is used.
40 -- The inner integral is computed along U parameter of
41 -- surface. The integrand function is encapsulated in the
42 -- support class UFunction that is defined below.
44 -- The outer integral is computed along T parameter of a
45 -- bounding curve. The integrand function is encapsulated in
46 -- the support class TFunction that is defined below.
53 Address from Standard,
54 Boolean from Standard,
58 -- Template class functions. Used for integration. Begin
60 class UFunction from GProp inherits Function from math
61 ---Purpose: This class represents the integrand function for
62 -- computation of an inner integral. The returned value
63 -- depends on the value type and the flag IsByPoint.
65 -- The type of returned value is the one of the following
67 -- - GProp_Mass - volume computation.
68 -- - GProp_CenterMassX, GProp_CenterMassY,
69 -- GProp_CenterMassZ - X, Y and Z coordinates of center
70 -- of mass computation.
71 -- - GProp_InertiaXX, GProp_InertiaYY, GProp_InertiaZZ,
72 -- GProp_InertiaXY, GProp_InertiaXZ, GProp_InertiaYZ
73 -- - moments of inertia computation.
75 -- If the flag IsByPoint is set to Standard_True, the value is
76 -- returned for the region of space that is delimited by a
77 -- surface and a point. Otherwise all computations are
78 -- performed for the region of space delimited by a surface
85 Address from Standard,
86 Boolean from Standard,
92 Create(theSurface: Face;
93 theVertex : Pnt from gp;
94 IsByPoint : Boolean from Standard;
95 theCoeffs : Address from Standard)
96 ---Purpose: Constructor. Initializes the function with the face, the
97 -- location point, the flag IsByPoint and the coefficients
98 -- theCoeff that have different meaning depending on the value
100 -- If IsByPoint is equal to Standard_True, the number of the
101 -- coefficients is equal to 3 and they represent X, Y and Z
102 -- coordinates (theCoeff[0], theCoeff[1] and theCoeff[2]
103 -- correspondingly) of the shift, if the inertia is computed
104 -- with respect to the point different then the location.
105 -- If IsByPoint is equal to Standard_False, the number of the
106 -- coefficients is 4 and they represent the combination of
107 -- plane parameters and shift values.
108 returns UFunction from GProp;
110 SetValueType(me: in out; theType: ValueType from GProp);
111 ---Purpose: Setting the type of the value to be returned.
114 SetVParam(me: in out; theVParam: Real from Standard);
115 ---Purpose: Setting the V parameter that is constant during the
116 -- integral computation.
119 Value(me: in out; X: Real from Standard;
120 F: out Real from Standard)
121 ---Purpose: Returns a value of the function.
122 returns Boolean from Standard
125 -----------------------
126 -- Private methods --
127 -----------------------
129 VolumeValue(me: in out; X : Real from Standard;
130 thePMP0: out XYZ from gp;
131 theS : out Real from Standard;
132 theD1 : out Real from Standard)
133 ---Purpose: Private method. Returns the value for volume computation.
134 -- Other returned values are:
135 -- - thePMP0 - PSurf(X,Y) minus Location.
136 -- - theS and theD1 coeffitients that are computed and used
137 -- for computation of center of mass and inertia values
139 returns Real from Standard
142 CenterMassValue(me: in out; X: Real from Standard;
143 F: out Real from Standard)
144 ---Purpose: Private method. Returns a value for the center of mass
145 -- computation. If the value type other then GProp_CenterMassX,
146 -- GProp_CenterMassY or GProp_CenterMassZ this method returns
147 -- Standard_False. Returns Standard_True in case of successful
148 -- computation of a value.
149 returns Boolean from Standard
152 InertiaValue(me: in out; X: Real from Standard;
153 F: out Real from Standard)
154 ---Purpose: Private method. Computes the value of intertia. The type of
155 -- a value returned is defined by the value type. If it is
156 -- other then GProp_InertiaXX, GProp_InertiaYY,
157 -- GProp_InertiaZZ, GProp_InertiaXY, GProp_InertiaXZ or
158 -- GProp_InertiaYZ, the method returns Standard_False. Returns
159 -- Standard_True in case of successful computation of a value.
160 returns Boolean from Standard
166 myVertex : Pnt from gp;
167 myCoeffs : Address from Standard;
168 myVParam : Real from Standard;
169 myValueType: ValueType from GProp;
170 myIsByPoint: Boolean from Standard;
177 class TFunction from GProp inherits Function from math
178 ---Purpose: This class represents the integrand function for the outer
179 -- integral computation. The returned value represents the
180 -- integral of UFunction. It depends on the value type and the
186 Address from Standard,
187 Boolean from Standard,
188 Integer from Standard,
194 Create(theSurface : Face;
195 theVertex : Pnt from gp;
196 IsByPoint : Boolean from Standard;
197 theCoeffs : Address from Standard;
198 theUMin : Real from Standard;
199 theTolerance: Real from Standard)
200 ---Purpose: Constructor. Initializes the function with the face, the
201 -- location point, the flag IsByPoint, the coefficients
202 -- theCoeff that have different meaning depending on the value
203 -- of IsByPoint. The last two parameters are theUMin - the
204 -- lower bound of the inner integral. This value is fixed for
205 -- any integral. And the value of tolerance of inner integral
207 -- If IsByPoint is equal to Standard_True, the number of the
208 -- coefficients is equal to 3 and they represent X, Y and Z
209 -- coordinates (theCoeff[0], theCoeff[1] and theCoeff[2]
210 -- correspondingly) of the shift if the inertia is computed
211 -- with respect to the point different then the location.
212 -- If IsByPoint is equal to Standard_False, the number of the
213 -- coefficients is 4 and they represent the compbination of
214 -- plane parameters and shift values.
215 returns TFunction from GProp;
219 SetNbKronrodPoints(me: in out; theNbPoints: Integer from Standard);
220 ---Purpose: Setting the expected number of Kronrod points for the outer
221 -- integral computation. This number is required for
222 -- computation of a value of tolerance for inner integral
223 -- computation. After GetStateNumber method call, this number
224 -- is recomputed by the same law as in
225 -- math_KronrodSingleIntegration, i.e. next number of points
226 -- is equal to the current number plus a square root of the
227 -- current number. If the law in math_KronrodSingleIntegration
228 -- is changed, the modification algo should be modified
232 SetValueType(me: in out; aType: ValueType from GProp);
233 ---Purpose: Setting the type of the value to be returned. This
234 -- parameter is directly passed to the UFunction.
237 SetTolerance(me: in out; aTol: Real from Standard);
238 ---Purpose: Setting the tolerance for inner integration
242 ---Purpose: Returns the relative reached error of all values computation since
243 -- the last call of GetStateNumber method.
245 returns Real from Standard;
248 ---Purpose: Returns the absolut reached error of all values computation since
249 -- the last call of GetStateNumber method.
251 returns Real from Standard;
253 Value(me: in out; X: Real from Standard;
254 F: out Real from Standard)
255 ---Purpose: Returns a value of the function. The value represents an
256 -- integral of UFunction. It is computed with the predefined
257 -- tolerance using the adaptive Gauss-Kronrod method.
258 returns Boolean from Standard
261 GetStateNumber(me: in out)
262 ---Purpose: Redefined method. Remembers the error reached during
263 -- computation of integral values since the object creation
264 -- or the last call of GetStateNumber. It is invoked in each
265 -- algorithm from the package math. Particularly in the
266 -- algorithm math_KronrodSingleIntegration that is used to
267 -- compute the integral of TFunction.
274 myUFunction : UFunction;
275 myUMin : Real from Standard;
276 myTolerance : Real from Standard;
277 myTolReached: Real from Standard;
278 myErrReached: Real from Standard;
279 myAbsError : Real from Standard;
280 myValueType : ValueType from GProp;
281 myIsByPoint : Boolean from Standard;
282 myNbPntOuter: Integer from Standard;
286 -- Template class functions. Used for integration. End
291 ---Purpose: Empty constructor.
295 Create(theSurface : in out Face;
296 theLocation : Pnt from gp;
297 theTolerance: Real from Standard = 0.001;
298 theCGFlag: Boolean from Standard = Standard_False;
299 theIFlag: Boolean from Standard = Standard_False)
300 ---Purpose: Constructor. Computes the global properties of a region of
301 -- 3D space delimited with the naturally restricted surface
302 -- and the point VLocation.
305 Create(theSurface : in out Face;
306 thePoint : Pnt from gp;
307 theLocation : Pnt from gp;
308 theTolerance: Real from Standard = 0.001;
309 theCGFlag: Boolean from Standard = Standard_False;
310 theIFlag: Boolean from Standard = Standard_False)
312 ---Purpose: Constructor. Computes the global properties of a region of
313 -- 3D space delimited with the naturally restricted surface
314 -- and the point VLocation. The inertia is computed with
315 -- respect to thePoint.
318 Create(theSurface : in out Face;
319 theDomain : in out Domain;
320 theLocation : Pnt from gp;
321 theTolerance: Real from Standard = 0.001;
322 theCGFlag: Boolean from Standard = Standard_False;
323 theIFlag: Boolean from Standard = Standard_False)
325 ---Purpose: Constructor. Computes the global properties of a region of
326 -- 3D space delimited with the surface bounded by the domain
327 -- and the point VLocation.
330 Create(theSurface : in out Face;
331 theDomain : in out Domain;
332 thePoint : Pnt from gp;
333 theLocation : Pnt from gp;
334 theTolerance: Real from Standard = 0.001;
335 theCGFlag: Boolean from Standard = Standard_False;
336 theIFlag: Boolean from Standard = Standard_False)
337 ---Purpose: Constructor. Computes the global properties of a region of
338 -- 3D space delimited with the surface bounded by the domain
339 -- and the point VLocation. The inertia is computed with
340 -- respect to thePoint.
343 Create(theSurface : in out Face;
344 thePlane : Pln from gp;
345 theLocation : Pnt from gp;
346 theTolerance: Real from Standard = 0.001;
347 theCGFlag: Boolean from Standard = Standard_False;
348 theIFlag: Boolean from Standard = Standard_False)
350 ---Purpose: Constructor. Computes the global properties of a region of
351 -- 3D space delimited with the naturally restricted surface
355 Create(theSurface : in out Face;
356 theDomain : in out Domain;
357 thePlane : Pln from gp;
358 theLocation : Pnt from gp;
359 theTolerance: Real from Standard = 0.001;
360 theCGFlag: Boolean from Standard = Standard_False;
361 theIFlag: Boolean from Standard = Standard_False)
363 ---Purpose: Constructor. Computes the global properties of a region of
364 -- 3D space delimited with the surface bounded by the domain
368 SetLocation(me: in out; theLocation: Pnt from gp);
369 ---Purpose: Sets the vertex that delimit 3D closed region of space.
372 Perform(me: in out; theSurface : in out Face;
373 theTolerance: Real from Standard = 0.001;
374 theCGFlag: Boolean from Standard = Standard_False;
375 theIFlag: Boolean from Standard = Standard_False)
377 ---Purpose: Computes the global properties of a region of 3D space
378 -- delimited with the naturally restricted surface and the
380 returns Real from Standard;
382 Perform(me: in out; theSurface : in out Face;
383 thePoint : Pnt from gp;
384 theTolerance: Real from Standard = 0.001;
385 theCGFlag: Boolean from Standard = Standard_False;
386 theIFlag: Boolean from Standard = Standard_False)
388 ---Purpose: Computes the global properties of a region of 3D space
389 -- delimited with the naturally restricted surface and the
390 -- point VLocation. The inertia is computed with respect to
392 returns Real from Standard;
394 Perform(me: in out; theSurface : in out Face;
395 theDomain : in out Domain;
396 theTolerance: Real from Standard = 0.001;
397 theCGFlag: Boolean from Standard = Standard_False;
398 theIFlag: Boolean from Standard = Standard_False)
400 ---Purpose: Computes the global properties of a region of 3D space
401 -- delimited with the surface bounded by the domain and the
403 returns Real from Standard;
405 Perform(me: in out; theSurface : in out Face;
406 theDomain : in out Domain;
407 thePoint : Pnt from gp;
408 theTolerance: Real from Standard = 0.001;
409 theCGFlag: Boolean from Standard = Standard_False;
410 theIFlag: Boolean from Standard = Standard_False)
411 ---Purpose: Computes the global properties of a region of 3D space
412 -- delimited with the surface bounded by the domain and the
413 -- point VLocation. The inertia is computed with respect to
415 returns Real from Standard;
417 Perform(me: in out; theSurface : in out Face;
418 thePlane : Pln from gp;
419 theTolerance: Real from Standard = 0.001;
420 theCGFlag: Boolean from Standard = Standard_False;
421 theIFlag: Boolean from Standard = Standard_False)
423 ---Purpose: Computes the global properties of a region of 3D space
424 -- delimited with the naturally restricted surface and the
426 returns Real from Standard;
428 Perform(me: in out; theSurface : in out Face;
429 theDomain : in out Domain;
430 thePlane : Pln from gp;
431 theTolerance: Real from Standard = 0.001;
432 theCGFlag: Boolean from Standard = Standard_False;
433 theIFlag: Boolean from Standard = Standard_False)
435 ---Purpose: Computes the global properties of a region of 3D space
436 -- delimited with the surface bounded by the domain and the
438 returns Real from Standard;
441 ---Purpose: Returns the relative reached computation error.
443 returns Real from Standard;
446 ---Purpose: Returns the absolut reached computation error.
448 returns Real from Standard;
450 -----------------------
451 -- Private methods --
452 -----------------------
454 PrivatePerform(me: in out;
455 theSurface : in out Face;
456 thePtrDomain: Address from Standard; -- pointer to Domain.
457 IsByPoint : Boolean from Standard;
458 theCoeffs : Address from Standard;
459 theTolerance: Real from Standard;
460 theCGFlag : Boolean from Standard;
461 theIFlag : Boolean from Standard)
463 ---Purpose: Main method for computation of the global properties that
464 -- is invoked by each Perform method.
465 returns Real from Standard
470 myErrorReached: Real from Standard;
471 myAbsolutError: Real from Standard;