FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

polyLine.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::polyLine
00026 
00027 Description
00028     A series of straight line segments, which can also be interpreted as
00029     a series of control points for splines, etc.
00030 
00031 ToDo
00032     A future implementation could also handle a closed polyLine.
00033 
00034 SourceFiles
00035     polyLine.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef polyLine_H
00040 #define polyLine_H
00041 
00042 #include <OpenFOAM/pointField.H>
00043 #include <OpenFOAM/scalarList.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                           Class polyLine Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 
00055 class polyLine
00056 {
00057     // Private Member Functions
00058 
00059         //- Disallow default bitwise copy construct
00060         polyLine(const polyLine&);
00061 
00062         //- Disallow default bitwise assignment
00063         void operator=(const polyLine&);
00064 
00065 protected:
00066 
00067     // Protected data
00068 
00069         //- The control points or ends of each segments
00070         pointField points_;
00071 
00072         //- The real line length
00073         scalar lineLength_;
00074 
00075         //- The rational (0-1) cumulative parameter value for each point
00076         scalarList param_;
00077 
00078     // Protected member functions
00079 
00080         //- Precalculate the rational cumulative parameter value
00081         //  and the line-length
00082         void calcParam();
00083 
00084 
00085         //- Return the line segment and the local parameter [0..1]
00086         //  corresponding to the global lambda [0..1]
00087         label localParameter(scalar& lambda) const;
00088 
00089 public:
00090 
00091     // Constructors
00092 
00093         //- Construct from components
00094         polyLine
00095         (
00096             const pointField&,
00097             const bool notImplementedClosed = false
00098         );
00099 
00100 
00101     // Member Functions
00102 
00103         //- Return const-access to the control-points
00104         const pointField& points() const;
00105 
00106         //- Return the number of line segments
00107         label nSegments() const;
00108 
00109         //- Return the point position corresponding to the curve parameter
00110         //  0 <= lambda <= 1
00111         point position(const scalar) const;
00112 
00113         //- Return the point position corresponding to the local parameter
00114         //  0 <= lambda <= 1 on the given segment
00115         point position(const label segment, const scalar) const;
00116 
00117         //- Return the length of the curve
00118         scalar length() const;
00119 };
00120 
00121 
00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00123 
00124 } // End namespace Foam
00125 
00126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00127 
00128 #endif
00129 
00130 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines