Identifies intersections between a collection of line segments.
More...
#include <SegmentChecker.h>
|
| SegmentChecker () |
|
| SegmentChecker (const std::vector< Segment2 * > &vSegments_) |
| Constructor to initialize the SegmentChecker with a collection of segments. More...
|
|
| ~SegmentChecker () |
|
ClipResult | clipSegment (Segment2 &seg) |
| Clips a segment to the intersection with a bounding box. More...
|
|
void | getIllegalSegments (bool bAlsoEndPointIntersections, std::vector< Segment2 * > &vIllegalSegmentsOut) const |
|
int | getIndex (Segment2 *pSeg) const |
| Retrieves the index of a given segment. More...
|
|
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 |
| Determines the intersection type of two segments. More...
|
|
void | getIntersectors (Segment2 *pTestSegment, bool bAlsoEndPointIntersections, std::vector< std::pair< Segment2 *, SegmentIntersectionType > > &vIntersectorsOut) const |
| Gets all segments intersecting a specified segment. More...
|
|
Bbox2 | getLimit () const |
| Retrieves the current bounding box used for clipping. More...
|
|
size_t | getNumberOfSegments () const |
| Returns the total number of segments in this SegmentChecker object. More...
|
|
Segment2 * | getSegment (size_t i) const |
| Gets the segment at the specified index. More...
|
|
void | setLimit (const Bbox2 &bbx) |
| Sets the bounding box for segment clipping. More...
|
|
void | showIllegalSegments (bool bAlsoEndPointIntersections, const char *name) const |
| Visualizes only the intersecting segments. More...
|
|
void | showSegments (const char *name) const |
| Visualizes all segments, both intersecting and non-intersecting. More...
|
|
void | subscribe (MsgType msgType, MsgBase *pMsg) |
| Subscribes a message handler to receive progress updates. More...
|
|
void | unsubscribe (MsgType msgType, MsgBase *pMsg) |
| Unsubscribes a message handler from receiving updates. More...
|
|
Polylines: Intersecting segments are automatically found
This class is used to check a collection of line segments for intersections. The class provides efficient spatial search algorithms, making it suitable for very large inputs.
- See also
- C++ Example: Segment Checker
◆ SegmentChecker() [1/2]
GEOM_FADE2D::SegmentChecker::SegmentChecker |
( |
const std::vector< Segment2 * > & |
vSegments_ | ) |
|
|
explicit |
This constructor processes the input segments and prepares an internal data structure that allows for efficient spatial searches.
- Parameters
-
vSegments_ | The collection of segments to be checked for intersections. |
◆ SegmentChecker() [2/2]
GEOM_FADE2D::SegmentChecker::SegmentChecker |
( |
| ) |
|
◆ ~SegmentChecker()
GEOM_FADE2D::SegmentChecker::~SegmentChecker |
( |
| ) |
|
◆ clipSegment()
This method clips a segment to its intersection with a predefined bounding box.
- Parameters
-
[in,out] | seg | The segment to be clipped. |
- Returns
- A ClipResult indicating the status of the clipping operation. The segment can be clipped into the same segment, a subsegment, become degenerate, or be completely outside the box.
- Note
- Ensure that setLimit() has been called with a valid bounding box before using this method, otherwise the method returns CR_INVALID.
◆ getIllegalSegments()
void GEOM_FADE2D::SegmentChecker::getIllegalSegments |
( |
bool |
bAlsoEndPointIntersections, |
|
|
std::vector< Segment2 * > & |
vIllegalSegmentsOut |
|
) |
| const |
Get illegal segments
This method returns the segments involved in intersections. Intersections at endpoints are reported only when bAlsoEndPointIntersections
is set to true. The result is provided in the output vector vIllegalSegmentsOut
.
Types of segment intersections: (1) Non-collinear, (2) collinear, (3) duplicate segments, (4) endpoint intersection
- Parameters
-
| bAlsoEndPointIntersections | If true, intersections at endpoints will also be detected. |
[out] | vIllegalSegmentsOut | Output vector to hold the segments involved in intersections. |
◆ getIndex()
int GEOM_FADE2D::SegmentChecker::getIndex |
( |
Segment2 * |
pSeg | ) |
const |
This method returns the index of the provided segment in the internal collection.
- Parameters
-
pSeg | The segment whose index is to be returned. |
- Returns
- The index of the segment, or -1 if not found.
◆ getIntersectionPoint()
Compute the intersection point of two segments
This method computes the intersection point of two segments. Use getIntersectionType() to determine the segment intersection type sit
before calling this function. Call this function only if sit
is SIT_POINT
or SIT_ENDPOINT
.
- Parameters
-
| typ | The intersection type (SIT_POINT or SIT_ENDPOINT ). |
| seg0,seg1 | The intersecting segments. |
[out] | ispOut | The output intersection point. |
Details
seg0
and seg1
can be any arbitrary Segment2 objects. They do not need to be part of the segment set used to initialize the SegmentChecker.
◆ getIntersectionSegment()
void GEOM_FADE2D::SegmentChecker::getIntersectionSegment |
( |
const Segment2 & |
seg0, |
|
|
const Segment2 & |
seg1, |
|
|
Segment2 & |
issOut |
|
) |
| const |
Computes the intersection segment of two collinear intersecting segments
This method computes the intersection segment of two collinear segments that intersect. This function should only be used when the intersection type is SIT_SEGMENT.
- Parameters
-
| seg0,seg1 | The intersecting segments, where their SegmentIntersectionType is SIT_SEGMENT. |
[out] | issOut | The computed intersection segment of seg0 and seg1 . |
Details
seg0
and seg1
can be any arbitrary Segment2 objects. They do not need to be part of the segment set initialized in the SegmentChecker.
◆ getIntersectionType()
This method computes the type of intersection between two segments, such as no intersection, endpoint intersection, or collinear intersection.
- Parameters
-
pSeg1,pSeg2 | The segments to be checked for intersection. |
- Returns
- The intersection type (e.g., SIT_NONE, SIT_SEGMENT, SIT_POINT, or SIT_ENDPOINT).
- Note
pSeg1
and pSeg2
are pointers to arbitrary Segment2 objects. They do not need to be included in the set that has been used to initialize the SegmentChecker.
◆ getIntersectionTypeString()
Return the intersection type as a human-readable string.
This method converts the given intersection type sit
to a human-readable string.
- Parameters
-
sit | The intersection type to be converted to a string. |
- Returns
- A string representation of the intersection type.
◆ getIntersectors()
void GEOM_FADE2D::SegmentChecker::getIntersectors |
( |
Segment2 * |
pTestSegment, |
|
|
bool |
bAlsoEndPointIntersections, |
|
|
std::vector< std::pair< Segment2 *, SegmentIntersectionType > > & |
vIntersectorsOut |
|
) |
| const |
This method returns all segments that intersect a given segment along with the type of their intersection.
- Parameters
-
| pTestSegment | The segment to check for intersections. |
| bAlsoEndPointIntersections | Flag to include endpoint intersections. |
[out] | vIntersectorsOut | The output vector holding the intersecting segments and their intersection types. |
◆ getLimit()
Bbox2 GEOM_FADE2D::SegmentChecker::getLimit |
( |
| ) |
const |
Retrieves the current bounding box used for clipSegment().
- Returns
- The currently set bounding box.
◆ getNumberOfSegments()
size_t GEOM_FADE2D::SegmentChecker::getNumberOfSegments |
( |
| ) |
const |
- Returns
- The number of segments in the current object.
◆ getSegment()
Segment2* GEOM_FADE2D::SegmentChecker::getSegment |
( |
size_t |
i | ) |
const |
This method returns the Segment2 at index i
from the internal collection of segments.
- Parameters
-
i | The index of the segment to be returned. |
- Returns
- The segment at the specified index.
◆ setLimit()
void GEOM_FADE2D::SegmentChecker::setLimit |
( |
const Bbox2 & |
bbx | ) |
|
This method defines the bounding box that will be used by clipSegment().
- Parameters
-
bbx | The bounding box to be set. |
◆ showIllegalSegments()
void GEOM_FADE2D::SegmentChecker::showIllegalSegments |
( |
bool |
bAlsoEndPointIntersections, |
|
|
const char * |
name |
|
) |
| const |
Visualization of polyline intersections
This method highlights the intersecting segments in a PDF or postscript file.
- Parameters
-
bAlsoEndPointIntersections | Flag to include or exclude endpoint intersections as illegal. |
name | he filename, use .pdf or .ps as file extension. |
◆ showSegments()
void GEOM_FADE2D::SegmentChecker::showSegments |
( |
const char * |
name | ) |
const |
Line segments written to a postscript file
This method generates a PDF or PostScript file showing all the segments.
- Parameters
-
name | The filename, use .pdf or .ps as file extension. |
◆ subscribe()
void GEOM_FADE2D::SegmentChecker::subscribe |
( |
MsgType |
msgType, |
|
|
MsgBase * |
pMsg |
|
) |
| |
This method allows a custom progress bar or message handler to be registered to receive progress updates during the intersection check. This is optional and is primarily used for larger datasets.
- Parameters
-
msgType | The type of message (e.g., MSG_PROGRESS). |
pMsg | A user-defined progress bar or message handler derived from MsgBase. |
◆ unsubscribe()
void GEOM_FADE2D::SegmentChecker::unsubscribe |
( |
MsgType |
msgType, |
|
|
MsgBase * |
pMsg |
|
) |
| |
This method removes a previously registered message handler.
- Parameters
-
msgType | The type of message to unsubscribe from. |
pMsg | The message handler to unsubscribe. |
The documentation for this class was generated from the following file: