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 // *****************************************************************
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:
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  {
87  copy->setIndex(m_nIndex);
88  return copy;
89  }
90 
91 protected:
93  int m_nIndex;
94 };
95 
96 // *****************************************************************
97 // types
98 // *****************************************************************
99 using TEdgeList = std::vector<CSGEdge*>;
100 using TNodeList = std::vector<CSGNode*>;
101 
102 // *****************************************************************
103 // definition of class CSphericalGraph
104 // *****************************************************************
106 {
107 public:
108  ///////////////////////////////
109  // construction / destruction
110  ///////////////////////////////
111  CSphericalGraph();
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  ///////////////////////////////
141  TEdgeList* getEdges();
142  TNodeList* getNodes();
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 
165 protected:
168  std::vector<int> m_NodeAdjacency[MAX_NODES];
169 };
TNodeList
std::vector< CSGNode * > TNodeList
Definition: SphericalGraph.h:100
CSGNode::getIndex
int getIndex()
Definition: SphericalGraph.h:72
CSphericalGraph::operator=
CSphericalGraph & operator=(CSphericalGraph const &rhs)
Definition: SphericalGraph.cpp:37
CSGNode::setIndex
void setIndex(int nIndex)
Definition: SphericalGraph.h:78
CSphericalGraph::read
virtual bool read(std::istream &infile)
Definition: SphericalGraph.cpp:197
CSGEdge::nLeftFace
int nLeftFace
Definition: SphericalGraph.h:39
CSphericalGraph::getEdges
TEdgeList * getEdges()
Definition: SphericalGraph.cpp:164
CSGNode::CSGNode
CSGNode(TSphereCoord position)
Definition: SphericalGraph.h:50
CSphericalGraph::readNode
virtual bool readNode(std::istream &infile)
Definition: SphericalGraph.cpp:231
CSphericalGraph::addNode
int addNode(CSGNode *pNode)
Definition: SphericalGraph.cpp:99
CSGNode::m_nIndex
int m_nIndex
Definition: SphericalGraph.h:93
CSGNode::getPosition
TSphereCoord getPosition()
Definition: SphericalGraph.h:60
CSphericalGraph::getNewNode
virtual CSGNode * getNewNode()
Definition: SphericalGraph.h:117
CSphericalGraph::addEdge
int addEdge(int nIndex1, int nIndex2)
Definition: SphericalGraph.cpp:109
CSGNode::~CSGNode
virtual ~CSGNode()
Definition: SphericalGraph.h:55
CSGNode::m_Position
TSphereCoord m_Position
Definition: SphericalGraph.h:92
CSGEdge::nIndex2
int nIndex2
Definition: SphericalGraph.h:36
CSGNode::setPosition
void setPosition(TSphereCoord position)
Definition: SphericalGraph.h:66
CSphericalGraph::CSphericalGraph
CSphericalGraph()
Definition: SphericalGraph.cpp:21
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:167
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:254
CSphericalGraph::getNodeAdjacency
std::vector< int > * getNodeAdjacency(int nIndex)
Definition: SphericalGraph.cpp:188
CSphericalGraph::clear
void clear()
Definition: SphericalGraph.cpp:69
CSphericalGraph::writeNode
virtual bool writeNode(std::ostream &outfile, int n)
Definition: SphericalGraph.cpp:302
CSphericalGraph::m_Edges
TEdgeList m_Edges
Definition: SphericalGraph.h:166
CSphericalGraph::getNodes
TNodeList * getNodes()
Definition: SphericalGraph.cpp:170
CSGEdge::nIndex1
int nIndex1
Definition: SphericalGraph.h:35
TEdgeList
std::vector< CSGEdge * > TEdgeList
Definition: SphericalGraph.h:99
CSphericalGraph::getEdge
CSGEdge * getEdge(int nEdgeIndex)
Definition: SphericalGraph.cpp:176
CSphericalGraph::addNodeAdjacency
void addNodeAdjacency(int nNode, int nAdjacency)
Definition: SphericalGraph.cpp:136
CSphericalGraph::writeEdge
virtual bool writeEdge(std::ostream &outfile, int e)
Definition: SphericalGraph.cpp:315
CSphericalGraph::m_NodeAdjacency
std::vector< int > m_NodeAdjacency[MAX_NODES]
Definition: SphericalGraph.h:168
CSphericalGraph
Definition: SphericalGraph.h:105
TSphereCoord
Definition: Structs.h:23
CSphericalGraph::write
virtual bool write(std::ostream &outfile)
Definition: SphericalGraph.cpp:269
CSGNode::clone
virtual CSGNode * clone()
Definition: SphericalGraph.h:84
CSphericalGraph::getNode
CSGNode * getNode(int nIndex)
Definition: SphericalGraph.cpp:182
CSphericalGraph::~CSphericalGraph
virtual ~CSphericalGraph()
Definition: SphericalGraph.cpp:31