1 // Created on: 2013-07-12
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2013-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 #include <Graphic3d_ClipPlane.hxx>
17 #include <Graphic3d_AspectFillArea3d.hxx>
19 #include <Standard_Atomic.hxx>
24 static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
27 // =======================================================================
28 // function : Graphic3d_ClipPlane
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),
37 myHatch (Aspect_HS_HORIZONTAL),
38 myHatchOn (Standard_False),
46 // =======================================================================
47 // function : Graphic3d_ClipPlane
49 // =======================================================================
50 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
51 : myEquation (theEquation),
52 myIsOn (Standard_True),
53 myIsCapping (Standard_False),
54 myMaterial (Graphic3d_NOM_DEFAULT),
56 myHatch (Aspect_HS_HORIZONTAL),
57 myHatchOn (Standard_False),
65 // =======================================================================
66 // function : Graphic3d_ClipPlane
68 // =======================================================================
69 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
70 : Standard_Transient(theOther),
71 myEquation (theOther.myEquation),
72 myIsOn (theOther.myIsOn),
73 myIsCapping (theOther.myIsCapping),
74 myMaterial (theOther.myMaterial),
75 myTexture (theOther.myTexture),
76 myHatch (theOther.myHatch),
77 myHatchOn (theOther.myHatchOn),
85 // =======================================================================
86 // function : Graphic3d_ClipPlane
88 // =======================================================================
89 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
91 myIsOn (Standard_True),
92 myIsCapping (Standard_False),
93 myMaterial (Graphic3d_NOM_DEFAULT),
95 myHatch (Aspect_HS_HORIZONTAL),
96 myHatchOn (Standard_False),
102 SetEquation (thePlane);
105 // =======================================================================
106 // function : SetEquation
108 // =======================================================================
109 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
111 myEquation = theEquation;
115 // =======================================================================
116 // function : SetPlane
118 // =======================================================================
119 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
121 thePlane.Coefficients (myEquation[0],
128 // =======================================================================
131 // =======================================================================
132 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
137 // =======================================================================
138 // function : SetCapping
140 // =======================================================================
141 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
143 myIsCapping = theIsOn;
146 // =======================================================================
147 // function : ToPlane
149 // =======================================================================
150 gp_Pln Graphic3d_ClipPlane::ToPlane() const
152 return gp_Pln (myEquation[0],
158 // =======================================================================
161 // =======================================================================
162 Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
164 return new Graphic3d_ClipPlane(*this);
167 // =======================================================================
168 // function : SetCappingMaterial
170 // =======================================================================
171 void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
177 // =======================================================================
178 // function : SetCappingTexture
180 // =======================================================================
181 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
183 myTexture = theTexture;
187 // =======================================================================
188 // function : SetCappingHatch
190 // =======================================================================
191 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
197 // =======================================================================
198 // function : SetCappingHatchOn
200 // =======================================================================
201 void Graphic3d_ClipPlane::SetCappingHatchOn()
203 myHatchOn = Standard_True;
207 // =======================================================================
208 // function : SetCappingHatchOff
210 // =======================================================================
211 void Graphic3d_ClipPlane::SetCappingHatchOff()
213 myHatchOn = Standard_False;
217 // =======================================================================
220 // =======================================================================
221 void Graphic3d_ClipPlane::MakeId()
223 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
224 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
227 // =======================================================================
228 // function : CappingAspect
230 // =======================================================================
231 Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
233 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
234 anAspect->SetDistinguishOff();
235 anAspect->SetFrontMaterial (myMaterial);
236 anAspect->SetTextureMap (myTexture);
237 anAspect->SetHatchStyle (myHatch);
238 anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
239 anAspect->SetInteriorColor (myMaterial.Color());
240 if (!myTexture.IsNull())
241 anAspect->SetTextureMapOn();
243 anAspect->SetTextureMapOff();