1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 // Modified 1/08/97 ; PCT : Ajout texture mapping
21 // 26/01/00 ; EUG/GG degeneration management (G003)
22 // Add SetDegenerateModel() and DegenerateModel() methods
23 // JR 02.01.100 : Initialization order of fields in contructors
24 // 29/09/00 ; GG Add SetDefaultDegerateModel() and
25 // DefaultDegenerateModel() class methods
26 // 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
31 //-Design Declaration of variables specific to the context
32 // of tracing of facets 3D
34 //-Warning Ccontext of tracing of facets 3d inherits the context
36 // - the style of the interior of the facet
37 // - the style of the facet border
39 // Additionally, it has more than one definition of material
40 // for internal and external faces.
49 #include <Graphic3d_AspectFillArea3d.ixx>
51 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
52 #include <Aspect_PolygonOffsetMode.hxx>
53 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
55 #include <Standard_Boolean.hxx>
59 //-Global data definitions
60 static Aspect_TypeOfDegenerateModel theDefaultDegenerateModel = Aspect_TDM_WIREFRAME;
61 static Quantity_Ratio theDefaultDegenerateRatio = 0.0;
64 // MyFrontMaterial : MaterialAspect;
65 // MyBackMaterial : MaterialAspect;
67 // -- flag de distinction entre faces internes et externes
68 // DistinguishModeActive : Standard_Boolean;
70 // -- flag de trace des aretes
71 // EdgeModeActive : Standard_Boolean;
73 // -- flag d'affichage des polygones tournant le dos
74 // BackFaceRemovalActive : Standard_Boolean;
82 Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d ():
83 DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial () {
84 MyDegenerateModel = theDefaultDegenerateModel;
85 MyDegenerateRatio = theDefaultDegenerateRatio;
87 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
88 // By default, aspect do not change current polygon offset parameters
89 MyPolygonOffsetMode = Aspect_POM_Fill;
90 MyPolygonOffsetFactor = 1.;
91 MyPolygonOffsetUnits = 0.;
92 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
95 // (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth)
96 // because AspectFillArea3d inherits AspectFillArea and it is necessary to call
97 // initialisation of AspectFillArea with InteriorStyle, InteriorColor,
98 // EdgeColor, EdgeLineType and EdgeLineWidth.
100 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):
101 Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) {
102 MyDegenerateModel = theDefaultDegenerateModel;
103 MyDegenerateRatio = theDefaultDegenerateRatio;
105 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
106 // By default, aspect do not change current polygon offset parameters
107 MyPolygonOffsetMode = Aspect_POM_Fill;
108 MyPolygonOffsetFactor = 1.;
109 MyPolygonOffsetUnits = 0.;
110 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
113 void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) {
115 MyBackMaterial = AMaterial;
119 void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) {
121 MyFrontMaterial = AMaterial;
125 Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::BackMaterial () const {
127 return (MyBackMaterial);
131 Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::FrontMaterial () const {
133 return (MyFrontMaterial);
137 void Graphic3d_AspectFillArea3d::AllowBackFace () {
139 BackFaceRemovalActive = Standard_False;
143 void Graphic3d_AspectFillArea3d::SuppressBackFace () {
145 BackFaceRemovalActive = Standard_True;
149 Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const {
151 return (BackFaceRemovalActive);
155 void Graphic3d_AspectFillArea3d::SetDistinguishOn () {
157 DistinguishModeActive = Standard_True;
161 void Graphic3d_AspectFillArea3d::SetDistinguishOff () {
163 DistinguishModeActive = Standard_False;
167 Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const {
169 return (DistinguishModeActive);
173 void Graphic3d_AspectFillArea3d::SetEdgeOn () {
175 EdgeModeActive = Standard_True;
179 void Graphic3d_AspectFillArea3d::SetEdgeOff () {
181 EdgeModeActive = Standard_False;
186 void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture)
188 MyTextureMap = ATexture;
192 void Graphic3d_AspectFillArea3d::SetTextureMapOn()
194 MyTextureMapState = Standard_True;
198 void Graphic3d_AspectFillArea3d::SetTextureMapOff()
200 MyTextureMapState = Standard_False;
204 Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const {
206 return (EdgeModeActive);
211 Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const
217 Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const
219 return MyTextureMapState;
222 void Graphic3d_AspectFillArea3d::SetDefaultDegenerateModel(
223 const Aspect_TypeOfDegenerateModel aModel,
224 const Quantity_Ratio aRatio) {
225 theDefaultDegenerateModel = aModel;
226 theDefaultDegenerateRatio = aRatio;
229 void Graphic3d_AspectFillArea3d::SetDegenerateModel(
230 const Aspect_TypeOfDegenerateModel aModel,
231 const Quantity_Ratio aRatio) {
233 MyDegenerateModel = aModel;
234 MyDegenerateRatio = aRatio;
237 Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DefaultDegenerateModel(
238 Quantity_Ratio& aRatio) {
239 aRatio = theDefaultDegenerateRatio;
240 return theDefaultDegenerateModel;
243 Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DegenerateModel(
244 Quantity_Ratio& aRatio) const {
245 aRatio = MyDegenerateRatio;
246 return MyDegenerateModel;
249 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
250 void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode,
251 const Standard_Real aFactor,
252 const Standard_Real aUnits) {
253 MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask );
254 MyPolygonOffsetFactor = aFactor;
255 MyPolygonOffsetUnits = aUnits;
258 void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode,
259 Standard_Real& aFactor,
260 Standard_Real& aUnits) const {
261 aMode = MyPolygonOffsetMode;
262 aFactor = MyPolygonOffsetFactor;
263 aUnits = MyPolygonOffsetUnits;
265 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets