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