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>
22 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
26 static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
29 // =======================================================================
30 // function : Graphic3d_ClipPlane
32 // =======================================================================
33 Graphic3d_ClipPlane::Graphic3d_ClipPlane()
34 : myEquation (0.0, 0.0, 1.0, 0.0),
35 myIsOn (Standard_True),
36 myIsCapping (Standard_False),
37 myMaterial (Graphic3d_NOM_DEFAULT),
38 myHatch (Aspect_HS_HORIZONTAL),
39 myHatchOn (Standard_False),
47 // =======================================================================
48 // function : Graphic3d_ClipPlane
50 // =======================================================================
51 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
52 : myEquation (theEquation),
53 myIsOn (Standard_True),
54 myIsCapping (Standard_False),
55 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),
94 myHatch (Aspect_HS_HORIZONTAL),
95 myHatchOn (Standard_False),
101 SetEquation (thePlane);
104 // =======================================================================
105 // function : SetEquation
107 // =======================================================================
108 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
110 myEquation = theEquation;
114 // =======================================================================
115 // function : SetPlane
117 // =======================================================================
118 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
120 thePlane.Coefficients (myEquation[0],
127 // =======================================================================
130 // =======================================================================
131 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
136 // =======================================================================
137 // function : SetCapping
139 // =======================================================================
140 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
142 myIsCapping = theIsOn;
145 // =======================================================================
146 // function : ToPlane
148 // =======================================================================
149 gp_Pln Graphic3d_ClipPlane::ToPlane() const
151 return gp_Pln (myEquation[0],
157 // =======================================================================
160 // =======================================================================
161 Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
163 return new Graphic3d_ClipPlane(*this);
166 // =======================================================================
167 // function : SetCappingMaterial
169 // =======================================================================
170 void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
176 // =======================================================================
177 // function : SetCappingTexture
179 // =======================================================================
180 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
182 myTexture = theTexture;
186 // =======================================================================
187 // function : SetCappingHatch
189 // =======================================================================
190 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
196 // =======================================================================
197 // function : SetCappingHatchOn
199 // =======================================================================
200 void Graphic3d_ClipPlane::SetCappingHatchOn()
202 myHatchOn = Standard_True;
206 // =======================================================================
207 // function : SetCappingHatchOff
209 // =======================================================================
210 void Graphic3d_ClipPlane::SetCappingHatchOff()
212 myHatchOn = Standard_False;
216 // =======================================================================
219 // =======================================================================
220 void Graphic3d_ClipPlane::MakeId()
222 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
223 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
226 // =======================================================================
227 // function : CappingAspect
229 // =======================================================================
230 Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
232 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
233 anAspect->SetDistinguishOff();
234 anAspect->SetFrontMaterial (myMaterial);
235 anAspect->SetTextureMap (myTexture);
236 anAspect->SetHatchStyle (myHatch);
237 anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
238 anAspect->SetInteriorColor (myMaterial.Color());
239 anAspect->SetSuppressBackFaces (false);
240 anAspect->SetTextureMap (!myTexture.IsNull());