b311480e |
1 | -- Created on: 1992-12-04 |
2 | -- Created by: Isabelle GRIGNON |
3 | -- Copyright (c) 1992-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 | package BRepGProp |
18 | |
19 | ---Purpose: Provides global functions to compute a shape's global |
20 | -- properties for lines, surfaces or volumes, and bring |
21 | -- them together with the global properties already |
22 | -- computed for a geometric system. |
23 | -- The global properties computed for a system are : |
24 | -- - its mass, |
25 | -- - its center of mass, |
26 | -- - its matrix of inertia, |
27 | -- - its moment about an axis, |
28 | -- - its radius of gyration about an axis, |
29 | -- - and its principal properties of inertia such as |
30 | -- principal axis, principal moments, principal radius of gyration. |
31 | |
32 | uses GProp, |
33 | BRepAdaptor, |
34 | BRepTools, |
35 | BRep, |
36 | TopExp, |
37 | TopoDS, |
38 | Geom2dAdaptor, |
39 | gp, |
40 | GeomAbs, |
41 | TColStd |
42 | |
43 | is |
44 | |
45 | class EdgeTool; |
46 | |
47 | class Face; |
424cd6bb |
48 | |
7fd59977 |
49 | class Domain; |
424cd6bb |
50 | |
51 | class Cinert; |
7fd59977 |
52 | |
424cd6bb |
53 | class Sinert; |
54 | |
55 | class Vinert; |
56 | |
57 | class VinertGK; |
58 | |
59 | class UFunction; |
60 | class TFunction; |
7fd59977 |
61 | |
7fd59977 |
62 | -- |
63 | -- Package methods to compute global properties. |
424cd6bb |
64 | -- |
7fd59977 |
65 | |
66 | LinearProperties(S : Shape from TopoDS; LProps : in out GProps from GProp); |
67 | ---Purpose: Computes the linear global properties of the shape S, |
68 | -- i.e. the global properties induced by each edge of the |
69 | -- shape S, and brings them together with the global |
70 | -- properties still retained by the framework LProps. If |
71 | -- the current system of LProps was empty, its global |
72 | -- properties become equal to the linear global |
73 | -- properties of S. |
74 | -- For this computation no linear density is attached to |
75 | -- the edges. So, for example, the added mass |
76 | -- corresponds to the sum of the lengths of the edges of |
77 | -- S. The density of the composed systems, i.e. that of |
78 | -- each component of the current system of LProps, and |
79 | -- that of S which is considered to be equal to 1, must be coherent. |
80 | -- Note that this coherence cannot be checked. You are |
81 | -- advised to use a separate framework for each |
82 | -- density, and then to bring these frameworks together |
83 | -- into a global one. |
84 | -- The point relative to which the inertia of the system is |
85 | -- computed is the reference point of the framework LProps. |
86 | -- Note: if your programming ensures that the framework |
87 | -- LProps retains only linear global properties (brought |
88 | -- together for example, by the function |
89 | -- LinearProperties) for objects the density of which is |
90 | -- equal to 1 (or is not defined), the function Mass will |
91 | -- return the total length of edges of the system analysed by LProps. |
92 | -- Warning |
93 | -- No check is performed to verify that the shape S |
94 | -- retains truly linear properties. If S is simply a vertex, it |
95 | -- is not considered to present any additional global properties. |
96 | |
97 | SurfaceProperties(S : Shape from TopoDS; SProps : in out GProps from GProp); |
98 | ---Purpose: Computes the surface global properties of the |
99 | -- shape S, i.e. the global properties induced by each |
100 | -- face of the shape S, and brings them together with |
101 | -- the global properties still retained by the framework |
102 | -- SProps. If the current system of SProps was empty, |
103 | -- its global properties become equal to the surface |
104 | -- global properties of S. |
105 | -- For this computation, no surface density is attached |
106 | -- to the faces. Consequently, the added mass |
107 | -- corresponds to the sum of the areas of the faces of |
108 | -- S. The density of the component systems, i.e. that |
109 | -- of each component of the current system of |
110 | -- SProps, and that of S which is considered to be |
111 | -- equal to 1, must be coherent. |
112 | -- Note that this coherence cannot be checked. You |
113 | -- are advised to use a framework for each different |
114 | -- value of density, and then to bring these |
115 | -- frameworks together into a global one. |
116 | -- The point relative to which the inertia of the system |
117 | -- is computed is the reference point of the framework SProps. |
118 | -- Note : if your programming ensures that the |
119 | -- framework SProps retains only surface global |
120 | -- properties, brought together, for example, by the |
121 | -- function SurfaceProperties, for objects the density |
122 | -- of which is equal to 1 (or is not defined), the |
123 | -- function Mass will return the total area of faces of |
124 | -- the system analysed by SProps. |
125 | -- Warning |
126 | -- No check is performed to verify that the shape S |
127 | -- retains truly surface properties. If S is simply a |
128 | -- vertex, an edge or a wire, it is not considered to |
129 | -- present any additional global properties. |
130 | |
131 | SurfaceProperties(S : Shape from TopoDS; SProps : in out GProps from GProp; |
132 | Eps: Real) returns Real; |
133 | ---Purpose: Updates <SProps> with the shape <S>, that contains its pricipal properties. |
134 | -- The surface properties of all the faces in <S> are computed. |
135 | -- Adaptive 2D Gauss integration is used. |
136 | -- Parameter Eps sets maximal relative error of computed mass (area) for each face. |
137 | -- Error is calculated as Abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values |
138 | -- for two successive steps of adaptive integration. |
139 | -- Method returns estimation of relative error reached for whole shape. |
140 | -- WARNING: if Eps > 0.001 algorithm performs non-adaptive integration. |
141 | |
142 | |
143 | ------------------------ |
144 | -- VolumeProperties -- |
145 | ------------------------ |
146 | |
147 | ---Purpose: |
148 | -- Computes the global volume properties of the solid |
149 | -- S, and brings them together with the global |
150 | -- properties still retained by the framework VProps. If |
151 | -- the current system of VProps was empty, its global |
152 | -- properties become equal to the global properties of S for volume. |
153 | -- For this computation, no volume density is attached |
154 | -- to the solid. Consequently, the added mass |
155 | -- corresponds to the volume of S. The density of the |
156 | -- component systems, i.e. that of each component of |
157 | -- the current system of VProps, and that of S which |
158 | -- is considered to be equal to 1, must be coherent to each other. |
159 | -- Note that this coherence cannot be checked. You |
160 | -- are advised to use a separate framework for each |
161 | -- density, and then to bring these frameworks |
162 | -- together into a global one. |
163 | -- The point relative to which the inertia of the system |
164 | -- is computed is the reference point of the framework VProps. |
165 | -- Note: if your programming ensures that the |
166 | -- framework VProps retains only global properties of |
167 | -- volume (brought together for example, by the |
168 | -- function VolumeProperties) for objects the density |
169 | -- of which is equal to 1 (or is not defined), the |
170 | -- function Mass will return the total volume of the |
171 | -- solids of the system analysed by VProps. |
172 | -- Warning |
173 | -- The shape S must represent an object whose |
174 | -- global volume properties can be computed. It may |
175 | -- be a finite solid, or a series of finite solids all |
176 | -- oriented in a coherent way. Nonetheless, S must be |
177 | -- exempt of any free boundary. Note that these |
178 | -- conditions of coherence are not checked by this |
179 | -- algorithm, and results will be false if they are not respected. |
180 | VolumeProperties(S : Shape from TopoDS; VProps : in out GProps from GProp; |
181 | OnlyClosed: Boolean = Standard_False); |
182 | |
183 | VolumeProperties(S : Shape from TopoDS; VProps : in out GProps from GProp; |
184 | Eps: Real; OnlyClosed: Boolean = Standard_False) returns Real; |
185 | ---Purpose: Updates <VProps> with the shape <S>, that contains its pricipal properties. |
186 | -- The volume properties of all the FORWARD and REVERSED faces in <S> are computed. |
187 | -- If OnlyClosed is True then computed faces must belong to closed Shells. |
188 | -- Adaptive 2D Gauss integration is used. |
189 | -- Parameter Eps sets maximal relative error of computed mass (volume) for each face. |
190 | -- Error is calculated as Abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values |
191 | -- for two successive steps of adaptive integration. |
192 | -- Method returns estimation of relative error reached for whole shape. |
193 | -- WARNING: if Eps > 0.001 algorithm performs non-adaptive integration. |
194 | |
195 | |
196 | |
197 | |
198 | |
199 | |
200 | -- ---------------------------------------------------------------------------------------- |
201 | VolumePropertiesGK(S : Shape from TopoDS; |
202 | VProps : in out GProps from GProp; |
203 | Eps : Real from Standard = 0.001; |
204 | OnlyClosed: Boolean from Standard = Standard_False; |
205 | IsUseSpan : Boolean from Standard = Standard_False; |
206 | CGFlag : Boolean from Standard = Standard_False; |
207 | IFlag : Boolean from Standard = Standard_False) |
208 | |
209 | returns Real; |
210 | ---Purpose: Updates <VProps> with the shape <S>, that contains its pricipal properties. |
211 | -- The volume properties of all the FORWARD and REVERSED faces in <S> are computed. |
212 | -- If OnlyClosed is True then computed faces must belong to closed Shells. |
213 | -- Adaptive 2D Gauss integration is used. |
214 | -- Parameter IsUseSpan says if it is necessary to define spans on a face. |
215 | -- This option has an effect only for BSpline faces. |
216 | -- Parameter Eps sets maximal relative error of computed property for each face. |
217 | -- Error is delivered by the adaptive Gauss-Kronrod method of integral computation |
218 | -- that is used for properties computation. |
219 | -- Method returns estimation of relative error reached for whole shape. |
220 | -- Returns negative value if the computation is failed. |
221 | VolumePropertiesGK(S : Shape from TopoDS; |
222 | VProps : in out GProps from GProp; |
223 | thePln: Pln from gp; |
224 | Eps : Real from Standard = 0.001; |
225 | OnlyClosed: Boolean from Standard = Standard_False; |
226 | IsUseSpan : Boolean from Standard = Standard_False; |
227 | CGFlag : Boolean from Standard = Standard_False; |
228 | IFlag : Boolean from Standard = Standard_False) |
229 | returns Real; |
230 | |
231 | end BRepGProp; |
232 | |