| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #include "DataInputStream.h" |
|---|
| 19 | #include "StateSet.h" |
|---|
| 20 | #include "AlphaFunc.h" |
|---|
| 21 | #include "BlendColor.h" |
|---|
| 22 | #include "Stencil.h" |
|---|
| 23 | #include "BlendFunc.h" |
|---|
| 24 | #include "BlendEquation.h" |
|---|
| 25 | #include "Depth.h" |
|---|
| 26 | #include "Material.h" |
|---|
| 27 | #include "CullFace.h" |
|---|
| 28 | #include "ColorMask.h" |
|---|
| 29 | #include "ClipPlane.h" |
|---|
| 30 | #include "PolygonOffset.h" |
|---|
| 31 | #include "PolygonMode.h" |
|---|
| 32 | #include "ShadeModel.h" |
|---|
| 33 | #include "Point.h" |
|---|
| 34 | #include "LineWidth.h" |
|---|
| 35 | #include "LineStipple.h" |
|---|
| 36 | #include "Texture1D.h" |
|---|
| 37 | #include "Texture2D.h" |
|---|
| 38 | #include "Texture3D.h" |
|---|
| 39 | #include "TextureCubeMap.h" |
|---|
| 40 | #include "TextureRectangle.h" |
|---|
| 41 | #include "TexEnv.h" |
|---|
| 42 | #include "TexEnvCombine.h" |
|---|
| 43 | #include "TexGen.h" |
|---|
| 44 | #include "TexMat.h" |
|---|
| 45 | #include "FragmentProgram.h" |
|---|
| 46 | #include "VertexProgram.h" |
|---|
| 47 | #include "LightModel.h" |
|---|
| 48 | #include "ProxyNode.h" |
|---|
| 49 | #include "FrontFace.h" |
|---|
| 50 | #include "Program.h" |
|---|
| 51 | #include "Viewport.h" |
|---|
| 52 | #include "Scissor.h" |
|---|
| 53 | #include "Image.h" |
|---|
| 54 | #include "ImageSequence.h" |
|---|
| 55 | #include "PointSprite.h" |
|---|
| 56 | #include "Multisample.h" |
|---|
| 57 | #include "Fog.h" |
|---|
| 58 | #include "Light.h" |
|---|
| 59 | #include "PolygonStipple.h" |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | #include "Group.h" |
|---|
| 63 | #include "MatrixTransform.h" |
|---|
| 64 | #include "Camera.h" |
|---|
| 65 | #include "CameraView.h" |
|---|
| 66 | #include "Geode.h" |
|---|
| 67 | #include "LightSource.h" |
|---|
| 68 | #include "TexGenNode.h" |
|---|
| 69 | #include "ClipNode.h" |
|---|
| 70 | #include "Billboard.h" |
|---|
| 71 | #include "Sequence.h" |
|---|
| 72 | #include "LOD.h" |
|---|
| 73 | #include "PagedLOD.h" |
|---|
| 74 | #include "PositionAttitudeTransform.h" |
|---|
| 75 | #include "AutoTransform.h" |
|---|
| 76 | #include "DOFTransform.h" |
|---|
| 77 | #include "Transform.h" |
|---|
| 78 | #include "Switch.h" |
|---|
| 79 | #include "OccluderNode.h" |
|---|
| 80 | #include "OcclusionQueryNode.h" |
|---|
| 81 | #include "Impostor.h" |
|---|
| 82 | #include "CoordinateSystemNode.h" |
|---|
| 83 | #include "Uniform.h" |
|---|
| 84 | #include "Shader.h" |
|---|
| 85 | |
|---|
| 86 | #include "LightPointNode.h" |
|---|
| 87 | #include "MultiSwitch.h" |
|---|
| 88 | #include "VisibilityGroup.h" |
|---|
| 89 | |
|---|
| 90 | #include "MultiTextureControl.h" |
|---|
| 91 | #include "ShapeAttributeList.h" |
|---|
| 92 | #include "Effect.h" |
|---|
| 93 | #include "AnisotropicLighting.h" |
|---|
| 94 | #include "BumpMapping.h" |
|---|
| 95 | #include "Cartoon.h" |
|---|
| 96 | #include "Scribe.h" |
|---|
| 97 | #include "SpecularHighlights.h" |
|---|
| 98 | |
|---|
| 99 | #include "Geometry.h" |
|---|
| 100 | #include "ShapeDrawable.h" |
|---|
| 101 | #include "Shape.h" |
|---|
| 102 | |
|---|
| 103 | #include "Text.h" |
|---|
| 104 | |
|---|
| 105 | #include "TerrainTile.h" |
|---|
| 106 | #include "Locator.h" |
|---|
| 107 | #include "ImageLayer.h" |
|---|
| 108 | #include "HeightFieldLayer.h" |
|---|
| 109 | #include "CompositeLayer.h" |
|---|
| 110 | #include "SwitchLayer.h" |
|---|
| 111 | |
|---|
| 112 | #include "FadeText.h" |
|---|
| 113 | #include "Text3D.h" |
|---|
| 114 | |
|---|
| 115 | #include <osg/Endian> |
|---|
| 116 | #include <osg/Notify> |
|---|
| 117 | #include <osg/io_utils> |
|---|
| 118 | #include <osgDB/ReadFile> |
|---|
| 119 | #include <osgDB/FileNameUtils> |
|---|
| 120 | |
|---|
| 121 | #include <stdio.h> |
|---|
| 122 | #include <sstream> |
|---|
| 123 | |
|---|
| 124 | using namespace ive; |
|---|
| 125 | using namespace std; |
|---|
| 126 | |
|---|
| 127 | DataInputStream::DataInputStream(std::istream* istream, const osgDB::ReaderWriter::Options* options) |
|---|
| 128 | { |
|---|
| 129 | unsigned int endianType ; |
|---|
| 130 | |
|---|
| 131 | _loadExternalReferenceFiles = false; |
|---|
| 132 | |
|---|
| 133 | _verboseOutput = false; |
|---|
| 134 | |
|---|
| 135 | _istream = istream; |
|---|
| 136 | _owns_istream = false; |
|---|
| 137 | _peeking = false; |
|---|
| 138 | _peekValue = 0; |
|---|
| 139 | _byteswap = 0; |
|---|
| 140 | |
|---|
| 141 | _options = options; |
|---|
| 142 | |
|---|
| 143 | if (_options.get()) |
|---|
| 144 | { |
|---|
| 145 | setLoadExternalReferenceFiles(_options->getOptionString().find("noLoadExternalReferenceFiles")==std::string::npos); |
|---|
| 146 | osg::notify(osg::DEBUG_INFO) << "ive::DataInputStream.setLoadExternalReferenceFiles()=" << getLoadExternalReferenceFiles() << std::endl; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | if(!istream){ |
|---|
| 150 | throw Exception("DataInputStream::DataInputStream(): null pointer exception in argument."); |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | endianType = readUInt() ; |
|---|
| 154 | |
|---|
| 155 | if ( endianType != ENDIAN_TYPE) { |
|---|
| 156 | |
|---|
| 157 | if ( endianType != OPPOSITE_ENDIAN_TYPE ) { |
|---|
| 158 | throw Exception("DataInputStream::DataInputStream(): This file has an unreadable endian type.") ; |
|---|
| 159 | } |
|---|
| 160 | osg::notify(osg::INFO)<<"DataInputStream::DataInputStream: Reading a byteswapped file" << std::endl ; |
|---|
| 161 | _byteswap = 1 ; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | _version = readUInt(); |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | if(_version>VERSION){ |
|---|
| 168 | throw Exception("DataInputStream::DataInputStream(): The version found in the file is newer than this library can handle."); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | if (_version>=VERSION_0033) |
|---|
| 172 | { |
|---|
| 173 | int compressionLevel = readInt(); |
|---|
| 174 | |
|---|
| 175 | if (compressionLevel>0) |
|---|
| 176 | { |
|---|
| 177 | osg::notify(osg::INFO)<<"compressed ive stream"<<std::endl; |
|---|
| 178 | |
|---|
| 179 | unsigned int maxSize = readUInt(); |
|---|
| 180 | |
|---|
| 181 | std::string data; |
|---|
| 182 | data.reserve(maxSize); |
|---|
| 183 | |
|---|
| 184 | if (!uncompress(*istream, data)) |
|---|
| 185 | { |
|---|
| 186 | throw Exception("Error in uncompressing .ive"); |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | _istream = new std::stringstream(data); |
|---|
| 190 | _owns_istream = true; |
|---|
| 191 | } |
|---|
| 192 | else |
|---|
| 193 | { |
|---|
| 194 | osg::notify(osg::INFO)<<"uncompressed ive stream"<<std::endl; |
|---|
| 195 | } |
|---|
| 196 | } |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | DataInputStream::~DataInputStream() |
|---|
| 200 | { |
|---|
| 201 | if (_owns_istream) delete _istream; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | #ifdef USE_ZLIB |
|---|
| 205 | |
|---|
| 206 | #include <zlib.h> |
|---|
| 207 | |
|---|
| 208 | bool DataInputStream::uncompress(std::istream& fin, std::string& destination) const |
|---|
| 209 | { |
|---|
| 210 | |
|---|
| 211 | #define CHUNK 32768 |
|---|
| 212 | |
|---|
| 213 | int ret; |
|---|
| 214 | unsigned have; |
|---|
| 215 | z_stream strm; |
|---|
| 216 | unsigned char in[CHUNK]; |
|---|
| 217 | unsigned char out[CHUNK]; |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | strm.zalloc = Z_NULL; |
|---|
| 221 | strm.zfree = Z_NULL; |
|---|
| 222 | strm.opaque = Z_NULL; |
|---|
| 223 | strm.avail_in = 0; |
|---|
| 224 | strm.next_in = Z_NULL; |
|---|
| 225 | ret = inflateInit2(&strm, |
|---|
| 226 | 15 + 32 |
|---|
| 227 | ); |
|---|
| 228 | if (ret != Z_OK) |
|---|
| 229 | { |
|---|
| 230 | osg::notify(osg::INFO)<<"failed to init"<<std::endl; |
|---|
| 231 | return ret != 0; |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | do { |
|---|
| 236 | |
|---|
| 237 | fin.read((char *)in, CHUNK); |
|---|
| 238 | strm.avail_in = fin.gcount(); |
|---|
| 239 | |
|---|
| 240 | if (strm.avail_in == 0) |
|---|
| 241 | { |
|---|
| 242 | break; |
|---|
| 243 | } |
|---|
| 244 | strm.next_in = in; |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | do { |
|---|
| 248 | strm.avail_out = CHUNK; |
|---|
| 249 | strm.next_out = out; |
|---|
| 250 | ret = inflate(&strm, Z_NO_FLUSH); |
|---|
| 251 | |
|---|
| 252 | switch (ret) { |
|---|
| 253 | case Z_NEED_DICT: |
|---|
| 254 | case Z_DATA_ERROR: |
|---|
| 255 | case Z_MEM_ERROR: |
|---|
| 256 | (void)inflateEnd(&strm); |
|---|
| 257 | return false; |
|---|
| 258 | } |
|---|
| 259 | have = CHUNK - strm.avail_out; |
|---|
| 260 | |
|---|
| 261 | destination.append((char*)out, have); |
|---|
| 262 | |
|---|
| 263 | } while (strm.avail_out == 0); |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | } while (ret != Z_STREAM_END); |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | (void)inflateEnd(&strm); |
|---|
| 270 | |
|---|
| 271 | return ret == Z_STREAM_END ? true : false; |
|---|
| 272 | } |
|---|
| 273 | #else |
|---|
| 274 | bool DataInputStream::uncompress(std::istream& fin, std::string& destination) const |
|---|
| 275 | { |
|---|
| 276 | return false; |
|---|
| 277 | } |
|---|
| 278 | #endif |
|---|
| 279 | |
|---|
| 280 | bool DataInputStream::readBool(){ |
|---|
| 281 | char c; |
|---|
| 282 | _istream->read(&c, CHARSIZE); |
|---|
| 283 | |
|---|
| 284 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 285 | throw Exception("DataInputStream::readBool(): Failed to read boolean value."); |
|---|
| 286 | |
|---|
| 287 | if (_verboseOutput) std::cout<<"read/writeBool() ["<<(int)c<<"]"<<std::endl; |
|---|
| 288 | |
|---|
| 289 | return c!=0; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | char DataInputStream::readChar(){ |
|---|
| 293 | char c; |
|---|
| 294 | _istream->read(&c, CHARSIZE); |
|---|
| 295 | |
|---|
| 296 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 297 | throw Exception("DataInputStream::readChar(): Failed to read char value."); |
|---|
| 298 | |
|---|
| 299 | if (_verboseOutput) std::cout<<"read/writeChar() ["<<(int)c<<"]"<<std::endl; |
|---|
| 300 | |
|---|
| 301 | return c; |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | unsigned char DataInputStream::readUChar(){ |
|---|
| 305 | unsigned char c; |
|---|
| 306 | _istream->read((char*)&c, CHARSIZE); |
|---|
| 307 | |
|---|
| 308 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 309 | throw Exception("DataInputStream::readUChar(): Failed to read unsigned char value."); |
|---|
| 310 | |
|---|
| 311 | if (_verboseOutput) std::cout<<"read/writeUChar() ["<<(int)c<<"]"<<std::endl; |
|---|
| 312 | |
|---|
| 313 | return c; |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | unsigned short DataInputStream::readUShort(){ |
|---|
| 317 | unsigned short s; |
|---|
| 318 | _istream->read((char*)&s, SHORTSIZE); |
|---|
| 319 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 320 | throw Exception("DataInputStream::readUShort(): Failed to read unsigned short value."); |
|---|
| 321 | |
|---|
| 322 | if (_verboseOutput) std::cout<<"read/writeUShort() ["<<s<<"]"<<std::endl; |
|---|
| 323 | |
|---|
| 324 | if (_byteswap) osg::swapBytes((char *)&s,SHORTSIZE); |
|---|
| 325 | |
|---|
| 326 | return s; |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | unsigned int DataInputStream::readUInt(){ |
|---|
| 330 | unsigned int s; |
|---|
| 331 | _istream->read((char*)&s, INTSIZE); |
|---|
| 332 | |
|---|
| 333 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 334 | throw Exception("DataInputStream::readUInt(): Failed to read unsigned int value."); |
|---|
| 335 | |
|---|
| 336 | if (_byteswap) osg::swapBytes((char *)&s,INTSIZE) ; |
|---|
| 337 | |
|---|
| 338 | if (_verboseOutput) std::cout<<"read/writeUInt() ["<<s<<"]"<<std::endl; |
|---|
| 339 | |
|---|
| 340 | return s; |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | int DataInputStream::readInt(){ |
|---|
| 344 | if(_peeking){ |
|---|
| 345 | _peeking = false; |
|---|
| 346 | return _peekValue; |
|---|
| 347 | } |
|---|
| 348 | int i; |
|---|
| 349 | _istream->read((char*)&i, INTSIZE); |
|---|
| 350 | |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | if (_byteswap) osg::swapBytes((char *)&i,INTSIZE) ; |
|---|
| 359 | |
|---|
| 360 | if (_verboseOutput) std::cout<<"read/writeInt() ["<<i<<"]"<<std::endl; |
|---|
| 361 | |
|---|
| 362 | return i; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | |
|---|
| 370 | int DataInputStream::peekInt(){ |
|---|
| 371 | if(_peeking){ |
|---|
| 372 | return _peekValue; |
|---|
| 373 | } |
|---|
| 374 | _peekValue = readInt(); |
|---|
| 375 | _peeking = true; |
|---|
| 376 | return _peekValue; |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | float DataInputStream::readFloat(){ |
|---|
| 380 | float f; |
|---|
| 381 | _istream->read((char*)&f, FLOATSIZE); |
|---|
| 382 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 383 | throw Exception("DataInputStream::readFloat(): Failed to read float value."); |
|---|
| 384 | |
|---|
| 385 | if (_byteswap) osg::swapBytes((char *)&f,FLOATSIZE) ; |
|---|
| 386 | |
|---|
| 387 | if (_verboseOutput) std::cout<<"read/writeFloat() ["<<f<<"]"<<std::endl; |
|---|
| 388 | return f; |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | long DataInputStream::readLong(){ |
|---|
| 392 | long l; |
|---|
| 393 | _istream->read((char*)&l, LONGSIZE); |
|---|
| 394 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 395 | throw Exception("DataInputStream::readLong(): Failed to read long value."); |
|---|
| 396 | |
|---|
| 397 | if (_byteswap) osg::swapBytes((char *)&l,LONGSIZE) ; |
|---|
| 398 | |
|---|
| 399 | if (_verboseOutput) std::cout<<"read/writeLong() ["<<l<<"]"<<std::endl; |
|---|
| 400 | return l; |
|---|
| 401 | } |
|---|
| 402 | |
|---|
| 403 | unsigned long DataInputStream::readULong(){ |
|---|
| 404 | unsigned long l; |
|---|
| 405 | _istream->read((char*)&l, LONGSIZE); |
|---|
| 406 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 407 | throw Exception("DataInputStream::readULong(): Failed to read unsigned long value."); |
|---|
| 408 | |
|---|
| 409 | if (_byteswap) osg::swapBytes((char *)&l,LONGSIZE) ; |
|---|
| 410 | |
|---|
| 411 | if (_verboseOutput) std::cout<<"read/writeULong() ["<<l<<"]"<<std::endl; |
|---|
| 412 | |
|---|
| 413 | return l; |
|---|
| 414 | } |
|---|
| 415 | |
|---|
| 416 | double DataInputStream::readDouble() |
|---|
| 417 | { |
|---|
| 418 | double d; |
|---|
| 419 | _istream->read((char*)&d, DOUBLESIZE); |
|---|
| 420 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 421 | throw Exception("DataInputStream::readDouble(): Failed to read double value."); |
|---|
| 422 | |
|---|
| 423 | if (_byteswap) osg::swapBytes((char *)&d,DOUBLESIZE) ; |
|---|
| 424 | if (_verboseOutput) std::cout<<"read/writeDouble() ["<<d<<"]"<<std::endl; |
|---|
| 425 | return d; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | std::string DataInputStream::readString() |
|---|
| 429 | { |
|---|
| 430 | std::string s; |
|---|
| 431 | int size = readInt(); |
|---|
| 432 | if (size != 0) |
|---|
| 433 | { |
|---|
| 434 | s.resize(size); |
|---|
| 435 | _istream->read((char*)s.c_str(), size); |
|---|
| 436 | |
|---|
| 437 | |
|---|
| 438 | |
|---|
| 439 | if (_verboseOutput) std::cout<<"read/writeString() ["<<s<<"]"<<std::endl; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | return s; |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | void DataInputStream::readCharArray(char* data, int size) |
|---|
| 446 | { |
|---|
| 447 | _istream->read(data, size); |
|---|
| 448 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 449 | throw Exception("DataInputStream::readCharArray(): Failed to read char value."); |
|---|
| 450 | |
|---|
| 451 | if (_verboseOutput) std::cout<<"read/writeCharArray() ["<<data<<"]"<<std::endl; |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | osg::Vec2 DataInputStream::readVec2() |
|---|
| 455 | { |
|---|
| 456 | osg::Vec2 v; |
|---|
| 457 | v.x()=readFloat(); |
|---|
| 458 | v.y()=readFloat(); |
|---|
| 459 | |
|---|
| 460 | if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl; |
|---|
| 461 | |
|---|
| 462 | return v; |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | osg::Vec3 DataInputStream::readVec3(){ |
|---|
| 466 | osg::Vec3 v; |
|---|
| 467 | v.x()=readFloat(); |
|---|
| 468 | v.y()=readFloat(); |
|---|
| 469 | v.z()=readFloat(); |
|---|
| 470 | |
|---|
| 471 | if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl; |
|---|
| 472 | |
|---|
| 473 | return v; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | osg::Vec4 DataInputStream::readVec4(){ |
|---|
| 477 | osg::Vec4 v; |
|---|
| 478 | v.x()=readFloat(); |
|---|
| 479 | v.y()=readFloat(); |
|---|
| 480 | v.z()=readFloat(); |
|---|
| 481 | v.w()=readFloat(); |
|---|
| 482 | |
|---|
| 483 | if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl; |
|---|
| 484 | |
|---|
| 485 | return v; |
|---|
| 486 | } |
|---|
| 487 | osg::Vec2d DataInputStream::readVec2d() |
|---|
| 488 | { |
|---|
| 489 | osg::Vec2d v; |
|---|
| 490 | v.x()=readDouble(); |
|---|
| 491 | v.y()=readDouble(); |
|---|
| 492 | |
|---|
| 493 | if (_verboseOutput) std::cout<<"read/writeVec2d() ["<<v<<"]"<<std::endl; |
|---|
| 494 | |
|---|
| 495 | return v; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | osg::Vec3d DataInputStream::readVec3d(){ |
|---|
| 499 | osg::Vec3d v; |
|---|
| 500 | v.x()=readDouble(); |
|---|
| 501 | v.y()=readDouble(); |
|---|
| 502 | v.z()=readDouble(); |
|---|
| 503 | |
|---|
| 504 | if (_verboseOutput) std::cout<<"read/writeVec3d() ["<<v<<"]"<<std::endl; |
|---|
| 505 | |
|---|
| 506 | return v; |
|---|
| 507 | } |
|---|
| 508 | |
|---|
| 509 | osg::Vec4d DataInputStream::readVec4d(){ |
|---|
| 510 | osg::Vec4d v; |
|---|
| 511 | v.x()=readDouble(); |
|---|
| 512 | v.y()=readDouble(); |
|---|
| 513 | v.z()=readDouble(); |
|---|
| 514 | v.w()=readDouble(); |
|---|
| 515 | |
|---|
| 516 | if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl; |
|---|
| 517 | |
|---|
| 518 | return v; |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | osg::Plane DataInputStream::readPlane(){ |
|---|
| 522 | osg::Plane v; |
|---|
| 523 | |
|---|
| 524 | if (getVersion() <= VERSION_0018) |
|---|
| 525 | { |
|---|
| 526 | v[0]=readFloat(); |
|---|
| 527 | v[1]=readFloat(); |
|---|
| 528 | v[2]=readFloat(); |
|---|
| 529 | v[3]=readFloat(); |
|---|
| 530 | } |
|---|
| 531 | else |
|---|
| 532 | { |
|---|
| 533 | |
|---|
| 534 | |
|---|
| 535 | v[0]=readDouble(); |
|---|
| 536 | v[1]=readDouble(); |
|---|
| 537 | v[2]=readDouble(); |
|---|
| 538 | v[3]=readDouble(); |
|---|
| 539 | } |
|---|
| 540 | |
|---|
| 541 | if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl; |
|---|
| 542 | |
|---|
| 543 | return v; |
|---|
| 544 | } |
|---|
| 545 | |
|---|
| 546 | osg::Vec4ub DataInputStream::readVec4ub(){ |
|---|
| 547 | osg::Vec4ub v; |
|---|
| 548 | v.r()=readChar(); |
|---|
| 549 | v.g()=readChar(); |
|---|
| 550 | v.b()=readChar(); |
|---|
| 551 | v.a()=readChar(); |
|---|
| 552 | |
|---|
| 553 | if (_verboseOutput) std::cout<<"read/writeVec4ub() ["<<v<<"]"<<std::endl; |
|---|
| 554 | |
|---|
| 555 | return v; |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | osg::Quat DataInputStream::readQuat(){ |
|---|
| 559 | osg::Quat q; |
|---|
| 560 | q.x()=readFloat(); |
|---|
| 561 | q.y()=readFloat(); |
|---|
| 562 | q.z()=readFloat(); |
|---|
| 563 | q.w()=readFloat(); |
|---|
| 564 | |
|---|
| 565 | if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl; |
|---|
| 566 | |
|---|
| 567 | return q; |
|---|
| 568 | } |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | |
|---|
| 572 | |
|---|
| 573 | osg::Geometry::AttributeBinding DataInputStream::readBinding(){ |
|---|
| 574 | char c = readChar(); |
|---|
| 575 | |
|---|
| 576 | if (_verboseOutput) std::cout<<"read/writeBinding() ["<<(int)c<<"]"<<std::endl; |
|---|
| 577 | |
|---|
| 578 | switch((int)c){ |
|---|
| 579 | case 0: return osg::Geometry::BIND_OFF; |
|---|
| 580 | case 1: return osg::Geometry::BIND_OVERALL; |
|---|
| 581 | case 2: return osg::Geometry::BIND_PER_PRIMITIVE; |
|---|
| 582 | case 3: return osg::Geometry::BIND_PER_PRIMITIVE_SET; |
|---|
| 583 | case 4: return osg::Geometry::BIND_PER_VERTEX; |
|---|
| 584 | default: throw Exception("Unknown binding type in DataInputStream::readBinding()"); |
|---|
| 585 | } |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | osg::Array* DataInputStream::readArray(){ |
|---|
| 589 | char c = readChar(); |
|---|
| 590 | switch((int)c){ |
|---|
| 591 | case 0: return readIntArray(); |
|---|
| 592 | case 1: return readUByteArray(); |
|---|
| 593 | case 2: return readUShortArray(); |
|---|
| 594 | case 3: return readUIntArray(); |
|---|
| 595 | case 4: return readVec4ubArray(); |
|---|
| 596 | case 5: return readFloatArray(); |
|---|
| 597 | case 6: return readVec2Array(); |
|---|
| 598 | case 7: return readVec3Array(); |
|---|
| 599 | case 8: return readVec4Array(); |
|---|
| 600 | case 9: return readVec2sArray(); |
|---|
| 601 | case 10: return readVec3sArray(); |
|---|
| 602 | case 11: return readVec4sArray(); |
|---|
| 603 | case 12: return readVec2bArray(); |
|---|
| 604 | case 13: return readVec3bArray(); |
|---|
| 605 | case 14: return readVec4bArray(); |
|---|
| 606 | case 15: return readVec2dArray(); |
|---|
| 607 | case 16: return readVec3dArray(); |
|---|
| 608 | case 17: return readVec4dArray(); |
|---|
| 609 | default: throw Exception("Unknown array type in DataInputStream::readArray()"); |
|---|
| 610 | } |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | osg::IntArray* DataInputStream::readIntArray() |
|---|
| 614 | { |
|---|
| 615 | int size = readInt(); |
|---|
| 616 | if (size == 0) |
|---|
| 617 | return NULL; |
|---|
| 618 | osg::IntArray* a = new osg::IntArray(size); |
|---|
| 619 | |
|---|
| 620 | _istream->read((char*)&((*a)[0]), INTSIZE*size); |
|---|
| 621 | |
|---|
| 622 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 623 | throw Exception("DataInputStream::readIntArray(): Failed to read Int array."); |
|---|
| 624 | |
|---|
| 625 | if (_verboseOutput) std::cout<<"read/writeIntArray() ["<<size<<"]"<<std::endl; |
|---|
| 626 | |
|---|
| 627 | if (_byteswap) { |
|---|
| 628 | for (int i = 0 ; i < size ; i++ ) osg::swapBytes((char *)&((*a)[i]),INTSIZE) ; |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | return a; |
|---|
| 632 | } |
|---|
| 633 | |
|---|
| 634 | osg::UByteArray* DataInputStream::readUByteArray() |
|---|
| 635 | { |
|---|
| 636 | int size = readInt(); |
|---|
| 637 | if (size == 0) |
|---|
| 638 | return NULL; |
|---|
| 639 | osg::UByteArray* a = new osg::UByteArray(size); |
|---|
| 640 | |
|---|
| 641 | _istream->read((char*)&((*a)[0]), CHARSIZE*size); |
|---|
| 642 | |
|---|
| 643 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 644 | throw Exception("DataInputStream::readUByteArray(): Failed to read UByte array."); |
|---|
| 645 | |
|---|
| 646 | if (_verboseOutput) std::cout<<"read/writeUByteArray() ["<<size<<"]"<<std::endl; |
|---|
| 647 | |
|---|
| 648 | return a; |
|---|
| 649 | } |
|---|
| 650 | |
|---|
| 651 | osg::UShortArray* DataInputStream::readUShortArray() |
|---|
| 652 | { |
|---|
| 653 | int size = readInt(); |
|---|
| 654 | if (size == 0) |
|---|
| 655 | return NULL; |
|---|
| 656 | osg::UShortArray* a = new osg::UShortArray(size); |
|---|
| 657 | |
|---|
| 658 | _istream->read((char*)&((*a)[0]), SHORTSIZE*size); |
|---|
| 659 | |
|---|
| 660 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 661 | throw Exception("DataInputStream::readUShortArray(): Failed to read UShort array."); |
|---|
| 662 | |
|---|
| 663 | if (_verboseOutput) std::cout<<"read/writeUShortArray() ["<<size<<"]"<<std::endl; |
|---|
| 664 | |
|---|
| 665 | if (_byteswap) |
|---|
| 666 | { |
|---|
| 667 | for (int i = 0 ; i < size ; i++ ) |
|---|
| 668 | osg::swapBytes((char *)&((*a)[i]),SHORTSIZE) ; |
|---|
| 669 | } |
|---|
| 670 | return a; |
|---|
| 671 | } |
|---|
| 672 | |
|---|
| 673 | osg::UIntArray* DataInputStream::readUIntArray() |
|---|
| 674 | { |
|---|
| 675 | int size = readInt(); |
|---|
| 676 | if (size == 0) |
|---|
| 677 | return NULL; |
|---|
| 678 | osg::UIntArray* a = new osg::UIntArray(size); |
|---|
| 679 | |
|---|
| 680 | _istream->read((char*)&((*a)[0]), INTSIZE*size); |
|---|
| 681 | |
|---|
| 682 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 683 | throw Exception("DataInputStream::readUIntArray(): Failed to read UInt array."); |
|---|
| 684 | |
|---|
| 685 | if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<<size<<"]"<<std::endl; |
|---|
| 686 | |
|---|
| 687 | if (_byteswap) |
|---|
| 688 | { |
|---|
| 689 | for (int i = 0 ; i < size ; i++ ) |
|---|
| 690 | osg::swapBytes((char *)&((*a)[i]),INTSIZE) ; |
|---|
| 691 | } |
|---|
| 692 | return a; |
|---|
| 693 | } |
|---|
| 694 | |
|---|
| 695 | osg::Vec4ubArray* DataInputStream::readVec4ubArray() |
|---|
| 696 | { |
|---|
| 697 | int size = readInt(); |
|---|
| 698 | if (size == 0) |
|---|
| 699 | return NULL; |
|---|
| 700 | osg::Vec4ubArray* a = new osg::Vec4ubArray(size); |
|---|
| 701 | |
|---|
| 702 | _istream->read((char*)&((*a)[0]), INTSIZE*size); |
|---|
| 703 | |
|---|
| 704 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 705 | throw Exception("DataInputStream::readVec4ubArray(): Failed to read Vec4ub array."); |
|---|
| 706 | |
|---|
| 707 | if (_verboseOutput) std::cout<<"read/writeVec4ubArray() ["<<size<<"]"<<std::endl; |
|---|
| 708 | |
|---|
| 709 | return a; |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | bool DataInputStream::readPackedFloatArray(osg::FloatArray* a) |
|---|
| 713 | { |
|---|
| 714 | int size = readInt(); |
|---|
| 715 | |
|---|
| 716 | a->resize(size); |
|---|
| 717 | |
|---|
| 718 | if (size == 0) |
|---|
| 719 | return true; |
|---|
| 720 | |
|---|
| 721 | if (readBool()) |
|---|
| 722 | { |
|---|
| 723 | float value = readFloat(); |
|---|
| 724 | |
|---|
| 725 | for(int i=0; i<size; ++i) |
|---|
| 726 | { |
|---|
| 727 | (*a)[i] = value; |
|---|
| 728 | } |
|---|
| 729 | } |
|---|
| 730 | else |
|---|
| 731 | { |
|---|
| 732 | int packingSize = readInt(); |
|---|
| 733 | |
|---|
| 734 | if (packingSize==1) |
|---|
| 735 | { |
|---|
| 736 | float minValue = readFloat(); |
|---|
| 737 | float maxValue = readFloat(); |
|---|
| 738 | |
|---|
| 739 | float byteMultiplier = 255.0f/(maxValue-minValue); |
|---|
| 740 | float byteInvMultiplier = 1.0f/byteMultiplier; |
|---|
| 741 | |
|---|
| 742 | for(int i=0; i<size; ++i) |
|---|
| 743 | { |
|---|
| 744 | unsigned char byte_value = readUChar(); |
|---|
| 745 | float value = minValue + float(byte_value)*byteInvMultiplier; |
|---|
| 746 | (*a)[i] = value; |
|---|
| 747 | } |
|---|
| 748 | } |
|---|
| 749 | else if (packingSize==2) |
|---|
| 750 | { |
|---|
| 751 | float minValue = readFloat(); |
|---|
| 752 | float maxValue = readFloat(); |
|---|
| 753 | |
|---|
| 754 | float shortMultiplier = 65535.0f/(maxValue-minValue); |
|---|
| 755 | float shortInvMultiplier = 1.0f/shortMultiplier; |
|---|
| 756 | |
|---|
| 757 | for(int i=0; i<size; ++i) |
|---|
| 758 | { |
|---|
| 759 | unsigned short short_value = readUShort(); |
|---|
| 760 | float value = minValue + float(short_value)*shortInvMultiplier; |
|---|
| 761 | (*a)[i] = value; |
|---|
| 762 | } |
|---|
| 763 | } |
|---|
| 764 | else |
|---|
| 765 | { |
|---|
| 766 | for(int i=0; i<size; ++i) |
|---|
| 767 | { |
|---|
| 768 | (*a)[i] = readFloat(); |
|---|
| 769 | } |
|---|
| 770 | } |
|---|
| 771 | } |
|---|
| 772 | |
|---|
| 773 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 774 | throw Exception("DataInputStream::readFloatArray(): Failed to read float array."); |
|---|
| 775 | |
|---|
| 776 | if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl; |
|---|
| 777 | |
|---|
| 778 | return true; |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | osg::FloatArray* DataInputStream::readFloatArray() |
|---|
| 783 | { |
|---|
| 784 | int size = readInt(); |
|---|
| 785 | if (size == 0) |
|---|
| 786 | return NULL; |
|---|
| 787 | |
|---|
| 788 | osg::FloatArray* a = new osg::FloatArray(size); |
|---|
| 789 | |
|---|
| 790 | _istream->read((char*)&((*a)[0]), FLOATSIZE*size); |
|---|
| 791 | |
|---|
| 792 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 793 | throw Exception("DataInputStream::readFloatArray(): Failed to read float array."); |
|---|
| 794 | |
|---|
| 795 | if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl; |
|---|
| 796 | |
|---|
| 797 | if (_byteswap) |
|---|
| 798 | { |
|---|
| 799 | for (int i = 0 ; i < size ; i++ ) |
|---|
| 800 | osg::swapBytes((char *)&((*a)[i]),FLOATSIZE) ; |
|---|
| 801 | } |
|---|
| 802 | return a; |
|---|
| 803 | } |
|---|
| 804 | |
|---|
| 805 | osg::Vec2Array* DataInputStream::readVec2Array() |
|---|
| 806 | { |
|---|
| 807 | int size = readInt(); |
|---|
| 808 | if (size == 0) |
|---|
| 809 | return NULL; |
|---|
| 810 | |
|---|
| 811 | osg::Vec2Array* a = new osg::Vec2Array(size); |
|---|
| 812 | |
|---|
| 813 | _istream->read((char*)&((*a)[0]), FLOATSIZE*2*size); |
|---|
| 814 | |
|---|
| 815 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 816 | throw Exception("DataInputStream::readVec2Array(): Failed to read Vec2 array."); |
|---|
| 817 | |
|---|
| 818 | if (_verboseOutput) std::cout<<"read/writeVec2Array() ["<<size<<"]"<<std::endl; |
|---|
| 819 | |
|---|
| 820 | if (_byteswap) |
|---|
| 821 | { |
|---|
| 822 | float *ptr = (float*)&((*a)[0]) ; |
|---|
| 823 | for (int i = 0 ; i < size*2 ; i++ ) |
|---|
| 824 | { |
|---|
| 825 | osg::swapBytes((char *)&(ptr[i]), FLOATSIZE) ; |
|---|
| 826 | } |
|---|
| 827 | } |
|---|
| 828 | return a; |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | osg::Vec3Array* DataInputStream::readVec3Array() |
|---|
| 832 | { |
|---|
| 833 | int size = readInt(); |
|---|
| 834 | if (size == 0) |
|---|
| 835 | return NULL; |
|---|
| 836 | osg::Vec3Array* a = new osg::Vec3Array(size); |
|---|
| 837 | |
|---|
| 838 | _istream->read((char*)&((*a)[0]), FLOATSIZE*3*size); |
|---|
| 839 | |
|---|
| 840 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 841 | throw Exception("DataInputStream::readVec3Array(): Failed to read Vec3 array."); |
|---|
| 842 | |
|---|
| 843 | if (_verboseOutput) std::cout<<"read/writeVec3Array() ["<<size<<"]"<<std::endl; |
|---|
| 844 | |
|---|
| 845 | |
|---|
| 846 | if (_byteswap) |
|---|
| 847 | { |
|---|
| 848 | float *ptr = (float*)&((*a)[0]) ; |
|---|
| 849 | for (int i = 0 ; i < size*3 ; i++ ) |
|---|
| 850 | { |
|---|
| 851 | osg::swapBytes((char *)&(ptr[i]),FLOATSIZE) ; |
|---|
| 852 | } |
|---|
| 853 | } |
|---|
| 854 | return a; |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | osg::Vec4Array* DataInputStream::readVec4Array(){ |
|---|
| 858 | int size = readInt(); |
|---|
| 859 | if (size == 0) |
|---|
| 860 | return NULL; |
|---|
| 861 | osg::Vec4Array* a = new osg::Vec4Array(size); |
|---|
| 862 | |
|---|
| 863 | _istream->read((char*)&((*a)[0]), FLOATSIZE*4*size); |
|---|
| 864 | |
|---|
| 865 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 866 | throw Exception("DataInputStream::readVec4Array(): Failed to read Vec4 array."); |
|---|
| 867 | |
|---|
| 868 | if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl; |
|---|
| 869 | |
|---|
| 870 | if (_byteswap) { |
|---|
| 871 | float *ptr = (float*)&((*a)[0]) ; |
|---|
| 872 | for (int i = 0 ; i < size*4 ; i++ ) { |
|---|
| 873 | osg::swapBytes((char *)&(ptr[i]),FLOATSIZE) ; |
|---|
| 874 | } |
|---|
| 875 | } |
|---|
| 876 | return a; |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | osg::Vec2bArray* DataInputStream::readVec2bArray() |
|---|
| 880 | { |
|---|
| 881 | int size = readInt(); |
|---|
| 882 | if (size == 0) |
|---|
| 883 | return NULL; |
|---|
| 884 | osg::Vec2bArray* a = new osg::Vec2bArray(size); |
|---|
| 885 | |
|---|
| 886 | _istream->read((char*)&((*a)[0]), CHARSIZE * 2 * size); |
|---|
| 887 | |
|---|
| 888 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 889 | throw Exception("DataInputStream::readVec2bArray(): Failed to read Vec2b array."); |
|---|
| 890 | |
|---|
| 891 | if (_verboseOutput) std::cout<<"read/writeVec2bArray() ["<<size<<"]"<<std::endl; |
|---|
| 892 | |
|---|
| 893 | return a; |
|---|
| 894 | } |
|---|
| 895 | |
|---|
| 896 | osg::Vec3bArray* DataInputStream::readVec3bArray() |
|---|
| 897 | { |
|---|
| 898 | int size = readInt(); |
|---|
| 899 | if (size == 0) |
|---|
| 900 | return NULL; |
|---|
| 901 | osg::Vec3bArray* a = new osg::Vec3bArray(size); |
|---|
| 902 | |
|---|
| 903 | _istream->read((char*)&((*a)[0]), CHARSIZE * 3 * size); |
|---|
| 904 | |
|---|
| 905 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 906 | throw Exception("DataInputStream::readVec3bArray(): Failed to read Vec3b array."); |
|---|
| 907 | |
|---|
| 908 | if (_verboseOutput) std::cout<<"read/writeVec3bArray() ["<<size<<"]"<<std::endl; |
|---|
| 909 | |
|---|
| 910 | return a; |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | osg::Vec4bArray* DataInputStream::readVec4bArray() |
|---|
| 914 | { |
|---|
| 915 | int size = readInt(); |
|---|
| 916 | if (size == 0) |
|---|
| 917 | return NULL; |
|---|
| 918 | osg::Vec4bArray* a = new osg::Vec4bArray(size); |
|---|
| 919 | |
|---|
| 920 | _istream->read((char*)&((*a)[0]), CHARSIZE * 4 * size); |
|---|
| 921 | |
|---|
| 922 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 923 | throw Exception("DataInputStream::readVec4bArray(): Failed to read Vec4b array."); |
|---|
| 924 | |
|---|
| 925 | if (_verboseOutput) std::cout<<"read/writeVec4bArray() ["<<size<<"]"<<std::endl; |
|---|
| 926 | |
|---|
| 927 | return a; |
|---|
| 928 | } |
|---|
| 929 | |
|---|
| 930 | osg::Vec2sArray* DataInputStream::readVec2sArray() |
|---|
| 931 | { |
|---|
| 932 | int size = readInt(); |
|---|
| 933 | if (size == 0) |
|---|
| 934 | return NULL; |
|---|
| 935 | osg::Vec2sArray* a = new osg::Vec2sArray(size); |
|---|
| 936 | |
|---|
| 937 | _istream->read((char*)&((*a)[0]), SHORTSIZE * 2 * size); |
|---|
| 938 | |
|---|
| 939 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 940 | throw Exception("DataInputStream::readVec2sArray(): Failed to read Vec2s array."); |
|---|
| 941 | |
|---|
| 942 | if (_verboseOutput) std::cout<<"read/writeVec2sArray() ["<<size<<"]"<<std::endl; |
|---|
| 943 | |
|---|
| 944 | if (_byteswap) |
|---|
| 945 | { |
|---|
| 946 | short *ptr = (short*)&((*a)[0]) ; |
|---|
| 947 | for (int i = 0 ; i < size*2 ; i++ ) |
|---|
| 948 | { |
|---|
| 949 | osg::swapBytes((char *)&(ptr[i]), SHORTSIZE) ; |
|---|
| 950 | } |
|---|
| 951 | } |
|---|
| 952 | |
|---|
| 953 | return a; |
|---|
| 954 | } |
|---|
| 955 | |
|---|
| 956 | osg::Vec3sArray* DataInputStream::readVec3sArray() |
|---|
| 957 | { |
|---|
| 958 | int size = readInt(); |
|---|
| 959 | if (size == 0) |
|---|
| 960 | return NULL; |
|---|
| 961 | osg::Vec3sArray* a = new osg::Vec3sArray(size); |
|---|
| 962 | |
|---|
| 963 | _istream->read((char*)&((*a)[0]), SHORTSIZE * 3 * size); |
|---|
| 964 | |
|---|
| 965 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 966 | throw Exception("DataInputStream::readVec3sArray(): Failed to read Vec3s array."); |
|---|
| 967 | |
|---|
| 968 | if (_verboseOutput) std::cout<<"read/writeVec3sArray() ["<<size<<"]"<<std::endl; |
|---|
| 969 | |
|---|
| 970 | |
|---|
| 971 | if (_byteswap) |
|---|
| 972 | { |
|---|
| 973 | short *ptr = (short*)&((*a)[0]) ; |
|---|
| 974 | for (int i = 0 ; i < size*3 ; i++ ) |
|---|
| 975 | { |
|---|
| 976 | osg::swapBytes((char *)&(ptr[i]), SHORTSIZE) ; |
|---|
| 977 | } |
|---|
| 978 | } |
|---|
| 979 | |
|---|
| 980 | return a; |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | osg::Vec4sArray* DataInputStream::readVec4sArray() |
|---|
| 984 | { |
|---|
| 985 | int size = readInt(); |
|---|
| 986 | if (size == 0) |
|---|
| 987 | return NULL; |
|---|
| 988 | osg::Vec4sArray* a = new osg::Vec4sArray(size); |
|---|
| 989 | |
|---|
| 990 | _istream->read((char*)&((*a)[0]), SHORTSIZE * 4 * size); |
|---|
| 991 | |
|---|
| 992 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 993 | throw Exception("DataInputStream::readVec4sArray(): Failed to read Vec4s array."); |
|---|
| 994 | |
|---|
| 995 | if (_verboseOutput) std::cout<<"read/writeVec4sArray() ["<<size<<"]"<<std::endl; |
|---|
| 996 | |
|---|
| 997 | if (_byteswap) |
|---|
| 998 | { |
|---|
| 999 | short *ptr = (short*)&((*a)[0]) ; |
|---|
| 1000 | for (int i = 0 ; i < size*4 ; i++ ) |
|---|
| 1001 | { |
|---|
| 1002 | osg::swapBytes((char *)&(ptr[i]), SHORTSIZE) ; |
|---|
| 1003 | } |
|---|
| 1004 | } |
|---|
| 1005 | |
|---|
| 1006 | return a; |
|---|
| 1007 | } |
|---|
| 1008 | |
|---|
| 1009 | osg::Vec2dArray* DataInputStream::readVec2dArray() |
|---|
| 1010 | { |
|---|
| 1011 | int size = readInt(); |
|---|
| 1012 | if (size == 0) |
|---|
| 1013 | return NULL; |
|---|
| 1014 | |
|---|
| 1015 | osg::Vec2dArray* a = new osg::Vec2dArray(size); |
|---|
| 1016 | |
|---|
| 1017 | _istream->read((char*)&((*a)[0]), DOUBLESIZE*2*size); |
|---|
| 1018 | |
|---|
| 1019 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 1020 | throw Exception("DataInputStream::readVec2dArray(): Failed to read Vec2d array."); |
|---|
| 1021 | |
|---|
| 1022 | if (_verboseOutput) std::cout<<"read/writeVec2dArray() ["<<size<<"]"<<std::endl; |
|---|
| 1023 | |
|---|
| 1024 | if (_byteswap) |
|---|
| 1025 | { |
|---|
| 1026 | double *ptr = (double*)&((*a)[0]) ; |
|---|
| 1027 | for (int i = 0 ; i < size*2 ; i++ ) |
|---|
| 1028 | { |
|---|
| 1029 | osg::swapBytes((char *)&(ptr[i]), DOUBLESIZE) ; |
|---|
| 1030 | } |
|---|
| 1031 | } |
|---|
| 1032 | return a; |
|---|
| 1033 | } |
|---|
| 1034 | |
|---|
| 1035 | osg::Vec3dArray* DataInputStream::readVec3dArray() |
|---|
| 1036 | { |
|---|
| 1037 | int size = readInt(); |
|---|
| 1038 | if (size == 0) |
|---|
| 1039 | return NULL; |
|---|
| 1040 | osg::Vec3dArray* a = new osg::Vec3dArray(size); |
|---|
| 1041 | |
|---|
| 1042 | _istream->read((char*)&((*a)[0]), DOUBLESIZE*3*size); |
|---|
| 1043 | |
|---|
| 1044 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 1045 | throw Exception("DataInputStream::readVec3dArray(): Failed to read Vec3d array."); |
|---|
| 1046 | |
|---|
| 1047 | if (_verboseOutput) std::cout<<"read/writeVec3dArray() ["<<size<<"]"<<std::endl; |
|---|
| 1048 | |
|---|
| 1049 | |
|---|
| 1050 | if (_byteswap) |
|---|
| 1051 | { |
|---|
| 1052 | double *ptr = (double*)&((*a)[0]) ; |
|---|
| 1053 | for (int i = 0 ; i < size*3 ; i++ ) |
|---|
| 1054 | { |
|---|
| 1055 | osg::swapBytes((char *)&(ptr[i]),DOUBLESIZE) ; |
|---|
| 1056 | } |
|---|
| 1057 | } |
|---|
| 1058 | return a; |
|---|
| 1059 | } |
|---|
| 1060 | |
|---|
| 1061 | osg::Vec4dArray* DataInputStream::readVec4dArray(){ |
|---|
| 1062 | int size = readInt(); |
|---|
| 1063 | if (size == 0) |
|---|
| 1064 | return NULL; |
|---|
| 1065 | osg::Vec4dArray* a = new osg::Vec4dArray(size); |
|---|
| 1066 | |
|---|
| 1067 | _istream->read((char*)&((*a)[0]), DOUBLESIZE*4*size); |
|---|
| 1068 | |
|---|
| 1069 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 1070 | throw Exception("DataInputStream::readVec4dArray(): Failed to read Vec4d array."); |
|---|
| 1071 | |
|---|
| 1072 | if (_verboseOutput) std::cout<<"read/writeVec4dArray() ["<<size<<"]"<<std::endl; |
|---|
| 1073 | |
|---|
| 1074 | if (_byteswap) { |
|---|
| 1075 | double *ptr = (double*)&((*a)[0]) ; |
|---|
| 1076 | for (int i = 0 ; i < size*4 ; i++ ) { |
|---|
| 1077 | osg::swapBytes((char *)&(ptr[i]),DOUBLESIZE) ; |
|---|
| 1078 | } |
|---|
| 1079 | } |
|---|
| 1080 | return a; |
|---|
| 1081 | } |
|---|
| 1082 | |
|---|
| 1083 | osg::Matrixf DataInputStream::readMatrixf() |
|---|
| 1084 | { |
|---|
| 1085 | osg::Matrixf mat; |
|---|
| 1086 | for(int r=0;r<4;r++) |
|---|
| 1087 | { |
|---|
| 1088 | for(int c=0;c<4;c++) |
|---|
| 1089 | { |
|---|
| 1090 | mat(r,c) = readFloat(); |
|---|
| 1091 | } |
|---|
| 1092 | } |
|---|
| 1093 | |
|---|
| 1094 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 1095 | throw Exception("DataInputStream::readMatrix(): Failed to read Matrix array."); |
|---|
| 1096 | |
|---|
| 1097 | if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl; |
|---|
| 1098 | |
|---|
| 1099 | |
|---|
| 1100 | return mat; |
|---|
| 1101 | } |
|---|
| 1102 | |
|---|
| 1103 | osg::Matrixd DataInputStream::readMatrixd() |
|---|
| 1104 | { |
|---|
| 1105 | osg::Matrixd mat; |
|---|
| 1106 | for(int r=0;r<4;r++) |
|---|
| 1107 | { |
|---|
| 1108 | for(int c=0;c<4;c++) |
|---|
| 1109 | { |
|---|
| 1110 | mat(r,c) = readDouble(); |
|---|
| 1111 | } |
|---|
| 1112 | } |
|---|
| 1113 | |
|---|
| 1114 | if (_istream->rdstate() & _istream->failbit) |
|---|
| 1115 | throw Exception("DataInputStream::readMatrix(): Failed to read Matrix array."); |
|---|
| 1116 | |
|---|
| 1117 | if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl; |
|---|
| 1118 | |
|---|
| 1119 | |
|---|
| 1120 | return mat; |
|---|
| 1121 | } |
|---|
| 1122 | |
|---|
| 1123 | osg::Image* DataInputStream::readImage(std::string filename) |
|---|
| 1124 | { |
|---|
| 1125 | |
|---|
| 1126 | |
|---|
| 1127 | ImageMap::iterator mitr=_imageMap.find(filename); |
|---|
| 1128 | if (mitr!=_imageMap.end()) return mitr->second.get(); |
|---|
| 1129 | |
|---|
| 1130 | |
|---|
| 1131 | |
|---|
| 1132 | osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename.c_str(),_options.get()); |
|---|
| 1133 | |
|---|
| 1134 | |
|---|
| 1135 | _imageMap[filename] = image; |
|---|
| 1136 | |
|---|
| 1137 | |
|---|
| 1138 | if (_verboseOutput) std::cout<<"read/writeImage() ["<<image<<"]"<<std::endl; |
|---|
| 1139 | |
|---|
| 1140 | return image.release(); |
|---|
| 1141 | } |
|---|
| 1142 | |
|---|
| 1143 | osg::Image* DataInputStream::readImage() |
|---|
| 1144 | { |
|---|
| 1145 | if ( getVersion() >= VERSION_0029 ) |
|---|
| 1146 | { |
|---|
| 1147 | int id = peekInt(); |
|---|
| 1148 | if(id == IVEIMAGESEQUENCE) |
|---|
| 1149 | { |
|---|
| 1150 | osg::ImageSequence* image = new osg::ImageSequence(); |
|---|
| 1151 | ((ive::ImageSequence*)image)->read(this); |
|---|
| 1152 | return image; |
|---|
| 1153 | } |
|---|
| 1154 | else |
|---|
| 1155 | { |
|---|
| 1156 | readInt(); |
|---|
| 1157 | IncludeImageMode includeImg = (IncludeImageMode)readChar(); |
|---|
| 1158 | return readImage(includeImg); |
|---|
| 1159 | } |
|---|
| 1160 | } |
|---|
| 1161 | else |
|---|
| 1162 | { |
|---|
| 1163 | IncludeImageMode includeImg = (IncludeImageMode)readChar(); |
|---|
| 1164 | return readImage(includeImg); |
|---|
| 1165 | } |
|---|
| 1166 | } |
|---|
| 1167 | |
|---|
| 1168 | osg::Image* DataInputStream::readImage(IncludeImageMode mode) |
|---|
| 1169 | { |
|---|
| 1170 | switch(mode) { |
|---|
| 1171 | case IMAGE_INCLUDE_DATA: |
|---|
| 1172 | |
|---|
| 1173 | if(readBool()) |
|---|
| 1174 | { |
|---|
| 1175 | osg::Image* image = new osg::Image(); |
|---|
| 1176 | ((ive::Image*)image)->read(this); |
|---|
| 1177 | return image; |
|---|
| 1178 | } |
|---|
| 1179 | break; |
|---|
| 1180 | case IMAGE_REFERENCE_FILE: |
|---|
| 1181 | |
|---|
| 1182 | { |
|---|
| 1183 | std::string filename = readString(); |
|---|
| 1184 | if(!filename.empty()){ |
|---|
| 1185 | return readImage(filename); |
|---|
| 1186 | } |
|---|
| 1187 | } |
|---|
| 1188 | break; |
|---|
| 1189 | case IMAGE_INCLUDE_FILE: |
|---|
| 1190 | case IMAGE_COMPRESS_DATA: |
|---|
| 1191 | |
|---|
| 1192 | { |
|---|
| 1193 | std::string filename = readString(); |
|---|
| 1194 | int size = readInt(); |
|---|
| 1195 | if(filename.compare("")!=0 && size > 0){ |
|---|
| 1196 | |
|---|
| 1197 | |
|---|
| 1198 | char *buffer = new char[size]; |
|---|
| 1199 | readCharArray(buffer,size); |
|---|
| 1200 | |
|---|
| 1201 | |
|---|
| 1202 | std::string ext = osgDB::getFileExtension(filename); |
|---|
| 1203 | osgDB::ReaderWriter *reader = osgDB::Registry::instance()->getReaderWriterForExtension(ext); |
|---|
| 1204 | |
|---|
| 1205 | osgDB::ReaderWriter::ReadResult rr; |
|---|
| 1206 | if(reader) { |
|---|
| 1207 | |
|---|
| 1208 | std::stringstream inputStream; |
|---|
| 1209 | inputStream.write(buffer,size); |
|---|
| 1210 | |
|---|
| 1211 | |
|---|
| 1212 | rr = reader->readImage(inputStream,_options.get()); |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | |
|---|
| 1216 | delete [] buffer; |
|---|
| 1217 | |
|---|
| 1218 | |
|---|
| 1219 | if(rr.validImage()) { |
|---|
| 1220 | return rr.takeImage(); |
|---|
| 1221 | } |
|---|
| 1222 | } |
|---|
| 1223 | } |
|---|
| 1224 | break; |
|---|
| 1225 | default: |
|---|
| 1226 | throw Exception("DataInputStream::readImage(): Invalid IncludeImageMode value."); |
|---|
| 1227 | break; |
|---|
| 1228 | } |
|---|
| 1229 | return 0; |
|---|
| 1230 | } |
|---|
| 1231 | |
|---|
| 1232 | osg::StateSet* DataInputStream::readStateSet() |
|---|
| 1233 | { |
|---|
| 1234 | |
|---|
| 1235 | int id = readInt(); |
|---|
| 1236 | |
|---|
| 1237 | StateSetMap::iterator itr= _statesetMap.find(id); |
|---|
| 1238 | if (itr!=_statesetMap.end()) return itr->second.get(); |
|---|
| 1239 | |
|---|
| 1240 | |
|---|
| 1241 | |
|---|
| 1242 | osg::StateSet* stateset = new osg::StateSet(); |
|---|
| 1243 | |
|---|
| 1244 | |
|---|
| 1245 | ((ive::StateSet*)(stateset))->read(this); |
|---|
| 1246 | |
|---|
| 1247 | |
|---|
| 1248 | _statesetMap[id] = stateset; |
|---|
| 1249 | |
|---|
| 1250 | |
|---|
| 1251 | if (_verboseOutput) std::cout<<"read/writeStateSet() ["<<id<<"]"<<std::endl; |
|---|
| 1252 | |
|---|
| 1253 | return stateset; |
|---|
| 1254 | } |
|---|
| 1255 | |
|---|
| 1256 | osg::StateAttribute* DataInputStream::readStateAttribute() |
|---|
| 1257 | { |
|---|
| 1258 | |
|---|
| 1259 | int id = readInt(); |
|---|
| 1260 | |
|---|
| 1261 | StateAttributeMap::iterator itr= _stateAttributeMap.find(id); |
|---|
| 1262 | if (itr!=_stateAttributeMap.end()) return itr->second.get(); |
|---|
| 1263 | |
|---|
| 1264 | |
|---|
| 1265 | |
|---|
| 1266 | |
|---|
| 1267 | |
|---|
| 1268 | osg::StateAttribute* attribute; |
|---|
| 1269 | int attributeID = peekInt(); |
|---|
| 1270 | if(attributeID == IVEALPHAFUNC){ |
|---|
| 1271 | attribute = new osg::AlphaFunc(); |
|---|
| 1272 | ((ive::AlphaFunc*)(attribute))->read(this); |
|---|
| 1273 | } |
|---|
| 1274 | else if(attributeID == IVEBLENDCOLOR){ |
|---|
| 1275 | attribute = new osg::BlendColor(); |
|---|
| 1276 | ((ive::BlendColor*)(attribute))->read(this); |
|---|
| 1277 | } |
|---|
| 1278 | else if(attributeID == IVEBLENDFUNC || |
|---|
| 1279 | attributeID == IVEBLENDFUNCSEPARATE){ |
|---|
| 1280 | attribute = new osg::BlendFunc(); |
|---|
| 1281 | ((ive::BlendFunc*)(attribute))->read(this); |
|---|
| 1282 | } |
|---|
| 1283 | else if(attributeID == IVEBLENDEQUATION){ |
|---|
| 1284 | attribute = new osg::BlendEquation(); |
|---|
| 1285 | ((ive::BlendEquation*)(attribute))->read(this); |
|---|
| 1286 | } |
|---|
| 1287 | else if(attributeID == IVEDEPTH){ |
|---|
| 1288 | attribute = new osg::Depth(); |
|---|
| 1289 | ((ive::Depth*)(attribute))->read(this); |
|---|
| 1290 | } |
|---|
| 1291 | else if(attributeID == IVEVIEWPORT){ |
|---|
| 1292 | attribute = new osg::Viewport(); |
|---|
| 1293 | ((ive::Viewport*)(attribute))->read(this); |
|---|
| 1294 | } |
|---|
| 1295 | else if(attributeID == IVESCISSOR){ |
|---|
| 1296 | attribute = new osg::Scissor(); |
|---|
| 1297 | ((ive::Scissor*)(attribute))->read(this); |
|---|
| 1298 | } |
|---|
| 1299 | else if(attributeID == IVEMATERIAL){ |
|---|
| 1300 | attribute = new osg::Material(); |
|---|
| 1301 | ((ive::Material*)(attribute))->read(this); |
|---|
| 1302 | } |
|---|
| 1303 | else if(attributeID == IVECULLFACE){ |
|---|
| 1304 | attribute = new osg::CullFace(); |
|---|
| 1305 | ((ive::CullFace*)(attribute))->read(this); |
|---|
| 1306 | } |
|---|
| 1307 | else if(attributeID == IVECOLORMASK){ |
|---|
| 1308 | attribute = new osg::ColorMask(); |
|---|
| 1309 | ((ive::ColorMask*)(attribute))->read(this); |
|---|
| 1310 | } |
|---|
| 1311 | else if(attributeID == IVECLIPPLANE){ |
|---|
| 1312 | attribute = new osg::ClipPlane(); |
|---|
| 1313 | ((ive::ClipPlane*)(attribute))->read(this); |
|---|
| 1314 | } |
|---|
| 1315 | else if(attributeID == IVEPOLYGONOFFSET){ |
|---|
| 1316 | attribute = new osg::PolygonOffset(); |
|---|
| 1317 | ((ive::PolygonOffset*)(attribute))->read(this); |
|---|
| 1318 | } |
|---|
| 1319 | else if(attributeID == IVEPOLYGONMODE){ |
|---|
| 1320 | attribute = new osg::PolygonMode(); |
|---|
| 1321 | ((ive::PolygonMode*)(attribute))->read(this); |
|---|
| 1322 | } |
|---|
| 1323 | else if(attributeID == IVESHADEMODEL){ |
|---|
| 1324 | attribute = new osg::ShadeModel(); |
|---|
| 1325 | ((ive::ShadeModel*)(attribute))->read(this); |
|---|
| 1326 | } |
|---|
| 1327 | else if(attributeID == IVEPOINT){ |
|---|
| 1328 | attribute = new osg::Point(); |
|---|
| 1329 | ((ive::Point*)(attribute))->read(this); |
|---|
| 1330 | } |
|---|
| 1331 | else if(attributeID == IVELINEWIDTH){ |
|---|
| 1332 | attribute = new osg::LineWidth(); |
|---|
| 1333 | ((ive::LineWidth*)(attribute))->read(this); |
|---|
| 1334 | } |
|---|
| 1335 | else if(attributeID == IVETEXTURE1D){ |
|---|
| 1336 | attribute = new osg::Texture1D(); |
|---|
| 1337 | ((ive::Texture1D*)(attribute))->read(this); |
|---|
| 1338 | } |
|---|
| 1339 | else if(attributeID == IVETEXTURE2D){ |
|---|
| 1340 | attribute = new osg::Texture2D(); |
|---|
| 1341 | ((ive::Texture2D*)(attribute))->read(this); |
|---|
| 1342 | } |
|---|
| 1343 | else if(attributeID == IVETEXTURE3D){ |
|---|
| 1344 | attribute = new osg::Texture3D(); |
|---|
| 1345 | ((ive::Texture3D*)(attribute))->read(this); |
|---|
| 1346 | } |
|---|
| 1347 | else if(attributeID == IVETEXTURECUBEMAP){ |
|---|
| 1348 | attribute = new osg::TextureCubeMap(); |
|---|
| 1349 | ((ive::TextureCubeMap*)(attribute))->read(this); |
|---|
| 1350 | } |
|---|
| 1351 | else if(attributeID == IVETEXTURERECTANGLE){ |
|---|
| 1352 | attribute = new osg::TextureRectangle(); |
|---|
| 1353 | ((ive::TextureRectangle*)(attribute))->read(this); |
|---|
| 1354 | } |
|---|
| 1355 | else if(attributeID == IVETEXENV){ |
|---|
| 1356 | attribute = new osg::TexEnv(); |
|---|
| 1357 | ((ive::TexEnv*)(attribute))->read(this); |
|---|
| 1358 | } |
|---|
| 1359 | else if(attributeID == IVETEXENVCOMBINE){ |
|---|
| 1360 | attribute = new osg::TexEnvCombine(); |
|---|
| 1361 | ((ive::TexEnvCombine*)(attribute))->read(this); |
|---|
| 1362 | } |
|---|
| 1363 | else if(attributeID == IVETEXGEN){ |
|---|
| 1364 | attribute = new osg::TexGen(); |
|---|
| 1365 | ((ive::TexGen*)(attribute))->read(this); |
|---|
| 1366 | } |
|---|
| 1367 | else if(attributeID == IVETEXMAT){ |
|---|
| 1368 | attribute = new osg::TexMat(); |
|---|
| 1369 | ((ive::TexMat*)(attribute))->read(this); |
|---|
| 1370 | } |
|---|
| 1371 | else if(attributeID == IVEFRAGMENTPROGRAM){ |
|---|
| 1372 | attribute = new osg::FragmentProgram(); |
|---|
| 1373 | ((ive::FragmentProgram*)(attribute))->read(this); |
|---|
| 1374 | } |
|---|
| 1375 | else if(attributeID == IVEVERTEXPROGRAM){ |
|---|
| 1376 | attribute = new osg::VertexProgram(); |
|---|
| 1377 | ((ive::VertexProgram*)(attribute))->read(this); |
|---|
| 1378 | } |
|---|
| 1379 | else if(attributeID == IVELIGHTMODEL){ |
|---|
| 1380 | attribute = new osg::LightModel(); |
|---|
| 1381 | ((ive::LightModel*)(attribute))->read(this); |
|---|
| 1382 | } |
|---|
| 1383 | else if(attributeID == IVEFRONTFACE){ |
|---|
| 1384 | attribute = new osg::FrontFace(); |
|---|
| 1385 | ((ive::FrontFace*)(attribute))->read(this); |
|---|
| 1386 | } |
|---|
| 1387 | else if(attributeID == IVEPROGRAM){ |
|---|
| 1388 | attribute = new osg::Program(); |
|---|
| 1389 | ((ive::Program*)(attribute))->read(this); |
|---|
| 1390 | } |
|---|
| 1391 | else if(attributeID == IVEPOINTSPRITE){ |
|---|
| 1392 | attribute = new osg::PointSprite(); |
|---|
| 1393 | ((ive::PointSprite*)(attribute))->read(this); |
|---|
| 1394 | } |
|---|
| 1395 | else if(attributeID == IVEMULTISAMPLE){ |
|---|
| 1396 | attribute = new osg::Multisample(); |
|---|
| 1397 | ((ive::Multisample*)(attribute))->read(this); |
|---|
| 1398 | } |
|---|
| 1399 | else if(attributeID == IVELINESTIPPLE){ |
|---|
| 1400 | attribute = new osg::LineStipple(); |
|---|
| 1401 | ((ive::LineStipple*)(attribute))->read(this); |
|---|
| 1402 | } |
|---|
| 1403 | else if(attributeID == IVESTENCIL){ |
|---|
| 1404 | attribute = new osg::Stencil(); |
|---|
| 1405 | ((ive::Stencil*)(attribute))->read(this); |
|---|
| 1406 | } |
|---|
| 1407 | else if(attributeID == IVEFOG){ |
|---|
| 1408 | attribute = new osg::Fog(); |
|---|
| 1409 | ((ive::Fog*)(attribute))->read(this); |
|---|
| 1410 | } |
|---|
| 1411 | else if(attributeID == IVELIGHT){ |
|---|
| 1412 | attribute = new osg::Light(); |
|---|
| 1413 | ((ive::Light*)(attribute))->read(this); |
|---|
| 1414 | } |
|---|
| 1415 | else if(attributeID == IVEPOLYGONSTIPPLE){ |
|---|
| 1416 | attribute = new osg::PolygonStipple(); |
|---|
| 1417 | ((ive::PolygonStipple*)(attribute))->read(this); |
|---|
| 1418 | } |
|---|
| 1419 | else{ |
|---|
| 1420 | throw Exception("Unknown StateAttribute in StateSet::read()"); |
|---|
| 1421 | } |
|---|
| 1422 | |
|---|
| 1423 | |
|---|
| 1424 | _stateAttributeMap[id] = attribute; |
|---|
| 1425 | |
|---|
| 1426 | |
|---|
| 1427 | if (_verboseOutput) std::cout<<"read/writeStateAttribute() ["<<id<<"]"<<std::endl; |
|---|
| 1428 | |
|---|
| 1429 | return attribute; |
|---|
| 1430 | } |
|---|
| 1431 | |
|---|
| 1432 | osg::Uniform* DataInputStream::readUniform() |
|---|
| 1433 | { |
|---|
| 1434 | |
|---|
| 1435 | int id = readInt(); |
|---|
| 1436 | |
|---|
| 1437 | UniformMap::iterator itr= _uniformMap.find(id); |
|---|
| 1438 | if (itr!=_uniformMap.end()) return itr->second.get(); |
|---|
| 1439 | |
|---|
| 1440 | |
|---|
| 1441 | |
|---|
| 1442 | osg::Uniform* uniform = new osg::Uniform(); |
|---|
| 1443 | |
|---|
| 1444 | |
|---|
| 1445 | ((ive::Uniform*)(uniform))->read(this); |
|---|
| 1446 | |
|---|
| 1447 | |
|---|
| 1448 | _uniformMap[id] = uniform; |
|---|
| 1449 | |
|---|
| 1450 | |
|---|
| 1451 | if (_verboseOutput) std::cout<<"read/writeUniform() ["<<id<<"]"<<std::endl; |
|---|
| 1452 | |
|---|
| 1453 | return uniform; |
|---|
| 1454 | } |
|---|
| 1455 | |
|---|
| 1456 | |
|---|
| 1457 | osg::Shader* DataInputStream::readShader() |
|---|
| 1458 | { |
|---|
| 1459 | |
|---|
| 1460 | int id = readInt(); |
|---|
| 1461 | |
|---|
| 1462 | ShaderMap::iterator itr= _shaderMap.find(id); |
|---|
| 1463 | if (itr!=_shaderMap.end()) return itr->second.get(); |
|---|
| 1464 | |
|---|
| 1465 | |
|---|
| 1466 | |
|---|
| 1467 | osg::Shader* shader = new osg::Shader(); |
|---|
| 1468 | |
|---|
| 1469 | |
|---|
| 1470 | ((ive::Shader*)(shader))->read(this); |
|---|
| 1471 | |
|---|
| 1472 | |
|---|
| 1473 | _shaderMap[id] = shader; |
|---|
| 1474 | |
|---|
| 1475 | |
|---|
| 1476 | if (_verboseOutput) std::cout<<"read/writeShader() ["<<id<<"]"<<std::endl; |
|---|
| 1477 | |
|---|
| 1478 | return shader; |
|---|
| 1479 | } |
|---|
| 1480 | |
|---|
| 1481 | osg::Drawable* DataInputStream::readDrawable() |
|---|
| 1482 | { |
|---|
| 1483 | |
|---|
| 1484 | int id = readInt(); |
|---|
| 1485 | |
|---|
| 1486 | DrawableMap::iterator itr= _drawableMap.find(id); |
|---|
| 1487 | if (itr!=_drawableMap.end()) return itr->second.get(); |
|---|
| 1488 | |
|---|
| 1489 | |
|---|
| 1490 | |
|---|
| 1491 | |
|---|
| 1492 | int drawableTypeID = peekInt(); |
|---|
| 1493 | osg::Drawable* drawable; |
|---|
| 1494 | if(drawableTypeID == IVEGEOMETRY) |
|---|
| 1495 | { |
|---|
| 1496 | drawable = new osg::Geometry(); |
|---|
| 1497 | ((Geometry*)(drawable))->read(this); |
|---|
| 1498 | } |
|---|
| 1499 | else if(drawableTypeID == IVESHAPEDRAWABLE) |
|---|
| 1500 | { |
|---|
| 1501 | drawable = new osg::ShapeDrawable(); |
|---|
| 1502 | ((ShapeDrawable*)(drawable))->read(this); |
|---|
| 1503 | } |
|---|
| 1504 | else if(drawableTypeID == IVETEXT){ |
|---|
| 1505 | drawable = new osgText::Text(); |
|---|
| 1506 | ((Text*)(drawable))->read(this); |
|---|
| 1507 | } |
|---|
| 1508 | else if(drawableTypeID == IVEFADETEXT){ |
|---|
| 1509 | drawable = new osgText::FadeText(); |
|---|
| 1510 | ((FadeText*)(drawable))->read(this); |
|---|
| 1511 | } |
|---|
| 1512 | else if(drawableTypeID == IVETEXT3D){ |
|---|
| 1513 | drawable = new osgText::Text3D(); |
|---|
| 1514 | ((Text3D*)(drawable))->read(this); |
|---|
| 1515 | } |
|---|
| 1516 | else |
|---|
| 1517 | throw Exception("Unknown drawable drawableTypeIDentification in Geode::read()"); |
|---|
| 1518 | |
|---|
| 1519 | |
|---|
| 1520 | |
|---|
| 1521 | _drawableMap[id] = drawable; |
|---|
| 1522 | |
|---|
| 1523 | |
|---|
| 1524 | if (_verboseOutput) std::cout<<"read/writeDrawable() ["<<id<<"]"<<std::endl; |
|---|
| 1525 | |
|---|
| 1526 | return drawable; |
|---|
| 1527 | } |
|---|
| 1528 | |
|---|
| 1529 | osg::Shape* DataInputStream::readShape() |
|---|
| 1530 | { |
|---|
| 1531 | |
|---|
| 1532 | int id = readInt(); |
|---|
| 1533 | |
|---|
| 1534 | ShapeMap::iterator itr= _shapeMap.find(id); |
|---|
| 1535 | if (itr!=_shapeMap.end()) return itr->second.get(); |
|---|
| 1536 | |
|---|
| 1537 | |
|---|
| 1538 | |
|---|
| 1539 | |
|---|
| 1540 | int shapeTypeID = peekInt(); |
|---|
| 1541 | osg::Shape* shape; |
|---|
| 1542 | if(shapeTypeID == IVESPHERE) |
|---|
| 1543 | { |
|---|
| 1544 | shape = new osg::Sphere(); |
|---|
| 1545 | ((Sphere*)(shape))->read(this); |
|---|
| 1546 | } |
|---|
| 1547 | else if(shapeTypeID == IVEBOX) |
|---|
| 1548 | { |
|---|
| 1549 | shape = new osg::Box(); |
|---|
| 1550 | ((Box*)(shape))->read(this); |
|---|
| 1551 | } |
|---|
| 1552 | else if(shapeTypeID == IVECONE) |
|---|
| 1553 | { |
|---|
| 1554 | shape = new osg::Cone(); |
|---|
| 1555 | ((Cone*)(shape))->read(this); |
|---|
| 1556 | } |
|---|
| 1557 | else if(shapeTypeID == IVECYLINDER) |
|---|
| 1558 | { |
|---|
| 1559 | shape = new osg::Cylinder(); |
|---|
| 1560 | ((Cylinder*)(shape))->read(this); |
|---|
| 1561 | } |
|---|
| 1562 | else if(shapeTypeID == IVECAPSULE) |
|---|
| 1563 | { |
|---|
| 1564 | shape = new osg::Capsule(); |
|---|
| 1565 | ((Capsule*)(shape))->read(this); |
|---|
| 1566 | } |
|---|
| 1567 | else if(shapeTypeID == IVEHEIGHTFIELD) |
|---|
| 1568 | { |
|---|
| 1569 | shape = new osg::HeightField(); |
|---|
| 1570 | ((HeightField*)(shape))->read(this); |
|---|
| 1571 | } |
|---|
| 1572 | else |
|---|
| 1573 | throw Exception("Unknown shape shapeTypeIDentification in Shape::read()"); |
|---|
| 1574 | |
|---|
| 1575 | |
|---|
| 1576 | |
|---|
| 1577 | _shapeMap[id] = shape; |
|---|
| 1578 | |
|---|
| 1579 | |
|---|
| 1580 | if (_verboseOutput) std::cout<<"read/writeShape() ["<<id<<"]"<<std::endl; |
|---|
| 1581 | |
|---|
| 1582 | return shape; |
|---|
| 1583 | } |
|---|
| 1584 | |
|---|
| 1585 | osg::Node* DataInputStream::readNode() |
|---|
| 1586 | { |
|---|
| 1587 | |
|---|
| 1588 | int id = readInt(); |
|---|
| 1589 | |
|---|
| 1590 | NodeMap::iterator itr= _nodeMap.find(id); |
|---|
| 1591 | if (itr!=_nodeMap.end()) return itr->second.get(); |
|---|
| 1592 | |
|---|
| 1593 | |
|---|
| 1594 | |
|---|
| 1595 | |
|---|
| 1596 | osg::Node* node; |
|---|
| 1597 | int nodeTypeID= peekInt(); |
|---|
| 1598 | |
|---|
| 1599 | if(nodeTypeID== IVEMATRIXTRANSFORM){ |
|---|
| 1600 | node = new osg::MatrixTransform(); |
|---|
| 1601 | ((ive::MatrixTransform*)(node))->read(this); |
|---|
| 1602 | } |
|---|
| 1603 | else if(nodeTypeID== IVECAMERA){ |
|---|
| 1604 | node = new osg::Camera(); |
|---|
| 1605 | ((ive::Camera*)(node))->read(this); |
|---|
| 1606 | } |
|---|
| 1607 | else if(nodeTypeID== IVECAMERAVIEW){ |
|---|
| 1608 | node = new osg::CameraView(); |
|---|
| 1609 | ((ive::CameraView*)(node))->read(this); |
|---|
| 1610 | } |
|---|
| 1611 | else if(nodeTypeID== IVEPOSITIONATTITUDETRANSFORM){ |
|---|
| 1612 | node = new osg::PositionAttitudeTransform(); |
|---|
| 1613 | ((ive::PositionAttitudeTransform*)(node))->read(this); |
|---|
| 1614 | } |
|---|
| 1615 | else if(nodeTypeID== IVEAUTOTRANSFORM){ |
|---|
| 1616 | node = new osg::AutoTransform(); |
|---|
| 1617 | ((ive::AutoTransform*)(node))->read(this); |
|---|
| 1618 | } |
|---|
| 1619 | else if(nodeTypeID== IVEDOFTRANSFORM){ |
|---|
| 1620 | node = new osgSim::DOFTransform(); |
|---|
| 1621 | ((ive::DOFTransform*)(node))->read(this); |
|---|
| 1622 | } |
|---|
| 1623 | else if(nodeTypeID== IVETRANSFORM){ |
|---|
| 1624 | node = new osg::Transform(); |
|---|
| 1625 | ((ive::Transform*)(node))->read(this); |
|---|
| 1626 | } |
|---|
| 1627 | else if(nodeTypeID== IVELIGHTSOURCE){ |
|---|
| 1628 | node = new osg::LightSource(); |
|---|
| 1629 | ((ive::LightSource*)(node))->read(this); |
|---|
| 1630 | } |
|---|
| 1631 | else if(nodeTypeID== IVETEXGENNODE){ |
|---|
| 1632 | node = new osg::TexGenNode(); |
|---|
| 1633 | ((ive::TexGenNode*)(node))->read(this); |
|---|
| 1634 | } |
|---|
| 1635 | else if(nodeTypeID== IVECLIPNODE){ |
|---|
| 1636 | node = new osg::ClipNode(); |
|---|
| 1637 | ((ive::ClipNode*)(node))->read(this); |
|---|
| 1638 | } |
|---|
| 1639 | else if(nodeTypeID== IVESEQUENCE){ |
|---|
| 1640 | node = new osg::Sequence(); |
|---|
| 1641 | ((ive::Sequence*)(node))->read(this); |
|---|
| 1642 | } |
|---|
| 1643 | else if(nodeTypeID== IVELOD){ |
|---|
| 1644 | node = new osg::LOD(); |
|---|
| 1645 | ((ive::LOD*)(node))->read(this); |
|---|
| 1646 | } |
|---|
| 1647 | else if(nodeTypeID== IVEPAGEDLOD){ |
|---|
| 1648 | node = new osg::PagedLOD(); |
|---|
| 1649 | ((ive::PagedLOD*)(node))->read(this); |
|---|
| 1650 | } |
|---|
| 1651 | else if(nodeTypeID== IVECOORDINATESYSTEMNODE){ |
|---|
| 1652 | node = new osg::CoordinateSystemNode(); |
|---|
| 1653 | ((ive::CoordinateSystemNode*)(node))->read(this); |
|---|
| 1654 | } |
|---|
| 1655 | else if(nodeTypeID== IVESWITCH){ |
|---|
| 1656 | node = new osg::Switch(); |
|---|
| 1657 | ((ive::Switch*)(node))->read(this); |
|---|
| 1658 | } |
|---|
| 1659 | else if(nodeTypeID== IVEMULTISWITCH){ |
|---|
| 1660 | node = new osgSim::MultiSwitch(); |
|---|
| 1661 | ((ive::MultiSwitch*)(node))->read(this); |
|---|
| 1662 | } |
|---|
| 1663 | else if(nodeTypeID== IVEIMPOSTOR){ |
|---|
| 1664 | node = new osgSim::Impostor(); |
|---|
| 1665 | ((ive::Impostor*)(node))->read(this); |
|---|
| 1666 | } |
|---|
| 1667 | else if(nodeTypeID== IVEOCCLUDERNODE){ |
|---|
| 1668 | node = new osg::OccluderNode(); |
|---|
| 1669 | ((ive::OccluderNode*)(node))->read(this); |
|---|
| 1670 | } |
|---|
| 1671 | else if(nodeTypeID== IVEOCCLUSIONQUERYNODE){ |
|---|
| 1672 | node = new osg::OcclusionQueryNode(); |
|---|
| 1673 | ((ive::OcclusionQueryNode*)(node))->read(this); |
|---|
| 1674 | } |
|---|
| 1675 | else if(nodeTypeID== IVEVISIBILITYGROUP){ |
|---|
| 1676 | node = new osgSim::VisibilityGroup(); |
|---|
| 1677 | ((ive::VisibilityGroup*)(node))->read(this); |
|---|
| 1678 | } |
|---|
| 1679 | else if(nodeTypeID== IVEPROXYNODE){ |
|---|
| 1680 | node = new osg::ProxyNode(); |
|---|
| 1681 | ((ive::ProxyNode*)(node))->read(this); |
|---|
| 1682 | } |
|---|
| 1683 | else if(nodeTypeID== IVEGROUP){ |
|---|
| 1684 | node = new osg::Group(); |
|---|
| 1685 | ((ive::Group*)(node))->read(this); |
|---|
| 1686 | } |
|---|
| 1687 | else if(nodeTypeID== IVEBILLBOARD){ |
|---|
| 1688 | node = new osg::Billboard(); |
|---|
| 1689 | ((ive::Billboard*)(node))->read(this); |
|---|
| 1690 | } |
|---|
| 1691 | else if(nodeTypeID== IVEGEODE){ |
|---|
| 1692 | node = new osg::Geode(); |
|---|
| 1693 | ((ive::Geode*)(node))->read(this); |
|---|
| 1694 | } |
|---|
| 1695 | else if(nodeTypeID== IVELIGHTPOINTNODE){ |
|---|
| 1696 | node = new osgSim::LightPointNode(); |
|---|
| 1697 | ((ive::LightPointNode*)(node))->read(this); |
|---|
| 1698 | } |
|---|
| 1699 | else if(nodeTypeID== IVEMULTITEXTURECONTROL){ |
|---|
| 1700 | node = new osgFX::MultiTextureControl(); |
|---|
| 1701 | ((ive::MultiTextureControl*)(node))->read(this); |
|---|
| 1702 | } |
|---|
| 1703 | |
|---|
| 1704 | else if(nodeTypeID== IVEANISOTROPICLIGHTING){ |
|---|
| 1705 | node = new osgFX::AnisotropicLighting(); |
|---|
| 1706 | ((ive::AnisotropicLighting*)(node))->read(this); |
|---|
| 1707 | } |
|---|
| 1708 | else if(nodeTypeID== IVEBUMPMAPPING){ |
|---|
| 1709 | node = new osgFX::BumpMapping(); |
|---|
| 1710 | ((ive::BumpMapping*)(node))->read(this); |
|---|
| 1711 | } |
|---|
| 1712 | else if(nodeTypeID== IVECARTOON){ |
|---|
| 1713 | node = new osgFX::Cartoon(); |
|---|
| 1714 | ((ive::Cartoon*)(node))->read(this); |
|---|
| 1715 | } |
|---|
| 1716 | else if(nodeTypeID== IVESCRIBE){ |
|---|
| 1717 | node = new osgFX::Scribe(); |
|---|
| 1718 | ((ive::Scribe*)(node))->read(this); |
|---|
| 1719 | } |
|---|
| 1720 | else if(nodeTypeID== IVESPECULARHIGHLIGHTS){ |
|---|
| 1721 | node = new osgFX::SpecularHighlights(); |
|---|
| 1722 | ((ive::SpecularHighlights*)(node))->read(this); |
|---|
| 1723 | } |
|---|
| 1724 | |
|---|
| 1725 | else if(nodeTypeID== IVETERRAINTILE){ |
|---|
| 1726 | node = new osgTerrain::TerrainTile(); |
|---|
| 1727 | ((ive::TerrainTile*)(node))->read(this); |
|---|
| 1728 | } |
|---|
| 1729 | else{ |
|---|
| 1730 | throw Exception("Unknown node identification in DataInputStream::readNode()"); |
|---|
| 1731 | } |
|---|
| 1732 | |
|---|
| 1733 | |
|---|
| 1734 | _nodeMap[id] = node; |
|---|
| 1735 | |
|---|
| 1736 | |
|---|
| 1737 | if (_verboseOutput) std::cout<<"read/writeNode() ["<<id<<"]"<<std::endl; |
|---|
| 1738 | |
|---|
| 1739 | return node; |
|---|
| 1740 | } |
|---|
| 1741 | |
|---|
| 1742 | osgTerrain::Layer* DataInputStream::readLayer() |
|---|
| 1743 | { |
|---|
| 1744 | |
|---|
| 1745 | int id = readInt(); |
|---|
| 1746 | if (id<0) return 0; |
|---|
| 1747 | |
|---|
| 1748 | |
|---|
| 1749 | LayerMap::iterator itr= _layerMap.find(id); |
|---|
| 1750 | if (itr!=_layerMap.end()) return itr->second.get(); |
|---|
| 1751 | |
|---|
| 1752 | |
|---|
| 1753 | |
|---|
| 1754 | |
|---|
| 1755 | osgTerrain::Layer* layer = 0; |
|---|
| 1756 | int layerid = peekInt(); |
|---|
| 1757 | |
|---|
| 1758 | if (layerid==IVEHEIGHTFIELDLAYER) |
|---|
| 1759 | { |
|---|
| 1760 | layer = new osgTerrain::HeightFieldLayer; |
|---|
| 1761 | ((ive::HeightFieldLayer*)(layer))->read(this); |
|---|
| 1762 | } |
|---|
| 1763 | else if (layerid==IVEIMAGELAYER) |
|---|
| 1764 | { |
|---|
| 1765 | layer = new osgTerrain::ImageLayer; |
|---|
| 1766 | ((ive::ImageLayer*)(layer))->read(this); |
|---|
| 1767 | } |
|---|
| 1768 | else if (layerid==IVESWITCHLAYER) |
|---|
| 1769 | { |
|---|
| 1770 | layer = new osgTerrain::SwitchLayer; |
|---|
| 1771 | ((ive::SwitchLayer*)(layer))->read(this); |
|---|
| 1772 | } |
|---|
| 1773 | else if (layerid==IVECOMPOSITELAYER) |
|---|
| 1774 | { |
|---|
| 1775 | layer = new osgTerrain::CompositeLayer; |
|---|
| 1776 | ((ive::CompositeLayer*)(layer))->read(this); |
|---|
| 1777 | } |
|---|
| 1778 | else if (layerid==IVEPROXYLAYER) |
|---|
| 1779 | { |
|---|
| 1780 | std::string filename = readString(); |
|---|
| 1781 | osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename+".gdal"); |
|---|
| 1782 | osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(object.get()); |
|---|
| 1783 | |
|---|
| 1784 | osg::ref_ptr<osgTerrain::Locator> locator = readLocator(); |
|---|
| 1785 | unsigned int minLevel = readUInt(); |
|---|
| 1786 | unsigned int maxLevel = readUInt(); |
|---|
| 1787 | |
|---|
| 1788 | if (proxyLayer) |
|---|
| 1789 | { |
|---|
| 1790 | if (locator.valid()) proxyLayer->setLocator(locator.get()); |
|---|
| 1791 | |
|---|
| 1792 | proxyLayer->setMinLevel(minLevel); |
|---|
| 1793 | proxyLayer->setMaxLevel(maxLevel); |
|---|
| 1794 | } |
|---|
| 1795 | |
|---|
| 1796 | layer = proxyLayer; |
|---|
| 1797 | } |
|---|
| 1798 | else{ |
|---|
| 1799 | throw Exception("Unknown layer identification in DataInputStream::readLayer()"); |
|---|
| 1800 | } |
|---|
| 1801 | |
|---|
| 1802 | |
|---|
| 1803 | _layerMap[id] = layer; |
|---|
| 1804 | |
|---|
| 1805 | |
|---|
| 1806 | if (_verboseOutput) std::cout<<"read/writeLayer() ["<<id<<"]"<<std::endl; |
|---|
| 1807 | |
|---|
| 1808 | return layer; |
|---|
| 1809 | } |
|---|
| 1810 | |
|---|
| 1811 | |
|---|
| 1812 | osgTerrain::Locator* DataInputStream::readLocator() |
|---|
| 1813 | { |
|---|
| 1814 | |
|---|
| 1815 | int id = readInt(); |
|---|
| 1816 | if (id<0) return 0; |
|---|
| 1817 | |
|---|
| 1818 | |
|---|
| 1819 | LocatorMap::iterator itr= _locatorMap.find(id); |
|---|
| 1820 | if (itr!=_locatorMap.end()) return itr->second.get(); |
|---|
| 1821 | |
|---|
| 1822 | |
|---|
| 1823 | |
|---|
| 1824 | osgTerrain::Locator* locator = new osgTerrain::Locator(); |
|---|
| 1825 | |
|---|
| 1826 | |
|---|
| 1827 | ((ive::Locator*)(locator))->read(this); |
|---|
| 1828 | |
|---|
| 1829 | |
|---|
| 1830 | _locatorMap[id] = locator; |
|---|
| 1831 | |
|---|
| 1832 | if (_verboseOutput) std::cout<<"read/writeLocator() ["<<id<<"]"<<std::endl; |
|---|
| 1833 | |
|---|
| 1834 | return locator; |
|---|
| 1835 | } |
|---|
| 1836 | |
|---|
| 1837 | osg::Object* DataInputStream::readObject() |
|---|
| 1838 | { |
|---|
| 1839 | int id = readInt(); |
|---|
| 1840 | if (id<0) return 0; |
|---|
| 1841 | |
|---|
| 1842 | if (id==IVENODE) |
|---|
| 1843 | { |
|---|
| 1844 | return readNode(); |
|---|
| 1845 | } |
|---|
| 1846 | else if (id==IVESTATESET) |
|---|
| 1847 | { |
|---|
| 1848 | return readStateSet(); |
|---|
| 1849 | } |
|---|
| 1850 | else if (id==IVESTATEATTRIBUTE) |
|---|
| 1851 | { |
|---|
| 1852 | return readStateAttribute(); |
|---|
| 1853 | } |
|---|
| 1854 | else if (id==IVEDRAWABLE) |
|---|
| 1855 | { |
|---|
| 1856 | return readDrawable(); |
|---|
| 1857 | } |
|---|
| 1858 | else if (id==IVESHAPEATTRIBUTELIST) |
|---|
| 1859 | { |
|---|
| 1860 | osgSim::ShapeAttributeList* sal = new osgSim::ShapeAttributeList; |
|---|
| 1861 | ((ive::ShapeAttributeList*)sal)->read(this); |
|---|
| 1862 | return sal; |
|---|
| 1863 | } |
|---|
| 1864 | |
|---|
| 1865 | return 0; |
|---|
| 1866 | } |
|---|
| 1867 | |
|---|