Warnings on vc14 were eliminated
[occt.git] / src / gp / gp_Lin2d.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_Lin2d_HeaderFile
16 #define _gp_Lin2d_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <gp_Ax2d.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 class Standard_ConstructionError;
26 class gp_Ax2d;
27 class gp_Pnt2d;
28 class gp_Dir2d;
29 class gp_Trsf2d;
30 class gp_Vec2d;
31
32
33 //! Describes a line in 2D space.
34 //! A line is positioned in the plane with an axis (a gp_Ax2d
35 //! object) which gives the line its origin and unit vector. A
36 //! line and an axis are similar objects, thus, we can convert
37 //! one into the other.
38 //! A line provides direct access to the majority of the edit
39 //! and query functions available on its positioning axis. In
40 //! addition, however, a line has specific functions for
41 //! computing distances and positions.
42 //! See Also
43 //! GccAna and Geom2dGcc packages which provide
44 //! functions for constructing lines defined by geometric
45 //! constraints
46 //! gce_MakeLin2d which provides functions for more
47 //! complex line constructions
48 //! Geom2d_Line which provides additional functions for
49 //! constructing lines and works, in particular, with the
50 //! parametric equations of lines
51 class gp_Lin2d 
52 {
53 public:
54
55   DEFINE_STANDARD_ALLOC
56
57   
58   //! Creates a Line corresponding to X axis of the
59   //! reference coordinate system.
60     gp_Lin2d();
61   
62   //! Creates a line located with A.
63     gp_Lin2d(const gp_Ax2d& A);
64   
65
66   //! <P> is the location point (origin) of the line and
67   //! <V> is the direction of the line.
68     gp_Lin2d(const gp_Pnt2d& P, const gp_Dir2d& V);
69   
70
71   //! Creates the line from the equation A*X + B*Y + C = 0.0 Raises ConstructionError if Sqrt(A*A + B*B) <= Resolution from gp.
72   //! Raised if Sqrt(A*A + B*B) <= Resolution from gp.
73   Standard_EXPORT gp_Lin2d(const Standard_Real A, const Standard_Real B, const Standard_Real C);
74   
75     void Reverse();
76   
77
78   //! Reverses the positioning axis of this line.
79   //! Note:
80   //! -   Reverse assigns the result to this line, while
81   //! -   Reversed creates a new one.
82     gp_Lin2d Reversed() const;
83   
84   //! Changes the direction of the line.
85     void SetDirection (const gp_Dir2d& V);
86   
87   //! Changes the origin of the line.
88     void SetLocation (const gp_Pnt2d& P);
89   
90
91   //! Complete redefinition of the line.
92   //! The "Location" point of <A> is the origin of the line.
93   //! The "Direction" of <A> is  the direction of the line.
94     void SetPosition (const gp_Ax2d& A);
95   
96
97   //! Returns the normalized coefficients of the line :
98   //! A * X + B * Y + C = 0.
99     void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C) const;
100   
101   //! Returns the direction of the line.
102     const gp_Dir2d& Direction() const;
103   
104   //! Returns the location point (origin) of the line.
105     const gp_Pnt2d& Location() const;
106   
107
108   //! Returns the axis placement one axis whith the same
109   //! location and direction as <me>.
110     const gp_Ax2d& Position() const;
111   
112   //! Computes the angle between two lines in radians.
113     Standard_Real Angle (const gp_Lin2d& Other) const;
114   
115   //! Returns true if this line contains the point P, that is, if the
116   //! distance between point P and this line is less than or
117   //! equal to LinearTolerance.
118     Standard_Boolean Contains (const gp_Pnt2d& P, const Standard_Real LinearTolerance) const;
119   
120
121   //! Computes the distance between <me> and the point <P>.
122     Standard_Real Distance (const gp_Pnt2d& P) const;
123   
124   //! Computes the distance between two lines.
125     Standard_Real Distance (const gp_Lin2d& Other) const;
126   
127
128   //! Computes the square distance between <me> and the point
129   //! <P>.
130     Standard_Real SquareDistance (const gp_Pnt2d& P) const;
131   
132   //! Computes the square distance between two lines.
133     Standard_Real SquareDistance (const gp_Lin2d& Other) const;
134   
135
136   //! Computes the line normal to the direction of <me>,
137   //! passing through the point <P>.
138     gp_Lin2d Normal (const gp_Pnt2d& P) const;
139   
140   Standard_EXPORT void Mirror (const gp_Pnt2d& P);
141   
142
143   //! Performs the symmetrical transformation of a line
144   //! with respect to the point <P> which is the center
145   //! of the symmetry
146   Standard_EXPORT gp_Lin2d Mirrored (const gp_Pnt2d& P) const;
147   
148   Standard_EXPORT void Mirror (const gp_Ax2d& A);
149   
150
151   //! Performs the symmetrical transformation of a line
152   //! with respect to an axis placement which is the axis
153   //! of the symmetry.
154   Standard_EXPORT gp_Lin2d Mirrored (const gp_Ax2d& A) const;
155   
156     void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
157   
158
159   //! Rotates a line. P is the center of the rotation.
160   //! Ang is the angular value of the rotation in radians.
161     gp_Lin2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
162   
163   void Scale (const gp_Pnt2d& P, const Standard_Real S);
164   
165
166   //! Scales a line. S is the scaling value. Only the
167   //! origin of the line is modified.
168     gp_Lin2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
169   
170     void Transform (const gp_Trsf2d& T);
171   
172
173   //! Transforms a line with the transformation T from class Trsf2d.
174     gp_Lin2d Transformed (const gp_Trsf2d& T) const;
175   
176     void Translate (const gp_Vec2d& V);
177   
178
179   //! Translates a line in the direction of the vector V.
180   //! The magnitude of the translation is the vector's magnitude.
181     gp_Lin2d Translated (const gp_Vec2d& V) const;
182   
183     void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
184   
185
186   //! Translates a line from the point P1 to the point P2.
187     gp_Lin2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
188
189
190
191
192 protected:
193
194
195
196
197
198 private:
199
200
201
202   gp_Ax2d pos;
203
204
205 };
206
207
208 #include <gp_Lin2d.lxx>
209
210
211
212
213
214 #endif // _gp_Lin2d_HeaderFile