1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
33 \*---------------------------------------------------------------------------*/
41 #include "FixedList.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of classes
55 // Forward declaration of friend functions and operators
57 template<class Point, class PointRef> class line;
59 template<class Point, class PointRef>
60 inline Istream& operator>>(Istream&, line<Point, PointRef>&);
62 template<class Point, class PointRef>
63 inline Ostream& operator<<(Ostream&, const line<Point, PointRef>&);
66 /*---------------------------------------------------------------------------*\
67 Class line Declaration
68 \*---------------------------------------------------------------------------*/
70 template<class Point, class PointRef>
82 //- Construct from two points
83 inline line(const Point& start, const Point& end);
85 //- Construct from two points in the list of points
86 // The indices could be from edge etc.
90 const FixedList<label, 2>& indices
93 //- Construct from Istream
94 inline line(Istream&);
101 //- Return first vertex
102 inline PointRef start() const;
104 //- Return second vertex
105 inline PointRef end() const;
110 //- Return centre (centroid)
111 inline Point centre() const;
113 //- Return scalar magnitude
114 inline scalar mag() const;
116 //- Return start-end vector
117 inline Point vec() const;
119 //- Return nearest distance to line from a given point
120 // If the nearest point is on the line, return a hit
121 PointHit<Point> nearestDist(const Point& p) const;
123 //- Return nearest distance from line to line. Returns distance
124 // and sets both points (one on *this, one on the provided
128 const line<Point, const Point&>& edge,
136 friend Istream& operator>> <Point, PointRef>
142 friend Ostream& operator<< <Point, PointRef>
150 //- 2D specialisation
152 scalar line<point2D, const point2D&>::nearestDist
154 const line<point2D, const point2D&>& edge,
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 } // End namespace Foam
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 // ************************************************************************* //