geom/iostream: add segment ostream operator

This commit is contained in:
Danny Robson 2019-03-11 18:56:56 +11:00
parent 922d46dd8a
commit f58390de06
3 changed files with 29 additions and 12 deletions

View File

@ -12,13 +12,14 @@
#include <cstdlib>
namespace cruft::geom {
template <size_t S, typename T> struct ray;
template <size_t S, typename T> struct plane;
template <size_t S, typename T> struct aabb;
template <size_t S, typename T> struct sphere;
template <size_t S, typename T> struct ellipse;
template <size_t S, typename T> struct rect;
template <size_t S, typename T> struct cylinder;
template <size_t S, typename T> struct ellipse;
template <size_t S, typename T> struct plane;
template <size_t S, typename T> struct ray;
template <size_t S, typename T> struct rect;
template <size_t S, typename T> struct segment;
template <size_t S, typename T> struct sphere;
template <size_t S, typename T> struct tri;
template <typename T> struct frustum;

View File

@ -8,9 +8,11 @@
#include "iostream.hpp"
#include "sphere.hpp"
#include "plane.hpp"
#include "frustum.hpp"
#include "plane.hpp"
#include "segment.hpp"
#include "sphere.hpp"
#include "../coord/iostream.hpp"
@ -28,6 +30,19 @@ template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::sphe
template std::ostream& cruft::geom::operator<< (std::ostream&, cruft::geom::sphere<3,float>);
///////////////////////////////////////////////////////////////////////////////
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&);
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
std::ostream&

View File

@ -3,11 +3,10 @@
* 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/.
*
* Copyright 2015-2018 Danny Robson <danny@nerdcruft.net>
* Copyright 2015-2019 Danny Robson <danny@nerdcruft.net>
*/
#ifndef CRUFT_UTIL_GEOM_IOSTREAM_HPP
#define CRUFT_UTIL_GEOM_IOSTREAM_HPP
#pragma once
#include "fwd.hpp"
@ -20,6 +19,10 @@ namespace cruft::geom {
std::ostream&
operator<< (std::ostream&, aabb<S,T>);
template <size_t S, typename T>
std::ostream&
operator<< (std::ostream&, segment<S,T> const&);
template <size_t S, typename T>
std::ostream&
operator<< (std::ostream&, ray<S,T>);
@ -36,5 +39,3 @@ namespace cruft::geom {
std::ostream&
operator<< (std::ostream&, frustum<T>);
}
#endif