Fade2D Documentation pages v2.16.7
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 
40 class Segment2
41 {
42 protected:
45 public:
54  CLASS_DECLSPEC
55  Segment2(const Point2& src_,const Point2& trg_);
62  CLASS_DECLSPEC
64 
72  CLASS_DECLSPEC
73  Point2 getSrc() const;
74 
82  CLASS_DECLSPEC
83  Point2 getTrg() const;
84 
97  CLASS_DECLSPEC
98  double getSqLen2D() const;
99 
100 #if GEOM_PSEUDO3D==GEOM_TRUE
108  CLASS_DECLSPEC
109  double getSqLen25D() const;
110 #endif
118  CLASS_DECLSPEC
119  void swapSrcTrg();
120 
121 
132  CLASS_DECLSPEC
133  friend std::ostream &operator<<(std::ostream &stream, Segment2 seg);
134 
144  CLASS_DECLSPEC
145  bool operator==(const Segment2& other) const;
146 
155  bool operator<(const Segment2& other) const
156  {
157  if(src<other.src) return true;
158  if(src>other.src) return false;
159  return trg<other.trg;
160  }
161 
162 
163 };
164 
165 
166 
168 // Comparator class
169 struct CLASS_DECLSPEC Func_compareSegment
170 {
171  bool operator()(const Segment2* seg0,const Segment2* seg1) const
172  {
173  if(seg0->getSrc()<seg1->getSrc()) return true;
174  if(seg0->getSrc()>seg1->getSrc()) return false;
175  if(seg0->getTrg()<seg1->getTrg()) return true;
176  if(seg0->getTrg()>seg1->getTrg()) return false;
177  return false;
178  }
179 };
180 
181 } // (namespace)
Represents a 2D point.
Definition: Point2.h:61
Represents a line segment between two points.
Definition: Segment2.h:41
Point2 trg
The target point of the segment.
Definition: Segment2.h:44
CLASS_DECLSPEC bool operator==(const Segment2 &other) const
Equality operator for the Segment2 class.
CLASS_DECLSPEC friend std::ostream & operator<<(std::ostream &stream, Segment2 seg)
Stream output operator for the Segment2 class.
CLASS_DECLSPEC double getSqLen2D() const
Calculate the squared 2D length of the segment.
CLASS_DECLSPEC Segment2()
Default constructor for a Segment2 object.
CLASS_DECLSPEC Point2 getTrg() const
Get the target point of the segment.
CLASS_DECLSPEC Point2 getSrc() const
Get the source point of the segment.
CLASS_DECLSPEC void swapSrcTrg()
Swap the source and target points of the segment.
bool operator<(const Segment2 &other) const
Less-than operator for comparing two segments lexicographically.
Definition: Segment2.h:155
CLASS_DECLSPEC Segment2(const Point2 &src_, const Point2 &trg_)
Create a Segment2 object with specified source and target points.
Point2 src
The source point of the segment.
Definition: Segment2.h:43
Definition: Segment2.h:170