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