| Line 1... |
Line 1... |
| 1 |
#include "bob_dom_frame.h"
|
1 |
#include "bob_dom_frame.h"
|
| 2 |
//---------------------------------------------------------------------------------
|
2 |
//---------------------------------------------------------------------------------
|
| 3 |
bool bob_dom_frame::point3d::load(bob_dom_ibinaryfilestream& is)
|
- |
|
| 4 |
{
|
- |
|
| 5 |
if(!is.good()) return false;
|
- |
|
| 6 |
is >> x >> y >> z;
|
- |
|
| 7 |
return !is.fail();
|
- |
|
| 8 |
}
|
- |
|
| 9 |
//---------------------------------------------------------------------------------
|
- |
|
| 10 |
bool bob_dom_frame::point3d::toFile(bob_dom_otextfilestream & os)
|
3 |
bool bob_frame::Position::toFile(otextfilestream & os)
|
| 11 |
{
|
4 |
{
|
| 12 |
os << noSemicolons << x << ';' << y << ';' << z << "; ";
|
5 |
os << noSemicolons << x << ';' << y << ';' << z << "; ";
|
| 13 |
return os.good();
|
6 |
return os.good();
|
| 14 |
}
|
7 |
}
|
| 15 |
//---------------------------------------------------------------------------------
|
8 |
//---------------------------------------------------------------------------------
|
| 16 |
bool bob_dom_frame::point3d::toFile(bob_dom_obinaryfilestream& os)
|
- |
|
| 17 |
{
|
- |
|
| 18 |
os << x << y << z;
|
- |
|
| 19 |
return os.good();
|
- |
|
| 20 |
}
|
- |
|
| 21 |
//---------------------------------------------------------------------------------
|
- |
|
| 22 |
bool bob_dom_frame::rgb::load(bob_dom_ibinaryfilestream& is)
|
9 |
bool bob_frame::rgb::load(ibinaryfilestream& is)
|
| 23 |
{
|
10 |
{
|
| 24 |
if(!is.good()) return false;
|
11 |
if(!is.good()) return false;
|
| 25 |
is >> r >> g >> b;
|
12 |
is >> r >> g >> b;
|
| 26 |
return !is.fail();
|
13 |
return !is.fail();
|
| 27 |
}
|
14 |
}
|
| 28 |
//---------------------------------------------------------------------------------
|
15 |
//---------------------------------------------------------------------------------
|
| 29 |
bool bob_dom_frame::rgb::toFile(bob_dom_otextfilestream & os)
|
16 |
bool bob_frame::rgb::toFile(otextfilestream & os)
|
| 30 |
{
|
17 |
{
|
| 31 |
os << noSemicolons << r << ';' << g << ';' << b << "; ";
|
18 |
os << noSemicolons << r << ';' << g << ';' << b << "; ";
|
| 32 |
return os.good();
|
19 |
return os.good();
|
| 33 |
}
|
20 |
}
|
| 34 |
//---------------------------------------------------------------------------------
|
21 |
//---------------------------------------------------------------------------------
|
| 35 |
bool bob_dom_frame::rgb::toFile(bob_dom_obinaryfilestream& os)
|
22 |
bool bob_frame::rgb::toFile(obinaryfilestream& os)
|
| 36 |
{
|
23 |
{
|
| 37 |
os << r << g << b;
|
24 |
os << r << g << b;
|
| 38 |
return os.good();
|
25 |
return os.good();
|
| 39 |
}
|
26 |
}
|
| 40 |
//---------------------------------------------------------------------------------
|
27 |
//---------------------------------------------------------------------------------
|
| 41 |
bool bob_dom_frame::angle_axis::load(bob_dom_ibinaryfilestream& is)
|
28 |
bool bob_frame::AngleAxis::load(ibinaryfilestream& is)
|
| 42 |
{
|
29 |
{
|
| 43 |
if(!is.good()) return false;
|
30 |
if(!is.good()) return false;
|
| 44 |
is >> angle >> x >> y >> z;
|
31 |
is >> angle >> x >> y >> z;
|
| 45 |
|
32 |
|
| 46 |
return(!is.fail());
|
33 |
return(!is.fail());
|
| 47 |
}
|
34 |
}
|
| 48 |
//---------------------------------------------------------------------------------
|
35 |
//---------------------------------------------------------------------------------
|
| 49 |
bool bob_dom_frame::angle_axis::toFile(bob_dom_otextfilestream& os)
|
36 |
bool bob_frame::AngleAxis::toFile(otextfilestream& os)
|
| 50 |
{
|
37 |
{
|
| 51 |
os << noSemicolons << angle << ';' << x << ';' << y << ';' << z << "; ";
|
38 |
os << noSemicolons << angle << ';' << x << ';' << y << ';' << z << "; ";
|
| 52 |
return os.good();
|
39 |
return os.good();
|
| 53 |
}
|
40 |
}
|
| 54 |
//---------------------------------------------------------------------------------
|
41 |
//---------------------------------------------------------------------------------
|
| 55 |
bool bob_dom_frame::angle_axis::toFile(bob_dom_obinaryfilestream& os)
|
42 |
bool bob_frame::AngleAxis::toFile(obinaryfilestream& os)
|
| 56 |
{
|
43 |
{
|
| 57 |
os << angle << x << y << z;
|
44 |
os << angle << x << y << z;
|
| 58 |
return os.good();
|
45 |
return os.good();
|
| 59 |
}
|
46 |
}
|
| 60 |
//---------------------------------------------------------------------------------
|
47 |
//---------------------------------------------------------------------------------
|
| 61 |
bool bob_dom_frame::tcb_info::load(bob_dom_ibinaryfilestream& is)
|
48 |
bool bob_frame::tcb_info::load(ibinaryfilestream& is)
|
| 62 |
{
|
49 |
{
|
| 63 |
if(!is.good()) return false;
|
50 |
if(!is.good()) return false;
|
| 64 |
is >> tension >> continuity >> bias >> easeFrom >> easeTo;
|
51 |
is >> tension >> continuity >> bias >> easeFrom >> easeTo;
|
| 65 |
return !is.fail();
|
52 |
return !is.fail();
|
| 66 |
}
|
53 |
}
|
| 67 |
//---------------------------------------------------------------------------------
|
54 |
//---------------------------------------------------------------------------------
|
| 68 |
bool bob_dom_frame::tcb_info::toFile(bob_dom_otextfilestream & os)
|
55 |
bool bob_frame::tcb_info::toFile(otextfilestream & os)
|
| 69 |
{
|
56 |
{
|
| 70 |
os << noSemicolons;
|
57 |
os << noSemicolons;
|
| 71 |
os << tension << ';' << continuity << ';' << bias << ';' << easeFrom << ';' << easeTo << "; ";
|
58 |
os << tension << ';' << continuity << ';' << bias << ';' << easeFrom << ';' << easeTo << "; ";
|
| 72 |
return os.good();
|
59 |
return os.good();
|
| 73 |
}
|
60 |
}
|
| 74 |
//---------------------------------------------------------------------------------
|
61 |
//---------------------------------------------------------------------------------
|
| 75 |
bool bob_dom_frame::tcb_info::toFile(bob_dom_obinaryfilestream& os)
|
62 |
bool bob_frame::tcb_info::toFile(obinaryfilestream& os)
|
| 76 |
{
|
63 |
{
|
| 77 |
os << tension << continuity << bias << easeFrom << easeTo;
|
64 |
os << tension << continuity << bias << easeFrom << easeTo;
|
| 78 |
return os.good();
|
65 |
return os.good();
|
| 79 |
}
|
66 |
}
|
| 80 |
//---------------------------------------------------------------------------------
|
67 |
//---------------------------------------------------------------------------------
|
| 81 |
bool bob_dom_frame::load(bob_dom_ibinaryfilestream& is)
|
68 |
bool bob_frame::load(ibinaryfilestream& is)
|
| 82 |
{
|
69 |
{
|
| 83 |
is >> flags;
|
70 |
is >> flags;
|
| 84 |
|
71 |
|
| 85 |
// if we don't know some bits in the flags, the load will probably fail but not necessarily
|
72 |
// if we don't know some bits in the flags, the load will probably fail but not necessarily
|
| 86 |
if((flags & ~flagMask) > 0)
|
73 |
if((flags & ~flagMask) > 0)
|
| 87 |
error(s_warning, e_unsupportedFrameFlags, "0x%X - unsupported bits set in frame flags", flags);
|
74 |
error(s_warning, e_unsupportedFrameFlags, "0x%X - unsupported bits set in frame flags", flags);
|
| 88 |
|
75 |
|
| 89 |
// these flags are "known" but they were never found so I don't know how to treat them
|
76 |
// these flags are "known" but they were never found so I don't know how to treat them
|
| 90 |
if(flags & CUT_F_POSBEZINFO)
|
77 |
if(flags & CUT_F_POSBEZINFO)
|
| 91 |
error(s_warning, e_unsupportedFrameFlags, "0x%X: CUT_F_POSBEZINFO encountered - don't know how to output", flags);
|
78 |
error(s_warning, e_unsupportedFrameFlags, "0x%X: CUT_F_POSBEZINFO encountered - don't know how to output", flags);
|
| 92 |
if(flags & CUT_F_SAMESCALE)
|
79 |
if(flags & CUT_F_SAMESCALE)
|
| 93 |
error(s_warning, e_unsupportedFrameFlags, "0x%X: CUT_F_SAMESCALE encountered", flags);
|
80 |
error(s_warning, e_unsupportedFrameFlags, "0x%X: CUT_F_SAMESCALE encountered", flags);
|
| 94 |
|
81 |
|
| 95 |
if((flags & CUT_F_SAMEPOS)==0){
|
82 |
if((flags & CUT_F_SAMEPOS)==0){
|
| 96 |
if(position.load(is)==false) { error(e_notEnoughData, "Error loading position"); return false; }
|
83 |
if(position.load(is)==false) { error(e_notEnoughData, "Error loading position"); return false; }
|
| 97 |
if((flags & CUT_F_POSTCBINFO) > 0) {
|
84 |
if((flags & CUT_F_POSTCBINFO) > 0) {
|
| 98 |
pos_tcb_info=new tcb_info();
|
85 |
pos_tcb_info=new tcb_info();
|
| 99 |
if(pos_tcb_info->load(is)==false) { error(e_notEnoughData, "Error loading position TCB data"); return false; }
|
86 |
if(pos_tcb_info->load(is)==false) { error(e_notEnoughData, "Error loading position TCB data"); return false; }
|
| 100 |
}
|
87 |
}
|
| 101 |
}
|
88 |
}
|
| 102 |
if((flags & CUT_F_SAMEROT)==0 && (flags & CUT_F_ROT) > 0){
|
89 |
if((flags & CUT_F_SAMEROT)==0 && (flags & CUT_F_ROT) > 0){
|
| 103 |
rotation=new angle_axis();
|
90 |
rotation=new AngleAxis();
|
| 104 |
if(rotation->load(is)==false) { error(e_notEnoughData, "Error loading rotation"); return false; }
|
91 |
if(rotation->load(is)==false) { error(e_notEnoughData, "Error loading rotation"); return false; }
|
| 105 |
if((flags & CUT_F_ROTTCBINFO) > 0) {
|
92 |
if((flags & CUT_F_ROTTCBINFO) > 0) {
|
| 106 |
rot_tcb_info=new tcb_info();
|
93 |
rot_tcb_info=new tcb_info();
|
| 107 |
if(rot_tcb_info->load(is)==false) { error(e_notEnoughData, "Error loading rotation TCB data"); return false; }
|
94 |
if(rot_tcb_info->load(is)==false) { error(e_notEnoughData, "Error loading rotation TCB data"); return false; }
|
| 108 |
}
|
95 |
}
|
| 109 |
}
|
96 |
}
|
| 110 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
97 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
| 111 |
if((flags & CUT_F_SAMETARGET) == 0){
|
98 |
if((flags & CUT_F_SAMETARGET) == 0){
|
| 112 |
targetPos=new point3d();
|
99 |
targetPos=new Position();
|
| 113 |
if(targetPos->load(is)==false) { error(e_notEnoughData, "Error loading target position data"); return false; }
|
100 |
if(targetPos->load(is)==false) { error(e_notEnoughData, "Error loading target position data"); return false; }
|
| 114 |
}
|
101 |
}
|
| 115 |
if((flags & CUT_F_SAMEROT) == 0){
|
102 |
if((flags & CUT_F_SAMEROT) == 0){
|
| 116 |
is >> rollAngle;
|
103 |
is >> rollAngle;
|
| 117 |
if(is.fail()) { error(e_notEnoughData, "Error loading roll angle"); return false; }
|
104 |
if(is.fail()) { error(e_notEnoughData, "Error loading roll angle"); return false; }
|
| Line 127... |
Line 114... |
| 127 |
}
|
114 |
}
|
| 128 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0){
|
115 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0){
|
| 129 |
color=new rgb();
|
116 |
color=new rgb();
|
| 130 |
if(color->load(is)==false) { error(e_notEnoughData, "Error loading RGB"); return false; }
|
117 |
if(color->load(is)==false) { error(e_notEnoughData, "Error loading RGB"); return false; }
|
| 131 |
}
|
118 |
}
|
| 132 |
|
119 |
|
| 133 |
is >> length >> index;
|
120 |
is >> length >> index;
|
| 134 |
if(is.fail()) { error(e_notEnoughData, "Error loading length or index"); return false; }
|
121 |
if(is.fail()) { error(e_notEnoughData, "Error loading length or index"); return false; }
|
| 135 |
|
122 |
|
| 136 |
return !is.fail();
|
123 |
return !is.fail();
|
| 137 |
}
|
124 |
}
|
| 138 |
//---------------------------------------------------------------------------------
|
125 |
//---------------------------------------------------------------------------------
|
| 139 |
bool bob_dom_frame::toFile(bob_dom_obinaryfilestream& os)
|
126 |
bool bob_frame::toFile(obinaryfilestream& os)
|
| 140 |
{
|
127 |
{
|
| 141 |
os << flags;
|
128 |
os << flags;
|
| 142 |
|
129 |
|
| 143 |
if((flags & CUT_F_SAMEPOS)==0){
|
130 |
if((flags & CUT_F_SAMEPOS)==0){
|
| 144 |
position.toFile(os);
|
131 |
position.toFile(os);
|
| 145 |
if(pos_tcb_info)
|
132 |
if(pos_tcb_info)
|
| 146 |
pos_tcb_info->toFile(os);
|
133 |
pos_tcb_info->toFile(os);
|
| 147 |
}
|
134 |
}
|
| Line 151... |
Line 138... |
| 151 |
rot_tcb_info->toFile(os);
|
138 |
rot_tcb_info->toFile(os);
|
| 152 |
}
|
139 |
}
|
| 153 |
if(flags & CUT_F_TARGETPOS) {
|
140 |
if(flags & CUT_F_TARGETPOS) {
|
| 154 |
if(targetPos)
|
141 |
if(targetPos)
|
| 155 |
targetPos->toFile(os);
|
142 |
targetPos->toFile(os);
|
| 156 |
|
143 |
|
| 157 |
if((flags & CUT_F_SAMEROT) == 0)
|
144 |
if((flags & CUT_F_SAMEROT) == 0)
|
| 158 |
os << rollAngle;
|
145 |
os << rollAngle;
|
| 159 |
|
146 |
|
| 160 |
if(tpos_tcb_info)
|
147 |
if(tpos_tcb_info)
|
| 161 |
tpos_tcb_info->toFile(os);
|
148 |
tpos_tcb_info->toFile(os);
|
| 162 |
}
|
149 |
}
|
| 163 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
150 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
| 164 |
os << fov;
|
151 |
os << fov;
|
| 165 |
|
152 |
|
| 166 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0)
|
153 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0)
|
| 167 |
color->toFile(os);
|
154 |
color->toFile(os);
|
| 168 |
|
155 |
|
| 169 |
os << length << index;
|
156 |
os << length << index;
|
| 170 |
return os.good();
|
157 |
return os.good();
|
| 171 |
}
|
158 |
}
|
| 172 |
//---------------------------------------------------------------------------------
|
159 |
//---------------------------------------------------------------------------------
|
| 173 |
bool bob_dom_frame::toFile(bob_dom_otextfilestream& os)
|
160 |
bool bob_frame::toFile(otextfilestream& os)
|
| 174 |
{
|
161 |
{
|
| 175 |
os << noSemicolons << "{ " << hex << "0x" << flags << dec << "; ";
|
162 |
os << noSemicolons << "{ " << hex << "0x" << flags << dec << "; ";
|
| 176 |
|
163 |
|
| 177 |
if((flags & CUT_F_SAMEPOS)==0){
|
164 |
if((flags & CUT_F_SAMEPOS)==0){
|
| 178 |
position.toFile(os);
|
165 |
position.toFile(os);
|
| 179 |
if(pos_tcb_info)
|
166 |
if(pos_tcb_info)
|
| 180 |
pos_tcb_info->toFile(os);
|
167 |
pos_tcb_info->toFile(os);
|
| 181 |
}
|
168 |
}
|
| Line 185... |
Line 172... |
| 185 |
rot_tcb_info->toFile(os);
|
172 |
rot_tcb_info->toFile(os);
|
| 186 |
}
|
173 |
}
|
| 187 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
174 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
| 188 |
if(targetPos)
|
175 |
if(targetPos)
|
| 189 |
targetPos->toFile(os);
|
176 |
targetPos->toFile(os);
|
| 190 |
|
177 |
|
| 191 |
if((flags & CUT_F_SAMEROT) == 0)
|
178 |
if((flags & CUT_F_SAMEROT) == 0)
|
| 192 |
os << rollAngle << "; ";
|
179 |
os << rollAngle << "; ";
|
| 193 |
|
180 |
|
| 194 |
if(tpos_tcb_info)
|
181 |
if(tpos_tcb_info)
|
| 195 |
tpos_tcb_info->toFile(os);
|
182 |
tpos_tcb_info->toFile(os);
|
| 196 |
}
|
183 |
}
|
| 197 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
184 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
| 198 |
os << fov << "; ";
|
185 |
os << fov << "; ";
|
| 199 |
|
186 |
|
| 200 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0)
|
187 |
if((flags & CUT_F_SAMECOLOR)==0 && (flags & CUT_F_COLOR) > 0)
|
| 201 |
color->toFile(os);
|
188 |
color->toFile(os);
|
| 202 |
|
189 |
|
| 203 |
os << autoSemicolons << length << index << noSemicolons << '}';
|
190 |
os << autoSemicolons << length << index << noSemicolons << '}';
|
| 204 |
|
191 |
|
| 205 |
return os.good();
|
192 |
return os.good();
|
| 206 |
}
|
193 |
}
|
| 207 |
//---------------------------------------------------------------------------------
|
194 |
//---------------------------------------------------------------------------------
|
| 208 |
int bob_dom_frame::valueCount()
|
195 |
int bob_frame::valueCount()
|
| 209 |
{
|
196 |
{
|
| 210 |
int size=0;
|
197 |
int size=0;
|
| 211 |
|
198 |
|
| 212 |
if((flags & CUT_F_SAMEPOS)==0){
|
199 |
if((flags & CUT_F_SAMEPOS)==0){
|
| 213 |
size+=3;
|
200 |
size+=3;
|
| 214 |
if((flags & CUT_F_POSTCBINFO) > 0)
|
201 |
if((flags & CUT_F_POSTCBINFO) > 0)
|
| 215 |
size+=5;
|
202 |
size+=5;
|
| 216 |
}
|
203 |
}
|
| Line 220... |
Line 207... |
| 220 |
size+=5;
|
207 |
size+=5;
|
| 221 |
}
|
208 |
}
|
| 222 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
209 |
if((flags & CUT_F_TARGETPOS) > 0) {
|
| 223 |
if((flags & CUT_F_SAMETARGET) == 0)
|
210 |
if((flags & CUT_F_SAMETARGET) == 0)
|
| 224 |
size+=3;
|
211 |
size+=3;
|
| 225 |
|
212 |
|
| 226 |
if((flags & CUT_F_SAMEROT) == 0)
|
213 |
if((flags & CUT_F_SAMEROT) == 0)
|
| 227 |
size++;
|
214 |
size++;
|
| 228 |
|
215 |
|
| 229 |
if((flags & CUT_F_TPOSTCBINFO) > 0)
|
216 |
if((flags & CUT_F_TPOSTCBINFO) > 0)
|
| 230 |
size+=5;
|
217 |
size+=5;
|
| 231 |
}
|
218 |
}
|
| 232 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
219 |
if((flags & CUT_F_SAMEFOV)==0 && (flags & CUT_F_FOV) > 0)
|
| 233 |
size+=1;
|
220 |
size+=1;
|