00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BL_BOXARRAY_H
00024 #define BL_BOXARRAY_H
00025
00026
00027
00028 #if defined(BL_OLD_STL)
00029 #include <stddef.h>
00030 #else
00031 #include <cstddef>
00032 #endif
00033
00034 #include <IndexType.H>
00035 #include <BoxList.H>
00036 #include <Array.H>
00037 #include <Pointers.H>
00038
00039 class BoxArray;
00040
00041 namespace BoxLib
00042 {
00043
00045
00046 BoxArray boxComplement (const Box& b1in, const Box& b2);
00047
00049
00050 BoxArray complementIn (const Box& b, const BoxArray& ba);
00051
00053
00054 BoxArray intersect (const BoxArray& ba, const Box& b);
00055
00057
00058 BoxArray intersect (const BoxArray& lhs, const BoxArray& rhs);
00059 }
00060
00061
00063
00064 std::ostream& operator<< (std::ostream& os, const BoxArray& ba);
00065
00066
00067
00069
00076 class BoxArray
00077 {
00078 public:
00079
00081
00082 BoxArray ();
00083
00085
00086 BoxArray (const Box& bx);
00087
00089
00090 explicit BoxArray (size_t size);
00091
00093
00094 BoxArray (const Box* bxvec,
00095 int nbox);
00096
00098
00099 explicit BoxArray (const BoxList& bl);
00100
00102
00103 BoxArray (const BoxArray& bs);
00104
00106
00107 BoxArray& operator= (const BoxArray& rhs);
00108
00110
00111 ~BoxArray ();
00112
00116 void define (const BoxList& bl);
00117
00121 void define (const BoxArray& bs);
00122
00124
00125 void clear ();
00126
00128
00129 void resize (int len);
00130
00132
00133 int size () const;
00134
00135 long numPts() const;
00136
00142 void readFrom (std::istream& is);
00143
00145
00146 std::ostream& writeOn (std::ostream&) const;
00147
00149
00150 bool operator== (const BoxArray& rhs) const;
00151
00153
00154 bool operator!= (const BoxArray& rhs) const;
00155
00157
00158 BoxArray& maxSize (int block_size);
00159
00161
00162 BoxArray& refine (int refinement_ratio);
00163
00165
00166 BoxArray& refine (const IntVect& refinement_ratio);
00167
00169
00170 BoxArray& coarsen (int refinement_ratio);
00171
00173
00174 BoxArray& coarsen (const IntVect& refinement_ratio);
00175
00177
00178 BoxArray& grow (int n);
00179
00181
00182 BoxArray& grow (const IntVect& iv);
00183
00187 BoxArray& grow (int idir,
00188 int n_cell);
00189
00193 BoxArray& surroundingNodes ();
00194
00198 BoxArray& surroundingNodes (int dir);
00199
00201
00202 BoxArray& enclosedCells ();
00203
00205
00206 BoxArray& enclosedCells (int dir);
00207
00209
00210 BoxArray& convert (IndexType typ);
00211
00213
00214 BoxArray& convert (Box (*fp)(const Box&));
00215
00217
00218 BoxArray& shift (int dir,
00219 int nzones);
00220
00222
00223 BoxArray& shiftHalf (int dir,
00224 int num_halfs);
00225
00227
00228 BoxArray& shiftHalf (const IntVect &iv);
00229
00231
00232 void set (int i,
00233 const Box& ibox);
00234
00236
00237 const Box& operator[] (int index) const;
00238
00240
00241 const Box& get (int index) const;
00242
00246 bool ok () const;
00247
00249
00250 bool isDisjoint () const;
00251
00253
00254 BoxList boxList () const;
00255
00257
00258 bool contains (const IntVect& v) const;
00259
00264 bool contains (const Box& b) const;
00265
00267
00268 bool contains (const BoxArray& bl) const;
00269
00271
00272 Box minimalBox () const;
00273
00274 void reserve (long _truesize);
00275
00276 protected:
00277
00278 class Ref
00279 {
00280 friend class BoxArray;
00281
00282
00283
00284 Ref ();
00285
00286 Ref (size_t size);
00287
00288 Ref (const BoxList& bl);
00289
00290 Ref (std::istream& is);
00291
00292 Ref (const Ref& rhs);
00293
00294
00295
00296 void define (const BoxList& bl);
00297
00298 void define (std::istream& is);
00299
00300
00301
00302 Array<Box> m_abox;
00303 };
00304
00305
00306
00307 void uniqify ();
00308
00309
00310
00311 LnClassPtr<Ref> m_ref;
00312 };
00313
00314 inline
00315 int
00316 BoxArray::size () const
00317 {
00318 return m_ref->m_abox.size();
00319 }
00320
00321 inline
00322 const Box&
00323 BoxArray::operator[] (int index) const
00324 {
00325 return m_ref->m_abox.get(index);
00326 }
00327
00328 inline
00329 const Box&
00330 BoxArray::get (int index) const
00331 {
00332 return m_ref->m_abox.get(index);
00333 }
00334
00335 #endif