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

Revision 13041, 2.7 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14
15#include "Exception.h"
16#include "Locator.h"
17#include "Object.h"
18#include "EllipsoidModel.h"
19
20using namespace ive;
21
22void Locator::write(DataOutputStream* out)
23{
24    // Write Locator's identification.
25    out->writeInt(IVELOCATOR);
26
27    // If the osg class is inherited by any other class we should also write this to file.
28    osg::Object*  object = dynamic_cast<osg::Object*>(this);
29    if (object)
30        ((ive::Object*)(object))->write(out);
31    else
32        out_THROW_EXCEPTION("Layer::write(): Could not cast this osgLayer::Layer to an osg::Object.");
33
34    out->writeInt(getCoordinateSystemType());
35    out->writeString(getFormat());
36    out->writeString(getCoordinateSystem());
37
38    out->writeBool(getEllipsoidModel()!=0);
39    if(getEllipsoidModel())
40    {
41        ((ive::EllipsoidModel*)(getEllipsoidModel()))->write(out);
42    }
43
44    out->writeBool(getDefinedInFile());
45    out->writeBool(getTransformScaledByResolution());
46    out->writeMatrixd(getTransform());
47}
48
49void Locator::read(DataInputStream* in)
50{
51    // Peek on Locator's identification.
52    int id = in->peekInt();
53    if(id != IVELOCATOR)
54    {
55        in_THROW_EXCEPTION("Locator::read(): Expected Locator identification.");
56    }
57
58    // Read Locator's identification.
59    id = in->readInt();
60
61    // If the osg class is inherited by any other class we should also read this from file.
62    osg::Object*  object = dynamic_cast<osg::Object*>(this);
63    if(object)
64        ((ive::Object*)(object))->read(in);
65    else
66        in_THROW_EXCEPTION("Locator::read(): Could not cast this osgLocator::Locator to an osg::Group.");
67
68    setCoordinateSystemType(static_cast<osgTerrain::Locator::CoordinateSystemType>(in->readInt()));
69    setFormat(in->readString());
70    setCoordinateSystem(in->readString());
71
72    bool readEllipsoidModel = in->readBool();
73    if (readEllipsoidModel)
74    {
75        osg::EllipsoidModel* em = new osg::EllipsoidModel();
76        ((ive::EllipsoidModel*)(em))->read(in);
77        setEllipsoidModel(em);
78    }
79
80    setDefinedInFile(in->readBool());
81    setTransformScaledByResolution(in->readBool());
82    setTransform(in->readMatrixd());
83
84}
Note: See TracBrowser for help on using the browser.