pyramid.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 OpenFOAM Foundation
9  Copyright (C) 2020-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pyramid
29 
30 Description
31  A geometric pyramid primitive with a base of 'n' sides:
32  i.e. a parametric pyramid. A pyramid is constructed from
33  a base polygon and an apex point.
34 
35 SourceFiles
36  pyramidI.H
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_pyramid_H
41 #define Foam_pyramid_H
42 
43 #include "point.H"
44 #include "face.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 
53 template<class Point, class PointRef, class PolygonRef> class pyramid;
54 
55 template<class Point, class PointRef, class PolygonRef>
56 inline Istream& operator>>
57 (
58  Istream& is,
60 );
61 
62 template<class Point, class PointRef, class PolygonRef>
63 inline Ostream& operator<<
64 (
65  Ostream& os,
67 );
68 
69 
70 // Common Typedefs
71 
72 //- A pyramid using referred point and face
74 
75 
76 /*---------------------------------------------------------------------------*\
77  Class pyramid Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Point, class PointRef, class PolygonRef>
81 class pyramid
82 {
83  // Private Data
84 
85  PolygonRef base_;
86 
87  PointRef apex_;
88 
89 
90 public:
91 
92  // Public Typedefs
93 
94  //- The point type
95  typedef Point point_type;
96 
97 
98  // Constructors
99 
100  //- Construct from base polygon and apex point
101  inline pyramid(PolygonRef base, const Point& apex);
102 
103  //- Construct from Istream
104  inline explicit pyramid(Istream& is);
105 
106 
107  // Member Functions
108 
109  // Access
110 
111  //- The apex point
112  const Point& apex() const { return apex_; }
113 
114  //- The base polygon
115  PolygonRef base() const { return base_; }
116 
118  // Properties
119 
120  //- Return centre (centroid)
121  inline Point centre(const UList<point>& points) const;
123  //- Return height vector
124  inline vector height(const UList<point>& points) const;
125 
126  //- Return scalar magnitude - returns volume of pyramid
127  inline scalar mag(const UList<point>& points) const;
128 
129 
130  // IOstream Operators
131 
132  friend Istream& operator>> <Point, PointRef, PolygonRef>
133  (
134  Istream& is,
135  pyramid& p
136  );
137 
138  friend Ostream& operator<< <Point, PointRef, PolygonRef>
139  (
140  Ostream& os,
141  const pyramid& p
142  );
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #include "pyramidI.H"
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
pyramid(PolygonRef base, const Point &apex)
Construct from base polygon and apex point.
Definition: pyramidI.H:27
PolygonRef base() const
The base polygon.
Definition: pyramid.H:122
scalar mag(const UList< point > &points) const
Return scalar magnitude - returns volume of pyramid.
Definition: pyramidI.H:69
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
pyramid< point, const point &, const face & > pyramidPointFaceRef
A pyramid using referred point and face.
Definition: pyramid.H:70
const pointField & points
vector height(const UList< point > &points) const
Return height vector.
Definition: pyramidI.H:58
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
Point centre(const UList< point > &points) const
Return centre (centroid)
Definition: pyramidI.H:48
CGAL::Point_3< K > Point
volScalarField & p
const Point & apex() const
The apex point.
Definition: pyramid.H:117
Point point_type
The point type.
Definition: pyramid.H:94
A geometric pyramid primitive with a base of &#39;n&#39; sides: i.e. a parametric pyramid. A pyramid is constructed from a base polygon and an apex point.
Definition: pyramid.H:48
Namespace for OpenFOAM.