1 // Created on: 2013-07-12
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2013 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 65 (the "License") You may not use the content of this file
7 // except in compliance with the License Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file
10 // The Initial Developer of the Original Code is Open CASCADE SAS, having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License
20 #include <Graphic3d_ClipPlane.hxx>
21 #include <Graphic3d_AspectFillArea3d.hxx>
23 #include <Standard_Atomic.hxx>
25 IMPLEMENT_STANDARD_HANDLE(Graphic3d_ClipPlane, Standard_Transient)
26 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane, Standard_Transient)
30 static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
33 // =======================================================================
34 // function : Graphic3d_ClipPlane
36 // =======================================================================
37 Graphic3d_ClipPlane::Graphic3d_ClipPlane()
38 : myEquation (0.0, 0.0, 1.0, 0.0),
39 myIsOn (Standard_True),
40 myIsCapping (Standard_False),
41 myMaterial (Graphic3d_NOM_DEFAULT),
43 myHatch (Aspect_HS_HORIZONTAL),
44 myHatchOn (Standard_False),
52 // =======================================================================
53 // function : Graphic3d_ClipPlane
55 // =======================================================================
56 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
57 : myEquation (theEquation),
58 myIsOn (Standard_True),
59 myIsCapping (Standard_False),
60 myMaterial (Graphic3d_NOM_DEFAULT),
62 myHatch (Aspect_HS_HORIZONTAL),
63 myHatchOn (Standard_False),
71 // =======================================================================
72 // function : Graphic3d_ClipPlane
74 // =======================================================================
75 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
76 : myEquation (theOther.myEquation),
77 myIsOn (theOther.myIsOn),
78 myIsCapping (theOther.myIsCapping),
79 myMaterial (theOther.myMaterial),
80 myTexture (theOther.myTexture),
81 myHatch (theOther.myHatch),
82 myHatchOn (theOther.myHatchOn),
90 // =======================================================================
91 // function : Graphic3d_ClipPlane
93 // =======================================================================
94 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
96 myIsOn (Standard_True),
97 myIsCapping (Standard_False),
98 myMaterial (Graphic3d_NOM_DEFAULT),
100 myHatch (Aspect_HS_HORIZONTAL),
101 myHatchOn (Standard_False),
107 SetEquation (thePlane);
110 // =======================================================================
111 // function : SetEquation
113 // =======================================================================
114 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
116 myEquation = theEquation;
120 // =======================================================================
121 // function : SetPlane
123 // =======================================================================
124 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
126 thePlane.Coefficients (myEquation[0],
133 // =======================================================================
136 // =======================================================================
137 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
142 // =======================================================================
143 // function : SetCapping
145 // =======================================================================
146 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
148 myIsCapping = theIsOn;
151 // =======================================================================
152 // function : ToPlane
154 // =======================================================================
155 gp_Pln Graphic3d_ClipPlane::ToPlane() const
157 return gp_Pln (myEquation[0],
163 // =======================================================================
166 // =======================================================================
167 Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
169 return new Graphic3d_ClipPlane(*this);
172 // =======================================================================
173 // function : SetCappingMaterial
175 // =======================================================================
176 void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
182 // =======================================================================
183 // function : SetCappingTexture
185 // =======================================================================
186 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
188 myTexture = theTexture;
192 // =======================================================================
193 // function : SetCappingHatch
195 // =======================================================================
196 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
202 // =======================================================================
203 // function : SetCappingHatchOn
205 // =======================================================================
206 void Graphic3d_ClipPlane::SetCappingHatchOn()
208 myHatchOn = Standard_True;
212 // =======================================================================
213 // function : SetCappingHatchOff
215 // =======================================================================
216 void Graphic3d_ClipPlane::SetCappingHatchOff()
218 myHatchOn = Standard_False;
222 // =======================================================================
225 // =======================================================================
226 void Graphic3d_ClipPlane::MakeId()
228 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
229 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
232 // =======================================================================
233 // function : CappingAspect
235 // =======================================================================
236 Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
238 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
239 anAspect->SetDistinguishOff();
240 anAspect->SetFrontMaterial (myMaterial);
241 anAspect->SetTextureMap (myTexture);
242 anAspect->SetHatchStyle (myHatch);
243 anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
244 anAspect->SetInteriorColor (myMaterial.Color());
245 if (!myTexture.IsNull())
246 anAspect->SetTextureMapOn();
248 anAspect->SetTextureMapOff();