FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::polyLine
26 
27 Description
28  A series of straight line segments, which can also be interpreted as
29  a series of control points for splines, etc.
30 
31 ToDo
32  A future implementation could also handle a closed polyLine.
33 
34 SourceFiles
35  polyLine.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef polyLine_H
40 #define polyLine_H
41 
42 #include <OpenFOAM/pointField.H>
43 #include <OpenFOAM/scalarList.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class polyLine Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 
55 class polyLine
56 {
57  // Private Member Functions
58 
59  //- Disallow default bitwise copy construct
60  polyLine(const polyLine&);
61 
62  //- Disallow default bitwise assignment
63  void operator=(const polyLine&);
64 
65 protected:
66 
67  // Protected data
68 
69  //- The control points or ends of each segments
71 
72  //- The real line length
73  scalar lineLength_;
74 
75  //- The rational (0-1) cumulative parameter value for each point
77 
78  // Protected member functions
79 
80  //- Precalculate the rational cumulative parameter value
81  // and the line-length
82  void calcParam();
83 
84 
85  //- Return the line segment and the local parameter [0..1]
86  // corresponding to the global lambda [0..1]
87  label localParameter(scalar& lambda) const;
88 
89 public:
90 
91  // Constructors
92 
93  //- Construct from components
94  polyLine
95  (
96  const pointField&,
97  const bool notImplementedClosed = false
98  );
99 
100 
101  // Member Functions
102 
103  //- Return const-access to the control-points
104  const pointField& points() const;
105 
106  //- Return the number of line segments
107  label nSegments() const;
108 
109  //- Return the point position corresponding to the curve parameter
110  // 0 <= lambda <= 1
111  point position(const scalar) const;
112 
113  //- Return the point position corresponding to the local parameter
114  // 0 <= lambda <= 1 on the given segment
115  point position(const label segment, const scalar) const;
116 
117  //- Return the length of the curve
118  scalar length() const;
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #endif
129 
130 // ************************ vim: set sw=4 sts=4 et: ************************ //