line.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2018-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::line
29
30Description
31 A line primitive.
32
33SourceFiles
34 lineI.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef line_H
39#define line_H
40
41#include "vector.H"
42#include "PointHit.H"
43#include "point2D.H"
44#include "FixedList.H"
45#include "UList.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward Declarations
53
54template<class Point, class PointRef> class line;
55
56template<class Point, class PointRef>
58
59template<class Point, class PointRef>
61
62
63/*---------------------------------------------------------------------------*\
64 Class line Declaration
65\*---------------------------------------------------------------------------*/
66
67template<class Point, class PointRef>
68class line
69{
70 // Private Data
71
72 //- First point
73 PointRef a_;
74
75 //- Second point
76 PointRef b_;
77
78
79public:
80
81 // Constructors
82
83 //- Construct from two points
84 inline line(const Point& from, const Point& to);
85
86 //- Construct from two points in the list of points
87 // The indices could be from edge etc.
88 inline line
89 (
90 const UList<Point>& points,
91 const FixedList<label, 2>& indices
92 );
93
94 //- Construct from Istream
95 inline explicit line(Istream& is);
96
97
98 // Member Functions
99
100 // Access
101
102 //- Return first point
103 inline PointRef first() const noexcept;
104
105 //- Return second (last) point
106 inline PointRef second() const noexcept;
107
108 //- Return last (second) point
109 inline PointRef last() const noexcept;
110
111 //- Return first point
112 inline PointRef start() const noexcept;
113
114 //- Return second (last) point
115 inline PointRef end() const noexcept;
116
117
118 // Properties
119
120 //- Return centre (centroid)
121 inline Point centre() const;
122
123 //- Return scalar magnitude
124 inline scalar mag() const;
125
126 //- Return start-to-end vector
127 inline Point vec() const;
128
129 //- Return the unit vector (start-to-end)
130 inline Point unitVec() const;
131
132 //- Return nearest distance to line from a given point
133 // If the nearest point is on the line, return a hit
134 PointHit<Point> nearestDist(const Point& p) const;
135
136 //- Return nearest distance from line to line. Returns distance
137 // and sets both points (one on *this, one on the provided
138 // linePointRef.
139 scalar nearestDist
140 (
142 Point& thisPoint,
143 Point& edgePoint
144 ) const;
145
146
147 // IOstream operators
149 friend Istream& operator>> <Point, PointRef>
150 (
151 Istream& is,
152 line& l
153 );
155 friend Ostream& operator<< <Point, PointRef>
156 (
157 Ostream& os,
158 const line& l
159 );
160};
161
162
163//- 2D specialisation
164template<>
166(
168 point2D& thisPoint,
169 point2D& edgePoint
170) const;
171
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#include "lineI.H"
180
181// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182
183#endif
184
185// ************************************************************************* //
CGAL::Point_3< K > Point
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
Definition: PointHit.H:54
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
A line primitive.
Definition: line.H:68
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
Definition: lineI.H:130
PointRef end() const noexcept
Return second (last) point.
Definition: lineI.H:91
PointRef first() const noexcept
Return first point.
Definition: lineI.H:64
PointRef second() const noexcept
Return second (last) point.
Definition: lineI.H:71
Point centre() const
Return centre (centroid)
Definition: lineI.H:98
PointRef last() const noexcept
Return last (second) point.
Definition: lineI.H:78
scalar mag() const
Return scalar magnitude.
Definition: lineI.H:105
Point unitVec() const
Return the unit vector (start-to-end)
Definition: lineI.H:119
PointRef start() const noexcept
Return first point.
Definition: lineI.H:85
Point vec() const
Return start-to-end vector.
Definition: lineI.H:112
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)