Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

VectorDS.cpp

Go to the documentation of this file.
00001 
00006 #include "VectorDS.h"
00007 
00008 using namespace std;
00009 using namespace ParticleSystems;
00010 using namespace GraphicsLib;
00011 
00012 VectorDS::VectorDS() : DataStructure() {
00013 }
00014 
00015 VectorDS::~VectorDS() {
00016 }
00017 
00018 void VectorDS::addParticles(Particle *particle) {
00019         particles.insert(particles.begin(), particle);
00020 }
00021 
00022 void VectorDS::killParticles() {
00023         particles.erase(particles.begin(), particles.end());
00024 }
00025 
00026 void VectorDS::evolve() {
00027         pAllItt itt = particles.begin();
00028         pAllItt end = particles.end();
00029     #ifdef __PERFORMANCE__
00030     std::cout << "VectorDS: Before evolve"  << std::endl;
00031     #endif
00032         while(itt != end) {
00033         //Check if collision is enabled
00034         if(collision) {
00035             allcObjects itt2 = collisionObjects.begin();
00036                 //allcObjects end2 = collisionObjects.end();
00037             int size = collisionObjects.size();
00038             for(int i = 0; i < size; i++) {
00039                 #ifdef __COLLISION__
00040                     std::cout << collisionObjects.size() << std::endl;
00041                                         std::cout << " VectorDS: particle position vectords before" << (*itt)->position << std::endl;
00042                                         
00043                 #endif
00044                         (*itt2)->collide((*itt));
00045                         itt2++;
00046                 }
00047         }
00048                 (*itt)->update();
00049 
00050         if((*itt)->isDead() && deadParticles.size() < storageCapacity) {
00051                         deadParticles.insert(deadParticles.begin(), (*itt));
00052                 }
00053                 #ifdef __COLLISION__
00054                 std::cout << "VectorDS: Particle position vectords after" << " " << (*itt)->position << std::endl;
00055                 #endif
00056                 itt++;
00057 
00058         }
00059     #ifdef __PERFORMANCE__
00060     std::cout << "VectorDS: End evolve"  << std::endl;
00061     #endif
00062         #ifdef  __PARTICLE_GENERATION__
00063         std::cout << this->size()  << std::endl;
00064         #endif
00065 }
00066 
00067 bool VectorDS::positionCheck(GraphicsLib::Point3 pos) {
00068         return true;
00069 }
00070 
00071 void VectorDS::draw() {
00072 
00073     pAllItt itt = particles.begin();
00074         pAllItt end = particles.end();
00075     #ifdef __PERFORMANCE__
00076         cout << "VectorDS: beforedrawing particles" << endl;
00077     #endif
00078 
00079 
00080         while(itt != end) {
00081 
00082 
00083                 (*itt)->draw();
00084                 itt++;
00085         }
00086 
00087     #ifdef __PERFORMANCE__"ParticleSystem.cpp"
00088         cout << "VectorDS: afterdrawing particles" << endl;
00089     #endif
00090     allcObjects itt2 = collisionObjects.begin();
00091         allcObjects end2 = collisionObjects.end();
00092         while(itt2 != end2) {
00093                 (*itt2)->draw();
00094                 itt2++;
00095         }
00096         
00097     #ifdef __PERFORMANCE__
00098     std::cout << size()  << std::endl;
00099     #endif
00100 }
00101 
00102 int VectorDS::numParticles() {
00103         return particles.size();
00104 }
00105 
00106 bool VectorDS::hasDead() {
00107         return !(deadParticles.empty());
00108 }
00109 
00110 Particle* VectorDS::getDead() {
00111     #ifdef __PERFORMANCE__
00112     std::cout << "VectorDS: Before getting DeadParticles"  << std::endl;
00113     #endif
00114         allDeadItt itt = deadParticles.begin();
00115         #ifdef  __PARTICLE_GENERATION__
00116         std::cout << "VectorDS: before deletion " << deadParticles.size()  << std::endl;
00117         #endif
00118         deadParticles.erase(itt);
00119         #ifdef  __PARTICLE_GENERATION__
00120         std::cout << "VectorDS: after deletion " << deadParticles.size()  << std::endl;
00121         #endif
00122      #ifdef __PERFORMANCE__
00123     std::cout << "VectorDS: Before after DeadParticles"  << std::endl;
00124     #endif
00125         return (*itt);
00126         
00127 }
00128 
00129 void VectorDS::addCollisionObject(CollisionObject *co){
00130     collisionObjects.insert(collisionObjects.begin(), co);
00131 }
00132 
00133 void VectorDS::deleteCollisionObject(CollisionObject *co){
00134 
00135 }
00136 

Generated on Thu Mar 24 11:05:02 2005 for ParticleSystem by  doxygen 1.4.1