4269bd1b |
1 | // Created on: 2013-07-12 |
2 | // Created by: Anton POLETAEV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
4269bd1b |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
4269bd1b |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4269bd1b |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
4269bd1b |
15 | |
16 | #include <Graphic3d_ClipPlane.hxx> |
17 | #include <Graphic3d_AspectFillArea3d.hxx> |
18 | #include <gp_Pln.hxx> |
19 | #include <Standard_Atomic.hxx> |
20 | |
4269bd1b |
21 | |
22 | namespace |
23 | { |
24 | static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0; |
25 | }; |
26 | |
27 | // ======================================================================= |
28 | // function : Graphic3d_ClipPlane |
29 | // purpose : |
30 | // ======================================================================= |
31 | Graphic3d_ClipPlane::Graphic3d_ClipPlane() |
32 | : myEquation (0.0, 0.0, 1.0, 0.0), |
33 | myIsOn (Standard_True), |
34 | myIsCapping (Standard_False), |
35 | myMaterial (Graphic3d_NOM_DEFAULT), |
4269bd1b |
36 | myHatch (Aspect_HS_HORIZONTAL), |
37 | myHatchOn (Standard_False), |
38 | myId(), |
39 | myEquationMod(0), |
40 | myAspectMod(0) |
41 | { |
42 | MakeId(); |
43 | } |
44 | |
45 | // ======================================================================= |
46 | // function : Graphic3d_ClipPlane |
47 | // purpose : |
48 | // ======================================================================= |
49 | Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation) |
50 | : myEquation (theEquation), |
51 | myIsOn (Standard_True), |
52 | myIsCapping (Standard_False), |
53 | myMaterial (Graphic3d_NOM_DEFAULT), |
4269bd1b |
54 | myHatch (Aspect_HS_HORIZONTAL), |
55 | myHatchOn (Standard_False), |
56 | myId(), |
57 | myEquationMod(0), |
58 | myAspectMod(0) |
59 | { |
60 | MakeId(); |
61 | } |
62 | |
63 | // ======================================================================= |
64 | // function : Graphic3d_ClipPlane |
65 | // purpose : |
66 | // ======================================================================= |
67 | Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther) |
a9b30f0a |
68 | : Standard_Transient(theOther), |
69 | myEquation (theOther.myEquation), |
4269bd1b |
70 | myIsOn (theOther.myIsOn), |
71 | myIsCapping (theOther.myIsCapping), |
72 | myMaterial (theOther.myMaterial), |
73 | myTexture (theOther.myTexture), |
74 | myHatch (theOther.myHatch), |
75 | myHatchOn (theOther.myHatchOn), |
76 | myId(), |
77 | myEquationMod (0), |
78 | myAspectMod (0) |
79 | { |
80 | MakeId(); |
81 | } |
82 | |
83 | // ======================================================================= |
84 | // function : Graphic3d_ClipPlane |
85 | // purpose : |
86 | // ======================================================================= |
87 | Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane) |
88 | : myEquation (), |
89 | myIsOn (Standard_True), |
90 | myIsCapping (Standard_False), |
91 | myMaterial (Graphic3d_NOM_DEFAULT), |
4269bd1b |
92 | myHatch (Aspect_HS_HORIZONTAL), |
93 | myHatchOn (Standard_False), |
94 | myId(), |
95 | myEquationMod(0), |
96 | myAspectMod(0) |
97 | { |
98 | MakeId(); |
99 | SetEquation (thePlane); |
100 | } |
101 | |
102 | // ======================================================================= |
103 | // function : SetEquation |
104 | // purpose : |
105 | // ======================================================================= |
106 | void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation) |
107 | { |
108 | myEquation = theEquation; |
109 | myEquationMod++; |
110 | } |
111 | |
112 | // ======================================================================= |
113 | // function : SetPlane |
114 | // purpose : |
115 | // ======================================================================= |
116 | void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane) |
117 | { |
118 | thePlane.Coefficients (myEquation[0], |
119 | myEquation[1], |
120 | myEquation[2], |
121 | myEquation[3]); |
122 | myEquationMod++; |
123 | } |
124 | |
125 | // ======================================================================= |
126 | // function : SetOn |
127 | // purpose : |
128 | // ======================================================================= |
129 | void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn) |
130 | { |
131 | myIsOn = theIsOn; |
132 | } |
133 | |
134 | // ======================================================================= |
135 | // function : SetCapping |
136 | // purpose : |
137 | // ======================================================================= |
138 | void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn) |
139 | { |
140 | myIsCapping = theIsOn; |
141 | } |
142 | |
143 | // ======================================================================= |
144 | // function : ToPlane |
145 | // purpose : |
146 | // ======================================================================= |
147 | gp_Pln Graphic3d_ClipPlane::ToPlane() const |
148 | { |
149 | return gp_Pln (myEquation[0], |
150 | myEquation[1], |
151 | myEquation[2], |
152 | myEquation[3]); |
153 | } |
154 | |
155 | // ======================================================================= |
156 | // function : Clone |
157 | // purpose : |
158 | // ======================================================================= |
159 | Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const |
160 | { |
161 | return new Graphic3d_ClipPlane(*this); |
162 | } |
163 | |
164 | // ======================================================================= |
165 | // function : SetCappingMaterial |
166 | // purpose : |
167 | // ======================================================================= |
168 | void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat) |
169 | { |
170 | myMaterial = theMat; |
171 | myAspectMod++; |
172 | } |
173 | |
174 | // ======================================================================= |
175 | // function : SetCappingTexture |
176 | // purpose : |
177 | // ======================================================================= |
178 | void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture) |
179 | { |
180 | myTexture = theTexture; |
181 | myAspectMod++; |
182 | } |
183 | |
184 | // ======================================================================= |
185 | // function : SetCappingHatch |
186 | // purpose : |
187 | // ======================================================================= |
188 | void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle) |
189 | { |
190 | myHatch = theStyle; |
191 | myAspectMod++; |
192 | } |
193 | |
194 | // ======================================================================= |
195 | // function : SetCappingHatchOn |
196 | // purpose : |
197 | // ======================================================================= |
198 | void Graphic3d_ClipPlane::SetCappingHatchOn() |
199 | { |
200 | myHatchOn = Standard_True; |
201 | myAspectMod++; |
202 | } |
203 | |
204 | // ======================================================================= |
205 | // function : SetCappingHatchOff |
206 | // purpose : |
207 | // ======================================================================= |
208 | void Graphic3d_ClipPlane::SetCappingHatchOff() |
209 | { |
210 | myHatchOn = Standard_False; |
211 | myAspectMod++; |
212 | } |
213 | |
214 | // ======================================================================= |
215 | // function : MakeId |
216 | // purpose : |
217 | // ======================================================================= |
218 | void Graphic3d_ClipPlane::MakeId() |
219 | { |
220 | myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name() |
221 | + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER)); |
222 | } |
223 | |
224 | // ======================================================================= |
225 | // function : CappingAspect |
226 | // purpose : |
227 | // ======================================================================= |
228 | Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const |
229 | { |
230 | Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d(); |
231 | anAspect->SetDistinguishOff(); |
232 | anAspect->SetFrontMaterial (myMaterial); |
233 | anAspect->SetTextureMap (myTexture); |
234 | anAspect->SetHatchStyle (myHatch); |
235 | anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID); |
236 | anAspect->SetInteriorColor (myMaterial.Color()); |
237 | if (!myTexture.IsNull()) |
238 | anAspect->SetTextureMapOn(); |
239 | else |
240 | anAspect->SetTextureMapOff(); |
241 | |
242 | return anAspect; |
243 | } |