meshOctreeCube.C
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "meshOctreeCube.H"
29 #include "demandDrivenData.H"
30 #include "VRWGraph.H"
31 #include "Ostream.H"
32 #include "meshOctreeSlot.H"
33 
34 
35 // #define DEBUGSearch
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * * * * //
43 
44 const label meshOctreeCube::hOrder_[24][8] =
45 {
46  {0, 1, 3, 2, 4, 5, 7, 6}, // Morton addressing Z-order
47  //{6, 7, 4, 5, 1, 0, 3, 2},
48  {6, 2, 1, 5, 4, 0, 3, 7},
49  {6, 7, 3, 2, 1, 0, 4, 5},
50  {3, 7, 6, 2, 1, 5, 4, 0},
51  {4, 0, 1, 5, 6, 2, 3, 7},
52  {1, 0, 4, 5, 6, 7, 3, 2},
53  {3, 7, 4, 0, 1, 5, 6, 2},
54  {6, 2, 3, 7, 4, 0, 1, 5},
55  {3, 2, 6, 7, 4, 5, 1, 0},
56  {3, 2, 1, 0, 4, 5, 6, 7},
57  {6, 5, 4, 7, 3, 0, 1, 2},
58  {1, 2, 6, 5, 4, 7, 3, 0},
59  {3, 0, 4, 7, 6, 5, 1, 2},
60  {4, 0, 3, 7, 6, 2, 1, 5},
61  {1, 2, 3, 0, 4, 7, 6, 5},
62  {6, 5, 1, 2, 3, 0, 4, 7},
63  {1, 5, 6, 2, 3, 7, 4, 0},
64  {1, 5, 4, 0, 3, 7, 6, 2},
65  {4, 5, 6, 7, 3, 2, 1, 0},
66  {1, 0, 3, 2, 6, 7, 4, 5},
67  {3, 0, 1, 2, 6, 5, 4, 7},
68  {4, 5, 1, 0, 3, 2, 6, 7},
69  {4, 7, 6, 5, 1, 2, 3, 0},
70  {4, 7, 3, 0, 1, 2, 6, 5}
71 };
72 
73 const label meshOctreeCube::hOrient_[24][8] =
74 {
75  {0, 0, 0, 0, 0, 0, 0, 0}, // Morton addressing Z-order
76  //{1, 2, 0, 3, 4, 0, 5, 6},
77  {0, 7, 1, 8, 5, 1, 4, 9},
78  {15, 0, 2, 22, 20, 2, 19, 23},
79  {20, 6, 3, 23, 15, 3, 16, 22},
80  {22, 13, 4, 12, 11, 4, 1, 20},
81  {11, 19, 5, 20, 22, 5, 0, 12},
82  {9, 3, 6, 2, 21, 6, 17, 0},
83  {10, 1, 7, 11, 12, 7, 13, 14},
84  {12, 9, 8, 14, 10, 8, 18, 11},
85  {6, 8, 9, 7, 17, 9, 21, 1},
86  {7, 15, 10, 16, 13, 10, 12, 17},
87  {5, 14, 11, 9, 0, 11, 22, 8},
88  {8, 20, 12, 19, 18, 12, 10, 5},
89  {18, 4, 13, 5, 8, 13, 7, 19},
90  {17, 11, 14, 1, 6, 14, 23, 7},
91  {2, 10, 15, 18, 19, 15, 20, 21},
92  {19, 17, 16, 21, 2, 16, 3, 18},
93  {14, 16, 17, 15, 23, 17, 6, 10},
94  {13, 21, 18, 17, 7, 18, 8, 16},
95  {16, 5, 19, 4, 3, 19, 2, 13},
96  {3, 12, 20, 13, 16, 20, 15, 4},
97  {23, 18, 21, 10, 14, 21, 9, 15},
98  {4, 23, 22, 6, 1, 22, 11, 3},
99  {21, 22, 23, 0, 9, 23, 14, 2}
100 };
101 
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
103 
104 // Construct from coordinates and level
106 :
108  activeSlotPtr_(NULL),
109  subCubesPtr_(NULL),
110  cubeLabel_(-1),
111  containedElementsLabel_(-1),
112  containedEdgesLabel_(-1)
113 {}
114 
116 (
117  const meshOctreeCubeCoordinates& cc,
118  const label nElmts,
119  meshOctreeSlot* slotPtr
120 )
121 :
123  activeSlotPtr_(slotPtr),
124  subCubesPtr_(NULL),
125  cubeLabel_(0),
126  containedElementsLabel_(0),
127  containedEdgesLabel_(-1)
128 {
129  slotPtr->containedTriangles_.setSize(1);
130  slotPtr->containedTriangles_.setRowSize(0, nElmts),
131  slotPtr->containedEdges_.setSize(0);
132 
133  for(label i=0;i<nElmts;++i)
134  slotPtr->containedTriangles_(0, i) = i;
135 }
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
140 {}
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
145 {
146  if( !subCubesPtr_ )
148  (
149  "inline FixedList<meshOctreeCube*, 8>&"
150  " meshOctreeCube::subCubes() const"
151  ) << "Sub cubes do not exist!" << abort(FatalError);
152 
154 
155  for(label i=0;i<8;++i)
156  ret[i] = subCube(i);
157 
158  return ret;
159 }
160 
162 {
163  const meshOctreeCubeCoordinates cc(oc);
164  os << cc;
165 
166  return os;
167 }
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // ************************************************************************* //
Foam::meshOctreeCubeCoordinates
Definition: meshOctreeCubeCoordinates.H:55
VRWGraph.H
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
meshOctreeCube.H
meshOctreeSlot.H
Foam::meshOctreeCube::subCube
meshOctreeCube * subCube(const label) const
return a pointer to a child cubes at given position
Definition: meshOctreeCubeI.H:71
Foam::meshOctreeCube::~meshOctreeCube
~meshOctreeCube()
Definition: meshOctreeCube.C:139
Foam::meshOctreeSlot
Definition: meshOctreeSlot.H:50
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::meshOctreeCube::subCubesPtr_
meshOctreeCube ** subCubesPtr_
pointer to the first child element
Definition: meshOctreeCube.H:64
Foam::meshOctreeCube::subCubes
FixedList< meshOctreeCube *, 8 > subCubes() const
return the pointers to the sons
Definition: meshOctreeCube.C:144
Foam::VRWGraph::setSize
void setSize(const label)
Reset the number of rows.
Definition: VRWGraphI.H:132
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::FatalError
error FatalError
Foam::meshOctreeCube::hOrient_
static const label hOrient_[24][8]
Definition: meshOctreeCube.H:85
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::meshOctreeCube::meshOctreeCube
meshOctreeCube()
Default constructor.
Definition: meshOctreeCubeI.H:38
Foam::meshOctreeCube::hOrder_
static const label hOrder_[24][8]
Definition: meshOctreeCube.H:81
Ostream.H
Foam::meshOctreeSlot::containedEdges_
VRWGraph containedEdges_
feature edges contained in an octree cube
Definition: meshOctreeSlot.H:65
Foam::meshOctreeSlot::containedTriangles_
VRWGraph containedTriangles_
surface triangles contained in an octree cube
Definition: meshOctreeSlot.H:62
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::meshOctreeCube
Definition: meshOctreeCube.H:56
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::VRWGraph::setRowSize
void setRowSize(const label rowI, const label newSize)
Reset the size of the given row.
Definition: VRWGraphI.H:204
Foam::meshOctreeCubeBasic
Definition: meshOctreeCubeBasic.H:49