Geom Software - C++ Programming and Geometry Libraries
Fade2.5D Documentation pages v1.56
SegmentChecker.h
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 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
19 #pragma once
20 #include <map>
21 #include "common.h"
22 #include "Segment2.h"
23 #include "MsgBase.h"
24 
25 
29 enum SegmentIntersectionType
30 {
31  SIT_UNINITIALIZED,
32  SIT_NONE,
33  SIT_SEGMENT,
34  SIT_POINT,
35  SIT_ENDPOINT
36 };
37 
38 #if GEOM_PSEUDO3D==GEOM_TRUE
39  namespace GEOM_FADE25D {
40 #elif GEOM_PSEUDO3D==GEOM_FALSE
41  namespace GEOM_FADE2D {
42 #else
43  #error GEOM_PSEUDO3D is not defined
44 #endif
45 
46 class SegmentCheckerData; // FWD, pImpl to ease DLL export
47 
48 
63 class CLASS_DECLSPEC SegmentChecker
64 {
65 public:
66  // *** CTOR and DTOR ***
67 
71  explicit SegmentChecker(const std::vector<Segment2*>& vSegments_);
73  ~SegmentChecker();
74 
81  Segment2* getSegment(size_t i) const;
84  size_t getNumberOfSegments() const;
89  int getIndex(Segment2* pSeg) const;
105  void subscribe(MsgType msgType,MsgBase* pMsg);
112  void unsubscribe(MsgType msgType,MsgBase* pMsg);
113 
114  // *** Visualization and debug ***
122  void showSegments(const std::string& name) const;
123 
124 
133  void showIllegalSegments(bool bAlsoEndPointIntersections,const std::string& name) const;
134 
135  // *** Intersectors ***
148  void getIllegalSegments(bool bAlsoEndPointIntersections,std::vector<Segment2*>& vIllegalSegmentsOut) const;
149 
160  SegmentIntersectionType getIntersectionType(Segment2* pSeg1,Segment2* pSeg2) const;
161 
162 
171  void getIntersectors( Segment2* pTestSegment,
172  bool bAlsoEndPointIntersections,
173  std::vector<std::pair<Segment2*,SegmentIntersectionType> >& vIntersectorsOut) const;
174 
175  // Intersections
176 #if GEOM_PSEUDO3D==GEOM_TRUE
177 
194  void getIntersectionPoint( SegmentIntersectionType sit,
195  const Segment2& seg0,
196  const Segment2& seg1,
197  Point2& ispOut0,
198  Point2& ispOut1
199  ) const;
214  void getIntersectionSegment(const Segment2& seg0,
215  const Segment2& seg1,
216  Segment2& issOut0,
217  Segment2& issOut1
218  ) const;
219 #else
220 
233  void getIntersectionPoint( SegmentIntersectionType typ,
234  const Segment2& seg0,
235  const Segment2& seg1,
236  Point2& ispOut
237  ) const;
248  void getIntersectionSegment(const Segment2& seg0,
249  const Segment2& seg1,
250  Segment2& issOut
251  ) const;
252 #endif
253 
260  std::string getIntersectionTypeString(SegmentIntersectionType sit) const;
261 
262 
263 private:
268  SegmentIntersectionType getIntersectionType_degeneratePart(
269  Segment2*& pSeg1,
270  Segment2*& pSeg2,
271  Point2& p1,
272  Point2& p2,
273  Point2& p3,
274  Point2& p4
275  ) const;
276  void addSegments(const std::vector<Segment2*>& vSegments_);
277 
278  // Data
279  SegmentCheckerData* pSCD;
280 
281 
286 };
287 
288 } // Namespace
289 
MsgBase
Definition: MsgBase.h:46
SegmentChecker identifies intersecting line segments.
Definition: SegmentChecker.h:63
Segment.
Definition: Segment2.h:38
Definition: Bbox2.h:23
Point.
Definition: Point2.h:39