SphericalGraph.h
Go to the documentation of this file.
1// *****************************************************************
2// Filename: AspectGraph.h
3// Copyright: Kai Welke, Chair Prof. Dillmann (IAIM),
4// Institute for Computer Science and Engineering (CSE),
5// University of Karlsruhe. All rights reserved.
6// Author: Kai Welke
7// Date: 12.06.2007
8// *****************************************************************
9
10#pragma once
11
12// *****************************************************************
13// includes
14// *****************************************************************
15// stl includes
16#include <istream>
17#include <ostream>
18#include <vector>
19
20// local includes
21#include "Structs.h"
22
23// *****************************************************************
24// defines
25// *****************************************************************
26#define MAX_NODES 100000
27
28// *****************************************************************
29// nodes and edges
30// *****************************************************************
32{
33public:
34 // indices of nodes
37
38 // indices of faces (needed in triangulation
41};
42
44{
45public:
47 {
48 }
49
51 {
52 m_Position = position;
53 }
54
55 virtual ~CSGNode()
56 {
57 }
58
61 {
62 return m_Position;
63 }
64
65 void
67 {
68 m_Position = position;
69 }
70
71 int
73 {
74 return m_nIndex;
75 }
76
77 void
78 setIndex(int nIndex)
79 {
80 m_nIndex = nIndex;
81 }
82
83 virtual CSGNode*
85 {
86 CSGNode* copy = new CSGNode(m_Position);
87 copy->setIndex(m_nIndex);
88 return copy;
89 }
90
91protected:
94};
95
96// *****************************************************************
97// types
98// *****************************************************************
99using TEdgeList = std::vector<CSGEdge*>;
100using TNodeList = std::vector<CSGNode*>;
101
102// *****************************************************************
103// definition of class CSphericalGraph
104// *****************************************************************
106{
107public:
108 ///////////////////////////////
109 // construction / destruction
110 ///////////////////////////////
112 CSphericalGraph(const CSphericalGraph& prototype);
113
114 virtual ~CSphericalGraph();
115
116 virtual CSGNode*
118 {
119 return new CSGNode();
120 }
121
122 ///////////////////////////////
123 // aspect graph manipulation
124 ///////////////////////////////
125 // clear graph
126 void clear();
127
128 // add nodes
129 int addNode(CSGNode* pNode);
130
131 // add edges
132 int addEdge(int nIndex1, int nIndex2);
133 int addEdge(int nIndex1, int nIndex2, int nLeftFace, int nRightFace);
134
135 // node adjacency (usually only required by addEdge)
136 void addNodeAdjacency(int nNode, int nAdjacency);
137
138 ///////////////////////////////
139 // member access
140 ///////////////////////////////
143
144 CSGEdge* getEdge(int nEdgeIndex);
145 CSGNode* getNode(int nIndex);
146 std::vector<int>* getNodeAdjacency(int nIndex);
147
148 ///////////////////////////////
149 // file io
150 ///////////////////////////////
151 virtual bool read(std::istream& infile);
152 virtual bool readNode(std::istream& infile);
153 virtual bool readEdge(std::istream& infile);
154
155 virtual bool write(std::ostream& outfile);
156 virtual bool writeNode(std::ostream& outfile, int n);
157 virtual bool writeEdge(std::ostream& outfile, int e);
158
159
160 ///////////////////////////////
161 // operators
162 ///////////////////////////////
164
165protected:
168 std::vector<int> m_NodeAdjacency[MAX_NODES];
169};
std::vector< CSGEdge * > TEdgeList
std::vector< CSGNode * > TNodeList
#define MAX_NODES
CSGNode(TSphereCoord position)
virtual ~CSGNode()
int getIndex()
virtual CSGNode * clone()
TSphereCoord getPosition()
TSphereCoord m_Position
void setPosition(TSphereCoord position)
void setIndex(int nIndex)
CSGEdge * getEdge(int nEdgeIndex)
virtual bool writeNode(std::ostream &outfile, int n)
void addNodeAdjacency(int nNode, int nAdjacency)
TNodeList * getNodes()
virtual ~CSphericalGraph()
virtual bool write(std::ostream &outfile)
std::vector< int > * getNodeAdjacency(int nIndex)
std::vector< int > m_NodeAdjacency[MAX_NODES]
virtual bool readNode(std::istream &infile)
virtual bool readEdge(std::istream &infile)
int addEdge(int nIndex1, int nIndex2)
TEdgeList * getEdges()
int addNode(CSGNode *pNode)
virtual bool writeEdge(std::ostream &outfile, int e)
CSGNode * getNode(int nIndex)
virtual CSGNode * getNewNode()
CSphericalGraph & operator=(CSphericalGraph const &rhs)
virtual bool read(std::istream &infile)