|
Revision 13041, 2.5 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "Exception.h" |
|---|
| 15 | #include "VolumeCompositeLayer.h" |
|---|
| 16 | #include "VolumeLayer.h" |
|---|
| 17 | #include "Layer.h" |
|---|
| 18 | |
|---|
| 19 | using namespace ive; |
|---|
| 20 | |
|---|
| 21 | void VolumeCompositeLayer::write(DataOutputStream* out) |
|---|
| 22 | { |
|---|
| 23 | |
|---|
| 24 | out->writeInt(IVEVOLUMECOMPOSITELAYER); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | osgVolume::Layer* layer = dynamic_cast<osgVolume::Layer*>(this); |
|---|
| 28 | if (layer) |
|---|
| 29 | ((ive::VolumeLayer*)(layer))->write(out); |
|---|
| 30 | else |
|---|
| 31 | out_THROW_EXCEPTION("VolumeCompositeLayer::write(): Could not cast this osgVolume::CompositeLayer to an osgVolume::Layer."); |
|---|
| 32 | |
|---|
| 33 | out->writeUInt(getNumLayers()); |
|---|
| 34 | for(unsigned int i=0; i<getNumLayers(); ++i) |
|---|
| 35 | { |
|---|
| 36 | if(getLayer(i)) |
|---|
| 37 | { |
|---|
| 38 | out->writeBool(true); |
|---|
| 39 | out->writeVolumeLayer(getLayer(i)); |
|---|
| 40 | } |
|---|
| 41 | else |
|---|
| 42 | { |
|---|
| 43 | out->writeBool(false); |
|---|
| 44 | out->writeString(getFileName(i)); |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void VolumeCompositeLayer::read(DataInputStream* in) |
|---|
| 50 | { |
|---|
| 51 | |
|---|
| 52 | int id = in->peekInt(); |
|---|
| 53 | if (id != IVEVOLUMECOMPOSITELAYER) |
|---|
| 54 | in_THROW_EXCEPTION("VolumeCompositeLayer::read(): Expected CompositeLayer identification."); |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | id = in->readInt(); |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | osgVolume::Layer* layer = dynamic_cast<osgVolume::Layer*>(this); |
|---|
| 61 | if (layer) |
|---|
| 62 | ((ive::VolumeLayer*)(layer))->read(in); |
|---|
| 63 | else |
|---|
| 64 | in_THROW_EXCEPTION("VolumeCompositeLayer::read(): Could not cast this osgVolume::Layer to an osg::Group."); |
|---|
| 65 | |
|---|
| 66 | unsigned int numLayers = in->readUInt(); |
|---|
| 67 | for(unsigned int i=0; i<numLayers; ++i) |
|---|
| 68 | { |
|---|
| 69 | bool readInlineLayer = in->readBool(); |
|---|
| 70 | if (readInlineLayer) |
|---|
| 71 | { |
|---|
| 72 | addLayer(in->readVolumeLayer()); |
|---|
| 73 | } |
|---|
| 74 | else |
|---|
| 75 | { |
|---|
| 76 | setFileName(i, in->readString()); |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | } |
|---|