root/OpenSceneGraph/trunk/src/osgPlugins/ive/Group.cpp @ 13041

Revision 13041, 2.2 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            Group.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Group in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerated
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 17.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "Node.h"
17#include "Group.h"
18#include "MatrixTransform.h"
19#include "Geode.h"
20#include "LightSource.h"
21#include "Billboard.h"
22#include "Sequence.h"
23#include "LOD.h"
24#include "PositionAttitudeTransform.h"
25#include "Transform.h"
26
27using namespace ive;
28
29void Group::write(DataOutputStream* out){
30    // Write Group's identification.
31    out->writeInt(IVEGROUP);
32    // If the osg class is inherited by any other class we should also write this to file.
33    osg::Node* node = dynamic_cast<osg::Node*>(this);
34    if(node){
35        static_cast<ive::Node*>(node)->write(out);
36    }
37    else
38        out_THROW_EXCEPTION("Group::write(): Could not cast this osg::Group to an osg::Node.");
39
40    // Write Group's properties.
41
42    // Write number of children.
43    out->writeInt(getNumChildren());
44    // Write children.
45    for(unsigned int i=0; i<getNumChildren(); i++){
46        osg::Node* child = getChild(i);
47        out->writeNode(child);
48    }
49}
50
51void Group::read(DataInputStream* in){
52    // Read Group's identification.
53    int id = in->peekInt();
54    if(id == IVEGROUP){
55        // Read Group's identification.
56        id = in->readInt();
57
58        // If the osg class is inherited by any other class we should also read this from file.
59        osg::Node* node = dynamic_cast<osg::Node*>(this);
60        if(node){
61            ((ive::Node*)(node))->read(in);
62        }
63        else
64            in_THROW_EXCEPTION("Group::read(): Could not cast this osg::Group to an osg::Node.");
65
66
67        // Read groups properties.
68
69        // Read number of children.
70        int size = in->readInt();
71        // Read children.
72        for(int i=0; i<size; i++)
73        {
74            addChild(in->readNode());
75        }
76    }
77    else{
78        in_THROW_EXCEPTION("Group::read(): Expected Group identification");
79    }
80}
Note: See TracBrowser for help on using the browser.