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