Geom Software - C++ Programming and Geometry Libraries
Fade2.5D Documentation pages v1.58
GEOM_FADE25D::SegmentChecker Class Reference

SegmentChecker identifies intersecting line segments. More...

#include <SegmentChecker.h>

Public Member Functions

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

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.

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

Constructor & Destructor Documentation

◆ SegmentChecker()

GEOM_FADE25D::SegmentChecker::SegmentChecker ( const std::vector< Segment2 *> &  vSegments_)
explicit
Parameters
vSegments_contains the segments to be checked

Member Function Documentation

◆ getIllegalSegments()

void GEOM_FADE25D::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.

segment_intersection_types.png
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 GEOM_FADE25D::SegmentChecker::getIndex ( Segment2 pSeg) const

Returns the index of a segment

Parameters
pSegis the segment whose index is returned

◆ getIntersectionPoint()

void GEOM_FADE25D::SegmentChecker::getIntersectionPoint ( SegmentIntersectionType  sit,
const Segment2 seg0,
const Segment2 seg1,
Point2 ispOut0,
Point2 ispOut1 
) const

Compute the intersection point(s) of two segments

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

Parameters
sitis the segment intersection type (SIT_POINT or SIT_ENDPOINT for the present method)
seg0,seg1are the intersecting segments
[out]ispOut0output intersection point at seg0
[out]ispOut1output intersection point at seg1

The two output intersection points ispOut0 and ispOut1 have same (x,y) coordinates but possibly different heights z.

Note
It is not required that pSeg1 and pSeg2 are from the set of segments that have been used to initialize the SegmentChecker.

◆ getIntersectionSegment()

void GEOM_FADE25D::SegmentChecker::getIntersectionSegment ( const Segment2 seg0,
const Segment2 seg1,
Segment2 issOut0,
Segment2 issOut1 
) const

Compute the intersection segment(s) of two collinear intersecting segments

Parameters
seg0,seg1are intersecting segments such that their SegmentIntersectionType is SIT_SEGMENT
[out]issOut0intersection segment at seg0
[out]issOut1intersection segment at seg1

The two output segments have same (x,y) coordinates but possibly diffent heights z.

Note
pSeg1 and pSeg2 do not need to be from the set that has been used to initialize the SegmentChecker.

◆ getIntersectionType()

SegmentIntersectionType GEOM_FADE25D::SegmentChecker::getIntersectionType ( Segment2 pSeg1,
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()

std::string GEOM_FADE25D::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 GEOM_FADE25D::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. It returns segments which intersect pTestSegment along with their intersection type

◆ getNumberOfSegments()

size_t GEOM_FADE25D::SegmentChecker::getNumberOfSegments ( ) const

Returns the number of segments contained in this SegmentChecker object

◆ getSegment()

Segment2* GEOM_FADE25D::SegmentChecker::getSegment ( size_t  i) const

Returns the i-th segment

Parameters
iis the index of the segment to be returned

◆ showIllegalSegments()

void GEOM_FADE25D::SegmentChecker::showIllegalSegments ( bool  bAlsoEndPointIntersections,
const std::string &  name 
) const

Write a postscript file, highlight illegal segments

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

◆ showSegments()

void GEOM_FADE25D::SegmentChecker::showSegments ( const std::string &  name) const

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

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

◆ subscribe()

void GEOM_FADE25D::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 GEOM_FADE25D::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: