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 #ifndef treeNode_H
00047 #define treeNode_H
00048
00049 #include "treeBoundBoxList.H"
00050 #include "treeElem.H"
00051 #include "linePointRef.H"
00052 #include "labelHashSet.H"
00053
00054
00055
00056 namespace Foam
00057 {
00058
00059
00060
00061 template<class Type> class octree;
00062 template<class Type> class treeLeaf;
00063 template<class Type> class treeNode;
00064
00065
00066
00067 template<class Type> Istream& operator>>(Istream&, treeNode<Type>&);
00068 template<class Type> Ostream& operator<<(Ostream&, const treeNode<Type>&);
00069
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 labelList dummy;
00107
00108
00109 static const label leafOffset;
00110
00111
00112
00113
00114
00115 void setAsNode(const label octant);
00116
00117
00118 void setAsLeaf(const label octant);
00119
00120
00121 void setNodePtr(const label octant, treeElem<Type>* treeNodePtr);
00122
00123
00124 void setLeafPtr(const label octant, treeElem<Type>* treeLeafPtr);
00125
00126
00127 void setVolType(const label octant, const label type);
00128
00129
00130 inline label getVolType(const label octant) const;
00131
00132
00133 const treeLeaf<Type>* findLeafLineOctant
00134 (
00135 const int level,
00136 const Type& shapes,
00137 const label octant,
00138 const vector& direction,
00139 point& start,
00140 const point& end
00141 ) const;
00142
00143
00144
00145 static void space(Ostream&, const label);
00146
00147
00148 treeNode(const treeNode&);
00149
00150
00151 void operator=(const treeNode&);
00152
00153
00154 public:
00155
00156
00157
00158
00159 treeNode(const treeBoundBox& bb);
00160
00161
00162 treeNode(Istream&);
00163
00164
00165
00166
00167 ~treeNode();
00168
00169
00170
00171
00172
00173
00174
00175 const point& mid() const;
00176
00177
00178 inline treeElem<Type>* const* subNodes() const;
00179
00180
00181 inline label isNode(const label octant) const;
00182
00183
00184 inline treeNode<Type>* getNodePtr(const label octant) const;
00185
00186
00187 inline treeLeaf<Type>* getLeafPtr(const label octant) const;
00188
00189
00190
00191
00192 void distribute
00193 (
00194 const label,
00195 octree<Type>&,
00196 const Type& shapes,
00197 const labelList&
00198 );
00199
00200
00201 void redistribute
00202 (
00203 const label,
00204 octree<Type>&,
00205 const Type& shapes,
00206 const label
00207 );
00208
00209
00210 label setSubNodeType
00211 (
00212 const label level,
00213 octree<Type>& top,
00214 const Type& shapes
00215 );
00216
00217
00218
00219
00220
00221 label getSampleType
00222 (
00223 const label level,
00224 const octree<Type>& top,
00225 const Type& shapes,
00226 const point& sample
00227 ) const;
00228
00229
00230 label find
00231 (
00232 const Type& shapes,
00233 const point& sample
00234 ) const;
00235
00236
00237
00238
00239
00240 bool findTightest
00241 (
00242 const Type& shapes,
00243 const point& sample,
00244 treeBoundBox& tightest
00245 ) const;
00246
00247
00248
00249
00250 bool findNearest
00251 (
00252 const Type& shapes,
00253 const point& sample,
00254 treeBoundBox& tightest,
00255 label& tightesti,
00256 scalar& tightestDist
00257 ) const;
00258
00259
00260
00261
00262 bool findNearest
00263 (
00264 const Type& shapes,
00265 const linePointRef& ln,
00266 treeBoundBox& tightest,
00267 label& tightesti,
00268 point& linePoint,
00269 point& shapePoint
00270 ) const;
00271
00272
00273 bool findBox
00274 (
00275 const Type& shapes,
00276 const boundBox& bb,
00277 labelHashSet& elements
00278 ) const;
00279
00280
00281
00282 const treeLeaf<Type>* findLeafLine
00283 (
00284 const label level,
00285 const Type& shapes,
00286 point& start,
00287 const point& end
00288 ) const;
00289
00290
00291
00292
00293 void findLeaves
00294 (
00295 List<treeLeaf<Type>*>& leafArray,
00296 label& leafIndex
00297 ) const;
00298
00299
00300 void findLeaves
00301 (
00302 List<const treeLeaf<Type>*>& leafArray,
00303 label& leafIndex
00304 ) const;
00305
00306
00307
00308
00309
00310 void printNode
00311 (
00312 Ostream& os,
00313 const label level
00314 ) const;
00315
00316
00317 void writeOBJ
00318 (
00319 Ostream& os,
00320 const label level,
00321 label& vertNo
00322 ) const;
00323
00324
00325
00326
00327 friend Istream& operator>> <Type> (Istream&, treeNode<Type>&);
00328 friend Ostream& operator<< <Type> (Ostream&, const treeNode<Type>&);
00329 };
00330
00331
00332
00333
00334 }
00335
00336
00337 #include "treeNodeI.H"
00338
00339
00340
00341 #ifdef NoRepository
00342 # include "treeNode.C"
00343 #endif
00344
00345
00346
00347 #endif
00348
00349