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
8 // under the terms of the GNU Lesser General Public 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
19 //-Warning Ccontext of tracing of facets 3d inherits the context
21 // - the style of the interior of the facet
22 // - the style of the facet border
24 // Additionally, it has more than one definition of material
25 // for internal and external faces.
28 #include <Graphic3d_AspectFillArea3d.ixx>
30 #include <Aspect_PolygonOffsetMode.hxx>
31 #include <Standard_Boolean.hxx>
33 Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d ():
34 DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial ()
36 // By default, aspect do not change current polygon offset parameters
37 MyPolygonOffsetMode = Aspect_POM_Fill;
38 MyPolygonOffsetFactor = 1.;
39 MyPolygonOffsetUnits = 0.;
42 // (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth)
43 // because AspectFillArea3d inherits AspectFillArea and it is necessary to call
44 // initialisation of AspectFillArea with InteriorStyle, InteriorColor,
45 // EdgeColor, EdgeLineType and EdgeLineWidth.
47 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):
48 Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) {
49 // By default, aspect do not change current polygon offset parameters
50 MyPolygonOffsetMode = Aspect_POM_Fill;
51 MyPolygonOffsetFactor = 1.;
52 MyPolygonOffsetUnits = 0.;
55 void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) {
57 MyBackMaterial = AMaterial;
61 void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) {
63 MyFrontMaterial = AMaterial;
67 Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::BackMaterial () const {
69 return (MyBackMaterial);
73 Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::FrontMaterial () const {
75 return (MyFrontMaterial);
79 void Graphic3d_AspectFillArea3d::AllowBackFace () {
81 BackFaceRemovalActive = Standard_False;
85 void Graphic3d_AspectFillArea3d::SuppressBackFace () {
87 BackFaceRemovalActive = Standard_True;
91 Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const {
93 return (BackFaceRemovalActive);
97 void Graphic3d_AspectFillArea3d::SetDistinguishOn () {
99 DistinguishModeActive = Standard_True;
103 void Graphic3d_AspectFillArea3d::SetDistinguishOff () {
105 DistinguishModeActive = Standard_False;
109 Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const {
111 return (DistinguishModeActive);
115 void Graphic3d_AspectFillArea3d::SetEdgeOn () {
117 EdgeModeActive = Standard_True;
121 void Graphic3d_AspectFillArea3d::SetEdgeOff () {
123 EdgeModeActive = Standard_False;
128 void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture)
130 MyTextureMap = ATexture;
134 void Graphic3d_AspectFillArea3d::SetTextureMapOn()
136 MyTextureMapState = Standard_True;
140 void Graphic3d_AspectFillArea3d::SetTextureMapOff()
142 MyTextureMapState = Standard_False;
146 Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const {
148 return (EdgeModeActive);
153 Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const
159 Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const
161 return MyTextureMapState;
164 void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode,
165 const Standard_ShortReal aFactor,
166 const Standard_ShortReal aUnits) {
167 MyPolygonOffsetMode = ( aMode & Aspect_POM_Mask );
168 MyPolygonOffsetFactor = aFactor;
169 MyPolygonOffsetUnits = aUnits;
172 void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode,
173 Standard_ShortReal& aFactor,
174 Standard_ShortReal& aUnits) const {
175 aMode = MyPolygonOffsetMode;
176 aFactor = MyPolygonOffsetFactor;
177 aUnits = MyPolygonOffsetUnits;
180 void Graphic3d_AspectFillArea3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
182 MyShaderProgram = theProgram;
185 const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectFillArea3d::ShaderProgram() const
187 return MyShaderProgram;