MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PossibleContactList.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef POSSIBLECONTACTLIST_H
27 #define POSSIBLECONTACTLIST_H
28 
29 #include "PossibleContact.h"
30 
32 {
33 public:
34 
36  {
37 // std::cout<<"Standard constructor"<<std::endl;
39  }
40 
41  void add_PossibleContact(Particle *P1, Particle *P2)
42  {
43 // std::cout<<"Added new contact between particle "<<P1->get_Index()<<" and "<<P2->get_Index()<<std::endl;
44  FirstPossibleContact=new PossibleContact(P1,P2,FirstPossibleContact,P1->get_FirstPossibleContact(),P2->get_FirstPossibleContact());
45  P1->set_FirstPossibleContact(FirstPossibleContact);
46  P2->set_FirstPossibleContact(FirstPossibleContact);
53  }
54 
55  /*void remove_AllPosibleContacts()
56  {
57  //std::cout<<"Removing all contacts"<<std::endl;
58  PossibleContact* Next;
59  PossibleContact* Curr=FirstPossibleContact;
60  while(Curr)
61  {
62  Next=Curr->get_Next();
63  delete Curr;
64  Curr=Next;
65  }
66  FirstPossibleContact=NULL;
67 
68  for (vector<Particle*>::iterator it = particleHandler.begin(); it!=particleHandler.end(); ++it)
69  (*it)->set_FirstPossibleContact(0);
70  }*/
71 
73  {
74  //std::cout<<"Removing all contacts of particle "<<P->get_Index()<<std::endl;
75  Particle* O;
76  PossibleContact* Next;
77  PossibleContact* Curr=P->get_FirstPossibleContact();
78  while(Curr)
79  {
80  //std::cout<<"Removing contacts index="<<Curr->get_Index()<<" between particle "<<Curr->get_P1()->get_Index()<<" and "<<Curr->get_P2()->get_Index()<<std::endl;
81  Next=Curr->get_Next(P);
82  O=Curr->get_OtherParticle(P);
83  if(Curr->get_Next())
84  Curr->get_Next()->set_Prev(Curr->get_Prev());
85 
86  if(Curr->get_Prev())
87  Curr->get_Prev()->set_Next(Curr->get_Next());
88  else
90 
91  if(Curr->get_Next(O))
92  Curr->get_Next(O)->set_Prev(O,Curr->get_Prev(O));
93 
94  if(Curr->get_Prev(O))
95  Curr->get_Prev(O)->set_Next(O,Curr->get_Next(O));
96  else
97  O->set_FirstPossibleContact(Curr->get_Next(O));
98  delete Curr;
99  Curr=Next;
100  }
101  P->set_FirstPossibleContact(0);
102  }
103 
105 
106 private:
108 
109 };
110 
111 #endif
PossibleContact * get_Prev()
Particle * get_OtherParticle(Particle *P)
PossibleContact * get_Next()
PossibleContact * get_Next2()
void add_PossibleContact(Particle *P1, Particle *P2)
PossibleContact * get_Next1()
void remove_ParticlePosibleContacts(Particle *P)
PossibleContact * FirstPossibleContact
void set_Prev(PossibleContact *Prev)
PossibleContact * getFirstPossibleContact()
void set_Next(PossibleContact *Next)