-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMPI_IsctWithRemovalSegmentVisitor.cpp
53 lines (40 loc) · 1.7 KB
/
MPI_IsctWithRemovalSegmentVisitor.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
//
// MPI_IsctWithRemovalSegmentVisitor.cpp
//
#include "MPI_IsctWithRemovalSegmentVisitor.h"
#include "MPI_ParticleSegment.h"
#include "MPI_RemovalSegment.h"
#include "MPI_Scheduler.h"
#include "MPI_IntersectionPolyLine.h"
#include "MPI_RemovePolyLineEvent.h"
MPI_IsctWithRemovalSegmentVisitor::MPI_IsctWithRemovalSegmentVisitor( MPI_RemovalSegment &removalsegment, MPI_Scheduler &scheduler ) :
MPI_SegmentIntersectionVisitor( removalsegment ),
scheduler_( scheduler )
{
// empty
}
void MPI_IsctWithRemovalSegmentVisitor::visitSegment( MPI_Segment &segment ) const
{
// remove the polyline that owns the segment if there's an intersection
// schedule the removal at the current logical time -- this causes the
// removal to be called from the top level, outside any visitor traversals
// (in particular, the one we're in now).
float thissegpos = 0.0;
float othersegpos = 0.0;
if ( !segment.getIntersectionPolyLine().isMarkedForRemoval() &&
getSegment().findIntersection(segment, thissegpos, othersegpos) ) {
// schedule its removal. this is scheduled to go off at the current
// logical time, after any pending events are dispatched.
scheduler_.scheduleEvent( new MPI_RemovePolyLineEvent( segment.getWorkspace(), segment.getIntersectionPolyLine() ), 0.0 );
segment.getIntersectionPolyLine().markForRemoval();
}
}
void MPI_IsctWithRemovalSegmentVisitor::visitParticleSegment( MPI_ParticleSegment &segment ) const
{
visitSegment( segment );
}
void MPI_IsctWithRemovalSegmentVisitor::visitRemovalSegment( MPI_RemovalSegment &segment ) const
{
// empty -- do nothing if you intersect another removal segment
}
// vim:sw=4:et:cindent: