ESyS-Particle  2.3.2
Triangle.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef __TRIANGLE_H
14 #define __TRIANGLE_H
15 
16 
17 //-- Project includes --
18 #include "Foundation/vec3.h"
19 #include "Foundation/Matrix3.h"
20 
21 //-- STL includes --
22 #include <utility>
23 using std::pair;
24 using std::make_pair;
25 
26 //-- IO includes --
27 #include <iostream>
28 using std::ostream;
29 
32 {
33 public:
35 };
36 
37 
47 class Triangle
48 {
49  public: // types
50  typedef Vec3 (Triangle::* VectorFieldFunction)() const;
51  typedef double (Triangle::* ScalarFieldFunction)() const;
52 
53  private:
61 
62  double EdgeSep(const Vec3&, const Vec3& ,const Vec3& ) const;
63 
64  public:
65  Triangle(int,int,int,const Vec3&,const Vec3&,const Vec3&,int,int);
66 
67  double sep(const Vec3&) const;
68  pair<bool,double> dist(const Vec3&) const ; // signed separation according to direction of the normal
69  Vec3 getBoundingBoxMin() const;
70  Vec3 getBoundingBoxMax() const;
71  Vec3 getNormal() const {return m_normal;};
72  Vec3 toGlobal(const Vec3&);
73  Vec3 toLocal(const Vec3&);
74  bool containsEdge(const Vec3&,const Vec3&) const;
75  void moveNode(int,const Vec3&);
76  void move(const Vec3&);
77  inline int getID() const {return m_tri_id;};
78  inline int getTag() const {return m_tag;};
79  inline void applyForce(const Vec3& f){m_force+=f;};
80  inline void zeroForce(){m_force=Vec3(0.0,0.0,0.0);};
81 
82  // get id/pos pairs for each node -> mainly for checkpointing
83  pair<int,Vec3> getP0()const{return make_pair(m_id0,m_p0);};
84  pair<int,Vec3> getP1()const{return make_pair(m_id1,m_p0+m_p1);};
85  pair<int,Vec3> getP2()const{return make_pair(m_id2,m_p0+m_p2);};
86 
87  // access functions
88  static VectorFieldFunction getVectorFieldFunction(const string&);
89  static ScalarFieldFunction getScalarFieldFunction(const string&);
90 
91  Vec3 getForce()const {return m_force;};
92  double getPressure() const;
93 
95  friend ostream& operator<<(ostream&,const Triangle&);
96 };
97 
98 #endif //__TRIANGLE_H