summaryrefslogtreecommitdiff
path: root/src/Graphic3d/Graphic3d_AspectFillArea3d.cxx
blob: b36803e0b99883c564f4bccc0ae4e584decdc8a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// File		Graphic3d_AspectFillArea3d.cxx
// Created	Mars 1992
// Author	NW,JPB,CAL
// Modified     1/08/97 ; PCT : Ajout texture mapping
//		26/01/00 ; EUG/GG degeneration management (G003)
//			Add SetDegenerateModel() and DegenerateModel() methods
// JR 02.01.100 : Initialization order of fields in contructors
//		29/09/00 ; GG Add SetDefaultDegerateModel() and
//			DefaultDegenerateModel() class methods
//              22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets 

//-Copyright	MatraDatavision 1991,1992

//-Version	

//-Design	Declaration of variables specific to the context
//		of tracing of facets 3D

//-Warning	Ccontext of tracing of facets 3d inherits the context
//		defined by :
//		- the style of the interior of the facet
//		- the style of the facet border
//		- the color
//		Additionally, it has more than one definition of material
//		for internal and external faces.

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Graphic3d_AspectFillArea3d.ixx>

// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
#include <Aspect_PolygonOffsetMode.hxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 

#include <Standard_Boolean.hxx>

//-Aliases

//-Global data definitions
static Aspect_TypeOfDegenerateModel theDefaultDegenerateModel = Aspect_TDM_WIREFRAME;
static Quantity_Ratio theDefaultDegenerateRatio = 0.0;

//	-- la matiere
//	MyFrontMaterial		:	MaterialAspect;
//	MyBackMaterial		:	MaterialAspect;

//	-- flag de distinction entre faces internes et externes
//	DistinguishModeActive	:	Standard_Boolean;

//	-- flag de trace des aretes
//	EdgeModeActive		:	Standard_Boolean;

//	-- flag d'affichage des polygones tournant le dos
//	BackFaceRemovalActive	:	Standard_Boolean;

//-Constructors

//-Destructors

//-Methods, in order

Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d ():
DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False),  MyTextureMapState(Standard_False), MyFrontMaterial (), MyBackMaterial () {
  MyDegenerateModel = theDefaultDegenerateModel;
  MyDegenerateRatio = theDefaultDegenerateRatio;

  // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
  // By default, aspect do not change current polygon offset parameters
  MyPolygonOffsetMode   = Aspect_POM_None;
  MyPolygonOffsetFactor = 1.;
  MyPolygonOffsetUnits  = 0.;
  // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
}

// (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth)
// because AspectFillArea3d inherits AspectFillArea and it is necessary to call
// initialisation of AspectFillArea with InteriorStyle, InteriorColor,
// EdgeColor, EdgeLineType and EdgeLineWidth.

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):
Aspect_AspectFillArea (InteriorStyle, InteriorColor, EdgeColor, EdgeLineType, EdgeLineWidth), DistinguishModeActive (Standard_False), EdgeModeActive (Standard_False), BackFaceRemovalActive (Standard_False), MyTextureMap(), MyTextureMapState(Standard_False), MyFrontMaterial (FrontMaterial), MyBackMaterial (BackMaterial) {
  MyDegenerateModel = theDefaultDegenerateModel;
  MyDegenerateRatio = theDefaultDegenerateRatio;

  // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
  // By default, aspect do not change current polygon offset parameters
  MyPolygonOffsetMode   = Aspect_POM_None;
  MyPolygonOffsetFactor = 1.;
  MyPolygonOffsetUnits  = 0.;
  // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
}

void Graphic3d_AspectFillArea3d::SetBackMaterial (const Graphic3d_MaterialAspect& AMaterial) {

	MyBackMaterial	= AMaterial;

}

void Graphic3d_AspectFillArea3d::SetFrontMaterial (const Graphic3d_MaterialAspect& AMaterial) {

	MyFrontMaterial	= AMaterial;

}

Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::BackMaterial () const {

	return (MyBackMaterial);

}

Graphic3d_MaterialAspect Graphic3d_AspectFillArea3d::FrontMaterial () const {

	return (MyFrontMaterial);

}

void Graphic3d_AspectFillArea3d::AllowBackFace () {

	BackFaceRemovalActive	= Standard_False;

}

void Graphic3d_AspectFillArea3d::SuppressBackFace () {

	BackFaceRemovalActive	= Standard_True;

}

Standard_Boolean Graphic3d_AspectFillArea3d::BackFace () const {

	return (BackFaceRemovalActive);

}

void Graphic3d_AspectFillArea3d::SetDistinguishOn () {

	DistinguishModeActive	= Standard_True;

}

void Graphic3d_AspectFillArea3d::SetDistinguishOff () {

	DistinguishModeActive	= Standard_False;

}

Standard_Boolean Graphic3d_AspectFillArea3d::Distinguish () const {

	return (DistinguishModeActive);

}

void Graphic3d_AspectFillArea3d::SetEdgeOn () {

	EdgeModeActive	= Standard_True;

}

void Graphic3d_AspectFillArea3d::SetEdgeOff () {

	EdgeModeActive	= Standard_False;

}


void Graphic3d_AspectFillArea3d::SetTextureMap(const Handle(Graphic3d_TextureMap)& ATexture)
{
  MyTextureMap = ATexture;
}


void Graphic3d_AspectFillArea3d::SetTextureMapOn()
{
  MyTextureMapState = Standard_True;
}


void Graphic3d_AspectFillArea3d::SetTextureMapOff()
{
  MyTextureMapState = Standard_False;
}


Standard_Boolean Graphic3d_AspectFillArea3d::Edge () const {

	return (EdgeModeActive);

}


Handle(Graphic3d_TextureMap) Graphic3d_AspectFillArea3d::TextureMap() const
{
  return MyTextureMap;
}


Standard_Boolean Graphic3d_AspectFillArea3d::TextureMapState() const
{
  return MyTextureMapState;
}

void Graphic3d_AspectFillArea3d::SetDefaultDegenerateModel(
	const Aspect_TypeOfDegenerateModel aModel,
	const Quantity_Ratio aRatio) {
  theDefaultDegenerateModel = aModel;
  theDefaultDegenerateRatio = aRatio;
}

void Graphic3d_AspectFillArea3d::SetDegenerateModel(
	const Aspect_TypeOfDegenerateModel aModel,
	const Quantity_Ratio aRatio) {

  MyDegenerateModel = aModel;
  MyDegenerateRatio = aRatio;
}

Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DefaultDegenerateModel(
			Quantity_Ratio& aRatio) {
  aRatio = theDefaultDegenerateRatio;
  return theDefaultDegenerateModel;
}

Aspect_TypeOfDegenerateModel Graphic3d_AspectFillArea3d::DegenerateModel(
			Quantity_Ratio& aRatio) const {
  aRatio = MyDegenerateRatio;
  return MyDegenerateModel;
}

// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets 
void Graphic3d_AspectFillArea3d::SetPolygonOffsets(const Standard_Integer aMode,
                                                   const Standard_Real    aFactor,
                                                   const Standard_Real    aUnits) {
  MyPolygonOffsetMode   = ( aMode & Aspect_POM_Mask );
  MyPolygonOffsetFactor = aFactor;
  MyPolygonOffsetUnits  = aUnits;
}

void Graphic3d_AspectFillArea3d::PolygonOffsets(Standard_Integer& aMode,
                                                Standard_Real&    aFactor,
                                                Standard_Real&    aUnits) const {
  aMode   = MyPolygonOffsetMode;
  aFactor = MyPolygonOffsetFactor;
  aUnits  = MyPolygonOffsetUnits;
}
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets