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),
36 myHatch (Aspect_HS_HORIZONTAL),
37 myHatchOn (Standard_False),
45 // =======================================================================
46 // function : Graphic3d_ClipPlane
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),
54 myHatch (Aspect_HS_HORIZONTAL),
55 myHatchOn (Standard_False),
63 // =======================================================================
64 // function : Graphic3d_ClipPlane
66 // =======================================================================
67 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
68 : Standard_Transient(theOther),
69 myEquation (theOther.myEquation),
70 myIsOn (theOther.myIsOn),
71 myIsCapping (theOther.myIsCapping),
72 myMaterial (theOther.myMaterial),
73 myTexture (theOther.myTexture),
74 myHatch (theOther.myHatch),
75 myHatchOn (theOther.myHatchOn),
83 // =======================================================================
84 // function : Graphic3d_ClipPlane
86 // =======================================================================
87 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
89 myIsOn (Standard_True),
90 myIsCapping (Standard_False),
91 myMaterial (Graphic3d_NOM_DEFAULT),
92 myHatch (Aspect_HS_HORIZONTAL),
93 myHatchOn (Standard_False),
99 SetEquation (thePlane);
102 // =======================================================================
103 // function : SetEquation
105 // =======================================================================
106 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
108 myEquation = theEquation;
112 // =======================================================================
113 // function : SetPlane
115 // =======================================================================
116 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
118 thePlane.Coefficients (myEquation[0],
125 // =======================================================================
128 // =======================================================================
129 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
134 // =======================================================================
135 // function : SetCapping
137 // =======================================================================
138 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
140 myIsCapping = theIsOn;
143 // =======================================================================
144 // function : ToPlane
146 // =======================================================================
147 gp_Pln Graphic3d_ClipPlane::ToPlane() const
149 return gp_Pln (myEquation[0],
155 // =======================================================================
158 // =======================================================================
159 Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
161 return new Graphic3d_ClipPlane(*this);
164 // =======================================================================
165 // function : SetCappingMaterial
167 // =======================================================================
168 void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
174 // =======================================================================
175 // function : SetCappingTexture
177 // =======================================================================
178 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
180 myTexture = theTexture;
184 // =======================================================================
185 // function : SetCappingHatch
187 // =======================================================================
188 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
194 // =======================================================================
195 // function : SetCappingHatchOn
197 // =======================================================================
198 void Graphic3d_ClipPlane::SetCappingHatchOn()
200 myHatchOn = Standard_True;
204 // =======================================================================
205 // function : SetCappingHatchOff
207 // =======================================================================
208 void Graphic3d_ClipPlane::SetCappingHatchOff()
210 myHatchOn = Standard_False;
214 // =======================================================================
217 // =======================================================================
218 void Graphic3d_ClipPlane::MakeId()
220 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
221 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
224 // =======================================================================
225 // function : CappingAspect
227 // =======================================================================
228 Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
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();
240 anAspect->SetTextureMapOff();