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>
18 #include <Graphic3d_AspectFillArea3d.hxx>
20 #include <Standard_Atomic.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
26 static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
28 static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
30 const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
31 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
32 anAspect->SetDistinguishOff();
33 anAspect->SetFrontMaterial (aMaterial);
34 anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
35 anAspect->SetInteriorStyle (Aspect_IS_SOLID);
36 anAspect->SetInteriorColor (aMaterial.Color());
37 anAspect->SetSuppressBackFaces (false);
42 // =======================================================================
43 // function : Graphic3d_ClipPlane
45 // =======================================================================
46 Graphic3d_ClipPlane::Graphic3d_ClipPlane()
47 : myAspect (defaultAspect()),
48 myPlane (0.0, 0.0, 1.0, 0.0),
49 myEquation (0.0, 0.0, 1.0, 0.0),
50 myFlags (Graphic3d_CappingFlags_None),
53 myIsOn (Standard_True),
54 myIsCapping (Standard_False)
59 // =======================================================================
60 // function : Graphic3d_ClipPlane
62 // =======================================================================
63 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
64 : myAspect (defaultAspect()),
65 myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
66 myEquation (theEquation),
67 myFlags (Graphic3d_CappingFlags_None),
70 myIsOn (Standard_True),
71 myIsCapping (Standard_False)
76 // =======================================================================
77 // function : Graphic3d_ClipPlane
79 // =======================================================================
80 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
81 : Standard_Transient(theOther),
82 myAspect (defaultAspect()),
83 myPlane (theOther.myPlane),
84 myEquation (theOther.myEquation),
85 myFlags (theOther.myFlags),
88 myIsOn (theOther.myIsOn),
89 myIsCapping (theOther.myIsCapping)
92 *myAspect = *theOther.CappingAspect();
95 // =======================================================================
96 // function : Graphic3d_ClipPlane
98 // =======================================================================
99 Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
100 : myAspect (defaultAspect()),
102 myFlags (Graphic3d_CappingFlags_None),
105 myIsOn (Standard_True),
106 myIsCapping (Standard_False)
108 thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
112 // =======================================================================
113 // function : SetEquation
115 // =======================================================================
116 void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
118 myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
119 myEquation = theEquation;
123 // =======================================================================
124 // function : SetPlane
126 // =======================================================================
127 void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
130 thePlane.Coefficients (myEquation[0],
137 // =======================================================================
140 // =======================================================================
141 void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
146 // =======================================================================
147 // function : SetCapping
149 // =======================================================================
150 void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
152 myIsCapping = theIsOn;
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)
170 myAspect->SetFrontMaterial (theMat);
171 myAspect->SetInteriorColor (theMat.Color());
175 // =======================================================================
176 // function : SetCappingTexture
178 // =======================================================================
179 void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
181 myAspect->SetTextureMap (theTexture);
182 if (!theTexture.IsNull())
184 myAspect->SetTextureMapOn();
188 myAspect->SetTextureMapOff();
193 // =======================================================================
194 // function : SetCappingHatch
196 // =======================================================================
197 void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
199 myAspect->SetHatchStyle (theStyle);
203 // =======================================================================
204 // function : SetCappingHatchOn
206 // =======================================================================
207 void Graphic3d_ClipPlane::SetCappingHatchOn()
209 myAspect->SetInteriorStyle (Aspect_IS_HATCH);
213 // =======================================================================
214 // function : SetCappingHatchOff
216 // =======================================================================
217 void Graphic3d_ClipPlane::SetCappingHatchOff()
219 myAspect->SetInteriorStyle (Aspect_IS_SOLID);
223 // =======================================================================
224 // function : SetCappingAspect
226 // =======================================================================
227 void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
229 myAspect = theAspect;
233 // =======================================================================
234 // function : setCappingFlag
236 // =======================================================================
237 void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
245 myFlags &= ~(theFlag);
250 // =======================================================================
253 // =======================================================================
254 void Graphic3d_ClipPlane::makeId()
256 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
257 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));