| 295 | }; |
| 296 | |
| 297 | float Shape::LoadTagged(QIStream& f, bool reversed, int ver, bool geometryOnly, AutoArray<float>& massArray, |
| 298 | bool tagged) |
| 299 | { |
| 300 | _loadWarning = false; |
| 301 | _face.Clear(); |
| 302 | |
| 303 | bool extended = false; |
| 304 | DataHeaderEx head; |
| 305 | f.read((char*)&head, sizeof(head)); |
| 306 | if (f.fail() || strncmp(head.magic, "SP3X", 4)) |
| 307 | { |
| 308 | // is not extended format, try old |
| 309 | f.seekg(-(int)sizeof(head), QIOS::cur); |
| 310 | DataHeader oHead; |
| 311 | f.read((char*)&oHead, sizeof(oHead)); |
| 312 | if (f.fail() || strncmp(oHead.magic, "SP3D", 4)) |
| 313 | { |
| 314 | char magicName[5]; |
| 315 | strncpy(magicName, head.magic, 4); |
| 316 | magicName[4] = 0; |
| 317 | WarningMessage("Bad file format (%s).", magicName); |
| 318 | return 0; // file input error |
| 319 | } |
| 320 | head.version = 0; |
| 321 | head.nPos = oHead.nPos; |
| 322 | head.nNorm = oHead.nNorm; |
| 323 | head.nFace = oHead.nFace; |
| 324 | head.flags = 0; |
| 325 | head.headSize = sizeof(oHead); |
| 326 | } |
| 327 | else |
| 328 | { |
| 329 | extended = true; |
| 330 | // skip rest of header |
| 331 | f.seekg(head.headSize - sizeof(head), QIOS::cur); |
| 332 | } |
| 333 | |
| 334 | _face.Realloc(head.nFace); |
| 335 | |
| 336 | _pos.Realloc(head.nPos); |
| 337 | _clip.Realloc(head.nPos); |
| 338 | _norm.Realloc(head.nNorm); |
| 339 | |
| 340 | #define maxPoints 2048 |
| 341 | AUTO_STATIC_ARRAY(Vector3, pos, maxPoints); |
| 342 | AUTO_STATIC_ARRAY(Vector3, norm, maxPoints); |
| 343 | AUTO_STATIC_ARRAY(ClipFlags, clip, maxPoints); |
| 344 | AUTO_STATIC_ARRAY(bool, hidden, maxPoints); |
| 345 | pos.Resize(head.nPos); |
| 346 | clip.Resize(head.nPos); |
| 347 | hidden.Resize(head.nPos); |
| 348 | norm.Resize(head.nNorm); |
| 349 | _pointToVertex.Resize(head.nPos); |
| 350 | _vertexToPoint.Realloc(head.nPos); |
| 351 | for (int i = 0; i < _pointToVertex.Size(); i++) |
| 352 | { |
| 353 | _pointToVertex[i] = -1; |
| 354 | } |
no test coverage detected