0032041: Modeling Data - Access violation ExchangeUV in Geom_BezierSurface
[occt.git] / src / Geom / Geom_Plane.cxx
CommitLineData
b311480e 1// Created on: 1993-03-10
2// Created by: JCV
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
7fd59977 18#include <ElSLib.hxx>
42cf5bc1 19#include <Geom_Curve.hxx>
20#include <Geom_Geometry.hxx>
7fd59977 21#include <Geom_Line.hxx>
42cf5bc1 22#include <Geom_Plane.hxx>
42cf5bc1 23#include <gp.hxx>
24#include <gp_Ax3.hxx>
25#include <gp_Dir.hxx>
26#include <gp_GTrsf2d.hxx>
27#include <gp_Lin.hxx>
28#include <gp_Pln.hxx>
29#include <gp_Pnt.hxx>
30#include <gp_Trsf.hxx>
31#include <gp_Trsf2d.hxx>
32#include <gp_Vec.hxx>
33#include <gp_XYZ.hxx>
34#include <Precision.hxx>
35#include <Standard_ConstructionError.hxx>
36#include <Standard_RangeError.hxx>
37#include <Standard_Type.hxx>
7fd59977 38
92efcf78 39IMPLEMENT_STANDARD_RTTIEXT(Geom_Plane,Geom_ElementarySurface)
40
7fd59977 41typedef Geom_Plane Plane;
7fd59977 42typedef gp_Ax1 Ax1;
43typedef gp_Ax2 Ax2;
44typedef gp_Ax3 Ax3;
45typedef gp_Dir Dir;
46typedef gp_Lin Lin;
47typedef gp_Pln Pln;
48typedef gp_Pnt Pnt;
49typedef gp_Trsf Trsf;
50typedef gp_Vec Vec;
51typedef gp_XYZ XYZ;
52
7fd59977 53//=======================================================================
54//function : Copy
55//purpose :
56//=======================================================================
57
58Handle(Geom_Geometry) Geom_Plane::Copy () const {
59
c04c30b3 60 Handle(Geom_Plane) Pl = new Plane ( pos);
7fd59977 61 return Pl;
62}
63
64
65
66
67//=======================================================================
68//function : Geom_Plane
69//purpose :
70//=======================================================================
71
72Geom_Plane::Geom_Plane (const gp_Ax3& A3) {
73
74 pos = A3;
75}
76
77
78//=======================================================================
79//function : Geom_Plane
80//purpose :
81//=======================================================================
82
83Geom_Plane::Geom_Plane (const gp_Pln& Pl) {
84
85 pos = Pl.Position();
86}
87
88
89//=======================================================================
90//function : Geom_Plane
91//purpose :
92//=======================================================================
93
94Geom_Plane::Geom_Plane (const Pnt& P, const Dir& V) {
95
96 gp_Pln Pl (P, V);
97 pos = Pl.Position();
98}
99
100
101//=======================================================================
102//function : Geom_Plane
103//purpose :
104//=======================================================================
105
106Geom_Plane::Geom_Plane ( const Standard_Real A,
107 const Standard_Real B,
108 const Standard_Real C,
109 const Standard_Real D) {
110
111 gp_Pln Pl (A, B, C, D);
112 pos = Pl.Position ();
113}
114
115
116//=======================================================================
117//function : SetPln
118//purpose :
119//=======================================================================
120
121void Geom_Plane::SetPln (const gp_Pln& Pl)
122{ pos = Pl.Position(); }
123
124//=======================================================================
125//function : Pln
126//purpose :
127//=======================================================================
128
129gp_Pln Geom_Plane::Pln () const {
130
131 return gp_Pln (Position());
132}
133
134
135//=======================================================================
136//function : UReverse
137//purpose :
138//=======================================================================
139
140void Geom_Plane::UReverse() {
141 pos.XReverse();
142}
143
144//=======================================================================
145//function : UReversedParameter
146//purpose :
147//=======================================================================
148
149Standard_Real Geom_Plane::UReversedParameter( const Standard_Real U) const {
150
151 return (-U);
152}
153
154
155//=======================================================================
156//function : VReverse
157//purpose :
158//=======================================================================
159
160void Geom_Plane::VReverse() {
161
162 pos.YReverse();
163}
164
165
166//=======================================================================
167//function : VReversedParameter
168//purpose :
169//=======================================================================
170
171Standard_Real Geom_Plane::VReversedParameter( const Standard_Real V) const {
172
173 return (-V);
174}
175
176//=======================================================================
177//function : Transform
178//purpose :
179//=======================================================================
180
181void Geom_Plane::Transform (const Trsf& T)
182{ pos.Transform (T); }
183
184//=======================================================================
185//function : IsUClosed
186//purpose :
187//=======================================================================
188
189Standard_Boolean Geom_Plane::IsUClosed () const {
190
191 return Standard_False;
192}
193
194//=======================================================================
195//function : IsVClosed
196//purpose :
197//=======================================================================
198
199Standard_Boolean Geom_Plane::IsVClosed () const {
200
201 return Standard_False;
202}
203
204//=======================================================================
205//function : IsUPeriodic
206//purpose :
207//=======================================================================
208
209Standard_Boolean Geom_Plane::IsUPeriodic () const {
210
211 return Standard_False;
212}
213
214//=======================================================================
215//function : IsVPeriodic
216//purpose :
217//=======================================================================
218
219Standard_Boolean Geom_Plane::IsVPeriodic () const {
220
221 return Standard_False;
222}
223
224//=======================================================================
225//function : Bounds
226//purpose :
227//=======================================================================
228
229void Geom_Plane::Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const {
230
231 U1 = -Precision::Infinite();
232 U2 = Precision::Infinite();
233 V1 = -Precision::Infinite();
234 V2 = Precision::Infinite();
235}
236
237
238//=======================================================================
239//function : Coefficients
240//purpose :
241//=======================================================================
242
243void Geom_Plane::Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const {
244
245 gp_Pln Pl (Position());
246 Pl.Coefficients (A, B, C, D);
247}
248
249
250//=======================================================================
251//function : D0
252//purpose :
253//=======================================================================
254
255void Geom_Plane::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const {
256
257 P = ElSLib::PlaneValue (U, V, pos);
258}
259
260
261
262//=======================================================================
263//function : D1
264//purpose :
265//=======================================================================
266
267void Geom_Plane::D1 ( const Standard_Real U, const Standard_Real V,
268 Pnt& P, Vec& D1U, Vec& D1V) const
269{
270
271 ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
272}
273
274
275//=======================================================================
276//function : D2
277//purpose :
278//=======================================================================
279
280void Geom_Plane::D2 ( const Standard_Real U , const Standard_Real V,
281 Pnt& P ,
282 Vec& D1U, Vec& D1V,
283 Vec& D2U, Vec& D2V, Vec& D2UV) const
284{
285
286 ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
287 D2U.SetCoord (0.0, 0.0, 0.0);
288 D2V.SetCoord (0.0, 0.0, 0.0);
289 D2UV.SetCoord (0.0, 0.0, 0.0);
290}
291
292
293//=======================================================================
294//function : D3
295//purpose :
296//=======================================================================
297
298void Geom_Plane::D3 ( const Standard_Real U, const Standard_Real V,
299 Pnt& P,
300 Vec& D1U, Vec& D1V,
301 Vec& D2U, Vec& D2V, Vec& D2UV,
302 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const
303{
304 ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
305 D2U.SetCoord (0.0, 0.0, 0.0);
306 D2V.SetCoord (0.0, 0.0, 0.0);
307 D2UV.SetCoord (0.0, 0.0, 0.0);
308 D3U.SetCoord (0.0, 0.0, 0.0);
309 D3V.SetCoord (0.0, 0.0, 0.0);
310 D3UUV.SetCoord (0.0, 0.0, 0.0);
311 D3UVV.SetCoord (0.0, 0.0, 0.0);
312}
313
314
315
316//=======================================================================
317//function : DN
318//purpose :
319//=======================================================================
320
321Vec Geom_Plane::DN ( const Standard_Real , const Standard_Real ,
322 const Standard_Integer Nu, const Standard_Integer Nv ) const {
323
324 Standard_RangeError_Raise_if (Nu < 0 || Nv < 0 || Nu + Nv < 1, " ");
325 if (Nu == 0 && Nv == 1) {
326 return Vec (pos.YDirection());
327 }
328 else if (Nu == 1 && Nv == 0) {
329 return Vec (pos.XDirection());
330 }
331 return Vec (0.0, 0.0, 0.0);
332}
333
334
335//=======================================================================
336//function : UIso
337//purpose :
338//=======================================================================
339
340Handle(Geom_Curve) Geom_Plane::UIso (const Standard_Real U) const
341{
342 Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneUIso(pos,U));
343 return GL;
344}
345
346
347//=======================================================================
348//function : VIso
349//purpose :
350//=======================================================================
351
352Handle(Geom_Curve) Geom_Plane::VIso (const Standard_Real V) const
353{
354 Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneVIso(pos,V));
355 return GL;
356}
357
358//=======================================================================
359//function : TransformParameters
360//purpose :
361//=======================================================================
362
363void Geom_Plane::TransformParameters(Standard_Real& U,
364 Standard_Real& V,
365 const gp_Trsf& T)
366const
367{
368 if (!Precision::IsInfinite(U)) U *= Abs(T.ScaleFactor());
369 if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
370}
371
372//=======================================================================
373//function : ParametricTransformation
374//purpose :
375//=======================================================================
376
377gp_GTrsf2d Geom_Plane::ParametricTransformation(const gp_Trsf& T) const
378{
379 gp_Trsf2d T2;
380 T2.SetScale(gp::Origin2d(), Abs(T.ScaleFactor()));
381 return gp_GTrsf2d(T2);
382}
bc73b006 383
384//=======================================================================
385//function : DumpJson
386//purpose :
387//=======================================================================
388void Geom_Plane::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
389{
390 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
391
392 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_ElementarySurface)
393}