/*------------------------------------------------------------------------------
 src/lib/dj/djBox_.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#include "djBox.h"

namespace dj {

template <int C, class T>
void _Box<C, T>::set(const Vec<C, T> & size)
{
  _position.zero();
  _size = size;
}

template <int C, class T>
void _Box<C, T>::set(const Vec<C, T> & position, const Vec<C, T> & size)
{
  _position = position;
  _size = size;
}

template <int C, class T>
void _Box<C, T>::zero()
{
  _position.zero();
  _size.zero();
}

template <int C, class T>
void _Box<C, T>::position(const Vec<C, T> & in) { _position = in; }

template <int C, class T>
void _Box<C, T>::size(const Vec<C, T> & in) { _size = in; }

template <int C, class T>
void _Box<C, T>::p0(const Vec<C, T> & in)
{
  _position = in;
}

template <int C, class T>
void _Box<C, T>::p1(const Vec<C, T> & in)
{
  _size = in - _position;
}

// XXX Partial template specialization?
//
template <>
inline const Vec<2, int> _Box<2, int>::p1() const
{
  return _position + _size - Vec<2, int>(1);
}
template <>
inline const Vec<3, int> _Box<3, int>::p1() const
{
  return _position + _size - Vec<3, int>(1);
}

}
