0031044: Coding - Standard_NODISCARD should be placed before Standard_EXPORT
[occt.git] / src / gp / gp_Pnt2d.hxx
CommitLineData
42cf5bc1 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_Pnt2d_HeaderFile
16#define _gp_Pnt2d_HeaderFile
17
18#include <Standard.hxx>
19#include <Standard_DefineAlloc.hxx>
20#include <Standard_Handle.hxx>
21
22#include <gp_XY.hxx>
23#include <Standard_Real.hxx>
24#include <Standard_Integer.hxx>
25#include <Standard_Boolean.hxx>
26class Standard_OutOfRange;
27class gp_XY;
28class gp_Ax2d;
29class gp_Trsf2d;
30class gp_Vec2d;
31
32
33//! Defines a non-persistent 2D cartesian point.
34class gp_Pnt2d
35{
36public:
37
38 DEFINE_STANDARD_ALLOC
39
40
41 //! Creates a point with zero coordinates.
42 gp_Pnt2d();
43
44 //! Creates a point with a doublet of coordinates.
45 gp_Pnt2d(const gp_XY& Coord);
46
47
48 //! Creates a point with its 2 cartesian's coordinates : Xp, Yp.
49 gp_Pnt2d(const Standard_Real Xp, const Standard_Real Yp);
50
51
52 //! Assigns the value Xi to the coordinate that corresponds to Index:
53 //! Index = 1 => X is modified
54 //! Index = 2 => Y is modified
55 //! Raises OutOfRange if Index != {1, 2}.
56 void SetCoord (const Standard_Integer Index, const Standard_Real Xi);
57
58 //! For this point, assigns the values Xp and Yp to its two coordinates
59 void SetCoord (const Standard_Real Xp, const Standard_Real Yp);
60
61 //! Assigns the given value to the X coordinate of this point.
62 void SetX (const Standard_Real X);
63
64 //! Assigns the given value to the Y coordinate of this point.
65 void SetY (const Standard_Real Y);
66
67 //! Assigns the two coordinates of Coord to this point.
68 void SetXY (const gp_XY& Coord);
69
70
71 //! Returns the coordinate of range Index :
72 //! Index = 1 => X is returned
73 //! Index = 2 => Y is returned
74 //! Raises OutOfRange if Index != {1, 2}.
be5c3602 75 Standard_Real Coord (const Standard_Integer Index) const;
42cf5bc1 76
77 //! For this point returns its two coordinates as a number pair.
78 void Coord (Standard_Real& Xp, Standard_Real& Yp) const;
79
80 //! For this point, returns its X coordinate.
81 Standard_Real X() const;
82
83 //! For this point, returns its Y coordinate.
84 Standard_Real Y() const;
85
86 //! For this point, returns its two coordinates as a number pair.
87 const gp_XY& XY() const;
88
89 //! For this point, returns its two coordinates as a number pair.
90 const gp_XY& Coord() const;
91
92
93 //! Returns the coordinates of this point.
94 //! Note: This syntax allows direct modification of the returned value.
95 gp_XY& ChangeCoord();
96
97 //! Comparison
98 //! Returns True if the distance between the two
99 //! points is lower or equal to LinearTolerance.
100 Standard_Boolean IsEqual (const gp_Pnt2d& Other, const Standard_Real LinearTolerance) const;
101
102 //! Computes the distance between two points.
103 Standard_Real Distance (const gp_Pnt2d& Other) const;
104
105 //! Computes the square distance between two points.
106 Standard_Real SquareDistance (const gp_Pnt2d& Other) const;
107
108
109 //! Performs the symmetrical transformation of a point
110 //! with respect to the point P which is the center of
111 //! the symmetry.
112 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
113
114
115 //! Performs the symmetrical transformation of a point
116 //! with respect to an axis placement which is the axis
6ed44b1c 117 Standard_NODISCARD Standard_EXPORT gp_Pnt2d Mirrored (const gp_Pnt2d& P) const;
42cf5bc1 118
119 Standard_EXPORT void Mirror (const gp_Ax2d& A);
120
121
122 //! Rotates a point. A1 is the axis of the rotation.
123 //! Ang is the angular value of the rotation in radians.
6ed44b1c 124 Standard_NODISCARD Standard_EXPORT gp_Pnt2d Mirrored (const gp_Ax2d& A) const;
42cf5bc1 125
126 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
127
128 //! Scales a point. S is the scaling value.
0be7dbe1 129 Standard_NODISCARD gp_Pnt2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
42cf5bc1 130
131 void Scale (const gp_Pnt2d& P, const Standard_Real S);
132
133 //! Transforms a point with the transformation T.
0be7dbe1 134 Standard_NODISCARD gp_Pnt2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
42cf5bc1 135
136 Standard_EXPORT void Transform (const gp_Trsf2d& T);
137
138
139 //! Translates a point in the direction of the vector V.
140 //! The magnitude of the translation is the vector's magnitude.
0be7dbe1 141 Standard_NODISCARD gp_Pnt2d Transformed (const gp_Trsf2d& T) const;
42cf5bc1 142
143 void Translate (const gp_Vec2d& V);
144
145
146 //! Translates a point from the point P1 to the point P2.
0be7dbe1 147 Standard_NODISCARD gp_Pnt2d Translated (const gp_Vec2d& V) const;
42cf5bc1 148
149 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
150
0be7dbe1 151 Standard_NODISCARD gp_Pnt2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
42cf5bc1 152
153
154
155
156protected:
157
158
159
160
161
162private:
163
164
165
166 gp_XY coord;
167
168
169};
170
171
172#include <gp_Pnt2d.lxx>
173
174
175
176
177
178#endif // _gp_Pnt2d_HeaderFile