1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_Line_HeaderFile
18 #define _Geom2d_Line_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <gp_Ax2d.hxx>
24 #include <Geom2d_Curve.hxx>
25 #include <Standard_Real.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <GeomAbs_Shape.hxx>
28 #include <Standard_Integer.hxx>
29 class Standard_RangeError;
36 class Geom2d_Geometry;
40 DEFINE_STANDARD_HANDLE(Geom2d_Line, Geom2d_Curve)
42 //! Describes an infinite line in the plane (2D space).
43 //! A line is defined and positioned in the plane with an
44 //! axis (gp_Ax2d object) which gives it an origin and a unit vector.
45 //! The Geom2d_Line line is parameterized as follows:
48 //! - P is the point of parameter U,
49 //! - O is the origin and Dir the unit vector of its positioning axis.
50 //! The parameter range is ] -infinite, +infinite [.
51 //! The orientation of the line is given by the unit vector
52 //! of its positioning axis.
54 //! GCE2d_MakeLine which provides functions for more
55 //! complex line constructions
57 //! gp_Lin2d for an equivalent, non-parameterized data structure.
58 class Geom2d_Line : public Geom2d_Curve
65 //! Creates a line located in 2D space with the axis placement A.
66 //! The Location of A is the origin of the line.
67 Standard_EXPORT Geom2d_Line(const gp_Ax2d& A);
70 //! Creates a line by conversion of the gp_Lin2d line L.
71 Standard_EXPORT Geom2d_Line(const gp_Lin2d& L);
73 //! Constructs a line passing through point P and parallel to
74 //! vector V (P and V are, respectively, the origin
75 //! and the unit vector of the positioning axis of the line).
76 Standard_EXPORT Geom2d_Line(const gp_Pnt2d& P, const gp_Dir2d& V);
79 //! Set <me> so that <me> has the same geometric properties as L.
80 Standard_EXPORT void SetLin2d (const gp_Lin2d& L);
82 //! changes the direction of the line.
83 Standard_EXPORT void SetDirection (const gp_Dir2d& V);
85 //! changes the direction of the line.
86 Standard_EXPORT const gp_Dir2d& Direction() const;
89 //! Changes the "Location" point (origin) of the line.
90 Standard_EXPORT void SetLocation (const gp_Pnt2d& P);
93 //! Changes the "Location" point (origin) of the line.
94 Standard_EXPORT const gp_Pnt2d& Location() const;
97 //! Changes the "Location" and a the "Direction" of <me>.
98 Standard_EXPORT void SetPosition (const gp_Ax2d& A);
100 Standard_EXPORT const gp_Ax2d& Position() const;
103 //! Returns non persistent line from gp with the same geometric
104 //! properties as <me>
105 Standard_EXPORT gp_Lin2d Lin2d() const;
107 //! Changes the orientation of this line. As a result, the
108 //! unit vector of the positioning axis of this line is reversed.
109 Standard_EXPORT void Reverse() Standard_OVERRIDE;
111 //! Computes the parameter on the reversed line for the
112 //! point of parameter U on this line.
113 //! For a line, the returned value is -U.
114 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
116 //! Returns RealFirst from Standard.
117 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
119 //! Returns RealLast from Standard
120 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
123 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
126 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
128 //! Returns GeomAbs_CN, which is the global continuity of any line.
129 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
131 //! Computes the distance between <me> and the point P.
132 Standard_EXPORT Standard_Real Distance (const gp_Pnt2d& P) const;
135 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
137 //! Returns in P the point of parameter U.
138 //! P (U) = O + U * Dir where O is the "Location" point of the
139 //! line and Dir the direction of the line.
140 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
143 //! Returns the point P of parameter u and the first derivative V1.
144 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
147 //! Returns the point P of parameter U, the first and second
148 //! derivatives V1 and V2. V2 is a vector with null magnitude
150 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
153 //! V2 and V3 are vectors with null magnitude for a line.
154 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
156 //! For the point of parameter U of this line, computes
157 //! the vector corresponding to the Nth derivative.
158 //! Note: if N is greater than or equal to 2, the result is a
159 //! vector with null magnitude.
160 //! Exceptions Standard_RangeError if N is less than 1.
161 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
163 //! Applies the transformation T to this line.
164 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
166 //! Computes the parameter on the line transformed by
167 //! T for the point of parameter U on this line.
168 //! For a line, the returned value is equal to U multiplied
169 //! by the scale factor of transformation T.
170 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf2d& T) const Standard_OVERRIDE;
172 //! Returns the coefficient required to compute the
173 //! parametric transformation of this line when
174 //! transformation T is applied. This coefficient is the
175 //! ratio between the parameter of a point on this line
176 //! and the parameter of the transformed point on the
177 //! new line transformed by T.
178 //! For a line, the returned value is the scale factor of the transformation T.
179 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const Standard_OVERRIDE;
181 //! Creates a new object, which is a copy of this line.
182 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
184 //! Dumps the content of me into the stream
185 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
190 DEFINE_STANDARD_RTTIEXT(Geom2d_Line,Geom2d_Curve)
211 #endif // _Geom2d_Line_HeaderFile