15#include <vsg/core/Exception.h>
16#include <vsg/core/ref_ptr.h>
17#include <vsg/core/type_name.h>
18#include <vsg/io/Path.h>
19#include <vsg/maths/box.h>
20#include <vsg/maths/mat3.h>
21#include <vsg/maths/mat4.h>
22#include <vsg/maths/plane.h>
23#include <vsg/maths/quat.h>
24#include <vsg/maths/sphere.h>
25#include <vsg/maths/vec2.h>
26#include <vsg/maths/vec3.h>
27#include <vsg/maths/vec4.h>
54 inline indentation operator-(
const indentation& lhs,
const int rhs) {
return indentation{lhs.indent - rhs}; }
56 inline std::ostream& operator<<(std::ostream& output,
const indentation& in)
58 for (
int i = 0; i < in.indent; ++i) output.put(
' ');
63 template<
typename... Args>
64 std::string make_string(
const Args&... args)
66 std::ostringstream stream;
67 (stream << ... << args);
73 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec2<T>& vec)
75 output << vec.x <<
" " << vec.y;
83 input >> vec.x >> vec.y;
89 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec3<T>& vec)
91 output << vec.x <<
" " << vec.y <<
" " << vec.z;
99 input >> vec.x >> vec.y >> vec.z;
105 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec4<T>& vec)
107 output << vec.x <<
" " << vec.y <<
" " << vec.z <<
" " << vec.w;
113 std::istream& operator>>(std::istream& input,
vsg::t_vec4<T>& vec)
115 input >> vec.x >> vec.y >> vec.z >> vec.w;
121 std::ostream& operator<<(std::ostream& output,
const vsg::t_quat<T>& q)
123 output << q.x <<
" " << q.y <<
" " << q.z <<
" " << q.w;
131 input >> q.x >> q.y >> q.z >> q.w;
137 std::ostream& operator<<(std::ostream& output,
const vsg::t_plane<T>& vec)
139 output << vec.value[0] <<
" " << vec.value[1] <<
" " << vec.value[2] <<
" " << vec.value[3];
147 input >> vec.value[0] >> vec.value[1] >> vec.value[2] >> vec.value[3];
153 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat3<T>& mat)
156 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) << std::endl;
157 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) << std::endl;
158 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) << std::endl;
164 std::istream& operator>>(std::istream& input,
vsg::t_mat3<T>& mat)
166 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0);
167 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1);
168 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2);
174 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat4<T>& mat)
177 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) <<
" " << mat(3, 0) << std::endl;
178 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) <<
" " << mat(3, 1) << std::endl;
179 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) <<
" " << mat(3, 2) << std::endl;
180 output <<
" " << mat(0, 3) <<
" " << mat(1, 3) <<
" " << mat(2, 3) <<
" " << mat(3, 3) << std::endl;
186 std::istream& operator>>(std::istream& input,
vsg::t_mat4<T>& mat)
188 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0) >> mat(3, 0);
189 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1) >> mat(3, 1);
190 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2) >> mat(3, 2);
191 input >> mat(0, 3) >> mat(1, 3) >> mat(2, 3) >> mat(3, 3);
213 std::ostream& operator<<(std::ostream& output,
const vsg::t_box<T>& bx)
216 output <<
" " << bx.min << std::endl;
217 output <<
" " << bx.max << std::endl;
223 std::istream& operator>>(std::istream& input,
vsg::t_box<T>& bx)
232 std::ostream& operator<<(std::ostream& output,
const vsg::ref_ptr<T>& ptr)
235 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(" << ptr->className() <<
" " << ptr.get() <<
")";
237 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(nullptr)";
242 template<
typename T,
typename R>
243 std::ostream& operator<<(std::ostream& output,
const std::pair<T, R>& wd)
245 output << wd.first <<
" " << wd.second;
250 template<
typename T,
typename R>
251 std::istream& operator>>(std::istream& input, std::pair<T, R>& wd)
253 input >> wd.first >> wd.second;
259 std::ostream& operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
261 return stream << static_cast<typename std::underlying_type<T>::type>(e);
265 inline std::ostream& operator<<(std::ostream& output,
const vsg::Path& path)
267 output << path.string();
272 inline std::istream& operator>>(std::istream& input,
vsg::Path& path)
281 inline std::ostream& operator<<(std::ostream& output,
const vsg::Exception& e)
283 output <<
"Error code: " << e.result <<
" | " << e.message;
Definition Exception.h:23
helper class for inserting indentation into streams useful for formatting output.
Definition stream.h:38
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