xmsgrid  1.0
TrTin.h
Go to the documentation of this file.
1 #pragma once
2 //------------------------------------------------------------------------------
7 //------------------------------------------------------------------------------
8 
9 //----- Included files ---------------------------------------------------------
10 
11 // 3. Standard library headers
12 #include <iosfwd> // forward declaration of ostream
13 
14 // 4. External library headers
15 #include <boost/serialization/assume_abstract.hpp>
16 
17 // 5. Shared code headers
18 #include <xmscore/points/ptsfwd.h>
19 #include <xmscore/misc/base_macros.h> // for XM_DISALLOW_COPY_AND_ASSIGN
20 #include <xmscore/misc/boost_defines.h> // for BSHP
21 #include <xmscore/stl/vector.h> // for VecPt3d
22 #include <xmscore/stl/set.h> // for SetInt
23 
24 namespace boost
25 {
26 namespace serialization
27 {
28 class access;
29 }
30 }
31 namespace xms
32 {
34 class TrTin
35 {
37  friend class boost::serialization::access;
39 public:
40  static BSHP<TrTin> New();
42 
43  // Setters
44  virtual void SetPoints(BSHP<VecPt3d> a_pts) = 0;
45  virtual void SetTriangles(BSHP<VecInt> a_tris) = 0;
46  virtual void SetTrianglesAdjacentToPoints(BSHP<VecInt2d> a_trisAdjToPts) = 0;
47  virtual void SetGeometry(BSHP<VecPt3d> a_pts,
48  BSHP<VecInt> a_tris,
49  BSHP<VecInt2d> a_trisAdjToPts) = 0;
50 
51  // Getters
52  virtual VecPt3d& Points() = 0;
53  virtual VecInt& Triangles() = 0;
54  virtual VecInt2d& TrisAdjToPts() = 0; // Triangles adjacent to points
55 
56  virtual const VecPt3d& Points() const = 0;
57  virtual const VecInt& Triangles() const = 0;
58  virtual const VecInt2d& TrisAdjToPts() const = 0; // Triangles adjacent to points
59 
60  virtual BSHP<VecPt3d> PointsPtr() = 0;
61  virtual BSHP<VecInt> TrianglesPtr() = 0;
62 
63  virtual int NumPoints() const = 0;
64  virtual int NumTriangles() const = 0;
65 
66  // Non modifiers
67  virtual bool TriangleFromEdge(int a_pt1,
68  int a_pt2,
69  int& a_tri,
70  int& a_localPt1,
71  int& a_localPt2) const = 0;
72  virtual int TriangleAdjacentToEdge(int a_pt1, int a_pt2) const = 0;
73  virtual int LocalIndex(int a_tri, int a_pt) const = 0;
74  virtual int GlobalIndex(int a_triIdx, int a_localPt) const = 0;
75  virtual bool VerticesAreAdjacent(int a_pt1, int a_pt2) const = 0;
76  virtual int CommonEdgeIndex(int a_tri, int a_adjTri) const = 0;
77  virtual int AdjacentTriangle(int a_triIdx, int a_edgeIdx) const = 0;
78  virtual Pt3d TriangleCentroid(int a_tri) const = 0;
79  virtual double TriangleArea(int a_tri) const = 0;
80  // virtual int FirstBoundaryPoint () const = 0;
81  virtual int NextBoundaryPoint(int a_point) const = 0;
82  virtual int PreviousBoundaryPoint(int a_point) const = 0;
83  virtual void GetBoundaryPoints(VecInt& a_boundaryPoints) const = 0;
84  virtual void GetBoundaryPolys(VecInt2d& a_polys) const = 0;
85  virtual bool GetExtents(Pt3d& a_mn, Pt3d& a_mx) const = 0;
86  virtual void ExportTinFile(std::ostream& a_os) const = 0;
87 
88  // Modifiers
89  virtual bool SwapEdge(int a_triA, int a_triB, bool a_checkAngle = true) = 0;
90  virtual void DeleteTriangles(const SetInt& a_triangles) = 0;
91  virtual void DeletePoints(const SetInt& a_points) = 0;
92  virtual bool OptimizeTriangulation() = 0;
93  virtual bool RemoveLongThinTrianglesOnPerimeter(const double a_ratio) = 0;
94  virtual void BuildTrisAdjToPts() = 0; // Triangles adjacent to points
95  virtual void Clear() = 0;
96 
97  virtual std::string ToString() const = 0;
98  virtual void FromString(const std::string&) = 0;
99  template <typename Archive>
100  void serialize(Archive& /*archive*/, const unsigned int /*version*/)
101  {
102  }
104 
105  virtual ~TrTin(); // moved from protected for boost serialize
106 protected:
107  TrTin();
108 
109 private:
111 
112 }; // class TrTin
113 
114 //----- Global methods ---------------------------------------------------------
115 
116 void trRenumberOnDelete(const SetInt& a_deleting, VecInt& a_vec);
117 
118 } // namespace xms
119 
120 BOOST_SERIALIZATION_ASSUME_ABSTRACT(xms::TrTin)
std::vector< int > VecInt
virtual ~TrTin()
destructor
Definition: TrTin.cpp:1340
std::vector< VecInt > VecInt2d
static BSHP< TrTin > New()
Create a TrTinImpl object.
Definition: TrTin.cpp:1347
std::set< int > SetInt
#define XM_DISALLOW_COPY_AND_ASSIGN(TypeName)
XMS Namespace.
Definition: geoms.cpp:34
void trRenumberOnDelete(const SetInt &a_deleting, VecInt &a_vec)
Boost serialize function.
Definition: TrTin.cpp:1376
TrTin()
constructor
Definition: TrTin.cpp:1334
std::vector< Pt3d > VecPt3d