| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
#include <OSGMathIO.h> |
|---|
| 40 |
|
|---|
| 41 |
#include <OSGMatrix.h> |
|---|
| 42 |
#include <OSGVector.h> |
|---|
| 43 |
#include <OSGQuaternion.h> |
|---|
| 44 |
#include <OSGColor.h> |
|---|
| 45 |
|
|---|
| 46 |
#include <iostream> |
|---|
| 47 |
#include <sstream> |
|---|
| 48 |
|
|---|
| 49 |
OSG_BEGIN_NAMESPACE |
|---|
| 50 |
|
|---|
| 51 |
namespace |
|---|
| 52 |
{ |
|---|
| 53 |
template<int S, class T> |
|---|
| 54 |
inline std::istream& vecRead(std::istream & is, T& obj) |
|---|
| 55 |
{ |
|---|
| 56 |
for (int i = 0; i < S; i++) { |
|---|
| 57 |
is >> obj[i]; |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
if (i != S - 1) { |
|---|
| 61 |
char tmp; |
|---|
| 62 |
is >> tmp; |
|---|
| 63 |
std::ws(is); |
|---|
| 64 |
} |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
return is; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
inline std::istream& consumeNewLine(std::istream& is) |
|---|
| 71 |
{ |
|---|
| 72 |
while(is) { |
|---|
| 73 |
int c = is.peek(); |
|---|
| 74 |
if (c != '\n' && c != '\r') { |
|---|
| 75 |
break; |
|---|
| 76 |
} |
|---|
| 77 |
is.get(); |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
return is; |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
template<class T> |
|---|
| 87 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, Color3<T> &obj) |
|---|
| 88 |
{ |
|---|
| 89 |
return vecRead<3> (is, obj); |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
template<class T> |
|---|
| 93 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, Color4<T> &obj) |
|---|
| 94 |
{ |
|---|
| 95 |
return vecRead<4> (is, obj); |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
template<class T, class S> |
|---|
| 99 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, PointInterface<T, S> &obj) |
|---|
| 100 |
{ |
|---|
| 101 |
return vecRead<S::_iSize> (is, obj); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
template<class T, class S> |
|---|
| 105 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, VectorInterface<T, S> &obj) |
|---|
| 106 |
{ |
|---|
| 107 |
return vecRead<S::_iSize> (is, obj); |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
template<class T> |
|---|
| 111 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, QuaternionBase<T> &obj) |
|---|
| 112 |
{ |
|---|
| 113 |
return vecRead<4>(is, obj); |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
template<class T> |
|---|
| 117 |
OSG_BASE_DLLMAPPING std::istream & operator >>(std::istream & is, TransformationMatrix<T> &obj) |
|---|
| 118 |
{ |
|---|
| 119 |
for (int j = 0; j < 4; j++) { |
|---|
| 120 |
for (int i = 0; i < 4; i++) { |
|---|
| 121 |
is >> std::ws >> obj[i][j] >> std::ws; |
|---|
| 122 |
|
|---|
| 123 |
if (j < 3 || i < 3) { |
|---|
| 124 |
is >> consumeNewLine; |
|---|
| 125 |
} |
|---|
| 126 |
} |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
return is; |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
namespace |
|---|
| 133 |
{ |
|---|
| 134 |
template<typename T> |
|---|
| 135 |
void instantiate2() |
|---|
| 136 |
{ |
|---|
| 137 |
std::istringstream is; |
|---|
| 138 |
is >> VectorInterface<T, VecStorage2<T> > (); |
|---|
| 139 |
is >> VectorInterface<T, VecStorage3<T> > (); |
|---|
| 140 |
is >> VectorInterface<T, VecStorage4<T> > (); |
|---|
| 141 |
is >> PointInterface<T, VecStorage2<T> > (); |
|---|
| 142 |
is >> PointInterface<T, VecStorage3<T> > (); |
|---|
| 143 |
is >> PointInterface<T, VecStorage4<T> > (); |
|---|
| 144 |
is >> Color3<T> (); |
|---|
| 145 |
is >> Color4<T> (); |
|---|
| 146 |
is >> TransformationMatrix<T> (); |
|---|
| 147 |
is >> QuaternionBase<T> (); |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
void instantiate1() |
|---|
| 151 |
{ |
|---|
| 152 |
instantiate2<Real32> (); |
|---|
| 153 |
instantiate2<Real64> (); |
|---|
| 154 |
instantiate2<Real128> (); |
|---|
| 155 |
instantiate2<Int8> (); |
|---|
| 156 |
instantiate2<UInt8> (); |
|---|
| 157 |
instantiate2<Int16> (); |
|---|
| 158 |
instantiate2<UInt16> (); |
|---|
| 159 |
instantiate2<Int32> (); |
|---|
| 160 |
instantiate2<UInt32> (); |
|---|
| 161 |
} |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
OSG_END_NAMESPACE |
|---|