00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef treeNode_H
00048 #define treeNode_H
00049
00050 #include "treeBoundBoxList.H"
00051 #include "treeElem.H"
00052 #include <OpenFOAM/linePointRef.H>
00053 #include <OpenFOAM/HashSet.H>
00054
00055
00056
00057 namespace Foam
00058 {
00059
00060
00061
00062 template<class Type> class octree;
00063 template<class Type> class treeLeaf;
00064 template<class Type> class treeNode;
00065
00066
00067
00068 template<class Type> Istream& operator>>(Istream&, treeNode<Type>&);
00069 template<class Type> Ostream& operator<<(Ostream&, const treeNode<Type>&);
00070
00071
00072
00073
00074
00075
00076 TemplateName(treeNode);
00077
00078
00079
00080
00081
00082
00083 template <class Type>
00084 class treeNode
00085 :
00086 public treeElem<Type>,
00087 public treeNodeName
00088 {
00089
00090
00091
00092 const point mid_;
00093
00094
00095 unsigned char subNodeTypes_;
00096
00097
00098 treeElem<Type>* subNodes_[8];
00099
00100
00101 label volType_;
00102
00103
00104
00105
00106 static const label leafOffset;
00107
00108
00109
00110
00111
00112 void setAsNode(const label octant);
00113
00114
00115 void setAsLeaf(const label octant);
00116
00117
00118 void setNodePtr(const label octant, treeElem<Type>* treeNodePtr);
00119
00120
00121 void setLeafPtr(const label octant, treeElem<Type>* treeLeafPtr);
00122
00123
00124 void setVolType(const label octant, const label type);
00125
00126
00127 inline label getVolType(const label octant) const;
00128
00129
00130 const treeLeaf<Type>* findLeafLineOctant
00131 (
00132 const int level,
00133 const Type& shapes,
00134 const label octant,
00135 const vector& direction,
00136 point& start,
00137 const point& end
00138 ) const;
00139
00140
00141
00142 static void space(Ostream&, const label);
00143
00144
00145 treeNode(const treeNode&);
00146
00147
00148 void operator=(const treeNode&);
00149
00150
00151 public:
00152
00153
00154
00155
00156 treeNode(const treeBoundBox&);
00157
00158
00159 treeNode(Istream&);
00160
00161
00162
00163
00164 ~treeNode();
00165
00166
00167
00168
00169
00170
00171
00172 inline const point& midpoint() const;
00173
00174
00175 inline treeElem<Type>* const* subNodes() const;
00176
00177
00178 inline label isNode(const label octant) const;
00179
00180
00181 inline treeNode<Type>* getNodePtr(const label octant) const;
00182
00183
00184 inline treeLeaf<Type>* getLeafPtr(const label octant) const;
00185
00186
00187
00188
00189 void distribute
00190 (
00191 const label,
00192 octree<Type>&,
00193 const Type& shapes,
00194 const labelList&
00195 );
00196
00197
00198 void redistribute
00199 (
00200 const label,
00201 octree<Type>&,
00202 const Type& shapes,
00203 const label
00204 );
00205
00206
00207 label setSubNodeType
00208 (
00209 const label level,
00210 octree<Type>& top,
00211 const Type& shapes
00212 );
00213
00214
00215
00216
00217
00218 label getSampleType
00219 (
00220 const label level,
00221 const octree<Type>& top,
00222 const Type& shapes,
00223 const point& sample
00224 ) const;
00225
00226
00227 label find
00228 (
00229 const Type& shapes,
00230 const point& sample
00231 ) const;
00232
00233
00234
00235
00236
00237 bool findTightest
00238 (
00239 const Type& shapes,
00240 const point& sample,
00241 treeBoundBox& tightest
00242 ) const;
00243
00244
00245
00246
00247 bool findNearest
00248 (
00249 const Type& shapes,
00250 const point& sample,
00251 treeBoundBox& tightest,
00252 label& tightestI,
00253 scalar& tightestDist
00254 ) const;
00255
00256
00257
00258
00259 bool findNearest
00260 (
00261 const Type& shapes,
00262 const linePointRef& ln,
00263 treeBoundBox& tightest,
00264 label& tightestI,
00265 point& linePoint,
00266 point& shapePoint
00267 ) const;
00268
00269
00270 bool findBox
00271 (
00272 const Type& shapes,
00273 const boundBox& bb,
00274 labelHashSet& elements
00275 ) const;
00276
00277
00278
00279 const treeLeaf<Type>* findLeafLine
00280 (
00281 const label level,
00282 const Type& shapes,
00283 point& start,
00284 const point& end
00285 ) const;
00286
00287
00288
00289
00290 void findLeaves
00291 (
00292 List<treeLeaf<Type>*>& leafArray,
00293 label& leafIndex
00294 ) const;
00295
00296
00297 void findLeaves
00298 (
00299 List<const treeLeaf<Type>*>& leafArray,
00300 label& leafIndex
00301 ) const;
00302
00303
00304
00305
00306
00307 void printNode
00308 (
00309 Ostream& os,
00310 const label level
00311 ) const;
00312
00313
00314 void writeOBJ
00315 (
00316 Ostream& os,
00317 const label level,
00318 label& vertNo
00319 ) const;
00320
00321
00322
00323
00324 friend Istream& operator>> <Type> (Istream&, treeNode<Type>&);
00325 friend Ostream& operator<< <Type> (Ostream&, const treeNode<Type>&);
00326 };
00327
00328
00329
00330
00331 }
00332
00333
00334 #include "treeNodeI.H"
00335
00336
00337
00338 #ifdef NoRepository
00339 # include "treeNode.C"
00340 #endif
00341
00342
00343
00344 #endif
00345
00346