meshOctreeCubeCoordinates.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  meshOctreeCubeCoordinates
26 
27 Description
28  A cube stores information needed for mesh generation
29 
30 SourceFiles
31  meshOctreeCubeCoordinates.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef meshOctreeCubeCoordinates_H
36 #define meshOctreeCubeCoordinates_H
37 
38 #include "label.H"
39 #include "direction.H"
40 #include "FixedList.H"
41 #include "boundBox.H"
42 #include "contiguous.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 class triSurf;
50 class boundBox;
51 
52 /*---------------------------------------------------------------------------*\
53  Class meshOctreeCubeCoordinates Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 {
58  // Private data
59  //- coordinates in the octree structure
62  label posZ_;
63 
64  //- cube level in the octree structure
66 
67 public:
68 
69  // Static data
70  //- edge nodes for an octree cube
71  static const label edgeNodes_[12][2];
72 
73  //- cube nodes making each face
74  static const label faceNodes_[6][4];
75 
76  //- node-faces addressing for the cube
77  static const label nodeFaces_[8][3];
78 
79  //- face-edges addressing for the octree cube
80  static const label faceEdges_[6][4];
81 
82  //- edge-faces addressing for the octree cube
83  static const label edgeFaces_[12][2];
84 
85  //- return the opposite face of each cube face
86  static const label oppositeFace_[6];
87 
88  // Constructors
89  //- Null constructor
91 
92  //- Construct from coordinates and level
93  explicit inline meshOctreeCubeCoordinates
94  (
95  const label posX,
96  const label posY,
97  const label posZ,
98  const direction level
99  );
100 
101  //- copy constructor
103  (
105  );
106 
107  // Destructor
108 
110  {}
111 
112  // Member functions
113  //- return level
114  inline direction level() const;
115 
116  //- return x, y, z coordinates
117  inline label posX() const;
118  inline label posY() const;
119  inline label posZ() const;
120 
121  //- return the coordinates of child cube at the given position
123 
124  //- return the coordinates of the parent at the level reduced by
125  //- the given number of levels
127  (
128  const direction diff
129  ) const;
130 
131  //- return the coordinates of the parent at the given level
133 
134  //- return the minimal coordinates of the child at the given level
136  (
137  const direction l
138  ) const;
139 
140  //- return the maximal coordinates of the child at the given level
142  (
143  const direction l
144  ) const;
145 
146  //- return min and max points
147  inline void cubeBox(const boundBox&, point&, point&) const;
148 
149  //- calculate vertices
150  void vertices(const boundBox&, FixedList<point, 8>&) const;
151 
152  //- return centre
153  inline point centre(const boundBox&) const;
154 
155  //- return size
156  inline scalar size(const boundBox&) const;
157 
158  //- edges of the cube
159  void edgeVertices
160  (
161  const boundBox&,
163  ) const;
164 
165  //- check if the surface triangle intersects the cube
166  bool intersectsTriangle
167  (
168  const triSurf&,
169  const boundBox&,
170  const label
171  ) const;
172 
174  (
175  const triSurf&,
176  const boundBox&,
177  const label
178  ) const;
179 
180  //- is a vertex inside the cube
181  bool isVertexInside(const boundBox&, const point&) const;
182  bool isPositionInside(const meshOctreeCubeCoordinates&) const;
183 
184  //- return the possible range of neighbour boxes one level
185  //- higher than the current cube. It is useful for parallel octree
186  inline void neighbourRange
187  (
188  meshOctreeCubeCoordinates& minCoord,
189  meshOctreeCubeCoordinates& maxCoord
190  ) const;
191 
192  //- check if the cube intersects a line
193  bool intersectsLine(const boundBox&, const point&, const point&) const;
194 
195  // Operators
196 
197  inline meshOctreeCubeCoordinates operator+
198  (
200  ) const;
201  inline void operator=(const meshOctreeCubeCoordinates&);
202  inline bool operator==(const meshOctreeCubeCoordinates&) const;
203  inline bool operator!=(const meshOctreeCubeCoordinates&) const;
204 
205  //- comparison of Morton codes
206  inline bool operator<=(const meshOctreeCubeCoordinates&) const;
207  inline bool operator>=(const meshOctreeCubeCoordinates&) const;
208 
209  inline bool operator<(const meshOctreeCubeCoordinates&) const;
210  inline bool operator>(const meshOctreeCubeCoordinates&) const;
211 
212  friend inline Istream& operator>>
213  (
214  Istream&,
216  );
217  friend inline Ostream& operator<<
218  (
219  Ostream&,
221  );
222 };
223 
224 //- Specify data associated with meshOctreeCubeCoordinates type is contiguous
225 template<>
226 inline bool contiguous<meshOctreeCubeCoordinates>() {return true;}
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
Foam::meshOctreeCubeCoordinates::edgeFaces_
static const label edgeFaces_[12][2]
edge-faces addressing for the octree cube
Definition: meshOctreeCubeCoordinates.H:82
Foam::meshOctreeCubeCoordinates::increaseToLevelMax
meshOctreeCubeCoordinates increaseToLevelMax(const direction l) const
return the maximal coordinates of the child at the given level
Definition: meshOctreeCubeCoordinatesI.H:159
Foam::meshOctreeCubeCoordinates::posX
label posX() const
return x, y, z coordinates
Definition: meshOctreeCubeCoordinatesI.H:79
Foam::meshOctreeCubeCoordinates::operator=
void operator=(const meshOctreeCubeCoordinates &)
Definition: meshOctreeCubeCoordinatesI.H:266
Foam::meshOctreeCubeCoordinates
Definition: meshOctreeCubeCoordinates.H:55
Foam::meshOctreeCubeCoordinates::centre
point centre(const boundBox &) const
return centre
Definition: meshOctreeCubeCoordinatesI.H:203
Foam::meshOctreeCubeCoordinates::operator<=
bool operator<=(const meshOctreeCubeCoordinates &) const
comparison of Morton codes
Definition: meshOctreeCubeCoordinatesI.H:309
Foam::meshOctreeCubeCoordinates::posY_
label posY_
Definition: meshOctreeCubeCoordinates.H:60
Foam::meshOctreeCubeCoordinates::faceEdges_
static const label faceEdges_[6][4]
face-edges addressing for the octree cube
Definition: meshOctreeCubeCoordinates.H:79
Foam::meshOctreeCubeCoordinates::nodeFaces_
static const label nodeFaces_[8][3]
node-faces addressing for the cube
Definition: meshOctreeCubeCoordinates.H:76
Foam::meshOctreeCubeCoordinates::intersectsLine
bool intersectsLine(const boundBox &, const point &, const point &) const
check if the cube intersects a line
Definition: meshOctreeCubeCoordinatesIntersections.C:309
Foam::meshOctreeCubeCoordinates::isVertexInside
bool isVertexInside(const boundBox &, const point &) const
is a vertex inside the cube
Definition: meshOctreeCubeCoordinatesIntersections.C:244
Foam::meshOctreeCubeCoordinates::operator>
bool operator>(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesI.H:468
Foam::contiguous< meshOctreeCubeCoordinates >
bool contiguous< meshOctreeCubeCoordinates >()
Specify data associated with meshOctreeCubeCoordinates type is contiguous.
Definition: meshOctreeCubeCoordinates.H:225
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:407
Foam::meshOctreeCubeCoordinates::~meshOctreeCubeCoordinates
~meshOctreeCubeCoordinates()
Definition: meshOctreeCubeCoordinates.H:108
Foam::meshOctreeCubeCoordinates::isPositionInside
bool isPositionInside(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesIntersections.C:270
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::meshOctreeCubeCoordinates::increaseToLevelMin
meshOctreeCubeCoordinates increaseToLevelMin(const direction l) const
return the minimal coordinates of the child at the given level
Definition: meshOctreeCubeCoordinatesI.H:144
Foam::meshOctreeCubeCoordinates::level_
direction level_
cube level in the octree structure
Definition: meshOctreeCubeCoordinates.H:64
Foam::meshOctreeCubeCoordinates::intersectsTriangleExact
bool intersectsTriangleExact(const triSurf &, const boundBox &, const label) const
Definition: meshOctreeCubeCoordinatesIntersections.C:187
Foam::meshOctreeCubeCoordinates::refineForPosition
meshOctreeCubeCoordinates refineForPosition(const label) const
return the coordinates of child cube at the given position
Definition: meshOctreeCubeCoordinatesI.H:95
Foam::meshOctreeCubeCoordinates::reduceToLevel
meshOctreeCubeCoordinates reduceToLevel(const direction) const
return the coordinates of the parent at the given level
Definition: meshOctreeCubeCoordinatesI.H:134
Foam::meshOctreeCubeCoordinates::operator==
bool operator==(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesI.H:277
Foam::meshOctreeCubeCoordinates::operator!=
bool operator!=(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesI.H:293
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshOctreeCubeCoordinates::edgeNodes_
static const label edgeNodes_[12][2]
edge nodes for an octree cube
Definition: meshOctreeCubeCoordinates.H:70
Foam::meshOctreeCubeCoordinates::faceNodes_
static const label faceNodes_[6][4]
cube nodes making each face
Definition: meshOctreeCubeCoordinates.H:73
direction.H
Direction is an integer type used to represent the Cartesian directions etc. Currently it is a typede...
Foam::meshOctreeCubeCoordinates::size
scalar size(const boundBox &) const
return size
Definition: meshOctreeCubeCoordinatesI.H:213
boundBox.H
meshOctreeCubeCoordinatesI.H
Foam::meshOctreeCubeCoordinates::posZ_
label posZ_
Definition: meshOctreeCubeCoordinates.H:61
Foam::meshOctreeCubeCoordinates::level
direction level() const
return level
Definition: meshOctreeCubeCoordinatesI.H:74
Foam::Vector< scalar >
label.H
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::meshOctreeCubeCoordinates::operator>=
bool operator>=(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesI.H:362
triSurf
A class for triangulated surface used in the meshing process. It is derived from points and facets wi...
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::meshOctreeCubeCoordinates::intersectsTriangle
bool intersectsTriangle(const triSurf &, const boundBox &, const label) const
check if the surface triangle intersects the cube
Definition: meshOctreeCubeCoordinatesIntersections.C:153
Foam::meshOctreeCubeCoordinates::posX_
label posX_
coordinates in the octree structure
Definition: meshOctreeCubeCoordinates.H:59
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::meshOctreeCubeCoordinates::oppositeFace_
static const label oppositeFace_[6]
return the opposite face of each cube face
Definition: meshOctreeCubeCoordinates.H:85
Foam::meshOctreeCubeCoordinates::operator<
bool operator<(const meshOctreeCubeCoordinates &) const
Definition: meshOctreeCubeCoordinatesI.H:415
Foam::meshOctreeCubeCoordinates::meshOctreeCubeCoordinates
meshOctreeCubeCoordinates()
Null constructor.
Definition: meshOctreeCubeCoordinatesI.H:38
Foam::meshOctreeCubeCoordinates::neighbourRange
void neighbourRange(meshOctreeCubeCoordinates &minCoord, meshOctreeCubeCoordinates &maxCoord) const
Definition: meshOctreeCubeCoordinatesI.H:223
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
FixedList.H
Foam::meshOctreeCubeCoordinates::cubeBox
void cubeBox(const boundBox &, point &, point &) const
return min and max points
Definition: meshOctreeCubeCoordinatesI.H:174
Foam::meshOctreeCubeCoordinates::vertices
void vertices(const boundBox &, FixedList< point, 8 > &) const
calculate vertices
Definition: meshOctreeCubeCoordinatesIntersections.C:114
Foam::triSurf
Definition: triSurf.H:59
Foam::meshOctreeCubeCoordinates::posZ
label posZ() const
Definition: meshOctreeCubeCoordinatesI.H:89
Foam::meshOctreeCubeCoordinates::posY
label posY() const
Definition: meshOctreeCubeCoordinatesI.H:84
Foam::meshOctreeCubeCoordinates::edgeVertices
void edgeVertices(const boundBox &, FixedList< FixedList< point, 2 >, 12 > &) const
edges of the cube
Definition: meshOctreeCubeCoordinatesIntersections.C:137
Foam::meshOctreeCubeCoordinates::reduceLevelBy
meshOctreeCubeCoordinates reduceLevelBy(const direction diff) const
Definition: meshOctreeCubeCoordinatesI.H:118