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>
36 template<
typename... Args>
37 std::string make_string(
const Args&... args)
39 std::ostringstream stream;
40 (stream << ... << args);
46 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec2<T>& vec)
48 output << vec.x <<
" " << vec.y;
56 input >> vec.x >> vec.y;
62 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec3<T>& vec)
64 output << vec.x <<
" " << vec.y <<
" " << vec.z;
72 input >> vec.x >> vec.y >> vec.z;
78 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec4<T>& vec)
80 output << vec.x <<
" " << vec.y <<
" " << vec.z <<
" " << vec.w;
88 input >> vec.x >> vec.y >> vec.z >> vec.w;
94 std::ostream& operator<<(std::ostream& output,
const vsg::t_quat<T>& q)
96 output << q.x <<
" " << q.y <<
" " << q.z <<
" " << q.w;
104 input >> q.x >> q.y >> q.z >> q.w;
110 std::ostream& operator<<(std::ostream& output,
const vsg::t_plane<T>& vec)
112 output << vec.value[0] <<
" " << vec.value[1] <<
" " << vec.value[2] <<
" " << vec.value[3];
120 input >> vec.value[0] >> vec.value[1] >> vec.value[2] >> vec.value[3];
126 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat3<T>& mat)
129 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) << std::endl;
130 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) << std::endl;
131 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) << std::endl;
137 std::istream& operator>>(std::istream& input,
vsg::t_mat3<T>& mat)
139 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0);
140 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1);
141 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2);
147 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat4<T>& mat)
150 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) <<
" " << mat(3, 0) << std::endl;
151 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) <<
" " << mat(3, 1) << std::endl;
152 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) <<
" " << mat(3, 2) << std::endl;
153 output <<
" " << mat(0, 3) <<
" " << mat(1, 3) <<
" " << mat(2, 3) <<
" " << mat(3, 3) << std::endl;
159 std::istream& operator>>(std::istream& input,
vsg::t_mat4<T>& mat)
161 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0) >> mat(3, 0);
162 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1) >> mat(3, 1);
163 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2) >> mat(3, 2);
164 input >> mat(0, 3) >> mat(1, 3) >> mat(2, 3) >> mat(3, 3);
186 std::ostream& operator<<(std::ostream& output,
const vsg::t_box<T>& bx)
189 output <<
" " << bx.min << std::endl;
190 output <<
" " << bx.max << std::endl;
196 std::istream& operator>>(std::istream& input,
vsg::t_box<T>& bx)
205 std::ostream& operator<<(std::ostream& output,
const vsg::ref_ptr<T>& ptr)
208 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(" << ptr->className() <<
" " << ptr.get() <<
")";
210 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(nullptr)";
215 template<
typename T,
typename R>
216 std::ostream& operator<<(std::ostream& output,
const std::pair<T, R>& wd)
218 output << wd.first <<
" " << wd.second;
223 template<
typename T,
typename R>
224 std::istream& operator>>(std::istream& input, std::pair<T, R>& wd)
226 input >> wd.first >> wd.second;
232 std::ostream& operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
234 return stream << static_cast<typename std::underlying_type<T>::type>(e);
238 inline std::ostream& operator<<(std::ostream& output,
const vsg::Path& path)
240 output << path.string();
245 inline std::istream& operator>>(std::istream& input,
vsg::Path& path)
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