Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TGalaxy Class Reference

Management of all stellar objects for a galaxy. More...

#include <galaxy.h>

Inheritance diagram for TGalaxy:

Inheritance graph
[legend]
Collaboration diagram for TGalaxy:

Collaboration graph
[legend]
List of all members.

Public Methods

 TGalaxy (const string &name="", const TPoint &Size=0, bool wrapX=false, bool wrapY=false, bool wrapZ=false)
 ~TGalaxy ()
bool addStellarObject (TStellarObject *obj)
int2 getDimension () const
double getDistance (const TPoint &one, const TPoint &two) const
double getDistance (const TStellarObject *one, const TStellarObject *two) const
TPoint getDistanceVector (const TPoint &from, const TPoint &to) const
TPoint getDistanceVector (const TStellarObject *from, const TStellarObject *to) const
const string & getName () const
const TPointgetSize () const
const TStellarObjectListgetStellarObjectList () const
int4 getTotalNumber () const
virtual int2 getType () const
virtual const string & getTypeName () const
virtual bool load (TDataPackageList *in)
bool remove (TStellarObject *obj)
virtual bool save (TDataPackageList *out) const
bool transform (TPoint &point) const

Private Methods

void removeAll ()
bool transformCoordinate (double &x, double max, bool wrap) const

Private Attributes

string fName
TPoint fSize
TStellarObjectList fStObj
bool fWrapX
bool fWrapY
bool fWrapZ

Detailed Description

Management of all stellar objects for a galaxy.

Author:
Marco Krohn <marco.krohn@gmx.de> , Simon Stich <>
Version:
Id:
galaxy.h,v 1.17 2002/05/15 08:30:55 ishark Exp
See also:
TStellarObject, TLinkable
This class manages the stellar objects of a whole galaxy. Methods for adding, removing and searching are implemented. Note that a galaxy (parent) will delete all its children (the stellar objects).

Also the galaxy contains the information about the "metric" of the space, that means calculating distances between two points in space is done by the galaxy. Distances will especially depend on the settings for wrapping ("wrapping" is just another word for gluing the borders of a galaxy together).


Constructor & Destructor Documentation

TGalaxy::TGalaxy const string &    name = "",
const TPoint   Size = 0,
bool    wrapX = false,
bool    wrapY = false,
bool    wrapZ = false
 

Initializes the galaxy object.

Parameters:
name  The name of this galaxy.
size  Size of the galaxy.
wrapX  true enables wrapping for the x axis, false disables wrapping.
wrapY  true enables wrapping for the y axis, false disables wrapping.
wrapZ  true enables wrapping for the z axis, false disables wrapping.

TGalaxy::~TGalaxy  
 

Removes all stellar objects from the array (and deletes the stellar objects)


Member Function Documentation

bool TGalaxy::addStellarObject TStellarObject   obj
 

Adds a stellar object to the galaxy. Note: after adding a stellar object to a galaxy the galaxy will take care of deleting the object. Note also that this method will not check for duplicate entries, thus you are responsible that this does not happen.

Parameters:
obj  The new stellar object.
Returns:
true if the object was added succesfuly, otherwise false.

int2 TGalaxy::getDimension   const
 

Returns:
The dimension of the galaxy (2 or 3).

double TGalaxy::getDistance const TStellarObject   one,
const TStellarObject   two
const
 

Calculates the shortest distance between two stellar objects. The distance is not only a function of the two stellar objects but also of the galaxy settings (e.g. wrap).

Parameters:
one  Stellar object number one.
two  Stellar object number two.
Returns:
The shortest distance between the given stellar objects.

double TGalaxy::getDistance const TPoint   one,
const TPoint   two
const
 

Calculates the shortest distance between two points. The distance is not only a function of the two points but also of the galaxy settings (e.g. wrap).

Parameters:
one  Point number one.
two  Point number two.
Returns:
The shortest distance between the given points.

TPoint TGalaxy::getDistanceVector const TStellarObject   from,
const TStellarObject   to
const
 

Calculates the shortest vector between two stellar objects, taking into account the wrap settings for this galaxy. The result is a vector pointing from 'pFrom' to 'pTo'.

Parameters:
from  Stellar object number one.
to  Stellar object number two.
Returns:
The shortest vector between these points pointing from pFrom to pTo.

TPoint TGalaxy::getDistanceVector const TPoint   from,
const TPoint   to
const
 

Calculates the shortest vector between two points, taking into account the wrap settings for this galaxy.

Parameters:
from  Start point.
to  Emd point.
Returns:
The shortest vector between these points pointing from 'From' to 'To'.

const string& TGalaxy::getName   const
 

Returns:
The name of this galaxy.

const TPoint& TGalaxy::getSize   const
 

Returns:
The size of the galaxy.

const TStellarObjectList& TGalaxy::getStellarObjectList   const
 

Access the list of the stellar objects present in the galaxy.

Returns:
a const reference to the Stellar Objects list.

int4 TGalaxy::getTotalNumber   const
 

Returns:
The total number of stellar objects within this galaxy.

virtual int2 TGalaxy::getType   const [virtual]
 

Returns:
TType::GALAXY.
See also:
TType

Reimplemented from TLinkable.

virtual const string& TGalaxy::getTypeName   const [virtual]
 

Returns the name of this class: "TGalaxy".

Returns:
The string "TGalaxy".
See also:
TType

Reimplemented from TLinkable.

virtual bool TGalaxy::load TDataPackageList   in [virtual]
 

Loads a TGalaxy object. Note that this method will not load any stellar objects. The galaxy will add itself automatically to the universe.

Parameters:
in  The list of data packages.
Returns:
true means that everything was loaded correctly, otherwise this method will return false.

Reimplemented from TLinkable.

bool TGalaxy::remove TStellarObject   obj
 

Removes a stellar object from the galaxy. The method does not only remove the pointer to the object but also deletes the stellar object.

Parameters:
obj  The object which will be removed.
Returns:
true if object was removed, otherwise false.

void TGalaxy::removeAll   [private]
 

Removes all stellar objects from the galaxy.

virtual bool TGalaxy::save TDataPackageList   out const [virtual]
 

Saves a TGalaxy object by adding the data packages to the list. Note that this method will not save the stellar objects.

Parameters:
out  The output stream of data packages.
Returns:
true means that everything was saved correctly, otherwise this method will return false.

Reimplemented from TLinkable.

bool TGalaxy::transform TPoint   point const
 

Transforms the coordinates so that the point is within the galaxy. In case the wrapping for a axis is on, the method will perform a "modulo" operation. If for example the x size of the galaxy is 3.0 (wrap active) and the x-component of the argument is 4.7 the method will change this to 1.7. If the wrapping is swichted off the result for this component would be 3.0 which is in the box.

Parameters:
point  is the point which will be transformed.
Returns:
true in case a transformation was necessary, otherwise false.
See also:
TGalaxy::transformCoordinate

bool TGalaxy::transformCoordinate double &    x,
double    max,
bool    wrap
const [private]
 

The same as transformPoint just for a single coordinate.

Parameters:
x  is the coordinate.
max  is the max. value for this argument (0 is the min value).
wrap  true = wrap is on, false = wrap is off.
See also:
TGalaxy::transformPoint


Member Data Documentation

string TGalaxy::fName [private]
 

Name of this galaxy.

TPoint TGalaxy::fSize [private]
 

The size of the galaxy.

TStellarObjectList TGalaxy::fStObj [private]
 

A list of stellar objects in this galaxy

bool TGalaxy::fWrapX [private]
 

Wrap setting for the x-axis.

bool TGalaxy::fWrapY [private]
 

Wrap setting for the y-axis.

bool TGalaxy::fWrapZ [private]
 

Wrap setting for the z-axis.


The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:22 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001