Fade2.5D Documentation pages v1.97
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
80  CLASS_DECLSPEC
81  double getSqLen25D() const;
82 #endif
83 
84 
88  CLASS_DECLSPEC
89  void swapSrcTrg();
90 
91  CLASS_DECLSPEC
92  friend std::ostream &operator<<(std::ostream &stream, Segment2 seg);
93 
94 
99  CLASS_DECLSPEC
100  bool operator==(const Segment2& other) const;
101 
102 };
103 
104 
105 
109 // Comparator class
110 struct CLASS_DECLSPEC Func_compareSegment
111 {
112  bool operator()(const Segment2* seg0,const Segment2* seg1) const
113  {
114  if(seg0->getSrc()<seg1->getSrc()) return true;
115  if(seg0->getSrc()>seg1->getSrc()) return false;
116  if(seg0->getTrg()<seg1->getTrg()) return true;
117  if(seg0->getTrg()>seg1->getTrg()) return false;
118  return false;
119  }
120 };
124 } // (namespace)
std::ostream & operator<<(std::ostream &stream, const Bbox2 &pC)
Print the box.
Definition: Bbox2.h:450
Point.
Definition: Point2.h:43
Segment.
Definition: Segment2.h:39
double getSqLen2D() const
Segment2(const Point2 &src_, const Point2 &trg_)
Create a Segment2.
double getSqLen25D() const
bool operator==(const Segment2 &other) const
Point2 getTrg() const
Point2 getSrc() const