Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomAPI_Lin_H_
22 #define GeomAPI_Lin_H_
23
24 #include <GeomAPI_Interface.h>
25 #include <memory>
26
27 class GeomAPI_Dir;
28 class GeomAPI_Pnt;
29
30 /**\class GeomAPI_Lin
31  * \ingroup DataModel
32  * \brief Line in 3D
33  */
34
35 class GeomAPI_Lin : public GeomAPI_Interface
36 {
37  public:
38   /// Creation of line defined by cordinates of start and end points
39   GEOMAPI_EXPORT
40   GeomAPI_Lin(const double theStartX, const double theStartY, const double theStartZ,
41               const double theEndX, const double theEndY, const double theEndZ);
42   /// Creation of line defined by start and end points
43   GEOMAPI_EXPORT
44   GeomAPI_Lin(const std::shared_ptr<GeomAPI_Pnt>& theStart,
45               const std::shared_ptr<GeomAPI_Pnt>& theEnd);
46   /// Creation of line defined by origin and direction
47   GEOMAPI_EXPORT
48   GeomAPI_Lin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
49               const std::shared_ptr<GeomAPI_Dir>& theDirection);
50
51   /// Returns point on the line (first point)
52   GEOMAPI_EXPORT
53   std::shared_ptr<GeomAPI_Pnt> location();
54
55   /// Returns a line direction
56   GEOMAPI_EXPORT
57   std::shared_ptr<GeomAPI_Dir> direction();
58
59   /// Distance between two points
60   GEOMAPI_EXPORT
61   double distance(const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
62   /// Intersection of two lines
63   GEOMAPI_EXPORT
64   const std::shared_ptr<GeomAPI_Pnt> intersect(
65       const std::shared_ptr<GeomAPI_Lin>& theLine) const;
66   /// Project point on line
67   GEOMAPI_EXPORT
68   const std::shared_ptr<GeomAPI_Pnt> project(
69       const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
70
71   /// \return true if this line contains thePoint, that is,
72   /// if the distance between thePoint and this line
73   ///         is less than or equal to theLinearTolerance.
74   GEOMAPI_EXPORT
75   bool contains(const std::shared_ptr<GeomAPI_Pnt> thePoint,
76                 const double theLinearTolerance = 1.e-7) const;
77
78   /// \return true if lines are parallel.
79   GEOMAPI_EXPORT
80   bool isParallel(const std::shared_ptr<GeomAPI_Lin> theLin) const;
81
82   /// \return true if lines are coplanar.
83   GEOMAPI_EXPORT
84   bool isCoplanar(const std::shared_ptr<GeomAPI_Lin> theLin) const;
85 };
86
87 #endif
88