Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
SweepEventQueue Class Reference

The structure to hold the intersections events encountered during the sweep. More...

#include <sweep-event-queue.h>

Public Member Functions

 SweepEventQueue (int s)
 
virtual ~SweepEventQueue ()
 
int size () const
 Number of events currently stored.
 
bool peek (SweepTree *&iLeft, SweepTree *&iRight, Geom::Point &oPt, double &itl, double &itr)
 Look for the top most intersection in the heap.
 
bool extract (SweepTree *&iLeft, SweepTree *&iRight, Geom::Point &oPt, double &itl, double &itr)
 Extract the top most intersection from the heap.
 
SweepEventadd (SweepTree *iLeft, SweepTree *iRight, Geom::Point &iPt, double itl, double itr)
 Add an intersection in the binary heap.
 
void remove (SweepEvent *e)
 Remove event from the event queue.
 
void relocate (SweepEvent *e, int to)
 Relocate the event e to the location to.
 

Private Attributes

int nbEvt
 
int maxEvt
 
int * inds
 
SweepEventevents
 

Detailed Description

The structure to hold the intersections events encountered during the sweep.

It's an array of SweepEvent (not allocated with "new SweepEvent[n]" but with a malloc). There's a list of indices because it's a binary heap: inds[i] tell that events[inds[i]] has position i in the heap. Each SweepEvent has a field to store its index in the heap, too.

Definition at line 24 of file sweep-event-queue.h.

Constructor & Destructor Documentation

◆ SweepEventQueue()

SweepEventQueue::SweepEventQueue ( int  s)

Definition at line 16 of file sweep-event.cpp.

References events, inds, and maxEvt.

◆ ~SweepEventQueue()

SweepEventQueue::~SweepEventQueue ( )
virtual

Definition at line 25 of file sweep-event.cpp.

References events, and inds.

Member Function Documentation

◆ add()

SweepEvent * SweepEventQueue::add ( SweepTree iLeft,
SweepTree iRight,
Geom::Point iPt,
double  itl,
double  itr 
)

Add an intersection in the binary heap.

Parameters
iLeftPointer to left node of intersection.
iRightPointer to right node of intersection.
iPtPoint of intersection.
itlTime of intersection on the left edge.
itrTime of intersection on the right edge.

Definition at line 31 of file sweep-event.cpp.

References Shape::dg_arete::en, events, Shape::getEdge(), SweepEvent::ind, inds, SweepEvent::MakeNew(), maxEvt, nbEvt, Shape::pData, and Shape::dg_arete::st.

Referenced by Shape::TesteIntersection().

◆ extract()

bool SweepEventQueue::extract ( SweepTree *&  iLeft,
SweepTree *&  iRight,
Geom::Point oPt,
double &  itl,
double &  itr 
)

Extract the top most intersection from the heap.

Parameters
iLeftReference that function will set to the left node of top most intersection.
iRightReference that function will set to the right node of top most intersection.
oPtReference that function will set to the point of top most intersection.
itlReference that function will set to time of top most intersection on the left edge.
itrReference that function will set to time of top most intersection on the right edge.
Returns
True if an intersection event exists false otherwise.

Definition at line 91 of file sweep-event.cpp.

References events, inds, LEFT, nbEvt, SweepEvent::posx, remove(), RIGHT, SweepEvent::sweep, SweepEvent::tl, and SweepEvent::tr.

Referenced by Shape::Booleen(), and Shape::ConvertToShape().

◆ peek()

bool SweepEventQueue::peek ( SweepTree *&  iLeft,
SweepTree *&  iRight,
Geom::Point oPt,
double &  itl,
double &  itr 
)

Look for the top most intersection in the heap.

Parameters
iLeftReference that function will set to the left node of top most intersection.
iRightReference that function will set to the right node of top most intersection.
oPtReference that function will set to the intersection point of top most intersection.
itlReference that function will set to time of top most intersection on the left edge.
itrReference that function will set to time of top most intersection on the right edge.
Returns
True if an intersection event exists false otherwise.

Definition at line 74 of file sweep-event.cpp.

References events, inds, LEFT, nbEvt, SweepEvent::posx, RIGHT, SweepEvent::sweep, SweepEvent::tl, and SweepEvent::tr.

Referenced by Shape::Booleen(), and Shape::ConvertToShape().

◆ relocate()

void SweepEventQueue::relocate ( SweepEvent e,
int  to 
)

Relocate the event e to the location to.

This will place all data of e in to and also update any evt pointers held by the intersection nodes.

Parameters
eThe SweepEvent to relocate.
toThe index of the location where we want to relocate e to.

Definition at line 216 of file sweep-event.cpp.

References events, SweepTree::evt, SweepEvent::ind, inds, LEFT, RIGHT, and SweepEvent::sweep.

Referenced by remove().

◆ remove()

void SweepEventQueue::remove ( SweepEvent e)

Remove event from the event queue.

Make sure to clear the evt pointers from the nodes involved.

Parameters
eThe event to remove.

Definition at line 110 of file sweep-event.cpp.

References events, SweepEvent::ind, inds, SweepEvent::MakeDelete(), nbEvt, SweepEvent::posx, and relocate().

Referenced by extract(), and SweepTree::RemoveEvent().

◆ size()

int SweepEventQueue::size ( ) const
inline

Number of events currently stored.

Returns
The number of elements stored.

Definition at line 35 of file sweep-event-queue.h.

References nbEvt.

Referenced by Shape::Booleen(), and Shape::ConvertToShape().

Member Data Documentation

◆ events

SweepEvent* SweepEventQueue::events
private

Sweep events.

Definition at line 94 of file sweep-event-queue.h.

Referenced by add(), extract(), peek(), relocate(), remove(), SweepEventQueue(), and ~SweepEventQueue().

◆ inds

int* SweepEventQueue::inds
private

Indices.

Definition at line 93 of file sweep-event-queue.h.

Referenced by add(), extract(), peek(), relocate(), remove(), SweepEventQueue(), and ~SweepEventQueue().

◆ maxEvt

int SweepEventQueue::maxEvt
private

Allocated size of the heap.

Definition at line 92 of file sweep-event-queue.h.

Referenced by add(), and SweepEventQueue().

◆ nbEvt

int SweepEventQueue::nbEvt
private

Number of events currently in the heap.

Definition at line 91 of file sweep-event-queue.h.

Referenced by add(), extract(), peek(), remove(), and size().


The documentation for this class was generated from the following files: