1 // Created on: 2013-07-12
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2013 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
8 // under the terms of the GNU Lesser General Public 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>
21 IMPLEMENT_STANDARD_HANDLE(Graphic3d_ClipPlane, Standard_Transient)
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),
39 myHatch (Aspect_HS_HORIZONTAL),
40 myHatchOn (Standard_False),
48 // =======================================================================
49 // function : Graphic3d_ClipPlane
51 // =======================================================================
52 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
53 : myEquation (theEquation),
54 myIsOn (Standard_True),
55 myIsCapping (Standard_False),
56 myMaterial (Graphic3d_NOM_DEFAULT),
58 myHatch (Aspect_HS_HORIZONTAL),
59 myHatchOn (Standard_False),
67 // =======================================================================
68 // function : Graphic3d_ClipPlane
70 // =======================================================================
71 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
72 : myEquation (theOther.myEquation),
73 myIsOn (theOther.myIsOn),
74 myIsCapping (theOther.myIsCapping),
75 myMaterial (theOther.myMaterial),
76 myTexture (theOther.myTexture),
77 myHatch (theOther.myHatch),
78 myHatchOn (theOther.myHatchOn),
86 // =======================================================================
87 // function : Graphic3d_ClipPlane
89 // =======================================================================
90 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
92 myIsOn (Standard_True),
93 myIsCapping (Standard_False),
94 myMaterial (Graphic3d_NOM_DEFAULT),
96 myHatch (Aspect_HS_HORIZONTAL),
97 myHatchOn (Standard_False),
103 SetEquation (thePlane);
106 // =======================================================================
107 // function : SetEquation
109 // =======================================================================
110 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
112 myEquation = theEquation;
116 // =======================================================================
117 // function : SetPlane
119 // =======================================================================
120 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
122 thePlane.Coefficients (myEquation[0],
129 // =======================================================================
132 // =======================================================================
133 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
138 // =======================================================================
139 // function : SetCapping
141 // =======================================================================
142 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
144 myIsCapping = theIsOn;
147 // =======================================================================
148 // function : ToPlane
150 // =======================================================================
151 gp_Pln Graphic3d_ClipPlane::ToPlane() const
153 return gp_Pln (myEquation[0],
159 // =======================================================================
162 // =======================================================================
163 Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
165 return new Graphic3d_ClipPlane(*this);
168 // =======================================================================
169 // function : SetCappingMaterial
171 // =======================================================================
172 void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
178 // =======================================================================
179 // function : SetCappingTexture
181 // =======================================================================
182 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
184 myTexture = theTexture;
188 // =======================================================================
189 // function : SetCappingHatch
191 // =======================================================================
192 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
198 // =======================================================================
199 // function : SetCappingHatchOn
201 // =======================================================================
202 void Graphic3d_ClipPlane::SetCappingHatchOn()
204 myHatchOn = Standard_True;
208 // =======================================================================
209 // function : SetCappingHatchOff
211 // =======================================================================
212 void Graphic3d_ClipPlane::SetCappingHatchOff()
214 myHatchOn = Standard_False;
218 // =======================================================================
221 // =======================================================================
222 void Graphic3d_ClipPlane::MakeId()
224 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
225 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
228 // =======================================================================
229 // function : CappingAspect
231 // =======================================================================
232 Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
234 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
235 anAspect->SetDistinguishOff();
236 anAspect->SetFrontMaterial (myMaterial);
237 anAspect->SetTextureMap (myTexture);
238 anAspect->SetHatchStyle (myHatch);
239 anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
240 anAspect->SetInteriorColor (myMaterial.Color());
241 if (!myTexture.IsNull())
242 anAspect->SetTextureMapOn();
244 anAspect->SetTextureMapOff();