polyLine.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-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::polyLine
28 
29 Description
30  A series of straight line segments, which can also be interpreted as
31  a series of control points for splines, etc.
32 
33  A future implementation could also handle a closed polyLine.
34 
35 SourceFiles
36  polyLine.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef polyLine_H
41 #define polyLine_H
42 
43 #include "pointField.H"
44 #include "scalarList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class polyLine Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 
56 class polyLine
57 {
58  // Private Member Functions
59 
60  //- No copy construct
61  polyLine(const polyLine&) = delete;
62 
63  //- No copy assignment
64  void operator=(const polyLine&) = delete;
65 
66 
67 protected:
68 
69  // Protected data
70 
71  //- The control points or ends of each segments
73 
74  //- The real line length
75  scalar lineLength_;
76 
77  //- The rational (0-1) cumulative parameter value for each point
79 
80 
81  // Protected Member Functions
82 
83  //- Precalculate the rational cumulative parameter value
84  // and the line-length
85  void calcParam();
86 
87  //- Return the line segment and the local parameter [0..1]
88  // corresponding to the global lambda [0..1]
89  label localParameter(scalar& lambda) const;
90 
91 
92 public:
93 
94  // Constructors
95 
96  //- Construct from components
97  polyLine
98  (
99  const pointField&,
100  const bool notImplementedClosed = false
101  );
102 
103 
104  // Member Functions
105 
106  //- Return const-access to the control-points
107  const pointField& points() const;
108 
109  //- Return the number of line segments
110  label nSegments() const;
111 
112  //- Return the point position corresponding to the curve parameter
113  // 0 <= lambda <= 1
114  point position(const scalar) const;
115 
116  //- Return the point position corresponding to the local parameter
117  // 0 <= lambda <= 1 on the given segment
118  point position(const label segment, const scalar) const;
119 
120  //- Return the length of the curve
121  scalar length() const;
122 };
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace Foam
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 #endif
132 
133 // ************************************************************************* //
Foam::polyLine
A series of straight line segments, which can also be interpreted as a series of control points for s...
Definition: polyLine.H:55
Foam::polyLine::points
const pointField & points() const
Return const-access to the control-points.
Definition: polyLine.C:75
Foam::polyLine::nSegments
label nSegments() const
Return the number of line segments.
Definition: polyLine.C:81
scalarList.H
Foam::Field< vector >
Foam::polyLine::param_
scalarList param_
The rational (0-1) cumulative parameter value for each point.
Definition: polyLine.H:77
Foam::polyLine::position
point position(const scalar) const
Return the point position corresponding to the curve parameter.
Definition: polyLine.C:120
Foam::polyLine::points_
pointField points_
The control points or ends of each segments.
Definition: polyLine.H:71
lambda
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:54
Foam::Vector< scalar >
Foam::List< scalar >
Foam::polyLine::lineLength_
scalar lineLength_
The real line length.
Definition: polyLine.H:74
Foam::polyLine::calcParam
void calcParam()
Precalculate the rational cumulative parameter value.
Definition: polyLine.C:32
Foam::polyLine::localParameter
label localParameter(scalar &lambda) const
Return the line segment and the local parameter [0..1].
Definition: polyLine.C:87
Foam::polyLine::length
scalar length() const
Return the length of the curve.
Definition: polyLine.C:174