Added support for decoration of the osgTerrain::DataSet generated databases

with a CoordinateSystemNode which reflect the coordinate system of the
database.

Added support for reading and writing CoordianteSystemNode into the .osg
and .ive formats.
This commit is contained in:
Robert Osfield
2004-05-02 21:50:15 +00:00
parent a709c0a474
commit fced94fab3
16 changed files with 363 additions and 6 deletions

View File

@@ -0,0 +1,76 @@
/**********************************************************************
*
* FILE: CoordinateSystemNode.cpp
*
* DESCRIPTION: Read/Write osg::CoordinateSystemNode in binary format to disk.
*
* CREATED BY: Auto generated by iveGenerator
* and later modified by Rune Schmidt Jensen.
*
* HISTORY: Created 9.4.2003
*
* Copyright 2003 VR-C
**********************************************************************/
#include "Exception.h"
#include "CoordinateSystemNode.h"
#include "EllipsoidModel.h"
#include "Group.h"
using namespace ive;
void CoordinateSystemNode::write(DataOutputStream* out)
{
// Write CoordinateSystemNode's identification.
out->writeInt(IVECOORDINATESYSTEMNODE);
// If the osg class is inherited by any other class we should also write this to file.
osg::Group* group = dynamic_cast<osg::Group*>(this);
if(group){
((ive::Group*)(group))->write(out);
}
else
throw Exception("CoordinateSystemNode::write(): Could not cast this osg::CoordinateSystemNode to an osg::Group.");
// Write CoordinateSystemNode's properties.
out->writeString(getCoordinateSystem());
out->writeBool(getEllipsoidModel()!=0);
if(getEllipsoidModel())
{
((ive::EllipsoidModel*)(getEllipsoidModel()))->write(out);
}
}
void CoordinateSystemNode::read(DataInputStream* in){
// Peek on CoordinateSystemNode's identification.
int id = in->peekInt();
if(id == IVECOORDINATESYSTEMNODE)
{
// Read CoordinateSystemNode's identification.
id = in->readInt();
// If the osg class is inherited by any other class we should also read this from file.
osg::Group* group = dynamic_cast<osg::Group*>(this);
if(group){
((ive::Group*)(group))->read(in);
}
else
throw Exception("CoordinateSystemNode::read(): Could not cast this osg::CoordinateSystemNode to an osg::Group.");
// Read CoordinateSystemNode's properties
// Read coord string
setCoordinateSystem( in->readString());
bool readEllopsoidModel = in->readBool();
if (readEllopsoidModel)
{
osg::EllipsoidModel* em = new osg::EllipsoidModel();
((ive::EllipsoidModel*)(em))->read(in);
setEllipsoidModel(em);
}
}
else{
throw Exception("CoordinateSystemNode::read(): Expected CoordinateSystemNode identification.");
}
}