2011-06-21 20:26:32 +10:00
|
|
|
/*
|
2015-04-13 18:05:28 +10:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-06-21 20:26:32 +10:00
|
|
|
*
|
2015-04-13 18:05:28 +10:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-06-21 20:26:32 +10:00
|
|
|
*
|
2015-04-13 18:05:28 +10:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2011-06-21 20:26:32 +10:00
|
|
|
*
|
2016-03-11 12:48:19 +11:00
|
|
|
* Copyright 2010-2016 Danny Robson <danny@nerdcruft.net>
|
2011-06-21 20:26:32 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-03-11 12:48:19 +11:00
|
|
|
#include "./region.hpp"
|
2011-05-23 17:18:52 +10:00
|
|
|
|
2016-03-11 12:48:19 +11:00
|
|
|
#include "./debug.hpp"
|
|
|
|
#include "./cast.hpp"
|
|
|
|
|
|
|
|
#include "./coord/iostream.hpp"
|
2011-05-23 17:18:52 +10:00
|
|
|
|
2011-10-24 19:55:51 +11:00
|
|
|
#include <cmath>
|
2011-08-15 20:10:43 +10:00
|
|
|
#include <type_traits>
|
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
|
2015-02-20 21:53:34 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>::region (extent_t _extent):
|
|
|
|
region (point_t::ORIGIN, _extent)
|
2015-03-07 03:20:28 +11:00
|
|
|
{
|
|
|
|
debug::sanity (*this);
|
|
|
|
}
|
2015-02-20 21:53:34 +11:00
|
|
|
|
|
|
|
|
2015-01-15 14:01:05 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::region (point_t _p,
|
|
|
|
extent_t _e):
|
|
|
|
p (_p),
|
|
|
|
e (_e)
|
2015-03-07 03:20:28 +11:00
|
|
|
{
|
|
|
|
debug::sanity (*this);
|
|
|
|
}
|
2015-01-15 14:01:05 +11:00
|
|
|
|
|
|
|
|
2015-02-17 18:25:29 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>::region (point_t _a,
|
2015-03-03 19:43:09 +11:00
|
|
|
point_t _b):
|
2015-09-09 18:44:20 +10:00
|
|
|
region (_a, extent_t { _b - _a })
|
2015-03-07 03:20:28 +11:00
|
|
|
{
|
|
|
|
debug::sanity (*this);
|
|
|
|
}
|
2015-03-06 01:09:37 +11:00
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>::region (std::array<T,S*2> args)
|
2015-02-17 18:25:29 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
std::copy (&args[0], &args[S], p.data);
|
|
|
|
std::copy (&args[S], &args[S*2], e.data);
|
2015-02-17 18:25:29 +11:00
|
|
|
}
|
|
|
|
|
2011-05-23 17:18:52 +10:00
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::size_type
|
|
|
|
util::region<S,T>::area (void) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return e.area ();
|
2015-01-21 23:33:35 +11:00
|
|
|
}
|
2011-05-23 17:18:52 +10:00
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::size_type
|
|
|
|
util::region<S,T>::diameter (void) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return e.diameter ();
|
2011-10-24 19:55:51 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 16:24:16 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::extent_t
|
|
|
|
util::region<S,T>::magnitude (void) const
|
2015-02-17 16:24:16 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return e;
|
2015-02-17 16:24:16 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-02 18:48:09 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::extent_t
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::magnitude (extent_t _e)
|
2015-03-02 18:48:09 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
e = _e;
|
|
|
|
return e;
|
2015-03-02 18:48:09 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2013-07-30 23:51:55 +10:00
|
|
|
void
|
2015-10-19 17:08:08 +11:00
|
|
|
util::region<S,T>::scale (size_type factor)
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-10-19 17:08:08 +11:00
|
|
|
auto o = (e * factor - e) / T(2);
|
2015-03-06 01:09:37 +11:00
|
|
|
p -= o;
|
|
|
|
e *= factor;
|
2013-07-30 23:51:55 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2015-02-17 16:25:41 +11:00
|
|
|
bool
|
2015-03-03 04:13:29 +11:00
|
|
|
util::region<S,T>::empty (void) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
|
|
|
return almost_zero (area ());
|
|
|
|
}
|
2011-05-23 17:18:52 +10:00
|
|
|
|
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::point_t
|
|
|
|
util::region<S,T>::base (void) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return p;
|
2011-10-26 21:43:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 16:24:33 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::point_t
|
|
|
|
util::region<S,T>::away (void) const
|
2015-02-17 16:24:33 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return p + e;
|
2015-02-17 16:24:33 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::point_t
|
|
|
|
util::region<S,T>::centre (void) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return p + e / T{2};
|
2011-10-20 23:53:18 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::point_t
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::closest (point_t q) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
point_t out;
|
2013-09-18 13:52:11 +10:00
|
|
|
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i)
|
|
|
|
out[i] = q[i] < p[i] ? p[i] :
|
|
|
|
q[i] > p[i] ? p[i] + e[i] :
|
|
|
|
q[i];
|
|
|
|
|
|
|
|
return out;
|
2013-09-18 13:52:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2011-10-17 17:20:17 +11:00
|
|
|
bool
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::includes (point_t q) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i)
|
|
|
|
if (q[i] < p[i] || q[i] > p[i] + e[i])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2011-10-17 17:20:17 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2011-10-20 21:09:47 +11:00
|
|
|
bool
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::contains (point_t q) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i)
|
|
|
|
if (q[i] <= p[i] || q[i] >= p[i] + e[i])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2011-10-20 21:09:47 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-06-15 16:38:57 +10:00
|
|
|
// FIXME: This will fail with an actual infinite range (NaNs will be generated
|
|
|
|
// in the conditionals).
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2011-10-10 22:37:27 +11:00
|
|
|
bool
|
2015-03-03 04:13:29 +11:00
|
|
|
util::region<S,T>::intersects (region<S,T> rhs) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i)
|
|
|
|
if (p[i] >= rhs.p[i] + rhs.e[i] ||
|
|
|
|
rhs.p[i] >= p[i] + e[i])
|
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
return true;
|
2011-10-10 22:37:27 +11:00
|
|
|
}
|
|
|
|
|
2012-05-11 12:22:23 +10:00
|
|
|
|
2013-07-30 23:52:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2013-08-05 16:38:05 +10:00
|
|
|
void
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::constrain (point_t &q) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i)
|
|
|
|
q[i] = limit (q[i], p[i], p[i] + e[i]);
|
2013-08-05 16:38:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
typename util::region<S,T>::point_t
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::constrained (point_t q) const
|
2014-12-15 20:10:56 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
constrain (q);
|
|
|
|
return q;
|
2013-07-30 23:52:09 +10:00
|
|
|
}
|
|
|
|
|
2015-01-21 23:33:35 +11:00
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template<size_t S, typename T>
|
|
|
|
util::region<S,T>
|
|
|
|
util::region<S,T>::intersection (region<S,T> rhs) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
// find the intersection corners
|
|
|
|
point_t a, b;
|
2012-05-11 12:22:23 +10:00
|
|
|
|
2015-03-06 01:09:37 +11:00
|
|
|
for (size_t i = 0; i < S; ++i) {
|
|
|
|
a[i] = max (p[i], rhs.p[i]);
|
|
|
|
b[i] = min (p[i] + e[i], rhs.p[i] + rhs.e[i]);
|
2012-06-13 15:50:47 +10:00
|
|
|
|
2015-03-06 01:09:37 +11:00
|
|
|
if (b[i] < a[i])
|
|
|
|
throw std::logic_error ("no overlap");
|
|
|
|
}
|
|
|
|
|
|
|
|
return { a, b };
|
2012-05-11 12:22:23 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-06 01:09:37 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>&
|
|
|
|
util::region<S,T>::resize (extent<S,T> _e)
|
|
|
|
{
|
|
|
|
e = _e;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-01-21 23:37:00 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>
|
|
|
|
util::region<S,T>::inset (T mag)
|
2015-01-21 23:37:00 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
// ensure we have enough space to inset
|
2015-03-07 03:20:28 +11:00
|
|
|
CHECK (min (e) >= 2 * mag);
|
2015-01-21 23:37:00 +11:00
|
|
|
|
2015-03-06 01:09:37 +11:00
|
|
|
return {
|
|
|
|
p + mag,
|
2015-10-19 12:05:13 +11:00
|
|
|
e - static_cast<T> (2 * mag)
|
2015-03-06 01:09:37 +11:00
|
|
|
};
|
2015-01-21 23:37:00 +11:00
|
|
|
}
|
|
|
|
|
2015-01-22 14:58:29 +11:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>&
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::expand (vector<S,T> v)
|
2015-01-22 14:58:29 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
p -= v;
|
|
|
|
e += v * T{2};
|
2015-01-22 14:58:29 +11:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-04 15:44:51 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>&
|
|
|
|
util::region<S,T>::expand (T mag)
|
2015-02-04 15:44:51 +11:00
|
|
|
{
|
2015-09-08 14:33:59 +10:00
|
|
|
return expand (vector<S,T> {mag});
|
2015-02-04 15:44:51 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-22 14:58:29 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>
|
2015-03-06 01:09:37 +11:00
|
|
|
util::region<S,T>::expanded (vector<S,T> v) const
|
2015-01-22 14:58:29 +11:00
|
|
|
{
|
|
|
|
return {
|
2015-03-06 01:09:37 +11:00
|
|
|
p - v,
|
|
|
|
e + v * T{2}
|
2015-01-22 14:58:29 +11:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-02-04 15:44:51 +11:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>
|
|
|
|
util::region<S,T>::expanded (T mag) const
|
2015-02-04 15:44:51 +11:00
|
|
|
{
|
2015-09-08 14:33:59 +10:00
|
|
|
return expanded (vector<S,T> {mag});
|
2015-02-04 15:44:51 +11:00
|
|
|
}
|
|
|
|
|
2015-02-20 15:26:59 +11:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>
|
|
|
|
util::region<S,T>::operator+ (vector<S,T> rhs) const
|
2015-02-20 15:26:59 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return { p + rhs, e };
|
2015-02-20 15:26:59 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-20 16:06:46 +11:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
util::region<S,T>
|
|
|
|
util::region<S,T>::operator- (vector<S,T> rhs) const
|
2015-02-20 16:06:46 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return { p - rhs, e };
|
2015-02-20 16:06:46 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-20 15:26:59 +11:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2011-05-23 17:18:52 +10:00
|
|
|
bool
|
2015-03-03 04:13:29 +11:00
|
|
|
util::region<S,T>::operator== (region rhs) const
|
2015-01-21 23:33:35 +11:00
|
|
|
{
|
2015-03-06 01:09:37 +11:00
|
|
|
return p == rhs.p && e == rhs.e;
|
2015-01-21 23:33:35 +11:00
|
|
|
}
|
2011-05-23 17:18:52 +10:00
|
|
|
|
|
|
|
|
2015-02-16 23:35:50 +11:00
|
|
|
///----------------------------------------------------------------------------
|
2015-02-17 16:24:49 +11:00
|
|
|
/// The largest specifiable finite region.
|
|
|
|
///
|
|
|
|
/// Starts at half the minimum value to allow the width to cover some positive
|
|
|
|
/// range rather than just cancelling out the lowest value for signed types.
|
|
|
|
///
|
|
|
|
/// Specifically does not allow infinities. Use/define INFINITE when required.
|
|
|
|
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
const util::region<S,T>
|
|
|
|
util::region<S,T>::MAX (
|
2015-04-02 14:58:43 +11:00
|
|
|
util::point<S,T> {std::numeric_limits<T>::lowest () / 2},
|
|
|
|
util::extent<S,T> {std::numeric_limits<T>::max ()}
|
2015-02-16 23:35:50 +11:00
|
|
|
);
|
2012-06-15 16:38:57 +10:00
|
|
|
|
|
|
|
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
const util::region<S,T>
|
2015-04-02 14:58:43 +11:00
|
|
|
util::region<S,T>::UNIT (util::point<S,T>{0}, util::extent<S,T>{1});
|
2012-06-15 16:38:57 +10:00
|
|
|
|
|
|
|
|
2012-06-14 18:29:09 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-03 04:13:29 +11:00
|
|
|
template <size_t S, typename T>
|
2011-10-20 23:53:30 +11:00
|
|
|
std::ostream&
|
2015-03-03 04:13:29 +11:00
|
|
|
util::operator<< (std::ostream &os, const util::region<S,T> &rhs) {
|
2015-03-06 01:09:37 +11:00
|
|
|
os << "region(" << rhs.p << ", " << rhs.e << ")";
|
2011-10-20 23:53:30 +11:00
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-07 03:20:28 +11:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2015-10-29 10:45:42 +11:00
|
|
|
namespace util { namespace debug {
|
2015-03-07 03:20:28 +11:00
|
|
|
template <size_t S, typename T>
|
|
|
|
struct validator<util::region,S,T> {
|
|
|
|
static bool is_valid (const util::region<S,T> &r)
|
|
|
|
{
|
|
|
|
CHECK_GE (r.area (), 0);
|
|
|
|
CHECK_GE (min (r.e), 0);
|
|
|
|
|
|
|
|
return r.area () >= 0 && min (r.e) >= 0;
|
|
|
|
}
|
|
|
|
};
|
2015-10-29 10:45:42 +11:00
|
|
|
} }
|
2015-03-06 17:52:40 +11:00
|
|
|
|
|
|
|
|
2015-03-07 03:20:28 +11:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define INSTANTIATE_S_T(S,T) \
|
2015-10-29 10:45:42 +11:00
|
|
|
template struct util::region<S,T>; \
|
|
|
|
template std::ostream& util::operator<< (std::ostream&, const region<S,T>&); \
|
|
|
|
template struct util::debug::validator<util::region,S,T>;
|
2015-03-07 03:20:28 +11:00
|
|
|
|
|
|
|
#define INSTANTIATE(T) \
|
|
|
|
INSTANTIATE_S_T(2,T) \
|
|
|
|
INSTANTIATE_S_T(3,T)
|
|
|
|
|
2015-09-22 17:24:16 +10:00
|
|
|
INSTANTIATE(uint16_t)
|
2015-03-07 03:20:28 +11:00
|
|
|
INSTANTIATE(uint32_t)
|
|
|
|
INSTANTIATE(uint64_t)
|
|
|
|
INSTANTIATE(float)
|
|
|
|
INSTANTIATE(double)
|