| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include <osgDB/Input> |
|---|
| 14 | |
|---|
| 15 | using namespace osgDB; |
|---|
| 16 | |
|---|
| 17 | FieldReaderIterator::FieldReaderIterator() |
|---|
| 18 | { |
|---|
| 19 | _init(); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | FieldReaderIterator::FieldReaderIterator(const FieldReaderIterator& ic) |
|---|
| 24 | { |
|---|
| 25 | _copy(ic); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | FieldReaderIterator::~FieldReaderIterator() |
|---|
| 30 | { |
|---|
| 31 | _free(); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | FieldReaderIterator& FieldReaderIterator::operator = (const FieldReaderIterator& ic) |
|---|
| 36 | { |
|---|
| 37 | if (this==&ic) return *this; |
|---|
| 38 | _free(); |
|---|
| 39 | _copy(ic); |
|---|
| 40 | return *this; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | void FieldReaderIterator::_free() |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | if (_previousField) |
|---|
| 48 | { |
|---|
| 49 | delete _previousField; |
|---|
| 50 | } |
|---|
| 51 | if (_fieldQueue) |
|---|
| 52 | { |
|---|
| 53 | for(int i=0;i<_fieldQueueCapacity;++i) |
|---|
| 54 | { |
|---|
| 55 | if (_fieldQueue[i]) delete _fieldQueue[i]; |
|---|
| 56 | _fieldQueue[i] = NULL; |
|---|
| 57 | } |
|---|
| 58 | delete [] _fieldQueue; |
|---|
| 59 | } |
|---|
| 60 | _init(); |
|---|
| 61 | |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | void FieldReaderIterator::_init() |
|---|
| 66 | { |
|---|
| 67 | _previousField = NULL; |
|---|
| 68 | _fieldQueue = NULL; |
|---|
| 69 | _fieldQueueSize = 0; |
|---|
| 70 | _fieldQueueCapacity = 0; |
|---|
| 71 | |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | void FieldReaderIterator::_copy(const FieldReaderIterator& ic) |
|---|
| 76 | { |
|---|
| 77 | _reader = ic._reader; |
|---|
| 78 | |
|---|
| 79 | if (ic._previousField) |
|---|
| 80 | { |
|---|
| 81 | _previousField = new Field(*ic._previousField); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | if (ic._fieldQueue && ic._fieldQueueCapacity>0) |
|---|
| 85 | { |
|---|
| 86 | _fieldQueue = new Field* [ic._fieldQueueCapacity]; |
|---|
| 87 | for(int i=0;i<ic._fieldQueueCapacity;++i) |
|---|
| 88 | { |
|---|
| 89 | if (ic._fieldQueue[i]) |
|---|
| 90 | { |
|---|
| 91 | _fieldQueue[i] = new Field(*ic._fieldQueue[i]); |
|---|
| 92 | } |
|---|
| 93 | else |
|---|
| 94 | { |
|---|
| 95 | _fieldQueue[i] = NULL; |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | _fieldQueueSize = ic._fieldQueueSize; |
|---|
| 99 | _fieldQueueCapacity = ic._fieldQueueCapacity; |
|---|
| 100 | } |
|---|
| 101 | else |
|---|
| 102 | { |
|---|
| 103 | _fieldQueue = NULL; |
|---|
| 104 | _fieldQueueSize = 0; |
|---|
| 105 | _fieldQueueCapacity = 0; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | void FieldReaderIterator::attach(std::istream* input) |
|---|
| 112 | { |
|---|
| 113 | _reader.attach(input); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | void FieldReaderIterator::detach() |
|---|
| 118 | { |
|---|
| 119 | _reader.detach(); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | bool FieldReaderIterator::eof() const |
|---|
| 124 | { |
|---|
| 125 | return _fieldQueueSize==0 && _reader.eof(); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | void FieldReaderIterator::insert(int pos,Field* field) |
|---|
| 130 | { |
|---|
| 131 | if (field==NULL) return; |
|---|
| 132 | |
|---|
| 133 | if (pos<0) pos=0; |
|---|
| 134 | if (pos>_fieldQueueSize) pos=_fieldQueueSize; |
|---|
| 135 | |
|---|
| 136 | int i; |
|---|
| 137 | |
|---|
| 138 | if (_fieldQueueSize>=_fieldQueueCapacity) |
|---|
| 139 | { |
|---|
| 140 | int newCapacity = _fieldQueueCapacity*2; |
|---|
| 141 | if (newCapacity<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE; |
|---|
| 142 | while(_fieldQueueSize>=newCapacity) newCapacity*=2; |
|---|
| 143 | Field** newFieldStack = new Field* [newCapacity]; |
|---|
| 144 | for(i=0;i<_fieldQueueCapacity;++i) |
|---|
| 145 | { |
|---|
| 146 | newFieldStack[i] = _fieldQueue[i]; |
|---|
| 147 | } |
|---|
| 148 | for(;i<newCapacity;++i) |
|---|
| 149 | { |
|---|
| 150 | newFieldStack[i] = NULL; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | delete [] _fieldQueue; |
|---|
| 155 | |
|---|
| 156 | _fieldQueue = newFieldStack; |
|---|
| 157 | _fieldQueueCapacity = newCapacity; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | for(i=_fieldQueueSize-1;i>=pos;++i) |
|---|
| 161 | { |
|---|
| 162 | _fieldQueue[i+1]=_fieldQueue[i]; |
|---|
| 163 | } |
|---|
| 164 | _fieldQueue[pos] = field; |
|---|
| 165 | ++_fieldQueueSize; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | void FieldReaderIterator::insert(int pos,const char* str) |
|---|
| 170 | { |
|---|
| 171 | if (str) |
|---|
| 172 | { |
|---|
| 173 | Field* field = new Field; |
|---|
| 174 | while(*str!=0) |
|---|
| 175 | { |
|---|
| 176 | field->addChar(*str); |
|---|
| 177 | ++str; |
|---|
| 178 | } |
|---|
| 179 | insert(pos,field); |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | Field& FieldReaderIterator::operator [] (int pos) |
|---|
| 185 | { |
|---|
| 186 | return field(pos); |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | Field& FieldReaderIterator::field (int pos) |
|---|
| 191 | { |
|---|
| 192 | if (pos<0) |
|---|
| 193 | { |
|---|
| 194 | _blank.setNoNestedBrackets(_reader.getNoNestedBrackets()); |
|---|
| 195 | return _blank; |
|---|
| 196 | } |
|---|
| 197 | else if (pos<_fieldQueueSize) |
|---|
| 198 | { |
|---|
| 199 | return *_fieldQueue[pos]; |
|---|
| 200 | } |
|---|
| 201 | else |
|---|
| 202 | { |
|---|
| 203 | |
|---|
| 204 | if (pos>=_fieldQueueCapacity) |
|---|
| 205 | { |
|---|
| 206 | int newCapacity = _fieldQueueCapacity*2; |
|---|
| 207 | if (newCapacity<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE; |
|---|
| 208 | while(_fieldQueueSize>=newCapacity) newCapacity*=2; |
|---|
| 209 | Field** newFieldStack = new Field* [newCapacity]; |
|---|
| 210 | int i; |
|---|
| 211 | for(i=0;i<_fieldQueueCapacity;++i) |
|---|
| 212 | { |
|---|
| 213 | newFieldStack[i] = _fieldQueue[i]; |
|---|
| 214 | } |
|---|
| 215 | for(;i<newCapacity;++i) |
|---|
| 216 | { |
|---|
| 217 | newFieldStack[i] = NULL; |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | delete [] _fieldQueue; |
|---|
| 221 | |
|---|
| 222 | _fieldQueue = newFieldStack; |
|---|
| 223 | _fieldQueueCapacity = newCapacity; |
|---|
| 224 | } |
|---|
| 225 | while(!_reader.eof() && pos>=_fieldQueueSize) |
|---|
| 226 | { |
|---|
| 227 | if (_fieldQueue[_fieldQueueSize]==NULL) _fieldQueue[_fieldQueueSize] = new Field; |
|---|
| 228 | if (_reader.readField(*_fieldQueue[_fieldQueueSize])) |
|---|
| 229 | { |
|---|
| 230 | ++_fieldQueueSize; |
|---|
| 231 | } |
|---|
| 232 | } |
|---|
| 233 | if (pos<_fieldQueueSize) |
|---|
| 234 | { |
|---|
| 235 | return *_fieldQueue[pos]; |
|---|
| 236 | } |
|---|
| 237 | else |
|---|
| 238 | { |
|---|
| 239 | _blank.setNoNestedBrackets(_reader.getNoNestedBrackets()); |
|---|
| 240 | return _blank; |
|---|
| 241 | } |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | FieldReaderIterator& FieldReaderIterator::operator ++ () |
|---|
| 247 | { |
|---|
| 248 | return (*this)+=1; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | FieldReaderIterator& FieldReaderIterator::operator += (int no) |
|---|
| 253 | { |
|---|
| 254 | if (no>_fieldQueueSize) |
|---|
| 255 | { |
|---|
| 256 | while (!_reader.eof() && no>_fieldQueueSize) |
|---|
| 257 | { |
|---|
| 258 | _reader.ignoreField(); |
|---|
| 259 | --no; |
|---|
| 260 | } |
|---|
| 261 | _fieldQueueSize=0; |
|---|
| 262 | } |
|---|
| 263 | else if (no>0) |
|---|
| 264 | { |
|---|
| 265 | Field** tmpFields = new Field* [no]; |
|---|
| 266 | int i; |
|---|
| 267 | for(i=0;i<no;++i) |
|---|
| 268 | { |
|---|
| 269 | tmpFields[i] = _fieldQueue[i]; |
|---|
| 270 | } |
|---|
| 271 | for(i=no;i<_fieldQueueSize;++i) |
|---|
| 272 | { |
|---|
| 273 | _fieldQueue[i-no] = _fieldQueue[i]; |
|---|
| 274 | } |
|---|
| 275 | _fieldQueueSize -= no; |
|---|
| 276 | for(i=0;i<no;++i) |
|---|
| 277 | { |
|---|
| 278 | _fieldQueue[_fieldQueueSize+i] = tmpFields[i]; |
|---|
| 279 | } |
|---|
| 280 | delete [] tmpFields; |
|---|
| 281 | } |
|---|
| 282 | return *this; |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | void FieldReaderIterator::advanceOverCurrentFieldOrBlock() |
|---|
| 289 | { |
|---|
| 290 | if (field(0).isOpenBracket()) |
|---|
| 291 | { |
|---|
| 292 | advanceToEndOfCurrentBlock(); |
|---|
| 293 | ++(*this); |
|---|
| 294 | } |
|---|
| 295 | else ++(*this); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | void FieldReaderIterator::advanceToEndOfCurrentBlock() |
|---|
| 300 | { |
|---|
| 301 | int entry = field(0).getNoNestedBrackets(); |
|---|
| 302 | while(!eof() && field(0).getNoNestedBrackets()>=entry) |
|---|
| 303 | { |
|---|
| 304 | ++(*this); |
|---|
| 305 | } |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | void FieldReaderIterator::advanceToEndOfBlock(int noNestedBrackets) |
|---|
| 310 | { |
|---|
| 311 | while(!eof() && field(0).getNoNestedBrackets()>=noNestedBrackets) |
|---|
| 312 | { |
|---|
| 313 | ++(*this); |
|---|
| 314 | } |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | bool FieldReaderIterator::matchSequence(const char* str) |
|---|
| 319 | { |
|---|
| 320 | if (str==NULL) return false; |
|---|
| 321 | if (*str==0) return false; |
|---|
| 322 | |
|---|
| 323 | int fieldCount = 0; |
|---|
| 324 | const char* end = str; |
|---|
| 325 | while((*end)!=0 && (*end)==' ') ++end; |
|---|
| 326 | const char* start = end; |
|---|
| 327 | while((*start)!=0) |
|---|
| 328 | { |
|---|
| 329 | if (*end!=' ' && *end!=0) |
|---|
| 330 | { |
|---|
| 331 | ++end; |
|---|
| 332 | } |
|---|
| 333 | else |
|---|
| 334 | { |
|---|
| 335 | if (start!=end) |
|---|
| 336 | { |
|---|
| 337 | if (end-start>1 && *start=='%') |
|---|
| 338 | { |
|---|
| 339 | const char type = *(start+1); |
|---|
| 340 | switch(type) |
|---|
| 341 | { |
|---|
| 342 | |
|---|
| 343 | case('i') : |
|---|
| 344 | { |
|---|
| 345 | if (!field(fieldCount).isInt()) return false; |
|---|
| 346 | break; |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | case('f') : |
|---|
| 350 | { |
|---|
| 351 | if (!field(fieldCount).isFloat()) return false; |
|---|
| 352 | break; |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | case('s') : |
|---|
| 356 | { |
|---|
| 357 | if (!field(fieldCount).isQuotedString()) return false; |
|---|
| 358 | break; |
|---|
| 359 | } |
|---|
| 360 | case('w') : |
|---|
| 361 | default : |
|---|
| 362 | { |
|---|
| 363 | if (!field(fieldCount).isWord()) return false; |
|---|
| 364 | break; |
|---|
| 365 | } |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | } |
|---|
| 369 | else |
|---|
| 370 | { |
|---|
| 371 | if (*start=='{') |
|---|
| 372 | { |
|---|
| 373 | if (!field(fieldCount).isOpenBracket()) return false; |
|---|
| 374 | } |
|---|
| 375 | else if (*start=='}') |
|---|
| 376 | { |
|---|
| 377 | if (!field(fieldCount).isCloseBracket()) return false; |
|---|
| 378 | } |
|---|
| 379 | else |
|---|
| 380 | { |
|---|
| 381 | if (!field(fieldCount).matchWord(start,end-start)) return false; |
|---|
| 382 | } |
|---|
| 383 | } |
|---|
| 384 | fieldCount++; |
|---|
| 385 | } |
|---|
| 386 | while((*end)==' ') ++end; |
|---|
| 387 | start = end; |
|---|
| 388 | } |
|---|
| 389 | } |
|---|
| 390 | return true; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | bool FieldReaderIterator::readSequence(const char* keyword,std::string& value) |
|---|
| 395 | { |
|---|
| 396 | if ((*this)[0].matchWord(keyword) && (*this)[1].isString()) |
|---|
| 397 | { |
|---|
| 398 | value = (*this)[1].getStr(); |
|---|
| 399 | (*this)+=2; |
|---|
| 400 | return true; |
|---|
| 401 | } |
|---|
| 402 | return false; |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | bool FieldReaderIterator::readSequence(const char* keyword,unsigned int& value) |
|---|
| 406 | { |
|---|
| 407 | if ((*this)[0].matchWord(keyword) && (*this)[1].getUInt(value)) |
|---|
| 408 | { |
|---|
| 409 | (*this)+=2; |
|---|
| 410 | return true; |
|---|
| 411 | } |
|---|
| 412 | return false; |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | bool FieldReaderIterator::readSequence(const char* keyword,int& value) |
|---|
| 416 | { |
|---|
| 417 | if ((*this)[0].matchWord(keyword) && (*this)[1].getInt(value)) |
|---|
| 418 | { |
|---|
| 419 | (*this)+=2; |
|---|
| 420 | return true; |
|---|
| 421 | } |
|---|
| 422 | return false; |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | bool FieldReaderIterator::readSequence(const char* keyword,float& value) |
|---|
| 426 | { |
|---|
| 427 | if ((*this)[0].matchWord(keyword) && |
|---|
| 428 | (*this)[1].getFloat(value)) |
|---|
| 429 | { |
|---|
| 430 | (*this)+=2; |
|---|
| 431 | return true; |
|---|
| 432 | } |
|---|
| 433 | return false; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec2f& value) |
|---|
| 437 | { |
|---|
| 438 | if ((*this)[0].matchWord(keyword) && |
|---|
| 439 | (*this)[1].getFloat(value[0]) && |
|---|
| 440 | (*this)[2].getFloat(value[1])) |
|---|
| 441 | { |
|---|
| 442 | (*this)+=3; |
|---|
| 443 | return true; |
|---|
| 444 | } |
|---|
| 445 | return false; |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec3f& value) |
|---|
| 449 | { |
|---|
| 450 | if ((*this)[0].matchWord(keyword) && |
|---|
| 451 | (*this)[1].getFloat(value[0]) && |
|---|
| 452 | (*this)[2].getFloat(value[1]) && |
|---|
| 453 | (*this)[3].getFloat(value[2])) |
|---|
| 454 | { |
|---|
| 455 | (*this)+=4; |
|---|
| 456 | return true; |
|---|
| 457 | } |
|---|
| 458 | return false; |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec4f& value) |
|---|
| 462 | { |
|---|
| 463 | if ((*this)[0].matchWord(keyword) && |
|---|
| 464 | (*this)[1].getFloat(value[0]) && |
|---|
| 465 | (*this)[2].getFloat(value[1]) && |
|---|
| 466 | (*this)[3].getFloat(value[2]) && |
|---|
| 467 | (*this)[4].getFloat(value[3])) |
|---|
| 468 | { |
|---|
| 469 | (*this)+=5; |
|---|
| 470 | return true; |
|---|
| 471 | } |
|---|
| 472 | return false; |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec2d& value) |
|---|
| 476 | { |
|---|
| 477 | if ((*this)[0].matchWord(keyword) && |
|---|
| 478 | (*this)[1].getFloat(value[0]) && |
|---|
| 479 | (*this)[2].getFloat(value[1])) |
|---|
| 480 | { |
|---|
| 481 | (*this)+=3; |
|---|
| 482 | return true; |
|---|
| 483 | } |
|---|
| 484 | return false; |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec3d& value) |
|---|
| 488 | { |
|---|
| 489 | if ((*this)[0].matchWord(keyword) && |
|---|
| 490 | (*this)[1].getFloat(value[0]) && |
|---|
| 491 | (*this)[2].getFloat(value[1]) && |
|---|
| 492 | (*this)[3].getFloat(value[2])) |
|---|
| 493 | { |
|---|
| 494 | (*this)+=4; |
|---|
| 495 | return true; |
|---|
| 496 | } |
|---|
| 497 | return false; |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec4d& value) |
|---|
| 501 | { |
|---|
| 502 | if ((*this)[0].matchWord(keyword) && |
|---|
| 503 | (*this)[1].getFloat(value[0]) && |
|---|
| 504 | (*this)[2].getFloat(value[1]) && |
|---|
| 505 | (*this)[3].getFloat(value[2]) && |
|---|
| 506 | (*this)[4].getFloat(value[3])) |
|---|
| 507 | { |
|---|
| 508 | (*this)+=5; |
|---|
| 509 | return true; |
|---|
| 510 | } |
|---|
| 511 | return false; |
|---|
| 512 | } |
|---|
| 513 | |
|---|
| 514 | bool FieldReaderIterator::readSequence(std::string& value) |
|---|
| 515 | { |
|---|
| 516 | if ((*this)[0].isString()) |
|---|
| 517 | { |
|---|
| 518 | value = (*this)[0].getStr(); |
|---|
| 519 | (*this)+=1; |
|---|
| 520 | return true; |
|---|
| 521 | } |
|---|
| 522 | return false; |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | bool FieldReaderIterator::readSequence(unsigned int& value) |
|---|
| 526 | { |
|---|
| 527 | if ((*this)[0].getUInt(value)) |
|---|
| 528 | { |
|---|
| 529 | (*this)+=1; |
|---|
| 530 | return true; |
|---|
| 531 | } |
|---|
| 532 | return false; |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | bool FieldReaderIterator::readSequence(int& value) |
|---|
| 536 | { |
|---|
| 537 | if ((*this)[0].getInt(value)) |
|---|
| 538 | { |
|---|
| 539 | (*this)+=1; |
|---|
| 540 | return true; |
|---|
| 541 | } |
|---|
| 542 | return false; |
|---|
| 543 | } |
|---|
| 544 | |
|---|
| 545 | bool FieldReaderIterator::readSequence(float& value) |
|---|
| 546 | { |
|---|
| 547 | if ((*this)[0].getFloat(value)) |
|---|
| 548 | { |
|---|
| 549 | (*this)+=1; |
|---|
| 550 | return true; |
|---|
| 551 | } |
|---|
| 552 | return false; |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | bool FieldReaderIterator::readSequence(osg::Vec2f& value) |
|---|
| 556 | { |
|---|
| 557 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 558 | (*this)[1].getFloat(value[1])) |
|---|
| 559 | { |
|---|
| 560 | (*this)+=2; |
|---|
| 561 | return true; |
|---|
| 562 | } |
|---|
| 563 | return false; |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | bool FieldReaderIterator::readSequence(osg::Vec3f& value) |
|---|
| 567 | { |
|---|
| 568 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 569 | (*this)[1].getFloat(value[1]) && |
|---|
| 570 | (*this)[2].getFloat(value[2])) |
|---|
| 571 | { |
|---|
| 572 | (*this)+=3; |
|---|
| 573 | return true; |
|---|
| 574 | } |
|---|
| 575 | return false; |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | bool FieldReaderIterator::readSequence(osg::Vec4f& value) |
|---|
| 579 | { |
|---|
| 580 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 581 | (*this)[1].getFloat(value[1]) && |
|---|
| 582 | (*this)[2].getFloat(value[2]) && |
|---|
| 583 | (*this)[3].getFloat(value[3])) |
|---|
| 584 | { |
|---|
| 585 | (*this)+=4; |
|---|
| 586 | return true; |
|---|
| 587 | } |
|---|
| 588 | return false; |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | |
|---|
| 592 | bool FieldReaderIterator::readSequence(osg::Vec2d& value) |
|---|
| 593 | { |
|---|
| 594 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 595 | (*this)[1].getFloat(value[1])) |
|---|
| 596 | { |
|---|
| 597 | (*this)+=2; |
|---|
| 598 | return true; |
|---|
| 599 | } |
|---|
| 600 | return false; |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | bool FieldReaderIterator::readSequence(osg::Vec3d& value) |
|---|
| 604 | { |
|---|
| 605 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 606 | (*this)[1].getFloat(value[1]) && |
|---|
| 607 | (*this)[2].getFloat(value[2])) |
|---|
| 608 | { |
|---|
| 609 | (*this)+=3; |
|---|
| 610 | return true; |
|---|
| 611 | } |
|---|
| 612 | return false; |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | bool FieldReaderIterator::readSequence(osg::Vec4d& value) |
|---|
| 616 | { |
|---|
| 617 | if ((*this)[0].getFloat(value[0]) && |
|---|
| 618 | (*this)[1].getFloat(value[1]) && |
|---|
| 619 | (*this)[2].getFloat(value[2]) && |
|---|
| 620 | (*this)[3].getFloat(value[3])) |
|---|
| 621 | { |
|---|
| 622 | (*this)+=4; |
|---|
| 623 | return true; |
|---|
| 624 | } |
|---|
| 625 | return false; |
|---|
| 626 | } |
|---|