initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / generation / blockMesh / curvedEdges / curvedEdge.H
blob7035568657dbfda8ea5d14b059f3c94e3ab66909
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::curvedEdge
28 Description
29     curvedEdges : library functions that will define a curvedEdge in space
30     parameterised for 0<lambda<1 from the beginning point to the end point.
31     This file contains the abstract base class curvedEdge.
33 SourceFiles
34     curvedEdge.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef curvedEdges_H
39 #define curvedEdges_H
41 #include "pointField.H"
42 #include "typeInfo.H"
43 #include "HashTable.H"
44 #include "autoPtr.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 /*---------------------------------------------------------------------------*\
52                            Class curvedEdge Declaration
53 \*---------------------------------------------------------------------------*/
55 class curvedEdge
57 protected:
59     // Protected data
61         const pointField& points_;
62         const label start_, end_;
64 public:
66     // Constructor Hash tables
68         //- Construct from Istream function pointer type
69         typedef autoPtr<curvedEdge> (*IstreamConstructorPtr_)
70             (const pointField&, Istream&);
72         //- Construct from Istream function pointer table pointer
73         static HashTable<IstreamConstructorPtr_>*
74             IstreamConstructorTablePtr_;
77     // Hash table constructor classes and functions
79         //- Hash table Constructor.
80         //  Must be called from the table add functions below.
81         static void constructTables();
84         //- Class to add constructor from Istream to Hash table
85         template<class curvedEdgeType>
86         class addIstreamConstructorToTable
87         {
88         public:
90             static autoPtr<curvedEdge> New
91             (
92                 const pointField& points,
93                 Istream& is
94             )
95             {
96                 return autoPtr<curvedEdge>(new curvedEdgeType(points, is));
97             }
99             addIstreamConstructorToTable()
100             {
101                 curvedEdge::constructTables();
103                 curvedEdge::IstreamConstructorTablePtr_
104                     ->insert(curvedEdgeType::typeName, New);
105             }
106         };
109     //- Runtime type information
110     TypeName("curvedEdge");
113     // Constructors
115         //- Construct from components
116         curvedEdge
117         (
118             const pointField& points,
119             const label start,
120             const label end
121         );
123         //- Construct from Istream setting pointsList
124         curvedEdge(const pointField&, Istream&);
126         //- Copy construct
127         curvedEdge(const curvedEdge&);
129         //- Clone function
130         virtual autoPtr<curvedEdge> clone() const;
132         //- New function which constructs and returns pointer to a curvedEdge
133         static autoPtr<curvedEdge> New(const pointField&, Istream&);
136     // Destructor
138         virtual ~curvedEdge(){}
141     // Member Functions
143         //- Return label of start point
144         label start() const
145         {
146             return start_;
147         }
149         //- Return label of end point
150         label end() const
151         {
152             return end_;
153         }
155         //- Compare the given start and end points with those of this curve
156         bool compare(const label start, const label end) const
157         {
158             return
159             (
160                 (start_ == start && end_ == end)
161              || (start_ == end && end_ == start)
162             );
163         }
165         //- Return the position of a point on the curve given by
166         //  the parameter 0 <= lambda <= 1
167         virtual vector position(const scalar) const = 0;
169         //- Return the length of the curve
170         virtual scalar length() const = 0;
172     // Member operators
174         void operator=(const curvedEdge&);
176     // Ostream operator
178         friend Ostream& operator<<(Ostream&, const curvedEdge&);
182 //- Return the complete knotList by adding the start and end points to the
183 //  given list
184 pointField knotlist
186     const pointField& points,
187     const label start,
188     const label end,
189     const pointField& otherknots
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 } // End namespace Foam
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 #endif
201 // ************************************************************************* //