00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __MOLECULE__
00027 #define __MOLECULE__
00028
00029
00030
00031 #include "nommgr.h"
00032 #include <vector>
00033 #include "mmgr.h"
00034 #include "Atom.h"
00035 #include <RigidBodyEntity.h>
00036 #include "SimMolecule.h"
00037 #include "Link.h"
00038
00039 class SimMolecule;
00040
00041 namespace API {
00042 class Atom;
00043 class Link;
00044
00052 class Molecule
00053 {
00054 class Util;
00055 friend class Util;
00056 friend class Atom;
00057 friend class Leg;
00058
00059 public:
00060
00068 class Util {
00069 friend class Molecule;
00070 private:
00071 Molecule * molecule;
00072 SimMolecule * simmolecule;
00073
00074 Util(Molecule * molecule);
00075 ~Util();
00076 public:
00080 void printAtoms() const;
00081
00085 void printLinks() const;
00089 void printAdjacencyMatrix() const;
00093 void printConnectedComponentID() const;
00094
00098 void print() const;
00099
00105 SimMolecule * getSimulatedObject();
00106
00107 };
00108
00113 Util * util;
00114
00120 unsigned int getID();
00121
00127 unsigned int getAtomCount() const;
00128
00135 Atom * getAtom(unsigned int index) const;
00136
00145 int getAtomIndex (Atom * anAtom) const;
00146
00154 unsigned int getLinkCount() const;
00155
00165 unsigned int getLinkCount(unsigned int atomIndex1,unsigned int atomIndex2) const;
00166
00176 Link * getLink(unsigned int atomIndex1,unsigned int atomIndex2, unsigned linkIndex=0) const;
00177
00178
00185 Link * getLink(unsigned int index) const;
00186
00195 int getLinkIndex (Link * aLink) const;
00196
00203 void atomize();
00208 void stop();
00215 unsigned int getNextSyncIndex();
00216
00223 unsigned int getSyncIndexCount();
00224
00233 unsigned int getSyncIndex(unsigned int index);
00234
00242 void releaseSyncIndex(unsigned int index);
00243
00251 bool isFinished(unsigned int index);
00252
00253 protected:
00258 Molecule ();
00259
00264 ~Molecule();
00265
00270 void setID (int aMoleculeID);
00271
00276 void addAtom (Atom * atom);
00277
00282 void removeAtom (Atom * atom);
00283
00288 void insertLink (Link* link);
00289
00294 void removeLink (Link* link);
00295
00296 private :
00297 void computeConnectedComponent();
00298 void computeConnectedComponent(unsigned int atomIndex);
00299 void setBaseConnectedComponent(unsigned int atomIndex);
00300 unsigned int getConnectedComponentCount() const;
00301 bool isConnected(unsigned int atomIndex, unsigned int anotherAtomIndex) const;
00302 unsigned int getConnectedComponentCard(unsigned int index) const;
00303 void adjItInit(unsigned int atomIndex) ;
00304 int adjItBeg() ;
00305 int adjItNext() ;
00306
00307 bool adjItEnd() const;
00308 std::vector<Atom *> atoms;
00309 unsigned int atomCount;
00310 std::vector<std::vector <Link *> > adj;
00311 unsigned int linkCount;
00312 std::vector<int> connectedComponentID;
00313 std::vector<unsigned int> syncIndexes;
00314 int connectedComponentCount;
00315 int ID;
00316 int adjItPos;
00317 int adjItAtom;
00318 };
00319 }
00320
00321 #endif // __MOLECULE__