7fd59977 |
1 | // File Graphic3d_AspectFillArea3d.cxx |
2 | // Created Mars 1992 |
3 | // Author NW,JPB,CAL |
4 | // Modified 1/08/97 ; PCT : Ajout texture mapping |
5 | // 26/01/00 ; EUG/GG degeneration management (G003) |
6 | // Add SetDegenerateModel() and DegenerateModel() methods |
7 | // JR 02.01.100 : Initialization order of fields in contructors |
8 | // 29/09/00 ; GG Add SetDefaultDegerateModel() and |
9 | // DefaultDegenerateModel() class methods |
10 | // 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets |
11 | |
12 | //-Copyright MatraDatavision 1991,1992 |
13 | |
14 | //-Version |
15 | |
81bba717 |
16 | //-Design Declaration of variables specific to the context |
17 | // of tracing of facets 3D |
7fd59977 |
18 | |
81bba717 |
19 | //-Warning Ccontext of tracing of facets 3d inherits the context |
20 | // defined by : |
21 | // - the style of the interior of the facet |
22 | // - the style of the facet border |
23 | // - the color |
24 | // Additionally, it has more than one definition of material |
25 | // for internal and external faces. |
7fd59977 |
26 | |
27 | //-References |
28 | |
29 | //-Language C++ 2.0 |
30 | |
31 | //-Declarations |
32 | |
33 | // for the class |
34 | #include <Graphic3d_AspectFillArea3d.ixx> |
35 | |
36 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
37 | #include <Aspect_PolygonOffsetMode.hxx> |
38 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
39 | |
40 | #include <Standard_Boolean.hxx> |
41 | |
42 | //-Aliases |
43 | |
44 | //-Global data definitions |
45 | static Aspect_TypeOfDegenerateModel theDefaultDegenerateModel = Aspect_TDM_WIREFRAME; |
46 | static Quantity_Ratio theDefaultDegenerateRatio = 0.0; |
47 | |
48 | // -- la matiere |
49 | // MyFrontMaterial : MaterialAspect; |
50 | // MyBackMaterial : MaterialAspect; |
51 | |
52 | // -- flag de distinction entre faces internes et externes |
53 | // DistinguishModeActive : Standard_Boolean; |
54 | |
55 | // -- flag de trace des aretes |
56 | // EdgeModeActive : Standard_Boolean; |
57 | |
58 | // -- flag d'affichage des polygones tournant le dos |
59 | // BackFaceRemovalActive : Standard_Boolean; |
60 | |
61 | //-Constructors |
62 | |
63 | //-Destructors |
64 | |
65 | //-Methods, in order |
66 | |
67 | Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (): |
68 | DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial () { |
69 | MyDegenerateModel = theDefaultDegenerateModel; |
70 | MyDegenerateRatio = theDefaultDegenerateRatio; |
71 | |
72 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
73 | // By default, aspect do not change current polygon offset parameters |
74 | MyPolygonOffsetMode = Aspect_POM_None; |
75 | MyPolygonOffsetFactor = 1.; |
76 | MyPolygonOffsetUnits = 0.; |
77 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
78 | } |
79 | |
81bba717 |
80 | // (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth) |
81 | // because AspectFillArea3d inherits AspectFillArea and it is necessary to call |
82 | // initialisation of AspectFillArea with InteriorStyle, InteriorColor, |
83 | // EdgeColor, EdgeLineType and EdgeLineWidth. |
7fd59977 |
84 | |
85 | Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorStyle InteriorStyle, const Quantity_Color& InteriorColor, const Quantity_Color& EdgeColor, const Aspect_TypeOfLine EdgeLineType, const Standard_Real EdgeLineWidth, const Graphic3d_MaterialAspect& FrontMaterial, const Graphic3d_MaterialAspect& BackMaterial): |
86 | Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) { |
87 | MyDegenerateModel = theDefaultDegenerateModel; |
88 | MyDegenerateRatio = theDefaultDegenerateRatio; |
89 | |
90 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
91 | // By default, aspect do not change current polygon offset parameters |
92 | MyPolygonOffsetMode = Aspect_POM_None; |
93 | MyPolygonOffsetFactor = 1.; |
94 | MyPolygonOffsetUnits = 0.; |
95 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
96 | } |
97 | |
98 | void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) { |
99 | |
100 | MyBackMaterial = AMaterial; |
101 | |
102 | } |
103 | |
104 | void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) { |
105 | |
106 | MyFrontMaterial = AMaterial; |
107 | |
108 | } |
109 | |
110 | Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::BackMaterial () const { |
111 | |
112 | return (MyBackMaterial); |
113 | |
114 | } |
115 | |
116 | Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::FrontMaterial () const { |
117 | |
118 | return (MyFrontMaterial); |
119 | |
120 | } |
121 | |
122 | void Graphic3d_AspectFillArea3d::AllowBackFace () { |
123 | |
124 | BackFaceRemovalActive = Standard_False; |
125 | |
126 | } |
127 | |
128 | void Graphic3d_AspectFillArea3d::SuppressBackFace () { |
129 | |
130 | BackFaceRemovalActive = Standard_True; |
131 | |
132 | } |
133 | |
134 | Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const { |
135 | |
136 | return (BackFaceRemovalActive); |
137 | |
138 | } |
139 | |
140 | void Graphic3d_AspectFillArea3d::SetDistinguishOn () { |
141 | |
142 | DistinguishModeActive = Standard_True; |
143 | |
144 | } |
145 | |
146 | void Graphic3d_AspectFillArea3d::SetDistinguishOff () { |
147 | |
148 | DistinguishModeActive = Standard_False; |
149 | |
150 | } |
151 | |
152 | Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const { |
153 | |
154 | return (DistinguishModeActive); |
155 | |
156 | } |
157 | |
158 | void Graphic3d_AspectFillArea3d::SetEdgeOn () { |
159 | |
160 | EdgeModeActive = Standard_True; |
161 | |
162 | } |
163 | |
164 | void Graphic3d_AspectFillArea3d::SetEdgeOff () { |
165 | |
166 | EdgeModeActive = Standard_False; |
167 | |
168 | } |
169 | |
170 | |
171 | void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture) |
172 | { |
173 | MyTextureMap = ATexture; |
174 | } |
175 | |
176 | |
177 | void Graphic3d_AspectFillArea3d::SetTextureMapOn() |
178 | { |
179 | MyTextureMapState = Standard_True; |
180 | } |
181 | |
182 | |
183 | void Graphic3d_AspectFillArea3d::SetTextureMapOff() |
184 | { |
185 | MyTextureMapState = Standard_False; |
186 | } |
187 | |
188 | |
189 | Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const { |
190 | |
191 | return (EdgeModeActive); |
192 | |
193 | } |
194 | |
195 | |
196 | Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const |
197 | { |
198 | return MyTextureMap; |
199 | } |
200 | |
201 | |
202 | Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const |
203 | { |
204 | return MyTextureMapState; |
205 | } |
206 | |
207 | void Graphic3d_AspectFillArea3d::SetDefaultDegenerateModel( |
208 | const Aspect_TypeOfDegenerateModel aModel, |
209 | const Quantity_Ratio aRatio) { |
210 | theDefaultDegenerateModel = aModel; |
211 | theDefaultDegenerateRatio = aRatio; |
212 | } |
213 | |
214 | void Graphic3d_AspectFillArea3d::SetDegenerateModel( |
215 | const Aspect_TypeOfDegenerateModel aModel, |
216 | const Quantity_Ratio aRatio) { |
217 | |
218 | MyDegenerateModel = aModel; |
219 | MyDegenerateRatio = aRatio; |
220 | } |
221 | |
222 | Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DefaultDegenerateModel( |
223 | Quantity_Ratio& aRatio) { |
224 | aRatio = theDefaultDegenerateRatio; |
225 | return theDefaultDegenerateModel; |
226 | } |
227 | |
228 | Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DegenerateModel( |
229 | Quantity_Ratio& aRatio) const { |
230 | aRatio = MyDegenerateRatio; |
231 | return MyDegenerateModel; |
232 | } |
233 | |
234 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |
235 | void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode, |
236 | const Standard_Real aFactor, |
237 | const Standard_Real aUnits) { |
238 | MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask ); |
239 | MyPolygonOffsetFactor = aFactor; |
240 | MyPolygonOffsetUnits = aUnits; |
241 | } |
242 | |
243 | void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode, |
244 | Standard_Real& aFactor, |
245 | Standard_Real& aUnits) const { |
246 | aMode = MyPolygonOffsetMode; |
247 | aFactor = MyPolygonOffsetFactor; |
248 | aUnits = MyPolygonOffsetUnits; |
249 | } |
250 | // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets |