Salome HOME
Update copyrights
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin2d.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef GeomAPI_Lin2d_H_
21 #define GeomAPI_Lin2d_H_
22
23 #include <GeomAPI_Interface.h>
24 #include <memory>
25
26 class GeomAPI_Dir2d;
27 class GeomAPI_Pnt2d;
28
29 /**\class GeomAPI_Lin2d
30  * \ingroup DataModel
31  * \brief Line in 2D
32  */
33
34 class GeomAPI_Lin2d : public GeomAPI_Interface
35 {
36  public:
37   /// Creation of line defined by cordinates of start and end points
38   GEOMAPI_EXPORT
39   GeomAPI_Lin2d(const double theStartX, const double theStartY, const double theEndX,
40                 const double theEndY);
41   /// Creation of line defined by start and end points
42   GEOMAPI_EXPORT
43   GeomAPI_Lin2d(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
44                 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd);
45   /// Creation of line defined by origin and direction
46   GEOMAPI_EXPORT
47   GeomAPI_Lin2d(const std::shared_ptr<GeomAPI_Pnt2d>& theOrigin,
48                 const std::shared_ptr<GeomAPI_Dir2d>& theDirection);
49
50   /// Returns point on the line (first point)
51   GEOMAPI_EXPORT
52   std::shared_ptr<GeomAPI_Pnt2d> location();
53
54   /// Returns a line direction
55   GEOMAPI_EXPORT
56   std::shared_ptr<GeomAPI_Dir2d> direction();
57
58   /// Distance between two points
59   GEOMAPI_EXPORT
60   double distance(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
61   /// Intersection of two lines
62   GEOMAPI_EXPORT
63   const std::shared_ptr<GeomAPI_Pnt2d> intersect(
64       const std::shared_ptr<GeomAPI_Lin2d>& theLine) const;
65   /// Project point on line
66   GEOMAPI_EXPORT
67   const std::shared_ptr<GeomAPI_Pnt2d> project(
68       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
69   /// Computes the cross product of the line direction and a vector
70   /// from the line start point to the point
71   GEOMAPI_EXPORT
72   bool isRight(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
73
74   /// Returns a location point shifted on theShift in perpendicular direction
75   GEOMAPI_EXPORT
76   std::shared_ptr<GeomAPI_Pnt2d> shiftedLocation(double theShift) const;
77 };
78
79 #endif
80