15#include <vsg/core/ref_ptr.h>
16#include <vsg/core/type_name.h>
17#include <vsg/io/Path.h>
18#include <vsg/maths/box.h>
19#include <vsg/maths/mat3.h>
20#include <vsg/maths/mat4.h>
21#include <vsg/maths/plane.h>
22#include <vsg/maths/quat.h>
23#include <vsg/maths/sphere.h>
24#include <vsg/maths/vec2.h>
25#include <vsg/maths/vec3.h>
26#include <vsg/maths/vec4.h>
53 inline indentation operator-(
const indentation& lhs,
const int rhs) {
return indentation{lhs.indent - rhs}; }
55 inline std::ostream& operator<<(std::ostream& output,
const indentation& in)
57 for (
int i = 0; i < in.indent; ++i) output.put(
' ');
62 template<
typename... Args>
63 std::string make_string(
const Args&... args)
65 std::ostringstream stream;
66 (stream << ... << args);
72 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec2<T>& vec)
74 output << vec.x <<
" " << vec.y;
82 input >> vec.x >> vec.y;
88 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec3<T>& vec)
90 output << vec.x <<
" " << vec.y <<
" " << vec.z;
98 input >> vec.x >> vec.y >> vec.z;
104 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec4<T>& vec)
106 output << vec.x <<
" " << vec.y <<
" " << vec.z <<
" " << vec.w;
112 std::istream& operator>>(std::istream& input,
vsg::t_vec4<T>& vec)
114 input >> vec.x >> vec.y >> vec.z >> vec.w;
120 std::ostream& operator<<(std::ostream& output,
const vsg::t_quat<T>& q)
122 output << q.x <<
" " << q.y <<
" " << q.z <<
" " << q.w;
130 input >> q.x >> q.y >> q.z >> q.w;
136 std::ostream& operator<<(std::ostream& output,
const vsg::t_plane<T>& vec)
138 output << vec.value[0] <<
" " << vec.value[1] <<
" " << vec.value[2] <<
" " << vec.value[3];
146 input >> vec.value[0] >> vec.value[1] >> vec.value[2] >> vec.value[3];
152 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat3<T>& mat)
155 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) << std::endl;
156 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) << std::endl;
157 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) << std::endl;
163 std::istream& operator>>(std::istream& input,
vsg::t_mat3<T>& mat)
165 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0);
166 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1);
167 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2);
173 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat4<T>& mat)
176 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) <<
" " << mat(3, 0) << std::endl;
177 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) <<
" " << mat(3, 1) << std::endl;
178 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) <<
" " << mat(3, 2) << std::endl;
179 output <<
" " << mat(0, 3) <<
" " << mat(1, 3) <<
" " << mat(2, 3) <<
" " << mat(3, 3) << std::endl;
185 std::istream& operator>>(std::istream& input,
vsg::t_mat4<T>& mat)
187 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0) >> mat(3, 0);
188 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1) >> mat(3, 1);
189 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2) >> mat(3, 2);
190 input >> mat(0, 3) >> mat(1, 3) >> mat(2, 3) >> mat(3, 3);
212 std::ostream& operator<<(std::ostream& output,
const vsg::t_box<T>& bx)
215 output <<
" " << bx.min << std::endl;
216 output <<
" " << bx.max << std::endl;
222 std::istream& operator>>(std::istream& input,
vsg::t_box<T>& bx)
231 std::ostream& operator<<(std::ostream& output,
const vsg::ref_ptr<T>& ptr)
234 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(" << ptr->className() <<
" " << ptr.get() <<
")";
236 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(nullptr)";
241 template<
typename T,
typename R>
242 std::ostream& operator<<(std::ostream& output,
const std::pair<T, R>& wd)
244 output << wd.first <<
" " << wd.second;
249 template<
typename T,
typename R>
250 std::istream& operator>>(std::istream& input, std::pair<T, R>& wd)
252 input >> wd.first >> wd.second;
258 std::ostream& operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
260 return stream << static_cast<typename std::underlying_type<T>::type>(e);
264 inline std::ostream& operator<<(std::ostream& output,
const vsg::Path& path)
266 output << path.string();
271 inline std::istream& operator>>(std::istream& input,
vsg::Path& path)
helper class for inserting indentation into streams useful for formatting output.
Definition stream.h:37
t_box template class that represents an axis aligned bounding box
Definition box.h:24
t_mat3 template class that represents a 3x3 matrix.
Definition mat3.h:23
t_mat4 template class that represents a 4x4 matrix.
Definition mat4.h:25
t_quat template class that represents a quaternion
Definition quat.h:35
template sphere class
Definition sphere.h:34
t_vec2 template class that represents a 2D vector
Definition vec2.h:38
t_vec3 template class that represents a 3D vector
Definition vec3.h:34
t_vec4 template class that represents a 4D vector
Definition vec4.h:35