Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / meshes / primitiveShapes / pyramid / pyramidI.H
blob6a9e9d8a01a7507cbf9dfbd461cf282b48c8fe91
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Point, class PointRef, class polygonRef>
38 inline pyramid<Point, PointRef, polygonRef>::pyramid
40     polygonRef base,
41     const Point& apex
44     base_(base),
45     apex_(apex)
49 template<class Point, class PointRef, class polygonRef>
50 inline pyramid<Point, PointRef, polygonRef>::pyramid(Istream& is)
52     is >> base_ >> apex_;
53     is.check("pyramid::pyramid(Istream& is)");
57 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
59 template<class Point, class PointRef, class polygonRef>
60 inline const Point& pyramid<Point, PointRef, polygonRef>::apex() const
62     return apex_;
65 template<class Point, class PointRef, class polygonRef>
66 inline polygonRef pyramid<Point, PointRef, polygonRef>::base() const
68     return base_;
72 template<class Point, class PointRef, class polygonRef>
73 inline Point pyramid<Point, PointRef, polygonRef>::centre
75     const pointField& points
76 ) const
78     return (3.0/4.0)*base_.centre(points) + (1.0/4.0)*apex_;
82 template<class Point, class PointRef, class polygonRef>
83 inline vector pyramid<Point, PointRef, polygonRef>::height
85     const pointField& points
86 ) const
88     // Height = apex - baseCentroid
89     return (apex_ - base_.centre(points));
93 template<class Point, class PointRef, class polygonRef>
94 inline scalar pyramid<Point, PointRef, polygonRef>::mag
96     const pointField& points
97 ) const
99     return (1.0/3.0)*(base_.normal(points)&(height(points)));
103 // * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * * //
105 template<class Point, class PointRef, class polygonRef>
106 inline Istream& operator>>
108     Istream& is,
109     pyramid<Point, PointRef, polygonRef>& p
112     is >> p.base_ >> p.apex_;
113     is.check("Istream& operator>>(Istream&, pyramid&)");
114     return is;
118 template<class Point, class PointRef, class polygonRef>
119 inline Ostream& operator<<
121     Ostream& os,
122     const pyramid<Point, PointRef, polygonRef>& p
125     os << p.base_ << tab << p.apex_ << nl;
126     return os;
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 } // End namespace Foam
134 // ************************************************************************* //