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