0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Graphic3d / Graphic3d_ClipPlane.cxx
CommitLineData
4269bd1b 1// Created on: 2013-07-12
2// Created by: Anton POLETAEV
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
4269bd1b 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
4269bd1b 6//
d5f74e42 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
973c2be1 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.
4269bd1b 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
4269bd1b 15
16#include <Graphic3d_ClipPlane.hxx>
17#include <Graphic3d_AspectFillArea3d.hxx>
18#include <gp_Pln.hxx>
19#include <Standard_Atomic.hxx>
20
4269bd1b 21
92efcf78 22IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
23
4269bd1b 24namespace
25{
26 static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
27};
28
29// =======================================================================
30// function : Graphic3d_ClipPlane
31// purpose :
32// =======================================================================
33Graphic3d_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),
4269bd1b 38 myHatch (Aspect_HS_HORIZONTAL),
39 myHatchOn (Standard_False),
40 myId(),
41 myEquationMod(0),
42 myAspectMod(0)
43{
44 MakeId();
45}
46
47// =======================================================================
48// function : Graphic3d_ClipPlane
49// purpose :
50// =======================================================================
51Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
52: myEquation (theEquation),
53 myIsOn (Standard_True),
54 myIsCapping (Standard_False),
55 myMaterial (Graphic3d_NOM_DEFAULT),
4269bd1b 56 myHatch (Aspect_HS_HORIZONTAL),
57 myHatchOn (Standard_False),
58 myId(),
59 myEquationMod(0),
60 myAspectMod(0)
61{
62 MakeId();
63}
64
65// =======================================================================
66// function : Graphic3d_ClipPlane
67// purpose :
68// =======================================================================
69Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
a9b30f0a 70: Standard_Transient(theOther),
71 myEquation (theOther.myEquation),
4269bd1b 72 myIsOn (theOther.myIsOn),
73 myIsCapping (theOther.myIsCapping),
74 myMaterial (theOther.myMaterial),
75 myTexture (theOther.myTexture),
76 myHatch (theOther.myHatch),
77 myHatchOn (theOther.myHatchOn),
78 myId(),
79 myEquationMod (0),
80 myAspectMod (0)
81{
82 MakeId();
83}
84
85// =======================================================================
86// function : Graphic3d_ClipPlane
87// purpose :
88// =======================================================================
89Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
90: myEquation (),
91 myIsOn (Standard_True),
92 myIsCapping (Standard_False),
93 myMaterial (Graphic3d_NOM_DEFAULT),
4269bd1b 94 myHatch (Aspect_HS_HORIZONTAL),
95 myHatchOn (Standard_False),
96 myId(),
97 myEquationMod(0),
98 myAspectMod(0)
99{
100 MakeId();
101 SetEquation (thePlane);
102}
103
104// =======================================================================
105// function : SetEquation
106// purpose :
107// =======================================================================
108void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
109{
110 myEquation = theEquation;
111 myEquationMod++;
112}
113
114// =======================================================================
115// function : SetPlane
116// purpose :
117// =======================================================================
118void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
119{
120 thePlane.Coefficients (myEquation[0],
121 myEquation[1],
122 myEquation[2],
123 myEquation[3]);
124 myEquationMod++;
125}
126
127// =======================================================================
128// function : SetOn
129// purpose :
130// =======================================================================
131void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
132{
133 myIsOn = theIsOn;
134}
135
136// =======================================================================
137// function : SetCapping
138// purpose :
139// =======================================================================
140void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
141{
142 myIsCapping = theIsOn;
143}
144
145// =======================================================================
146// function : ToPlane
147// purpose :
148// =======================================================================
149gp_Pln Graphic3d_ClipPlane::ToPlane() const
150{
151 return gp_Pln (myEquation[0],
152 myEquation[1],
153 myEquation[2],
154 myEquation[3]);
155}
156
157// =======================================================================
158// function : Clone
159// purpose :
160// =======================================================================
161Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
162{
163 return new Graphic3d_ClipPlane(*this);
164}
165
166// =======================================================================
167// function : SetCappingMaterial
168// purpose :
169// =======================================================================
170void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
171{
172 myMaterial = theMat;
173 myAspectMod++;
174}
175
176// =======================================================================
177// function : SetCappingTexture
178// purpose :
179// =======================================================================
180void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
181{
182 myTexture = theTexture;
183 myAspectMod++;
184}
185
186// =======================================================================
187// function : SetCappingHatch
188// purpose :
189// =======================================================================
190void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
191{
192 myHatch = theStyle;
193 myAspectMod++;
194}
195
196// =======================================================================
197// function : SetCappingHatchOn
198// purpose :
199// =======================================================================
200void Graphic3d_ClipPlane::SetCappingHatchOn()
201{
202 myHatchOn = Standard_True;
203 myAspectMod++;
204}
205
206// =======================================================================
207// function : SetCappingHatchOff
208// purpose :
209// =======================================================================
210void Graphic3d_ClipPlane::SetCappingHatchOff()
211{
212 myHatchOn = Standard_False;
213 myAspectMod++;
214}
215
216// =======================================================================
217// function : MakeId
218// purpose :
219// =======================================================================
220void Graphic3d_ClipPlane::MakeId()
221{
222 myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
223 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
224}
225
226// =======================================================================
227// function : CappingAspect
228// purpose :
229// =======================================================================
230Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
231{
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 if (!myTexture.IsNull())
240 anAspect->SetTextureMapOn();
241 else
242 anAspect->SetTextureMapOff();
243
244 return anAspect;
245}