MercuryDPM
0.10
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
31
class
PossibleContactList
32
{
33
public
:
34
35
PossibleContactList
()
36
{
37
// std::cout<<"Standard constructor"<<std::endl;
38
FirstPossibleContact
=0;
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
);
47
if
(
FirstPossibleContact
->
get_Next
())
48
FirstPossibleContact
->
get_Next
()->
set_Prev
(
FirstPossibleContact
);
49
if
(
FirstPossibleContact
->
get_Next1
())
50
FirstPossibleContact
->
get_Next1
()->
set_Prev
(P1,
FirstPossibleContact
);
51
if
(
FirstPossibleContact
->
get_Next2
())
52
FirstPossibleContact
->
get_Next2
()->
set_Prev
(P2,
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
72
void
remove_ParticlePosibleContacts
(Particle *P)
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
89
FirstPossibleContact
=Curr->
get_Next
();
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
104
PossibleContact
*
getFirstPossibleContact
(){
return
FirstPossibleContact
;}
105
106
private
:
107
PossibleContact
*
FirstPossibleContact
;
108
109
};
110
111
#endif
PossibleContact::get_Prev
PossibleContact * get_Prev()
Definition:
PossibleContact.h:103
PossibleContact::get_OtherParticle
Particle * get_OtherParticle(Particle *P)
Definition:
PossibleContact.h:78
PossibleContact.h
PossibleContact::get_Next
PossibleContact * get_Next()
Definition:
PossibleContact.h:90
PossibleContact::get_Next2
PossibleContact * get_Next2()
Definition:
PossibleContact.h:118
O
Definition:
StatisticsVector.h:34
PossibleContactList::PossibleContactList
PossibleContactList()
Definition:
PossibleContactList.h:35
PossibleContactList::add_PossibleContact
void add_PossibleContact(Particle *P1, Particle *P2)
Definition:
PossibleContactList.h:41
PossibleContact::get_Next1
PossibleContact * get_Next1()
Definition:
PossibleContact.h:116
PossibleContactList::remove_ParticlePosibleContacts
void remove_ParticlePosibleContacts(Particle *P)
Definition:
PossibleContactList.h:72
PossibleContactList
Definition:
PossibleContactList.h:31
PossibleContactList::FirstPossibleContact
PossibleContact * FirstPossibleContact
Definition:
PossibleContactList.h:107
PossibleContact::set_Prev
void set_Prev(PossibleContact *Prev)
Definition:
PossibleContact.h:134
PossibleContact
Definition:
PossibleContact.h:29
PossibleContactList::getFirstPossibleContact
PossibleContact * getFirstPossibleContact()
Definition:
PossibleContactList.h:104
PossibleContact::set_Next
void set_Next(PossibleContact *Next)
Definition:
PossibleContact.h:124
PossibleContactList.h
Generated on Thu Nov 10 2016 11:54:52 for MercuryDPM by
1.8.7