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()
31 //=======================================================================
32 //function : BRepGProp_Vinert
34 //=======================================================================
35 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
36 const gp_Pnt& theLocation,
37 const Standard_Real theEps)
39 SetLocation(theLocation);
40 Perform(theSurface, theEps);
43 //=======================================================================
44 //function : BRepGProp_Vinert
46 //=======================================================================
47 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
48 BRepGProp_Domain& theDomain,
49 const gp_Pnt& theLocation,
50 const Standard_Real theEps)
52 SetLocation(theLocation);
53 Perform(theSurface, theDomain, theEps);
56 //=======================================================================
57 //function : BRepGProp_Vinert
59 //=======================================================================
60 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
61 BRepGProp_Domain& theDomain,
62 const gp_Pnt& theLocation)
64 SetLocation(theLocation);
65 Perform(theSurface, theDomain);
68 //=======================================================================
69 //function : BRepGProp_Vinert
71 //=======================================================================
72 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
73 const gp_Pnt& theLocation)
75 SetLocation(theLocation);
79 //=======================================================================
80 //function : BRepGProp_Vinert
82 //=======================================================================
83 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
84 const gp_Pnt& theOrigin,
85 const gp_Pnt& theLocation,
86 const Standard_Real theEps)
88 SetLocation(theLocation);
89 Perform(theSurface, theOrigin, theEps);
92 //=======================================================================
93 //function : BRepGProp_Vinert
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)
102 SetLocation(theLocation);
103 Perform(theSurface, theDomain, theOrigin, theEps);
106 //=======================================================================
107 //function : BRepGProp_Vinert
109 //=======================================================================
110 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
111 const gp_Pnt& theOrigin,
112 const gp_Pnt& theLocation)
114 SetLocation(theLocation);
115 Perform(theSurface, theOrigin);
118 //=======================================================================
119 //function : BRepGProp_Vinert
121 //=======================================================================
122 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
123 BRepGProp_Domain& theDomain,
124 const gp_Pnt& theOrigin,
125 const gp_Pnt& theLocation)
127 SetLocation(theLocation);
128 Perform(theSurface, theDomain, theOrigin);
131 //=======================================================================
132 //function : BRepGProp_Vinert
134 //=======================================================================
135 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
136 const gp_Pln& thePlane,
137 const gp_Pnt& theLocation,
138 const Standard_Real theEps)
140 SetLocation(theLocation);
141 Perform(theSurface, thePlane, theEps);
144 //=======================================================================
145 //function : BRepGProp_Vinert
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)
154 SetLocation(theLocation);
155 Perform(theSurface, theDomain, thePlane, theEps);
158 //=======================================================================
159 //function : BRepGProp_Vinert
161 //=======================================================================
162 BRepGProp_Vinert::BRepGProp_Vinert(const BRepGProp_Face& theSurface,
163 const gp_Pln& thePlane,
164 const gp_Pnt& theLocation)
166 SetLocation(theLocation);
167 Perform(theSurface, thePlane);
170 //=======================================================================
171 //function : BRepGProp_Vinert
173 //=======================================================================
174 BRepGProp_Vinert::BRepGProp_Vinert(BRepGProp_Face& theSurface,
175 BRepGProp_Domain& theDomain,
176 const gp_Pln& thePlane,
177 const gp_Pnt& theLocation)
179 SetLocation(theLocation);
180 Perform(theSurface, theDomain, thePlane);
183 //=======================================================================
184 //function : SetLocation
186 //=======================================================================
187 void BRepGProp_Vinert::SetLocation(const gp_Pnt& theLocation)
192 //=======================================================================
195 //=======================================================================
196 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
197 const Standard_Real theEps)
199 BRepGProp_Domain anEmptyDomain;
200 return Perform(theSurface, anEmptyDomain, theEps);
203 //=======================================================================
206 //=======================================================================
207 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
208 BRepGProp_Domain& theDomain,
209 const Standard_Real theEps)
211 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
212 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
215 aGauss.Compute(theSurface, theDomain, loc, theEps,
216 aCoeff, Standard_True, dim, g, inertia);
219 //=======================================================================
222 //=======================================================================
223 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface)
225 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
226 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
229 aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia);
232 //=======================================================================
235 //=======================================================================
236 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
237 BRepGProp_Domain& theDomain)
239 const Standard_Real aCoeff[] = {0.0, 0.0, 0.0};
240 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
243 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia);
246 //=======================================================================
249 //=======================================================================
250 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
251 const gp_Pnt& theOrigin,
252 const Standard_Real theEps)
254 BRepGProp_Domain anEmptyDomain;
255 return Perform(theSurface, anEmptyDomain, theOrigin, theEps);
258 //=======================================================================
261 //=======================================================================
262 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
263 BRepGProp_Domain& theDomain,
264 const gp_Pnt& theOrigin,
265 const Standard_Real theEps)
267 const Standard_Real aCoeff[] =
269 theOrigin.X() - loc.X(),
270 theOrigin.Y() - loc.Y(),
271 theOrigin.Z() - loc.Z()
274 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
277 aGauss.Compute(theSurface, theDomain, loc, theEps,
278 aCoeff, Standard_True, dim, g, inertia);
281 //=======================================================================
284 //=======================================================================
285 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface,
286 const gp_Pnt& theOrigin)
288 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
289 const Standard_Real aCoeff[] =
291 theOrigin.X() - loc.X(),
292 theOrigin.Y() - loc.Y(),
293 theOrigin.Z() - loc.Z()
297 aGauss.Compute(theSurface, loc, aCoeff, Standard_True, dim, g, inertia);
300 //=======================================================================
303 //=======================================================================
304 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
305 BRepGProp_Domain& theDomain,
306 const gp_Pnt& theOrigin)
308 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
309 const Standard_Real aCoeff[] =
311 theOrigin.X() - loc.X(),
312 theOrigin.Y() - loc.Y(),
313 theOrigin.Z() - loc.Z()
317 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_True, dim, g, inertia);
320 //=======================================================================
323 //=======================================================================
324 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
325 const gp_Pln& thePlane,
326 const Standard_Real theEps)
328 BRepGProp_Domain anEmptyDomain;
329 return Perform(theSurface, anEmptyDomain, thePlane, theEps);
332 //=======================================================================
335 //=======================================================================
336 Standard_Real BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
337 BRepGProp_Domain& theDomain,
338 const gp_Pln& thePlane,
339 const Standard_Real theEps)
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();
347 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
350 aGauss.Compute(theSurface, theDomain, loc, theEps,
351 aCoeff, Standard_False, dim, g, inertia);
354 //=======================================================================
357 //=======================================================================
358 void BRepGProp_Vinert::Perform(const BRepGProp_Face& theSurface,
359 const gp_Pln& thePlane)
361 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
362 Standard_Real aCoeff[4];
364 thePlane.Coefficients (aCoeff[0],
369 aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X()
370 - aCoeff[1] * loc.Y()
371 - aCoeff[2] * loc.Z();
374 aGauss.Compute(theSurface, loc, aCoeff, Standard_False, dim, g, inertia);
377 //=======================================================================
380 //=======================================================================
381 void BRepGProp_Vinert::Perform(BRepGProp_Face& theSurface,
382 BRepGProp_Domain& theDomain,
383 const gp_Pln& thePlane)
385 BRepGProp_Gauss aGauss(BRepGProp_Gauss::Vinert);
386 Standard_Real aCoeff[4];
388 thePlane.Coefficients (aCoeff[0],
393 aCoeff[3] = aCoeff[3] - aCoeff[0] * loc.X()
394 - aCoeff[1] * loc.Y()
395 - aCoeff[2] * loc.Z();
398 aGauss.Compute(theSurface, theDomain, loc, aCoeff, Standard_False, dim, g, inertia);
401 //=======================================================================
402 //function : GetEpsilon
404 //=======================================================================
405 Standard_Real BRepGProp_Vinert::GetEpsilon()