AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
io_utils.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_IO_UTILS_H
18#define AGX_IO_UTILS_H
19
20#include <agx/Vec2.h>
21#include <agx/Vec3.h>
22#include <agx/Vec4.h>
23#include <agx/Quat.h>
24
25
26namespace agx
27{
28
30 // Vec2 streaming operators
31 inline std::ostream& operator << ( std::ostream& output, const Vec2& vec )
32 {
33 output << vec[0] << " " << vec[1];
34 return output; // to enable cascading
35 }
36
37 inline std::istream& operator >> ( std::istream& input, Vec2& vec )
38 {
39 input >> vec[0] >> vec[1];
40 return input;
41 }
42
43
45 // Vec3i steaming operators.
46 inline std::ostream& operator << ( std::ostream& output, const Vec3i& vec )
47 {
48 output << vec[0] << " "
49 << vec[1] << " "
50 << vec[2];
51 return output; // to enable cascading
52 }
53
54 inline std::istream& operator >> ( std::istream& input, Vec3i& vec )
55 {
56 input >> vec[0] >> vec[1] >> vec[2];
57 return input;
58 }
59
60
62 // Vec3d steaming operators.
63 inline std::ostream& operator << ( std::ostream& output, const Vec3d& vec )
64 {
65 output << vec[0] << " "
66 << vec[1] << " "
67 << vec[2];
68 return output; // to enable cascading
69 }
70
71 inline std::istream& operator >> ( std::istream& input, Vec3d& vec )
72 {
73 input >> vec[0] >> vec[1] >> vec[2];
74 return input;
75 }
76
77
79 // Vec3f steaming operators.
80 inline std::ostream& operator << ( std::ostream& output, const Vec3f& vec )
81 {
82 output << vec[0] << " "
83 << vec[1] << " "
84 << vec[2];
85 return output; // to enable cascading
86 }
87
88 inline std::istream& operator >> ( std::istream& input, Vec3f& vec )
89 {
90 input >> vec[0] >> vec[1] >> vec[2];
91 return input;
92 }
93
94
95
97 // Vec4 steaming operators.
98 inline std::ostream& operator << ( std::ostream& output, const Vec4& vec )
99 {
100 output << vec[0] << " "
101 << vec[1] << " "
102 << vec[2] << " "
103 << vec[3];
104 return output; // to enable cascading
105 }
106
107 inline std::istream& operator >> ( std::istream& input, Vec4& vec )
108 {
109 input >> vec[0] >> vec[1] >> vec[2] >> vec[3];
110 return input;
111 }
112
113
114
115
116
118 // Matrix steaming operators.
119#ifndef SWIG_CPPWRAPPER_BUILD
120 inline std::ostream& operator<< (std::ostream& os, const Matrix& m)
121 {
122 os << "{" << std::endl;
123 for ( int row = 0; row < 4; ++row ) {
124 os << "\t";
125 for ( int col = 0; col < 4; ++col )
126 os << m( row, col ) << " ";
127 os << std::endl;
128 }
129 os << "}" << std::endl;
130 return os;
131 }
132#endif
134 // Quat streaming operators.
135 inline std::ostream& operator << ( std::ostream& output, const Quat& vec )
136 {
137 output << vec[0] << " "
138 << vec[1] << " "
139 << vec[2] << " "
140 << vec[3];
141 return output; // to enable cascading
142 }
143
144 inline std::istream& operator >> ( std::istream& input, Quat& vec )
145 {
146 input >> vec[0] >> vec[1] >> vec[2] >> vec[3];
147 return input;
148 }
149
150
151
152} // end of namespace agx
153#endif
A class holding 4 dimensional vectors and providing basic arithmetic.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::istream & operator>>(std::istream &input, Vec2 &vec)
Definition io_utils.h:37
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)