fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGDirectedGraph.h
blob01fbb4fb1160e41675aaa459dda742eed26e1a93
1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
3 * *
4 * *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
6 * *
7 * http://cg.cs.uni-bonn.de/ *
8 * *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_DIRECTEDGRAPH_H_
39 #define _OSG_DIRECTEDGRAPH_H_
40 #ifdef __sgi
41 #pragma once
42 #endif
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
48 #include <iostream>
49 #include <fstream>
50 #include <iomanip>
52 #include "OSGdctptypes.h"
54 OSG_BEGIN_NAMESPACE
56 template <class T1>
57 class OSG_DRAWABLE_DLLMAPPING DirectedEdge
59 public:
60 bool direction; // true if directed
61 int from; // starting node
62 int to; // ending node
63 bool valid;
64 T1 edgeinfo;
66 typedef std::vector <DirectedEdge<T1> > edgevector;
68 DirectedEdge(void):
69 direction(true), from(0), to(0), valid(false), edgeinfo() {}
73 template <class T0>
74 class OSG_DRAWABLE_DLLMAPPING DirectedNode
76 public:
77 DCTPivector edges; // vector (pointers) of edges going to/from this node
78 T0 nodeinfo;
80 typedef std::vector <DirectedNode<T0> > nodevector;
82 DirectedNode(void) : edges(), nodeinfo() {}
85 template <class T0, class T1>
86 class OSG_DRAWABLE_DLLMAPPING DirectedGraph
89 public:
90 DirectedGraph();
91 // copy constructor
92 DirectedGraph(const DirectedGraph &d) :
93 nodes (d.nodes ),
94 edges (d.edges ),
95 invalid(d.invalid)
98 ~DirectedGraph() {}
100 int AddNode(T0 &n); // add a new node
101 int AddEdge(T1 &t, int from, int to, bool direction); // add a new (possibly directed) edge
102 int DeleteEdge(int edgeidx); // delete edge specified by the index
103 DCTPivector & getEdges(int n); // get all edges (indexes) from a node
104 DirectedNode<T0>& getNode(int nodeindex, int &error); // get one node
105 DirectedEdge<T1>& getEdge(int edgeindex, int &error); // get one edge
106 bool getEdgeDirection(int edgeindex, int &error); // get one edge's direction
107 int setEdgeDirection(int edgeindex, int to); // set the direction of an edge
108 int changeEdgeDirection(int edgeindex); // change (invert) the direction of an edge
109 int FindNode(T0 &nodeinfo);
110 int FindEdge(int from, int to);
112 bool isInvalid(void);
115 //private:
117 typename DirectedNode<T0>::nodevector nodes;
118 typename DirectedEdge<T1>::edgevector edges;
119 bool invalid;
122 OSG_END_NAMESPACE
124 #include "OSGDirectedGraph.inl"
126 #endif // DirectedGraph.h