lsst.afw  15.0-17-g0b88e3da8
Extent.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
24 #include "lsst/afw/geom/Point.h"
25 #include "lsst/afw/geom/Extent.h"
26 
27 namespace lsst {
28 namespace afw {
29 namespace geom {
30 
31 template <typename T, int N>
32 Extent<T, N>::Extent(Point<T, N> const &other) : Super(other.asEigen()) {}
33 
34 // The following two template specializations raise Doxygen warnings and produce no documenation.
35 // This is a known Doxygen bug: <https://bugzilla.gnome.org/show_bug.cgi?id=406027>
37 template <typename T>
39 
40 template <typename T>
41 Extent<T, 3>::Extent(Point<T, 3> const &other) : Super(other.asEigen()) {}
43 
44 template <typename T, int N>
47  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] == other[n];
48  return r;
49 }
50 
51 template <typename T, int N>
54  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] != other[n];
55  return r;
56 }
57 
58 template <typename T, int N>
61  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] < other[n];
62  return r;
63 }
64 
65 template <typename T, int N>
68  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] <= other[n];
69  return r;
70 }
71 
72 template <typename T, int N>
75  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] > other[n];
76  return r;
77 }
78 
79 template <typename T, int N>
82  for (int n = 0; n < N; ++n) r[n] = this->_vector[n] >= other[n];
83  return r;
84 }
85 
86 template <typename T, int N>
88  return Point<T, N>(static_cast<Extent<T, N> const &>(*this));
89 }
90 
91 template <typename T, int N>
93  return Point<T, N>(this->_vector + other.asEigen());
94 }
95 
96 template <int N>
99  for (int i = 0; i < N; ++i) {
100  result[i] = static_cast<int>(input[i]);
101  }
102  return result;
103 }
104 
105 template <int N>
108  for (int i = 0; i < N; ++i) {
109  result[i] = std::floor(input[i]);
110  }
111  return result;
112 }
113 
114 template <int N>
117  for (int i = 0; i < N; ++i) {
118  result[i] = std::ceil(input[i]);
119  }
120  return result;
121 }
122 
123 #ifndef DOXYGEN
124 
125 template class ExtentBase<int, 2>;
126 template class ExtentBase<int, 3>;
127 template class ExtentBase<double, 2>;
128 template class ExtentBase<double, 3>;
129 template class Extent<int, 2>;
130 template class Extent<int, 3>;
131 template class Extent<double, 2>;
132 template class Extent<double, 3>;
133 template Extent<double, 2>::Extent(Extent<int, 2> const &);
134 template Extent<double, 3>::Extent(Extent<int, 3> const &);
135 template Extent<double, 2>::Extent(Point<int, 2> const &);
136 template Extent<double, 3>::Extent(Point<int, 3> const &);
137 
138 template Extent<int, 2> truncate(Extent<double, 2> const &);
139 template Extent<int, 3> truncate(Extent<double, 3> const &);
140 template Extent<int, 2> floor(Extent<double, 2> const &);
141 template Extent<int, 3> floor(Extent<double, 3> const &);
142 template Extent<int, 2> ceil(Extent<double, 2> const &);
143 template Extent<int, 3> ceil(Extent<double, 3> const &);
144 
145 #endif // !DOXYGEN
146 }
147 }
148 } // end lsst::afw::geom
A boolean coordinate.
A coordinate class intended to represent absolute positions (2-d specialization). ...
Definition: Point.h:198
T ceil(T... args)
A coordinate class intended to represent offsets and dimensions.
T floor(T... args)
ItemVariant const * other
Definition: Schema.cc:55
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
Definition: Angle.h:277
A coordinate class intended to represent absolute positions.
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
A base class for image defects.
std::unique_ptr< SchemaItem< U > > result
Definition: Schema.cc:194
Extent< int, N > truncate(Extent< double, N > const &input)
Return the component-wise truncation (round towards zero).
Definition: Extent.cc:97
Extent< int, N > ceil(Extent< double, N > const &input)
Return the component-wise ceil (round towards more positive).
Definition: Extent.cc:115
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
Definition: Extent.cc:106
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
Definition: Extent.h:200
A coordinate class intended to represent absolute positions (3-d specialization). ...
Definition: Point.h:251