Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Tin2d.h
1 //
2 // Tin2d.h
3 //
4 // Copyright (c) 2005-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #pragma once
9 
10 #include "vtdata/vtTin.h"
11 #include "ScaledView.h"
12 
13 class vtElevationGrid;
16 
17 #include <set>
18 
19 struct IntPair
20 {
21  IntPair() {}
22  bool operator <(const IntPair &b) const
23  {
24  if (v0 < b.v0)
25  return true;
26  else if (v0 > b.v0)
27  return false;
28  else
29  {
30  if (v1 < b.v1)
31  return true;
32  else
33  return false;
34  }
35  }
36  bool operator==(const IntPair &b)
37  {
38  return (v0 == b.v0 && v1 == b.v1);
39  }
40  IntPair(int i0, int i1) { v0 = i0; v1 = i1; }
41  int v0, v1;
42 };
43 
44 struct Outline : public std::set<IntPair>
45 {
46  void AddUniqueEdge(const IntPair &b)
47  {
48  iterator it = find(b);
49  if (it != end())
50  erase(it);
51  else
52  insert(b);
53  }
54 };
55 
60 class vtTin2d : public vtTin
61 {
62 public:
63  vtTin2d();
64  ~vtTin2d();
65 
66  vtTin2d(vtElevationGrid *grid);
68  vtTin2d(vtFeatureSetPolygon *set, int iFieldNum);
69 
70  void DrawTin(wxDC *pDC, vtScaledView *pView);
71  void ComputeEdgeLengths();
72  void CullLongEdgeTris();
73  void FreeEdgeLengths();
74  void SetConstraint(bool bConstrain, double fMaxEdge);
75  void MakeOutline();
76  int GetMemoryUsed() const;
77 
78  double *m_fEdgeLen;
79  bool m_bConstrain;
80  double m_fMaxEdge;
81 
82  Outline m_edges;
83 };
84