1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //-Design Declaration of variables specific to the context
17 // of tracing of facets 3D
18 //-Warning Ccontext of tracing of facets 3d inherits the context
20 // - the style of the interior of the facet
21 // - the style of the facet border
23 // Additionally, it has more than one definition of material
24 // for internal and external faces.
27 #include <Aspect_PolygonOffsetMode.hxx>
28 #include <Graphic3d_AspectFillArea3d.hxx>
29 #include <Graphic3d_MaterialAspect.hxx>
30 #include <Graphic3d_TextureMap.hxx>
31 #include <Quantity_Color.hxx>
32 #include <Standard_Boolean.hxx>
33 #include <Standard_Type.hxx>
35 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d,Aspect_AspectFillArea)
37 Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d ():
38 DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial ()
40 // By default, aspect do not change current polygon offset parameters
41 MyPolygonOffsetMode = Aspect_POM_Fill;
42 MyPolygonOffsetFactor = 1.;
43 MyPolygonOffsetUnits = 0.;
46 // (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth)
47 // because AspectFillArea3d inherits AspectFillArea and it is necessary to call
48 // initialisation of AspectFillArea with InteriorStyle, InteriorColor,
49 // EdgeColor, EdgeLineType and EdgeLineWidth.
51 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):
52 Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) {
53 // By default, aspect do not change current polygon offset parameters
54 MyPolygonOffsetMode = Aspect_POM_Fill;
55 MyPolygonOffsetFactor = 1.;
56 MyPolygonOffsetUnits = 0.;
59 void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) {
61 MyBackMaterial = AMaterial;
65 void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) {
67 MyFrontMaterial = AMaterial;
71 const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::BackMaterial() const
73 return MyBackMaterial;
76 const Graphic3d_MaterialAspect& Graphic3d_AspectFillArea3d::FrontMaterial() const
78 return MyFrontMaterial;
81 void Graphic3d_AspectFillArea3d::AllowBackFace () {
83 BackFaceRemovalActive = Standard_False;
87 void Graphic3d_AspectFillArea3d::SuppressBackFace () {
89 BackFaceRemovalActive = Standard_True;
93 Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const {
95 return (BackFaceRemovalActive);
99 void Graphic3d_AspectFillArea3d::SetDistinguishOn () {
101 DistinguishModeActive = Standard_True;
105 void Graphic3d_AspectFillArea3d::SetDistinguishOff () {
107 DistinguishModeActive = Standard_False;
111 Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const {
113 return (DistinguishModeActive);
117 void Graphic3d_AspectFillArea3d::SetEdgeOn () {
119 EdgeModeActive = Standard_True;
123 void Graphic3d_AspectFillArea3d::SetEdgeOff () {
125 EdgeModeActive = Standard_False;
130 void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture)
132 MyTextureMap = ATexture;
136 void Graphic3d_AspectFillArea3d::SetTextureMapOn()
138 MyTextureMapState = Standard_True;
142 void Graphic3d_AspectFillArea3d::SetTextureMapOff()
144 MyTextureMapState = Standard_False;
148 Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const {
150 return (EdgeModeActive);
155 Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const
161 Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const
163 return MyTextureMapState;
166 void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode,
167 const Standard_ShortReal aFactor,
168 const Standard_ShortReal aUnits) {
169 MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask );
170 MyPolygonOffsetFactor = aFactor;
171 MyPolygonOffsetUnits = aUnits;
174 void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode,
175 Standard_ShortReal& aFactor,
176 Standard_ShortReal& aUnits) const {
177 aMode = MyPolygonOffsetMode;
178 aFactor = MyPolygonOffsetFactor;
179 aUnits = MyPolygonOffsetUnits;
182 void Graphic3d_AspectFillArea3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
184 MyShaderProgram = theProgram;
187 const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectFillArea3d::ShaderProgram() const
189 return MyShaderProgram;