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 #ifndef treeLeaf_H
00038 #define treeLeaf_H
00039
00040 #include "labelList.H"
00041 #include "treeElem.H"
00042 #include "boolList.H"
00043 #include "linePointRef.H"
00044 #include "labelHashSet.H"
00045
00046
00047
00048 namespace Foam
00049 {
00050
00051 class treeBoundBox;
00052 class Ostream;
00053
00054 template<class Type> class octree;
00055 template<class Type> class treeLeaf;
00056
00057
00058
00059 template<class Type> Istream& operator>>(Istream&, treeLeaf<Type>&);
00060 template<class Type> Ostream& operator<<(Ostream&, const treeLeaf<Type>&);
00061
00062
00063
00064
00065
00066
00067 TemplateName(treeLeaf);
00068
00069
00070
00071
00072
00073
00074 template <class Type>
00075 class treeLeaf
00076 :
00077 public treeElem<Type>,
00078 public treeLeafName
00079 {
00080
00081
00082
00083 label size_;
00084
00085
00086 labelList indices_;
00087
00088
00089
00090
00091 static void space(Ostream&, const label);
00092
00093
00094 treeLeaf(const treeLeaf&);
00095
00096
00097 void operator=(const treeLeaf&);
00098
00099
00100 public:
00101
00102
00103
00104
00105 treeLeaf(const treeBoundBox& bb, const label size);
00106
00107
00108 treeLeaf(const treeBoundBox& bb, const labelList& indices);
00109
00110
00111 treeLeaf(Istream&);
00112
00113
00114
00115
00116 ~treeLeaf();
00117
00118
00119
00120
00121
00122
00123 label size() const
00124 {
00125 return size_;
00126 }
00127
00128 const labelList& indices() const
00129 {
00130 return indices_;
00131 }
00132
00133
00134
00135 void insert(const label index)
00136 {
00137 if (size_ >= indices_.size())
00138 {
00139 FatalErrorIn
00140 (
00141 "treeLeaf<Type>::insert(index)"
00142 )
00143 << "overflow"
00144 << " size_ :" << size_
00145 << " size():" << indices_.size()
00146 << abort(FatalError);
00147 }
00148 indices_[size_++] = index;
00149 }
00150
00151 void trim()
00152 {
00153 if (size_ == 0)
00154 {
00155 FatalErrorIn
00156 (
00157 "treeLeaf<Type>::trim()"
00158 )
00159 << "Trying to trim empty leaf: " << endl
00160 << " size_ :" << size_
00161 << " size():" << indices_.size()
00162 << abort(FatalError);
00163 }
00164 indices_.setSize(size_);
00165 }
00166
00167
00168 treeLeaf<Type>* redistribute
00169 (
00170 const label,
00171 octree<Type>&,
00172 const Type&
00173 );
00174
00175 label setSubNodeType
00176 (
00177 const label level,
00178 octree<Type>& top,
00179 const Type& shapes
00180 ) const;
00181
00182
00183
00184
00185 label getSampleType
00186 (
00187 const label level,
00188 const octree<Type>& top,
00189 const Type& shapes,
00190 const point& sample
00191 ) const;
00192
00193
00194 label find
00195 (
00196 const Type& shapes,
00197 const point& sample
00198 ) const;
00199
00200
00201 bool findTightest
00202 (
00203 const Type& shapes,
00204 const point& sample,
00205 treeBoundBox& tightest
00206 ) const;
00207
00208
00209 bool findNearest
00210 (
00211 const Type& shapes,
00212 const point& sample,
00213 treeBoundBox& tightest,
00214 label& tightesti,
00215 scalar& tightestDist
00216 ) const;
00217
00218
00219
00220
00221 bool findNearest
00222 (
00223 const Type& shapes,
00224 const linePointRef& ln,
00225 treeBoundBox& tightest,
00226 label& tightesti,
00227 point& linePoint,
00228 point& shapePoint
00229 ) const;
00230
00231
00232 bool findBox
00233 (
00234 const Type& shapes,
00235 const boundBox& bb,
00236 labelHashSet& elements
00237 ) const;
00238
00239
00240
00241
00242 void printLeaf(Ostream&, const label) const;
00243
00244
00245 void writeOBJ
00246 (
00247 Ostream& os,
00248 const label level,
00249 label& vertNo
00250 ) const;
00251
00252
00253 label countLeaf(Ostream&, const label) const;
00254
00255
00256
00257
00258 friend Istream& operator>> <Type>(Istream&, treeLeaf<Type>&);
00259 friend Ostream& operator<< <Type>(Ostream&, const treeLeaf<Type>&);
00260 };
00261
00262
00263
00264
00265 }
00266
00267
00268
00269 #ifdef NoRepository
00270 # include "treeLeaf.C"
00271 #endif
00272
00273
00274
00275 #include "octreeDataPointTreeLeaf.H"
00276
00277
00278
00279 #endif
00280
00281