Fade2D Documentation pages v1.85
Delaunay Features
SegmentChecker Class Reference

SegmentChecker identifies intersecting line segments. More...

#include <SegmentChecker.h>

Public Member Functions

 SegmentChecker (const std::vector< Segment2 * > &vSegments_)
 
void getIllegalSegments (bool bAlsoEndPointIntersections, std::vector< Segment2 * > &vIllegalSegmentsOut) const
 
int getIndex (Segment2 *pSeg) const
 
void getIntersectionPoint (SegmentIntersectionType typ, const Segment2 &seg0, const Segment2 &seg1, Point2 &ispOut) const
 
void getIntersectionSegment (const Segment2 &seg0, const Segment2 &seg1, Segment2 &issOut) const
 
SegmentIntersectionType getIntersectionType (const Segment2 *pSeg1, const Segment2 *pSeg2) const
 
const char * getIntersectionTypeString (SegmentIntersectionType sit) const
 
void getIntersectors (Segment2 *pTestSegment, bool bAlsoEndPointIntersections, std::vector< std::pair< Segment2 *, SegmentIntersectionType > > &vIntersectorsOut) const
 
size_t getNumberOfSegments () const
 
Segment2getSegment (size_t i) const
 
void showIllegalSegments (bool bAlsoEndPointIntersections, const char *name) const
 
void showSegments (const char *name) const
 
void subscribe (MsgType msgType, MsgBase *pMsg)
 
void unsubscribe (MsgType msgType, MsgBase *pMsg)
 

Detailed Description

SegmentChecker takes a bunch of line segments and fully automatically identifies illegal segment intersections. The intersection points can be computed in 2D and in 2.5D. Further this class offers visualization methods. Due to the underlying datastructure the search algorithm scales very well to large inputs.

Polylines: Intersecting segments are automatically found
See also
http://www.geom.at/segment-checker/

Constructor & Destructor Documentation

◆ SegmentChecker()

SegmentChecker::SegmentChecker ( const std::vector< Segment2 * > &  vSegments_)
explicit

Internally this constructor prepares a data structure from vSegments that enables efficient spatial searches. The time complexity is O(n*log(n)).

Parameters
vSegments_contains the segments to be checked

Member Function Documentation

◆ getIllegalSegments()

void SegmentChecker::getIllegalSegments ( bool  bAlsoEndPointIntersections,
std::vector< Segment2 * > &  vIllegalSegmentsOut 
) const

Get illegal segments

Returns segments which are involved in intersections. Intersections at endpoints are only reported when bAlsoEndPointIntersections is true. The asymptotic time consumption for the lookup per segment S is O(log(n)+k) where k is the number of segments that intersect the minimal bounding box of S. Thus, for n segments the method takes O(n*(log(n)+k)) time.

Segment intersections: (1) Non-collinear, (2) collinear, (3) duplicate segments, (4) endpoint intersection
Parameters
bAlsoEndPointIntersectionsspecifies if intersections at endpoints shall be detected
[out]vIllegalSegmentsOutis the output vector

◆ getIndex()

int SegmentChecker::getIndex ( Segment2 pSeg) const

Returns the index of a segment

Parameters
pSegis the segment whose index is returned

◆ getIntersectionPoint()

void SegmentChecker::getIntersectionPoint ( SegmentIntersectionType  typ,
const Segment2 seg0,
const Segment2 seg1,
Point2 ispOut 
) const

Compute the intersection point of two segments

Use getIntersectionType() to determine the segment intersection type sit.

Parameters
typis the intersection type (SIT_POINT or SIT_ENDPOINT for the present method)
seg0,seg1are the intersecting segments
[out]ispOutis the output intersection point.
Note
pSeg1 and pSeg2 do not need to be from the set that has been used to initialize the SegmentChecker.

◆ getIntersectionSegment()

void SegmentChecker::getIntersectionSegment ( const Segment2 seg0,
const Segment2 seg1,
Segment2 issOut 
) const

Computes the intersection segment of two collinear intersecting segments

Parameters
seg0,seg1are intersecting segments such that their SegmentIntersectionType is SIT_SEGMENT
[out]issOutis the computed intersection of seg0 and seg1
Note
pSeg1 and pSeg2 do not need to be from the set that has been used to initialize the present object

◆ getIntersectionType()

SegmentIntersectionType SegmentChecker::getIntersectionType ( const Segment2 pSeg1,
const Segment2 pSeg2 
) const

Get the intersection type of two segments

Parameters
pSeg1,pSeg2are the segments to be checked
Returns
SIT_NONE (no intersection),
SIT_SEGMENT (collinear intersection),
SIT_POINT (intersection somewhere between the endpoints) or
SIT_ENDPOINT (endpoint intersection)
Note
pSeg1 and pSeg2 do not need to be from the set that has been used to initialize the present object

◆ getIntersectionTypeString()

const char* SegmentChecker::getIntersectionTypeString ( SegmentIntersectionType  sit) const

Return the intersection type as a human readable string. This is a convenience function

Parameters
sitis an intersection type to be converted to a string

◆ getIntersectors()

void SegmentChecker::getIntersectors ( Segment2 pTestSegment,
bool  bAlsoEndPointIntersections,
std::vector< std::pair< Segment2 *, SegmentIntersectionType > > &  vIntersectorsOut 
) const

Return segments that intersect a certain segment along with their intersection type

Parameters
pTestSegmentis the segment to be analyzed
bAlsoEndPointIntersectionsspecifies if intersections of type SIT_ENDPOINT shall also be reported.
[out]vIntersectorsOutis the output vector. Segments intersecting pTestSegment are added to vIntersectorsOut along with their intersection type.
Note
When vIntersectorsOut is non-empty, it is not cleared but the intersected segments are added.

The time complexity is O(log(n)+k) where n is the number of segments and k is the number of intersections for pTestSegment.

◆ getNumberOfSegments()

size_t SegmentChecker::getNumberOfSegments ( ) const

Returns the number of segments contained in this SegmentChecker object

◆ getSegment()

Segment2* SegmentChecker::getSegment ( size_t  i) const

Returns the i-th segment

Parameters
iis the index of the segment to be returned

◆ showIllegalSegments()

void SegmentChecker::showIllegalSegments ( bool  bAlsoEndPointIntersections,
const char *  name 
) const

Write a postscript file, highlight illegal segments

Parameters
bAlsoEndPointIntersectionsspecifies if intersections at endpoints are also illegal
nameis the output filename
Visualization of polyline intersections

◆ showSegments()

void SegmentChecker::showSegments ( const char *  name) const

Write all segments, with and without intersection, to a postscript file

Parameters
nameis the output filename
Line segments written to a postscript file

◆ subscribe()

void SegmentChecker::subscribe ( MsgType  msgType,
MsgBase pMsg 
)

Register a progress bar object

The SegmentChecker does its job typically in fractions of a second. But inputs may contain a quadratic number of intersections and such tasks take a while. Therefore a user defined message object (your own progress-bar class) can be registered in order to get progress updates. This step is optional.

Parameters
msgTypeis the message type. For progress information the type is always MSG_PROGRESS
pMsgis a user defined progress bar which derives from Fade's MsgBase.

◆ unsubscribe()

void SegmentChecker::unsubscribe ( MsgType  msgType,
MsgBase pMsg 
)

Unregister a progress bar object

Parameters
msgTypeis the message type. For progress information the type is always MSG_PROGRESS
pMsgis a user defined class which derives from Fade's MsgBase

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