-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPI_IntersectionElement.cpp
71 lines (55 loc) · 2.18 KB
/
MPI_IntersectionElement.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// MPI_IntersectionElement.cpp
//
#include "MPI_IntersectionElement.h"
#include "MPI_OneSpace.h"
#include "MPI_ElementFactory.h"
#include "MPI_ElementVisitor.h"
#include "MPI_ElementConstVisitor.h"
MPI_IntersectionElement::MPI_IntersectionElement( MPI_OneSpace &onespace, MPI_ElementFactory const& elementfactory ) :
onespace_( onespace ),
elementfactory_( elementfactory ),
otherintersection_( NULL )
{
// empty
}
MPI_IntersectionElement::~MPI_IntersectionElement()
{
// remove the corresponding intersection if it exists
if ( otherintersection_ != NULL ) {
otherintersection_->setOtherIntersection( NULL );
otherintersection_->onespace_.removeElement( otherintersection_ );
}
}
void MPI_IntersectionElement::setOtherIntersection( MPI_IntersectionElement *intersection )
{
otherintersection_ = intersection;
}
MPI_IntersectionElement* MPI_IntersectionElement::getOtherIntersection( void ) const
{
return otherintersection_;
}
void MPI_IntersectionElement::spawnElement( void ) const
{
// create an element and add it to our onespace at our location
onespace_.addElement( elementfactory_.createElement(),
onespace_.getElementPosition(this) );
}
void MPI_IntersectionElement::acceptVisitor( MPI_ElementVisitor& visitor )
{
visitor.visitIntersectionElement( *this );
}
void MPI_IntersectionElement::acceptConstVisitor( MPI_ElementConstVisitor& visitor ) const
{
visitor.visitIntersectionElement( *this );
}
void MPI_IntersectionElement::createIntersectionPair( MPI_OneSpace &onespaceone, MPI_ElementFactory const& elementfactoryone, float positionone, MPI_OneSpace &onespacetwo, MPI_ElementFactory const& elementfactorytwo, float positiontwo )
{
MPI_IntersectionElement *intersectionone = new MPI_IntersectionElement( onespaceone, elementfactoryone );
MPI_IntersectionElement *intersectiontwo = new MPI_IntersectionElement( onespacetwo, elementfactorytwo );
intersectionone->setOtherIntersection( intersectiontwo );
intersectiontwo->setOtherIntersection( intersectionone );
onespaceone.addElement( intersectionone, positionone );
onespacetwo.addElement( intersectiontwo, positiontwo );
}
// vim:sw=4:et:cindent: