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 <vector>
17 #include <istream>
18 #include <ostream>
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 // *****************************************************************
31 class CSGEdge
32 {
33 public:
34  // indices of nodes
35  int nIndex1;
36  int nIndex2;
37 
38  // indices of faces (needed in triangulation
39  int nLeftFace;
41 };
42 
43 class CSGNode
44 {
45 public:
46  CSGNode() {}
48  {
49  m_Position = position;
50  }
51  virtual ~CSGNode() {}
52 
54  {
55  return m_Position;
56  }
57  void setPosition(TSphereCoord position)
58  {
59  m_Position = position;
60  }
61 
62  int getIndex()
63  {
64  return m_nIndex;
65  }
66  void setIndex(int nIndex)
67  {
68  m_nIndex = nIndex;
69  }
70 
71  virtual CSGNode* clone()
72  {
74  copy->setIndex(m_nIndex);
75  return copy;
76  }
77 
78 protected:
80  int m_nIndex;
81 
82 };
83 
84 // *****************************************************************
85 // types
86 // *****************************************************************
87 using TEdgeList = std::vector<CSGEdge*>;
88 using TNodeList = std::vector<CSGNode*>;
89 
90 // *****************************************************************
91 // definition of class CSphericalGraph
92 // *****************************************************************
94 {
95 public:
96  ///////////////////////////////
97  // construction / destruction
98  ///////////////////////////////
100  CSphericalGraph(const CSphericalGraph& prototype);
101 
102  virtual ~CSphericalGraph();
103  virtual CSGNode* getNewNode()
104  {
105  return new CSGNode();
106  }
107 
108  ///////////////////////////////
109  // aspect graph manipulation
110  ///////////////////////////////
111  // clear graph
112  void clear();
113 
114  // add nodes
115  int addNode(CSGNode* pNode);
116 
117  // add edges
118  int addEdge(int nIndex1, int nIndex2);
119  int addEdge(int nIndex1, int nIndex2, int nLeftFace, int nRightFace);
120 
121  // node adjacency (usually only required by addEdge)
122  void addNodeAdjacency(int nNode, int nAdjacency);
123 
124  ///////////////////////////////
125  // member access
126  ///////////////////////////////
127  TEdgeList* getEdges();
128  TNodeList* getNodes();
129 
130  CSGEdge* getEdge(int nEdgeIndex);
131  CSGNode* getNode(int nIndex);
132  std::vector<int>* getNodeAdjacency(int nIndex);
133 
134  ///////////////////////////////
135  // file io
136  ///////////////////////////////
137  virtual bool read(std::istream& infile);
138  virtual bool readNode(std::istream& infile);
139  virtual bool readEdge(std::istream& infile);
140 
141  virtual bool write(std::ostream& outfile);
142  virtual bool writeNode(std::ostream& outfile, int n);
143  virtual bool writeEdge(std::ostream& outfile, int e);
144 
145 
146 
147  ///////////////////////////////
148  // operators
149  ///////////////////////////////
151 
152 protected:
155  std::vector<int> m_NodeAdjacency[MAX_NODES];
156 
157 };
158 
TNodeList
std::vector< CSGNode * > TNodeList
Definition: SphericalGraph.h:88
CSGNode::getIndex
int getIndex()
Definition: SphericalGraph.h:62
CSphericalGraph::operator=
CSphericalGraph & operator=(CSphericalGraph const &rhs)
Definition: SphericalGraph.cpp:35
CSGNode::setIndex
void setIndex(int nIndex)
Definition: SphericalGraph.h:66
CSphericalGraph::read
virtual bool read(std::istream &infile)
Definition: SphericalGraph.cpp:185
CSGEdge::nLeftFace
int nLeftFace
Definition: SphericalGraph.h:39
CSphericalGraph::getEdges
TEdgeList * getEdges()
Definition: SphericalGraph.cpp:157
CSGNode::CSGNode
CSGNode(TSphereCoord position)
Definition: SphericalGraph.h:47
CSphericalGraph::readNode
virtual bool readNode(std::istream &infile)
Definition: SphericalGraph.cpp:219
CSphericalGraph::addNode
int addNode(CSGNode *pNode)
Definition: SphericalGraph.cpp:96
CSGNode::m_nIndex
int m_nIndex
Definition: SphericalGraph.h:80
CSGNode::getPosition
TSphereCoord getPosition()
Definition: SphericalGraph.h:53
CSphericalGraph::getNewNode
virtual CSGNode * getNewNode()
Definition: SphericalGraph.h:103
CSphericalGraph::addEdge
int addEdge(int nIndex1, int nIndex2)
Definition: SphericalGraph.cpp:105
CSGNode::~CSGNode
virtual ~CSGNode()
Definition: SphericalGraph.h:51
CSGNode::m_Position
TSphereCoord m_Position
Definition: SphericalGraph.h:79
CSGEdge::nIndex2
int nIndex2
Definition: SphericalGraph.h:36
CSGNode::setPosition
void setPosition(TSphereCoord position)
Definition: SphericalGraph.h:57
CSphericalGraph::CSphericalGraph
CSphericalGraph()
Definition: SphericalGraph.cpp:20
CSGNode::CSGNode
CSGNode()
Definition: SphericalGraph.h:46
Structs.h
CSGEdge
Definition: SphericalGraph.h:31
CSGNode
Definition: SphericalGraph.h:43
MAX_NODES
#define MAX_NODES
Definition: SphericalGraph.h:26
CSGEdge::nRightFace
int nRightFace
Definition: SphericalGraph.h:40
CSphericalGraph::m_Nodes
TNodeList m_Nodes
Definition: SphericalGraph.h:154
copy
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition: license.txt:39
CSphericalGraph::readEdge
virtual bool readEdge(std::istream &infile)
Definition: SphericalGraph.cpp:243
CSphericalGraph::getNodeAdjacency
std::vector< int > * getNodeAdjacency(int nIndex)
Definition: SphericalGraph.cpp:177
CSphericalGraph::clear
void clear()
Definition: SphericalGraph.cpp:67
CSphericalGraph::writeNode
virtual bool writeNode(std::ostream &outfile, int n)
Definition: SphericalGraph.cpp:291
CSphericalGraph::m_Edges
TEdgeList m_Edges
Definition: SphericalGraph.h:153
CSphericalGraph::getNodes
TNodeList * getNodes()
Definition: SphericalGraph.cpp:162
CSGEdge::nIndex1
int nIndex1
Definition: SphericalGraph.h:35
TEdgeList
std::vector< CSGEdge * > TEdgeList
Definition: SphericalGraph.h:87
CSphericalGraph::getEdge
CSGEdge * getEdge(int nEdgeIndex)
Definition: SphericalGraph.cpp:167
CSphericalGraph::addNodeAdjacency
void addNodeAdjacency(int nNode, int nAdjacency)
Definition: SphericalGraph.cpp:130
CSphericalGraph::writeEdge
virtual bool writeEdge(std::ostream &outfile, int e)
Definition: SphericalGraph.cpp:303
CSphericalGraph::m_NodeAdjacency
std::vector< int > m_NodeAdjacency[MAX_NODES]
Definition: SphericalGraph.h:155
CSphericalGraph
Definition: SphericalGraph.h:93
TSphereCoord
Definition: Structs.h:22
CSphericalGraph::write
virtual bool write(std::ostream &outfile)
Definition: SphericalGraph.cpp:258
CSGNode::clone
virtual CSGNode * clone()
Definition: SphericalGraph.h:71
CSphericalGraph::getNode
CSGNode * getNode(int nIndex)
Definition: SphericalGraph.cpp:172
CSphericalGraph::~CSphericalGraph
virtual ~CSphericalGraph()
Definition: SphericalGraph.cpp:30