aimstil  5.0.5
graph.h
Go to the documentation of this file.
1 #ifndef TIL_GRAPH_H_
2 #define TIL_GRAPH_H_
3 
4 namespace til
5 {
6  /*
7  template < typename T >
8  struct OrientedGraphNode;
9 
10  template < typename T >
11  struct OrientedGraphEdge
12  {
13  std::list<OrientedGraphNode<T> >::iterator from;
14  std::list<OrientedGraphNode<T> >::iterator to;
15  };
16  */
17 
18  //---------------------------------------------------------------------------
19 
20  //NB: SIMPLE because edges are encoded in nodes. This is more efficient, on the other hand less general, since
21  // edges cannot have properties of their own (e.g. such as a cost) as there have no label to name them.
22  template < typename T >
24  {
25  explicit SimpleOrientedGraphNode(const T & v) : value(v) {}
26  std::list<typename std::list<SimpleOrientedGraphNode<T> >::iterator> from;
27  std::list<typename std::list<SimpleOrientedGraphNode<T> >::iterator> to;
28  T value;
29  };
30 
31  //---------------------------------------------------------------------------
32 
33  template < typename TMeshVertexNode >
35  {
37  };
38 
39  //---------------------------------------------------------------------------
40 
41  /*
42  template < typename T >
43  struct DefaultPointer
44  {
45  typedef typename std::list<T>::iterator type;
46  };
47  template < typename TAttribute, template < typename > class TPointerPolicy = DefaultPointer >
48  */
49 
50  //---------------------------------------------------------------------------
51 
52  // TODO: What we would like here is to be able to derive from MeshVertexNode. The problem comes from the fact
53  // that right now, MeshFaceNode must have the knowledge of MeshVertexNode and vice versa. It means that
54  // these classes cannot be templated over the other class. So the stuff to think about is how to get rid
55  // of this dependancy.
56  template < typename TAttribute >
58  {
59  public: // typedefs
60 
63  typedef std::list<Self> VertexCollection;
64  typedef typename VertexCollection::iterator VertexIndex;
65  typedef std::list<VertexIndex> VertexIndexCollection;
66 
68  typedef std::list<Face> FaceCollection;
69  typedef typename FaceCollection::iterator FaceIndex;
70  typedef std::list<FaceIndex> FaceIndexCollection;
71 
72  //typedef std::list<typename TPointerPolicy<Self>::type> NeighborCollection;
73  //typedef std::list<typename TPointerPolicy<MeshFaceNodeX<Self> >::type> FaceCollection;
74 
75  public: // set & get
76 
77  Vertex & pos() { return m_pos; }
78  Vertex const & pos() const { return m_pos; }
79 
80  VertexIndexCollection & neighbors() { return m_neighbors; }
81  VertexIndexCollection const & neighbors() const { return m_neighbors; }
82 
83  FaceIndexCollection & faces() { return m_faces; }
84  FaceIndexCollection const & faces() const { return m_faces; }
85 
86  TAttribute & attribute() { return m_attribute; }
87  TAttribute const & attribute() const { return m_attribute; }
88 
89  private: // data
90 
91  Vertex m_pos;
92  VertexIndexCollection m_neighbors;
93  FaceIndexCollection m_faces;
94  TAttribute m_attribute;
95  };
96 
97  //---------------------------------------------------------------------------
98 
99  template < typename TAttribute, typename TEdgeAttribute >
101  {
102  public: // typedefs
104  private: // data
105  TAttribute m_attribute;
106  std::list<std::pair<Self, TEdgeAttribute> > m_neighbors;
107  };
108 
109  template < typename TAttribute >
111  {
112  private: // data
113  TAttribute m_attribute;
114  // std::list<Edge> m_edges; // Edge is undeclared anyway
115  };
116 
117  //---------------------------------------------------------------------------
118 
119 } // namespace til
120 
121 
122 // Package include
123 #include "graph_accessors.h"
124 
125 #endif /*GRAPH_H_*/
Vertex const & pos() const
Definition: graph.h:78
std::list< typename std::list< SimpleOrientedGraphNode< T > >::iterator > from
Definition: graph.h:26
DirectedNode< TAttribute, TEdgeAttribute > Self
Definition: graph.h:103
SimpleOrientedGraphNode(const T &v)
Definition: graph.h:25
VertexCollection::iterator VertexIndex
Definition: graph.h:64
std::list< typename std::list< SimpleOrientedGraphNode< T > >::iterator > to
Definition: graph.h:27
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
FaceCollection::iterator FaceIndex
Definition: graph.h:69
MeshFaceNodeX< Self > Face
Definition: graph.h:67
std::list< Face > FaceCollection
Definition: graph.h:68
VertexIndexCollection & neighbors()
Definition: graph.h:80
FaceIndexCollection & faces()
Definition: graph.h:83
TAttribute const & attribute() const
Definition: graph.h:87
boost::array< typename std::list< TMeshVertexNode >::iterator, 3 > face
Definition: graph.h:36
std::list< Self > VertexCollection
Definition: graph.h:63
TAttribute & attribute()
Definition: graph.h:86
VertexIndexCollection const & neighbors() const
Definition: graph.h:81
til::numeric_array< float, 3 > Vertex
Definition: graph.h:62
std::list< VertexIndex > VertexIndexCollection
Definition: graph.h:65
MeshVertexNodeX< TAttribute > Self
Definition: graph.h:61
Vertex & pos()
Definition: graph.h:77
FaceIndexCollection const & faces() const
Definition: graph.h:84
std::list< FaceIndex > FaceIndexCollection
Definition: graph.h:70