|
| 1 | +/////////////////////////////////////////////////////////////////////////////// |
| 2 | +// BSD 3-Clause License |
| 3 | +// |
| 4 | +// Copyright (c) 2019-2023, Nefelus Inc, Google LLC |
| 5 | +// All rights reserved. |
| 6 | +// |
| 7 | +// Redistribution and use in source and binary forms, with or without |
| 8 | +// modification, are permitted provided that the following conditions are met: |
| 9 | +// |
| 10 | +// * Redistributions of source code must retain the above copyright notice, this |
| 11 | +// list of conditions and the following disclaimer. |
| 12 | +// |
| 13 | +// * Redistributions in binary form must reproduce the above copyright notice, |
| 14 | +// this list of conditions and the following disclaimer in the documentation |
| 15 | +// and/or other materials provided with the distribution. |
| 16 | +// |
| 17 | +// * Neither the name of the copyright holder nor the names of its |
| 18 | +// contributors may be used to endorse or promote products derived from |
| 19 | +// this software without specific prior written permission. |
| 20 | +// |
| 21 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 25 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 26 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 27 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 29 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 31 | +// POSSIBILITY OF SUCH DAMAGE. |
| 32 | + |
| 33 | +#pragma once |
| 34 | + |
| 35 | +#include <array> |
| 36 | +#include <cstdio> |
| 37 | + |
| 38 | +namespace rcx { |
| 39 | + |
| 40 | +class ext2dBox // assume cross-section on the z-direction |
| 41 | +{ |
| 42 | + public: |
| 43 | + // Implementation note: a default constructor is necessary because these are |
| 44 | + // AthPool allocated, and it requires the type to be default constructible. |
| 45 | + // We use placement new (with the full constructor below) for initialization |
| 46 | + // after pool allocation. |
| 47 | + ext2dBox() = default; |
| 48 | + |
| 49 | + ext2dBox(std::array<int, 2> ll, |
| 50 | + std::array<int, 2> ur, |
| 51 | + unsigned int met, |
| 52 | + unsigned int id, |
| 53 | + unsigned int map, |
| 54 | + bool dir); |
| 55 | + |
| 56 | + void rotate(); |
| 57 | + void printGeoms3D(FILE* fp, |
| 58 | + double h, |
| 59 | + double t, |
| 60 | + const std::array<int, 2>& orig) const; |
| 61 | + unsigned int length() const; |
| 62 | + unsigned int width() const; |
| 63 | + int loX() const; |
| 64 | + int loY() const; |
| 65 | + unsigned int id() const; |
| 66 | + |
| 67 | + unsigned int met() const { return _met; } |
| 68 | + unsigned int map() const { return _map; } |
| 69 | + bool dir() const { return _dir; } |
| 70 | + |
| 71 | + int ur0() const { return _ur[0]; } |
| 72 | + int ur1() const { return _ur[1]; } |
| 73 | + int ll0() const { return _ll[0]; } |
| 74 | + int ll1() const { return _ll[1]; } |
| 75 | + |
| 76 | + private: |
| 77 | + std::array<int, 2> _ll; |
| 78 | + std::array<int, 2> _ur; |
| 79 | + unsigned int _met; |
| 80 | + unsigned int _id; |
| 81 | + unsigned int _map; |
| 82 | + bool _dir; |
| 83 | +}; |
| 84 | + |
| 85 | +} // namespace rcx |
0 commit comments