b9c4b5c0870406826923e4dd7197cfb2e00ac76d
[occt.git] / src / gp / gp_Pnt.hxx
1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _gp_Pnt_HeaderFile
16 #define _gp_Pnt_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <gp_XYZ.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 class Standard_OutOfRange;
27 class gp_XYZ;
28 class gp_Ax1;
29 class gp_Ax2;
30 class gp_Trsf;
31 class gp_Vec;
32
33
34 //! Defines a 3D cartesian point.
35 class gp_Pnt 
36 {
37 public:
38
39   DEFINE_STANDARD_ALLOC
40
41   
42   //! Creates a point with zero coordinates.
43     gp_Pnt();
44   
45   //! Creates a point from a XYZ object.
46     gp_Pnt(const gp_XYZ& Coord);
47   
48
49   //! Creates a  point with its 3 cartesian's coordinates : Xp, Yp, Zp.
50     gp_Pnt(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp);
51   
52
53   //! Changes the coordinate of range Index :
54   //! Index = 1 => X is modified
55   //! Index = 2 => Y is modified
56   //! Index = 3 => Z is modified
57   //! Raised if Index != {1, 2, 3}.
58     void SetCoord (const Standard_Integer Index, const Standard_Real Xi);
59   
60   //! For this point, assigns  the values Xp, Yp and Zp to its three coordinates.
61     void SetCoord (const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp);
62   
63   //! Assigns the given value to the X coordinate of this point.
64     void SetX (const Standard_Real X);
65   
66   //! Assigns the given value to the Y coordinate of this point.
67     void SetY (const Standard_Real Y);
68   
69   //! Assigns the given value to the Z coordinate of this point.
70     void SetZ (const Standard_Real Z);
71   
72   //! Assigns the three coordinates of Coord to this point.
73     void SetXYZ (const gp_XYZ& Coord);
74   
75
76   //! Returns the coordinate of corresponding to the value of  Index :
77   //! Index = 1 => X is returned
78   //! Index = 2 => Y is returned
79   //! Index = 3 => Z is returned
80   //! Raises OutOfRange if Index != {1, 2, 3}.
81   //! Raised if Index != {1, 2, 3}.
82     Standard_Real Coord (const Standard_Integer Index) const;
83   
84   //! For this point gives its three coordinates Xp, Yp and Zp.
85     void Coord (Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp) const;
86   
87   //! For this point, returns its X coordinate.
88     Standard_Real X() const;
89   
90   //! For this point, returns its Y coordinate.
91     Standard_Real Y() const;
92   
93   //! For this point, returns its Z coordinate.
94     Standard_Real Z() const;
95   
96   //! For this point, returns its three coordinates as a XYZ object.
97     const gp_XYZ& XYZ() const;
98   
99   //! For this point, returns its three coordinates as a XYZ object.
100     const gp_XYZ& Coord() const;
101   
102
103   //! Returns the coordinates of this point.
104   //! Note: This syntax allows direct modification of the returned value.
105     gp_XYZ& ChangeCoord();
106   
107   //! Assigns the result of the following expression to this point
108   //! (Alpha*this + Beta*P) / (Alpha + Beta)
109     void BaryCenter (const Standard_Real Alpha, const gp_Pnt& P, const Standard_Real Beta);
110   
111   //! Comparison
112   //! Returns True if the distance between the two points is
113   //! lower or equal to LinearTolerance.
114     Standard_Boolean IsEqual (const gp_Pnt& Other, const Standard_Real LinearTolerance) const;
115   
116   //! Computes the distance between two points.
117     Standard_Real Distance (const gp_Pnt& Other) const;
118   
119   //! Computes the square distance between two points.
120     Standard_Real SquareDistance (const gp_Pnt& Other) const;
121   
122
123   //! Performs the symmetrical transformation of a point
124   //! with respect to the point P which is the center of
125   //! the  symmetry.
126   Standard_EXPORT void Mirror (const gp_Pnt& P);
127   
128
129   //! Performs the symmetrical transformation of a point
130   //! with respect to an axis placement which is the axis
131   //! of the symmetry.
132   Standard_NODISCARD Standard_EXPORT gp_Pnt Mirrored (const gp_Pnt& P) const;
133   
134   Standard_EXPORT void Mirror (const gp_Ax1& A1);
135   
136
137   //! Performs the symmetrical transformation of a point
138   //! with respect to a plane. The axis placement A2 locates
139   //! the plane of the symmetry : (Location, XDirection, YDirection).
140   Standard_NODISCARD Standard_EXPORT gp_Pnt Mirrored (const gp_Ax1& A1) const;
141   
142   Standard_EXPORT void Mirror (const gp_Ax2& A2);
143   
144
145   //! Rotates a point. A1 is the axis of the rotation.
146   //! Ang is the angular value of the rotation in radians.
147   Standard_NODISCARD Standard_EXPORT gp_Pnt Mirrored (const gp_Ax2& A2) const;
148   
149     void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
150   
151   //! Scales a point. S is the scaling value.
152     Standard_NODISCARD gp_Pnt Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
153   
154     void Scale (const gp_Pnt& P, const Standard_Real S);
155   
156   //! Transforms a point with the transformation T.
157     Standard_NODISCARD gp_Pnt Scaled (const gp_Pnt& P, const Standard_Real S) const;
158   
159   Standard_EXPORT void Transform (const gp_Trsf& T);
160   
161
162   //! Translates a point in the direction of the vector V.
163   //! The magnitude of the translation is the vector's magnitude.
164   Standard_NODISCARD gp_Pnt Transformed (const gp_Trsf& T) const;
165   
166     void Translate (const gp_Vec& V);
167   
168
169   //! Translates a point from the point P1 to the point P2.
170     Standard_NODISCARD gp_Pnt Translated (const gp_Vec& V) const;
171   
172     void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
173   
174     Standard_NODISCARD gp_Pnt Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
175
176
177   //! Dumps the content of me into the stream
178   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
179
180
181
182 protected:
183
184
185
186
187
188 private:
189
190
191
192   gp_XYZ coord;
193
194
195 };
196
197
198 #include <gp_Pnt.lxx>
199
200
201
202
203
204 #endif // _gp_Pnt_HeaderFile