1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
19 inline gp_Pln::gp_Pln()
22 inline gp_Pln::gp_Pln(const gp_Ax3& A3) : pos(A3)
25 inline void gp_Pln::Coefficients (Standard_Real& A,
28 Standard_Real& D) const
30 const gp_Dir& dir = pos.Direction();
41 const gp_Pnt& P = pos.Location();
42 D = -(A * P.X() + B * P.Y() + C * P.Z());
45 inline void gp_Pln::SetAxis (const gp_Ax1& A1)
48 inline void gp_Pln::SetLocation (const gp_Pnt& Loc)
49 { pos.SetLocation (Loc); }
51 inline void gp_Pln::SetPosition (const gp_Ax3& A3)
54 inline void gp_Pln::UReverse ()
57 inline void gp_Pln::VReverse ()
60 inline Standard_Boolean gp_Pln::Direct()const
61 { return pos.Direct(); }
63 inline const gp_Ax1& gp_Pln::Axis() const
64 { return pos.Axis(); }
66 inline const gp_Pnt& gp_Pln::Location() const
67 { return pos.Location(); }
69 inline const gp_Ax3& gp_Pln::Position() const
72 inline Standard_Real gp_Pln::Distance(const gp_Pnt& P) const
74 const gp_Pnt& loc = pos.Location ();
75 const gp_Dir& dir = pos.Direction();
76 Standard_Real D = (dir.X() * (P.X() - loc.X()) +
77 dir.Y() * (P.Y() - loc.Y()) +
78 dir.Z() * (P.Z() - loc.Z()));
83 inline Standard_Real gp_Pln::Distance (const gp_Lin& L) const
85 Standard_Real D = 0.0;
86 if ((pos.Direction()).IsNormal (L.Direction(), gp::Resolution())) {
87 const gp_Pnt& P = L .Location ();
88 const gp_Pnt& loc = pos.Location ();
89 const gp_Dir& dir = pos.Direction();
90 D = (dir.X() * (P.X() - loc.X()) +
91 dir.Y() * (P.Y() - loc.Y()) +
92 dir.Z() * (P.Z() - loc.Z()));
98 inline Standard_Real gp_Pln::Distance(const gp_Pln& Other) const
100 Standard_Real D = 0.0;
101 if ((pos.Direction()).IsParallel(Other.pos.Direction(), gp::Resolution())){
102 const gp_Pnt& P = Other.pos.Location();
103 const gp_Pnt& loc = pos.Location ();
104 const gp_Dir& dir = pos.Direction();
105 D = (dir.X() * (P.X() - loc.X()) +
106 dir.Y() * (P.Y() - loc.Y()) +
107 dir.Z() * (P.Z() - loc.Z()));
113 inline Standard_Real gp_Pln::SquareDistance (const gp_Pnt& P) const
114 { Standard_Real D = Distance(P); return D * D; }
116 inline Standard_Real gp_Pln::SquareDistance (const gp_Lin& L) const
117 { Standard_Real D = Distance(L); return D * D; }
119 inline Standard_Real gp_Pln::SquareDistance (const gp_Pln& Other) const
120 { Standard_Real D = Distance(Other); return D * D; }
122 inline gp_Ax1 gp_Pln::XAxis () const
123 { return gp_Ax1 (pos.Location(), pos.XDirection()); }
125 inline gp_Ax1 gp_Pln::YAxis () const
126 { return gp_Ax1 (pos.Location(), pos.YDirection()); }
128 inline Standard_Boolean gp_Pln::Contains
130 const Standard_Real LinearTolerance) const
131 { return Distance(P) <= LinearTolerance; }
133 inline Standard_Boolean gp_Pln::Contains
135 const Standard_Real LinearTolerance,
136 const Standard_Real AngularTolerance) const
137 { return Contains(L.Location(), LinearTolerance) &&
138 pos.Direction().IsNormal(L.Direction(), AngularTolerance);
141 inline void gp_Pln::Rotate (const gp_Ax1& A1, const Standard_Real Ang)
142 { pos.Rotate(A1, Ang); }
144 inline gp_Pln gp_Pln::Rotated (const gp_Ax1& A1,
145 const Standard_Real Ang) const
148 Pl.pos.Rotate(A1, Ang);
152 inline void gp_Pln::Scale (const gp_Pnt& P, const Standard_Real S)
155 inline gp_Pln gp_Pln::Scaled (const gp_Pnt& P,
156 const Standard_Real S) const
163 inline void gp_Pln::Transform (const gp_Trsf& T)
164 { pos.Transform(T); }
166 inline gp_Pln gp_Pln::Transformed (const gp_Trsf& T) const
173 inline void gp_Pln::Translate (const gp_Vec& V)
174 { pos.Translate(V); }
176 inline gp_Pln gp_Pln::Translated (const gp_Vec& V) const
183 inline void gp_Pln::Translate (const gp_Pnt& P1, const gp_Pnt& P2)
184 { pos.Translate(P1,P2); }
186 inline gp_Pln gp_Pln::Translated (const gp_Pnt& P1,
187 const gp_Pnt& P2) const
190 Pl.pos.Translate(P1, P2);