Fade2D Documentation pages v2.16.8
Delaunay Features
SegmentChecker.h
Go to the documentation of this file.
1 // Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
2 //
3 // This file is part of the Fade2D library. The student license is free
4 // of charge and covers personal, non-commercial research. Licensees
5 // holding a commercial license may use this file in accordance with
6 // the Commercial License Agreement.
7 //
8 // This software is provided AS IS with NO WARRANTY OF ANY KIND,
9 // INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
10 // FOR A PARTICULAR PURPOSE.
11 //
12 // Please contact the author if any conditions of this licensing are
13 // unclear to you.
14 //
15 // Support: https://www.geom.at/contact/
16 // Project: https://www.geom.at/fade2d/html/
17 
18 
19 #pragma once
20 #include <map>
21 #include "common.h"
22 #ifndef FADE2D_EXPORT
23  #include "License.h"
24 #endif
25 #include "Segment2.h"
26 #include "MsgBase.h"
27 #include "Bbox2.h"
28 
29 
31 
32 
39 {
45 };
46 
47 
54 {
61 };
62 
63 #if GEOM_PSEUDO3D==GEOM_TRUE
64  namespace GEOM_FADE25D {
65 #elif GEOM_PSEUDO3D==GEOM_FALSE
66  namespace GEOM_FADE2D {
67 #else
68  #error GEOM_PSEUDO3D is not defined
69 #endif
70 
71 class SegmentCheckerData; // FWD
72 
73 
87 class CLASS_DECLSPEC SegmentChecker
88 {
89 public:
90 
99  explicit SegmentChecker(const std::vector<Segment2*>& vSegments_);
104 
120 
121 
129  void setLimit(const Bbox2& bbx);
130 
131 
139  Bbox2 getLimit() const;
140 
141 
150  Segment2* getSegment(size_t i) const;
156  size_t getNumberOfSegments() const;
157 
166  int getIndex(Segment2* pSeg) const;
176  void subscribe(MsgType msgType,MsgBase* pMsg);
185  void unsubscribe(MsgType msgType,MsgBase* pMsg);
186 
197  void showSegments(const char* name) const;
198 
199 
212  void showIllegalSegments(bool bAlsoEndPointIntersections,const char* name) const;
213 
226  void getIllegalSegments(bool bAlsoEndPointIntersections,std::vector<Segment2*>& vIllegalSegmentsOut) const;
227 
228 
241 
242 
252  void getIntersectors( Segment2* pTestSegment,
253  bool bAlsoEndPointIntersections,
254  std::vector<std::pair<Segment2*,SegmentIntersectionType> >& vIntersectorsOut) const;
255 
256  // Intersections
257 #if GEOM_PSEUDO3D==GEOM_TRUE
258 
279  void getIntersectionPoint( SegmentIntersectionType sit,
280  const Segment2& seg0,
281  const Segment2& seg1,
282  Point2& ispOut0,
283  Point2& ispOut1
284  ) const;
304  void getIntersectionSegment(const Segment2& seg0,
305  const Segment2& seg1,
306  Segment2& issOut0,
307  Segment2& issOut1
308  ) const;
309 #else
310 
326  const Segment2& seg0,
327  const Segment2& seg1,
328  Point2& ispOut
329  ) const;
330 
346  const Segment2& seg1,
347  Segment2& issOut
348  ) const;
349 #endif
350 
360 
361 
362 
363 private:
365  SegmentChecker& operator=(const SegmentChecker&);
366 
368  SegmentIntersectionType getIntersectionType_degeneratePart(
369  const Segment2*& pSeg1,
370  const Segment2*& pSeg2,
371  Point2& p1,
372  Point2& p2,
373  Point2& p3,
374  Point2& p4
375  ) const;
377  void addSegments(const std::vector<Segment2*>& vSegments_);
378 
379  // Data
381  SegmentCheckerData* pSCD;
382 
383 
384 
385 };
386 
387 } // Namespace
388 
MsgType
Message types for the message system.
Definition: MsgBase.h:40
SegmentIntersectionType
Enumerates the possible intersection types between two line segments.
Definition: SegmentChecker.h:39
@ SIT_ENDPOINT
Definition: SegmentChecker.h:44
@ SIT_UNINITIALIZED
Definition: SegmentChecker.h:40
@ SIT_NONE
Definition: SegmentChecker.h:41
@ SIT_SEGMENT
Definition: SegmentChecker.h:42
@ SIT_POINT
Definition: SegmentChecker.h:43
ClipResult
Describes the result of clipping a segment with a bounding box.
Definition: SegmentChecker.h:54
@ CR_EMPTY
Definition: SegmentChecker.h:56
@ CR_CLIPPED_NONDEGENERATE
Definition: SegmentChecker.h:58
@ CR_INVALID
Definition: SegmentChecker.h:55
@ CR_COMPLETE_NONDEGENERATE
Definition: SegmentChecker.h:60
@ CR_COMPLETE_DEGENERATE
Definition: SegmentChecker.h:59
@ CR_CLIPPED_DEGENERATE
Definition: SegmentChecker.h:57
A 2D axis-aligned bounding box.
Definition: Bbox2.h:39
MsgBase, a base class for message subscriber classes.
Definition: MsgBase.h:55
Represents a 2D point.
Definition: Point2.h:76
Represents a line segment between two points.
Definition: Segment2.h:41
Identifies intersections between a collection of line segments.
Definition: SegmentChecker.h:88
void showSegments(const char *name) const
Visualizes all segments, both intersecting and non-intersecting.
void setLimit(const Bbox2 &bbx)
Sets the bounding box for segment clipping.
Bbox2 getLimit() const
Retrieves the current bounding box used for clipping.
size_t getNumberOfSegments() const
Returns the total number of segments in this SegmentChecker object.
void getIntersectors(Segment2 *pTestSegment, bool bAlsoEndPointIntersections, std::vector< std::pair< Segment2 *, SegmentIntersectionType > > &vIntersectorsOut) const
Gets all segments intersecting a specified segment.
void getIntersectionPoint(SegmentIntersectionType typ, const Segment2 &seg0, const Segment2 &seg1, Point2 &ispOut) const
static const char * getIntersectionTypeString(SegmentIntersectionType sit)
void unsubscribe(MsgType msgType, MsgBase *pMsg)
Unsubscribes a message handler from receiving updates.
void getIntersectionSegment(const Segment2 &seg0, const Segment2 &seg1, Segment2 &issOut) const
void subscribe(MsgType msgType, MsgBase *pMsg)
Subscribes a message handler to receive progress updates.
int getIndex(Segment2 *pSeg) const
Retrieves the index of a given segment.
SegmentIntersectionType getIntersectionType(const Segment2 *pSeg1, const Segment2 *pSeg2) const
Determines the intersection type of two segments.
Segment2 * getSegment(size_t i) const
Gets the segment at the specified index.
SegmentChecker(const std::vector< Segment2 * > &vSegments_)
Constructor to initialize the SegmentChecker with a collection of segments.
void showIllegalSegments(bool bAlsoEndPointIntersections, const char *name) const
Visualizes only the intersecting segments.
ClipResult clipSegment(Segment2 &seg)
Clips a segment to the intersection with a bounding box.
void getIllegalSegments(bool bAlsoEndPointIntersections, std::vector< Segment2 * > &vIllegalSegmentsOut) const