home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / graph.h < prev    next >
C/C++ Source or Header  |  2008-11-07  |  3KB  |  99 lines

  1. #ifndef K3DSDK_GRAPH_H
  2. #define K3DSDK_GRAPH_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2008, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. #include "attribute_arrays.h"
  24. #include "named_array_types.h"
  25. #include "typed_array.h"
  26. #include "uint_t_array.h"
  27.  
  28. #include <boost/graph/adjacency_list.hpp>
  29.  
  30. namespace k3d
  31. {
  32.  
  33. class inode;
  34.  
  35. ////////////////////////////////////////////////////////////////////////////////
  36. // graph
  37.  
  38. /// Encapsulates a directed graph stored as an adjacency list
  39. class graph
  40. {
  41. public:
  42.     graph();
  43.  
  44.     struct vertex
  45.     {
  46.     };
  47.  
  48.     struct edge
  49.     {
  50.         edge() : index(0) {}
  51.         uint_t index;
  52.     };
  53.  
  54.     /// Defines storage for a generic graph topology
  55.     typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, vertex, edge> adjacency_list_t;
  56.     typedef boost::graph_traits<adjacency_list_t>::vertex_descriptor vertex_descriptor_t;
  57.     typedef boost::graph_traits<adjacency_list_t>::edge_descriptor edge_descriptor_t;
  58.     typedef boost::graph_traits<adjacency_list_t>::vertex_iterator vertex_iterator_t;
  59.     typedef boost::graph_traits<adjacency_list_t>::edge_iterator edge_iterator_t;
  60.     typedef boost::graph_traits<adjacency_list_t>::out_edge_iterator out_edge_iterator_t;
  61.     typedef boost::graph_traits<adjacency_list_t>::in_edge_iterator in_edge_iterator_t;
  62.  
  63.     /// Defines storage for a generic collection of boolean values
  64.     typedef typed_array<bool_t> bools_t;
  65.     /// Defines storage for a generic collection of integer values
  66.     typedef typed_array<int32_t> ints_t;
  67.     /// Defines storage for a generic collection of index values
  68.     typedef uint_t_array indices_t;
  69.     /// Defines storage for a generic collection of floating-point values
  70.     typedef typed_array<double_t> doubles_t;
  71.     /// Defines storage for a generic collection of string values
  72.     typedef typed_array<string_t> strings_t;
  73.     /// Defines storage for a generic collection of two-dimensional points
  74.     typedef typed_array<point2> points_t;
  75.     /// Defines storage for a generic collection of two-dimensional vectors
  76.     typedef typed_array<vector2> vectors_t;
  77.     /// Defines storage for a generic collection of inode objects
  78.     typedef typed_array<inode*> nodes_t;
  79.     /// Defines a heterogeneous collection of named, shared arrays
  80.     typedef k3d::attribute_arrays attribute_arrays_t;
  81.  
  82.     /// Stores the graph topology
  83.     pipeline_data<adjacency_list_t> topology;
  84.     /// Stores user-defined per-graph data
  85.     attribute_arrays_t graph_data;
  86.     /// Stores user-defined per-vertex data
  87.     attribute_arrays_t vertex_data;
  88.     /// Stores user-defined per-edge data
  89.     attribute_arrays_t edge_data;
  90. };
  91.  
  92. /// Stream serialization
  93. std::ostream& operator<<(std::ostream& Stream, const graph& RHS);
  94.  
  95. } // namespace k3d
  96.  
  97. #endif // !K3DSDK_GRAPH_H
  98.  
  99.