libcruft-util/geom/iostream.cpp

72 lines
2.3 KiB
C++
Raw Normal View History

2015-02-19 13:28:36 +11:00
/*
2018-08-04 15:14:06 +10:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2015-02-19 13:28:36 +11:00
*
2018-03-13 22:37:40 +11:00
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
2015-02-19 13:28:36 +11:00
*/
#include "iostream.hpp"
2015-02-19 13:28:36 +11:00
2018-03-13 22:37:40 +11:00
#include "frustum.hpp"
#include "plane.hpp"
#include "segment.hpp"
#include "sphere.hpp"
#include "../coord/iostream.hpp"
#include "../iterator/infix.hpp"
2015-02-19 13:28:36 +11:00
///////////////////////////////////////////////////////////////////////////////
2015-02-19 13:28:36 +11:00
template <size_t S, typename T>
std::ostream&
cruft::geom::operator<< (std::ostream &os, cruft::geom::sphere<S,T> s)
2015-02-19 13:28:36 +11:00
{
return os << "sphere(" << s.centre << ',' << s.radius << ')';
2015-02-19 13:28:36 +11:00
}
//-----------------------------------------------------------------------------
template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::sphere<2,float>);
template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::sphere<3,float>);
2018-03-13 22:37:40 +11:00
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
std::ostream&
cruft::geom::operator<< (std::ostream &os, cruft::geom::segment<S,T> const &val)
{
return os << "[ " << val.a << ", " << val.b << " ]";
}
template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::segment2i const&);
template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::segment2f const&);
2018-03-13 22:37:40 +11:00
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
std::ostream&
cruft::geom::operator<< (std::ostream &os, plane<S,T> val)
2018-03-13 22:37:40 +11:00
{
return os << val.coefficients;
}
//-----------------------------------------------------------------------------
template std::ostream& cruft::geom::operator<< (std::ostream&, plane<2,float>);
template std::ostream& cruft::geom::operator<< (std::ostream&, plane<3,float>);
2018-03-13 22:37:40 +11:00
///////////////////////////////////////////////////////////////////////////////
template <typename T>
std::ostream&
cruft::geom::operator<< (std::ostream &os, frustum<T> val)
2018-03-13 22:37:40 +11:00
{
return os << "[ " << iterator::make_infix (val.planes) << " ]";
2018-03-13 22:37:40 +11:00
}
//-----------------------------------------------------------------------------
template std::ostream& cruft::geom::operator<< (std::ostream&, frustum<float>);