1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <BRepGProp_Domain.hxx>
17 #include <BRepGProp_Face.hxx>
18 #include <BRepGProp_Gauss.hxx>
19 #include <BRepGProp_Vinert.hxx>
23 //=======================================================================
24 //function : BRepGProp_Vinert
25 //purpose : Constructor
26 //=======================================================================
27 BRepGProp_Vinert::BRepGProp_Vinert()
32 //=======================================================================
33 //function : BRepGProp_Vinert
35 //=======================================================================
36 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
37 const gp_Pnt& theLocation,
38 const Standard_Real theEps)
40 SetLocation(theLocation);
41 Perform(theSurface, theEps);
44 //=======================================================================
45 //function : BRepGProp_Vinert
47 //=======================================================================
48 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
49 BRepGProp_Domain& theDomain,
50 const gp_Pnt& theLocation,
51 const Standard_Real theEps)
53 SetLocation(theLocation);
54 Perform(theSurface, theDomain, theEps);
57 //=======================================================================
58 //function : BRepGProp_Vinert
60 //=======================================================================
61 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
62 BRepGProp_Domain& theDomain,
63 const gp_Pnt& theLocation)
65 SetLocation(theLocation);
66 Perform(theSurface, theDomain);
69 //=======================================================================
70 //function : BRepGProp_Vinert
72 //=======================================================================
73 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
74 const gp_Pnt& theLocation)
76 SetLocation(theLocation);
80 //=======================================================================
81 //function : BRepGProp_Vinert
83 //=======================================================================
84 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
85 const gp_Pnt& theOrigin,
86 const gp_Pnt& theLocation,
87 const Standard_Real theEps)
89 SetLocation(theLocation);
90 Perform(theSurface, theOrigin, theEps);
93 //=======================================================================
94 //function : BRepGProp_Vinert
96 //=======================================================================
97 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
98 BRepGProp_Domain& theDomain,
99 const gp_Pnt& theOrigin,
100 const gp_Pnt& theLocation,
101 const Standard_Real theEps)
103 SetLocation(theLocation);
104 Perform(theSurface, theDomain, theOrigin, theEps);
107 //=======================================================================
108 //function : BRepGProp_Vinert
110 //=======================================================================
111 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
112 const gp_Pnt& theOrigin,
113 const gp_Pnt& theLocation)
115 SetLocation(theLocation);
116 Perform(theSurface, theOrigin);
119 //=======================================================================
120 //function : BRepGProp_Vinert
122 //=======================================================================
123 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
124 BRepGProp_Domain& theDomain,
125 const gp_Pnt& theOrigin,
126 const gp_Pnt& theLocation)
128 SetLocation(theLocation);
129 Perform(theSurface, theDomain, theOrigin);
132 //=======================================================================
133 //function : BRepGProp_Vinert
135 //=======================================================================
136 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
137 const gp_Pln& thePlane,
138 const gp_Pnt& theLocation,
139 const Standard_Real theEps)
141 SetLocation(theLocation);
142 Perform(theSurface, thePlane, theEps);
145 //=======================================================================
146 //function : BRepGProp_Vinert
148 //=======================================================================
149 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
150 BRepGProp_Domain& theDomain,
151 const gp_Pln& thePlane,
152 const gp_Pnt& theLocation,
153 const Standard_Real theEps)
155 SetLocation(theLocation);
156 Perform(theSurface, theDomain, thePlane, theEps);
159 //=======================================================================
160 //function : BRepGProp_Vinert
162 //=======================================================================
163 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
164 const gp_Pln& thePlane,
165 const gp_Pnt& theLocation)
167 SetLocation(theLocation);
168 Perform(theSurface, thePlane);
171 //=======================================================================
172 //function : BRepGProp_Vinert
174 //=======================================================================
175 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
176 BRepGProp_Domain& theDomain,
177 const gp_Pln& thePlane,
178 const gp_Pnt& theLocation)
180 SetLocation(theLocation);
181 Perform(theSurface, theDomain, thePlane);
184 //=======================================================================
185 //function : SetLocation
187 //=======================================================================
188 void BRepGProp_Vinert::SetLocation(const gp_Pnt& theLocation)
193 //=======================================================================
196 //=======================================================================
197 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
198 const Standard_Real theEps)
200 BRepGProp_Domain anEmptyDomain;
201 return Perform(theSurface, anEmptyDomain, theEps);
204 //=======================================================================
207 //=======================================================================
208 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
209 BRepGProp_Domain& theDomain,
210 const Standard_Real theEps)
212 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
213 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
216 aGauss.Compute(theSurface, theDomain, loc, theEps,
217 aCoeff, Standard_True, dim, g, inertia);
220 //=======================================================================
223 //=======================================================================
224 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface)
226 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
227 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
230 aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia);
233 //=======================================================================
236 //=======================================================================
237 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
238 BRepGProp_Domain& theDomain)
240 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
241 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
244 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia);
247 //=======================================================================
250 //=======================================================================
251 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
252 const gp_Pnt& theOrigin,
253 const Standard_Real theEps)
255 BRepGProp_Domain anEmptyDomain;
256 return Perform(theSurface, anEmptyDomain, theOrigin, theEps);
259 //=======================================================================
262 //=======================================================================
263 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
264 BRepGProp_Domain& theDomain,
265 const gp_Pnt& theOrigin,
266 const Standard_Real theEps)
268 const Standard_Real aCoeff[] =
270 theOrigin.X() - loc.X(),
271 theOrigin.Y() - loc.Y(),
272 theOrigin.Z() - loc.Z()
275 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
278 aGauss.Compute(theSurface, theDomain, loc, theEps,
279 aCoeff, Standard_True, dim, g, inertia);
282 //=======================================================================
285 //=======================================================================
286 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface,
287 const gp_Pnt& theOrigin)
289 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
290 const Standard_Real aCoeff[] =
292 theOrigin.X() - loc.X(),
293 theOrigin.Y() - loc.Y(),
294 theOrigin.Z() - loc.Z()
298 aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia);
301 //=======================================================================
304 //=======================================================================
305 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
306 BRepGProp_Domain& theDomain,
307 const gp_Pnt& theOrigin)
309 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
310 const Standard_Real aCoeff[] =
312 theOrigin.X() - loc.X(),
313 theOrigin.Y() - loc.Y(),
314 theOrigin.Z() - loc.Z()
318 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia);
321 //=======================================================================
324 //=======================================================================
325 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
326 const gp_Pln& thePlane,
327 const Standard_Real theEps)
329 BRepGProp_Domain anEmptyDomain;
330 return Perform(theSurface, anEmptyDomain, thePlane, theEps);
333 //=======================================================================
336 //=======================================================================
337 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
338 BRepGProp_Domain& theDomain,
339 const gp_Pln& thePlane,
340 const Standard_Real theEps)
342 Standard_Real aCoeff[4];
343 thePlane.Coefficients(aCoeff[0], aCoeff[1], aCoeff[2], aCoeff[3]);
344 aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X()
345 - aCoeff[1] * loc.Y()
346 - aCoeff[2] * loc.Z();
348 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
351 aGauss.Compute(theSurface, theDomain, loc, theEps,
352 aCoeff, Standard_False, dim, g, inertia);
355 //=======================================================================
358 //=======================================================================
359 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface,
360 const gp_Pln& thePlane)
362 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
363 Standard_Real aCoeff[4];
365 thePlane.Coefficients (aCoeff[0],
370 aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X()
371 - aCoeff[1] * loc.Y()
372 - aCoeff[2] * loc.Z();
375 aGauss.Compute(theSurface, loc, aCoeff, Standard_False, dim, g, inertia);
378 //=======================================================================
381 //=======================================================================
382 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
383 BRepGProp_Domain& theDomain,
384 const gp_Pln& thePlane)
386 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
387 Standard_Real aCoeff[4];
389 thePlane.Coefficients (aCoeff[0],
394 aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X()
395 - aCoeff[1] * loc.Y()
396 - aCoeff[2] * loc.Z();
399 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_False, dim, g, inertia);
402 //=======================================================================
403 //function : GetEpsilon
405 //=======================================================================
406 Standard_Real BRepGProp_Vinert::GetEpsilon()