0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / BRepGProp / BRepGProp_Sinert.cxx
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
15
16 #include <BRepGProp_Domain.hxx>
17 #include <BRepGProp_Face.hxx>
18 #include <BRepGProp_Gauss.hxx>
19 #include <BRepGProp_Sinert.hxx>
20 #include <gp_Pnt.hxx>
21
22 //=======================================================================
23 //function : BRepGProp_Sinert
24 //purpose  : Constructor
25 //=======================================================================
26 BRepGProp_Sinert::BRepGProp_Sinert()
27 : myEpsilon(0.0)
28 {
29 }
30
31 //=======================================================================
32 //function : BRepGProp_Sinert
33 //purpose  : Constructor
34 //=======================================================================
35 BRepGProp_Sinert::BRepGProp_Sinert (const BRepGProp_Face& theSurface,
36                                     const gp_Pnt&         theLocation)
37 {
38   SetLocation(theLocation);
39   Perform(theSurface);
40 }
41
42 //=======================================================================
43 //function : BRepGProp_Sinert
44 //purpose  : Constructor
45 //=======================================================================
46 BRepGProp_Sinert::BRepGProp_Sinert(BRepGProp_Face&   theSurface,
47                                    BRepGProp_Domain& theDomain,
48                                    const gp_Pnt&     theLocation)
49 {
50   SetLocation(theLocation);
51   Perform(theSurface, theDomain);
52 }
53
54 //=======================================================================
55 //function : BRepGProp_Sinert
56 //purpose  : Constructor
57 //=======================================================================
58 BRepGProp_Sinert::BRepGProp_Sinert(BRepGProp_Face&     theSurface,
59                                    const gp_Pnt&       theLocation,
60                                    const Standard_Real theEps)
61 {
62   SetLocation(theLocation);
63   Perform(theSurface, theEps);
64 }
65
66 //=======================================================================
67 //function : BRepGProp_Sinert
68 //purpose  : Constructor
69 //=======================================================================
70 BRepGProp_Sinert::BRepGProp_Sinert(BRepGProp_Face&     theSurface,
71                                    BRepGProp_Domain&   theDomain,
72                                    const gp_Pnt&       theLocation,
73                                    const Standard_Real theEps)
74 {
75   SetLocation(theLocation);
76   Perform(theSurface, theDomain, theEps);
77 }
78
79 //=======================================================================
80 //function : SetLocation
81 //purpose  : 
82 //=======================================================================
83 void BRepGProp_Sinert::SetLocation(const gp_Pnt& theLocation)
84 {
85   loc = theLocation;
86 }
87
88 //=======================================================================
89 //function : Perform
90 //purpose  : 
91 //=======================================================================
92 void BRepGProp_Sinert::Perform(const BRepGProp_Face& theSurface)
93 {
94   myEpsilon = 1.0;
95
96   BRepGProp_Gauss aGauss(BRepGProp_Gauss::Sinert);
97   aGauss.Compute(theSurface, loc, dim, g, inertia);
98 }
99
100 //=======================================================================
101 //function : Perform
102 //purpose  : 
103 //=======================================================================
104 void BRepGProp_Sinert::Perform(BRepGProp_Face&   theSurface,
105                                BRepGProp_Domain& theDomain)
106 {
107   myEpsilon = 1.0;
108
109   BRepGProp_Gauss aGauss(BRepGProp_Gauss::Sinert);
110   aGauss.Compute(theSurface, theDomain, loc, dim, g, inertia);
111 }
112
113 //=======================================================================
114 //function : Perform
115 //purpose  : 
116 //=======================================================================
117 Standard_Real BRepGProp_Sinert::Perform(BRepGProp_Face&     theSurface,
118                                         const Standard_Real theEps)
119 {
120   BRepGProp_Domain anEmptyDomian;
121   return Perform(theSurface, anEmptyDomian, theEps);
122 }
123
124 //=======================================================================
125 //function : Perform
126 //purpose  : 
127 //=======================================================================
128 Standard_Real BRepGProp_Sinert::Perform(BRepGProp_Face&     theSurface,
129                                         BRepGProp_Domain&   theDomain,
130                                         const Standard_Real theEps)
131 {
132   BRepGProp_Gauss  aGauss(BRepGProp_Gauss::Sinert);
133   return myEpsilon = aGauss.Compute(theSurface, theDomain, loc, theEps, dim, g, inertia);
134 }
135
136 //=======================================================================
137 //function : GetEpsilon
138 //purpose  : 
139 //=======================================================================
140 Standard_Real BRepGProp_Sinert::GetEpsilon()
141 {
142   return myEpsilon;
143 }