Fade2D Documentation pages v2.16.3
Delaunay Features
Segment2.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 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
20 #pragma once
21 
22 #include "Point2.h"
23 
24 #include "common.h"
25 #if GEOM_PSEUDO3D==GEOM_TRUE
26  namespace GEOM_FADE25D {
27 #elif GEOM_PSEUDO3D==GEOM_FALSE
28  namespace GEOM_FADE2D {
29 #else
30  #error GEOM_PSEUDO3D is not defined
31 #endif
32 
33 
34 //#include "TrPoint.h"
38 class Segment2
39 {
40 protected:
41  Point2 src,trg;
42 public:
48  CLASS_DECLSPEC
49  Segment2(const Point2& src_,const Point2& trg_);
53  CLASS_DECLSPEC
59  CLASS_DECLSPEC
60  Point2 getSrc() const;
65  CLASS_DECLSPEC
66  Point2 getTrg() const;
67 
72  CLASS_DECLSPEC
73  double getSqLen2D() const;
74 
75 #if GEOM_PSEUDO3D==GEOM_TRUE
78  CLASS_DECLSPEC
79  double getSqLen25D() const;
80 #endif
81 
82 
86  CLASS_DECLSPEC
87  void swapSrcTrg();
88 
89  CLASS_DECLSPEC
90  friend std::ostream &operator<<(std::ostream &stream, Segment2 seg);
91 
92 
97  CLASS_DECLSPEC
98  bool operator==(const Segment2& other) const;
99 
103  bool operator<(const Segment2& other) const
104  {
105  if(src<other.src) return true;
106  if(src>other.src) return false;
107  return trg<other.trg;
108  }
109 
110 
111 };
112 
113 
114 
118 // Comparator class
119 struct CLASS_DECLSPEC Func_compareSegment
120 {
121  bool operator()(const Segment2* seg0,const Segment2* seg1) const
122  {
123  if(seg0->getSrc()<seg1->getSrc()) return true;
124  if(seg0->getSrc()>seg1->getSrc()) return false;
125  if(seg0->getTrg()<seg1->getTrg()) return true;
126  if(seg0->getTrg()>seg1->getTrg()) return false;
127  return false;
128  }
129 };
133 } // (namespace)
Point.
Definition: Point2.h:53
Segment.
Definition: Segment2.h:39
Point2 getTrg() const
Segment2(const Point2 &src_, const Point2 &trg_)
Create a Segment2.
Point2 getSrc() const
double getSqLen2D() const
bool operator<(const Segment2 &other) const
Definition: Segment2.h:103
bool operator==(const Segment2 &other) const