/usr/include/BoxLib/Orientation.H is in libbox-dev 2.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | /*
** (c) 1996-2000 The Regents of the University of California (through
** E.O. Lawrence Berkeley National Laboratory), subject to approval by
** the U.S. Department of Energy. Your use of this software is under
** license -- the license agreement is attached and included in the
** directory as license.txt or you may contact Berkeley Lab's Technology
** Transfer Department at TTD@lbl.gov. NOTICE OF U.S. GOVERNMENT RIGHTS.
** The Software was developed under funding from the U.S. Government
** which consequently retains certain rights as follows: the
** U.S. Government has been granted for itself and others acting on its
** behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
** Software to reproduce, prepare derivative works, and perform publicly
** and display publicly. Beginning five (5) years after the date
** permission to assert copyright is obtained from the U.S. Department of
** Energy, and subject to any subsequent five (5) year renewals, the
** U.S. Government is granted for itself and others acting on its behalf
** a paid-up, nonexclusive, irrevocable, worldwide license in the
** Software to reproduce, prepare derivative works, distribute copies to
** the public, perform publicly and display publicly, and to permit
** others to do so.
*/
#ifndef BL_ORIENTATION_H
#define BL_ORIENTATION_H
//
// $Id: Orientation.H,v 1.15 2001/07/31 22:43:19 lijewski Exp $
//
#include <iosfwd>
#include <BLassert.H>
#include <SPACE.H>
class OrientationIter;
//
//@Man:
//@Memo: Encapsulation of the Orientation of the Faces of a Box
/*@Doc:
This class encapsulates the orientation of the faces of a Box by
providing an ordering of each of the faces of a Box in BL\_SPACEDIM
dimensions. This allows iterating over all the faces of a Box. The
ordering first traverses the BL\_SPACEDIM low sides from direction 0 ..
BL\_SPACEDIM-1 and then the BL\_SPACEDIM high sides from direction 0 ..
BL\_SPACEDIM-1.
*/
class Orientation
{
public:
friend class OrientationIter;
//
//@ManDoc: In each dimension a face is either low or high.
//
enum Side { low = 0, high = 1 };
//
//@ManDoc: The default constructor.
//
Orientation ();
//
//@ManDoc: Set the orientation of a side.
//
Orientation (int dir,
Side side);
//
//@ManDoc: The copy constructor.
//
Orientation (const Orientation& rhs);
//
//@ManDoc: The assignment operator.
//
Orientation& operator= (const Orientation& rhs);
//
//@ManDoc: Logical equality.
//
bool operator== (const Orientation& o) const;
//
//@ManDoc: Logical inequality.
//
bool operator!= (const Orientation& o) const;
//
//@ManDoc: Less-than.
//
bool operator< (const Orientation& o) const;
//
//@ManDoc: Less-than or equal.
//
bool operator<= (const Orientation& o) const;
//
//@ManDoc: Greater-than.
//
bool operator> (const Orientation& o) const;
//
//@ManDoc: Greater-than or equal.
//
bool operator>= (const Orientation& o) const;
/*@ManDoc: This conversion operator maps an orientation into a
unique integer in the range [0 .. 2*BL\_SPACEDIM-1]
according to the above ordering.
*/
operator int () const;
//
//@ManDoc: Return opposite orientation.
//
Orientation flip () const;
//
//@ManDoc: Returns the coordinate direction.
//
int coordDir () const;
//
//@ManDoc: Returns the orientation of the face -- low or high.
//
Side faceDir () const;
//
//@ManDoc: Returns true if Orientation is low.
//
bool isLow () const;
//
//@ManDoc: Returns true if Orientation is high.
//
bool isHigh () const;
//
//@ManDoc: Read from an istream.
//
friend std::istream& operator>> (std::istream& os, Orientation& o);
protected:
//
// Used internally.
//
Orientation (int val);
private:
int val;
};
//
//@ManDoc: Write to an ostream in ASCII format.
//
std::ostream& operator<< (std::ostream& os, const Orientation& o);
//
//@Man:
//@Memo: An Iterator over the Orientation of Faces of a Box
//@Doc:
//
class OrientationIter
{
public:
//
//@ManDoc: The default constructor.
//
OrientationIter ();
//
//@ManDoc: Construct an iterator on the Orientation.
//
OrientationIter (const Orientation& _face);
//
//@ManDoc: The copy constructor.
//
OrientationIter (const OrientationIter& it);
//
//@ManDoc: The assignment operator.
//
OrientationIter& operator= (const OrientationIter& it);
//
//@ManDoc: Reset (rewind) the iterator.
//
void rewind ();
//
//@ManDoc: Return the orientation of the face.
//
Orientation operator() () const;
//
//@ManDoc: Cast to void*. Used to test if iterator is valid.
//
operator void* ();
//
//@ManDoc: Pre-decrement.
//
OrientationIter& operator-- ();
//
//@ManDoc: Pre-increment.
//
OrientationIter& operator++ ();
//
//@ManDoc: Post-decrement.
//
OrientationIter operator-- (int);
//
//@ManDoc: Post-increment.
//
OrientationIter operator++ (int);
//
//@ManDoc: The equality operator.
//
bool operator== (const OrientationIter& oi) const;
//
//@ManDoc: The inequality operator.
//
bool operator!= (const OrientationIter& oi) const;
protected:
int face;
//
// Construct an iterator on the face.
//
OrientationIter (int _face);
//
// Is the iterator valid?
//
bool ok () const;
};
inline
Orientation::Orientation (int _val)
:
val(_val)
{}
inline
Orientation::Orientation ()
:
val(-1)
{}
inline
Orientation::Orientation (int _dir,
Side _side)
:
val(BL_SPACEDIM*_side + _dir)
{
BL_ASSERT(0 <= _dir && _dir < BL_SPACEDIM);
}
inline
Orientation::Orientation (const Orientation& o)
:
val(o.val)
{}
inline
Orientation&
Orientation::operator= (const Orientation& o)
{
val = o.val;
return *this;
}
inline
bool
Orientation::operator== (const Orientation& o) const
{
return val == o.val;
}
inline
bool
Orientation::operator!= (const Orientation& o) const
{
return val != o.val;
}
inline
bool
Orientation::operator< (const Orientation& o) const
{
return val < o.val;
}
inline
bool
Orientation::operator<= (const Orientation& o) const
{
return val <= o.val;
}
inline
bool
Orientation::operator> (const Orientation& o) const
{
return val > o.val;
}
inline
bool
Orientation::operator>= (const Orientation& o) const
{
return val >= o.val;
}
inline
Orientation::operator int () const
{
return val;
}
inline
int
Orientation::coordDir () const
{
return val%BL_SPACEDIM;
}
inline
Orientation::Side
Orientation::faceDir () const
{
return Side(val/BL_SPACEDIM);
}
inline
bool
Orientation::isLow () const
{
return val < BL_SPACEDIM;
}
inline
bool
Orientation::isHigh () const
{
return val >= BL_SPACEDIM;
}
inline
Orientation
Orientation::flip () const
{
return Orientation(val < BL_SPACEDIM ? val+BL_SPACEDIM : val-BL_SPACEDIM);
}
inline
OrientationIter::OrientationIter (int _face)
:
face(_face)
{}
inline
OrientationIter::OrientationIter ()
:
face(0)
{}
inline
OrientationIter::OrientationIter (const Orientation& _face)
:
face(_face)
{}
inline
bool
OrientationIter::ok () const
{
return 0 <= face && face < 2*BL_SPACEDIM;
}
inline
OrientationIter::OrientationIter (const OrientationIter& it)
{
BL_ASSERT(it.ok());
face = it.face;
}
inline
OrientationIter&
OrientationIter::operator= (const OrientationIter& it)
{
BL_ASSERT(it.ok());
face = it.face;
return *this;
}
inline
void
OrientationIter::rewind ()
{
face = 0;
}
inline
Orientation
OrientationIter::operator() () const
{
BL_ASSERT(ok());
return Orientation(face);
}
inline
OrientationIter::operator void* ()
{
return 0 <= face && face < 2*BL_SPACEDIM ? this : 0;
}
inline
OrientationIter&
OrientationIter::operator-- ()
{
BL_ASSERT(ok());
--face;
return *this;
}
inline
OrientationIter&
OrientationIter::operator++ ()
{
BL_ASSERT(ok());
++face;
return *this;
}
inline
OrientationIter
OrientationIter::operator-- (int)
{
BL_ASSERT(ok());
return OrientationIter(face--);
}
inline
OrientationIter
OrientationIter::operator++ (int)
{
BL_ASSERT(ok());
return OrientationIter(face++);
}
inline
bool
OrientationIter::operator== (const OrientationIter& oi) const
{
BL_ASSERT(ok() && oi.ok());
return face == oi.face;
}
inline
bool
OrientationIter::operator!= (const OrientationIter& oi) const
{
BL_ASSERT(ok() && oi.ok());
return face != oi.face;
}
#endif /*BL_ORIENTATION_H*/
|