HOG2
LoadedCliqueAbstraction.h
Go to the documentation of this file.
1 /*
2  * $Id: LoadedCliqueAbstraction.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 3/10/06.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 #include "GraphAbstraction.h"
13 #include "GLUtil.h"
14 
15 #ifndef loadedCLIQUEABSTRACTION_H
16 #define loadedCLIQUEABSTRACTION_H
17 
23 public:
26  virtual ~LoadedCliqueAbstraction();
27  virtual void VerifyHierarchy();
28  double h(node *a, node *b);
29  // virtual void draw();
30  // virtual void rebuild();
31  // virtual int GetRevision() { return 0; }
32 
33  bool Pathable(node *from, node *to);
34  bool Pathable(unsigned int from, unsigned int to);
35  //path *getQuickPath(node *from, node *to);
36  void GetNumAbstractGraphs(node *from, node *to, std::vector<node *> &fromChain, std::vector<node *> &toChain);
37  //node *GetNthParent(node *, int n);
38 
39  void clearDisplayLists();
40  void OpenGLDraw() const;
41  void ToggleDrawAbstraction(int which);
42  void DrawLevelConnections(node *n) const;
43  void DrawGraph(Graph *g) const;
44  recVec GetNodeLoc(node *n) const;
45 
46  // first step to allowing simple loaded adjustments...
47  virtual void RemoveNode(node *n);
48  void RemoveEdge(edge *e, unsigned int absLevel);
49  virtual void AddNode(node *n);
50  virtual void AddEdge(edge *e, unsigned int absLevel);
51  // this must be called after RemoveEdge, but RemoveNode will take care of itself
52  void RepairAbstraction();
54  edge *findEdgeParent(edge *e, unsigned int absLevel);
55 
56  // virtual int getNumPrimitiveActions() = 0;
57  // virtual node *getNodeForPrimitiveAction(node *, int) = 0;
58 protected:
59  Graph *loadGraph(char *fname);
60  virtual Graph *abstractGraph(Graph *g);
61  virtual Graph *cliqueAbstractGraph(Graph *g);
62  virtual Graph *neighborAbstractGraph(Graph *g, int width = 1);
63  void addNodesToParent(Graph *g, node *n, node *parent, int width);
64  void addTunnel(node *n, Graph *g, node *newNode);
65  void renameNodeInAbstraction(node *which, unsigned int oldID);
66  int getChildGroups(node *which);
67  void splitNode(node *which, int numGroups);
68  void addNodeToRepairQ(node *n);
69  void removeNodeFromRepairQ(node *n);
70  //void removeDiagonalEdgesAroundNode(node *n);
71 
72  // helper functions for splitting nodes
73  void resetLocationCache(node *n);
74  void checkAndCreateParent(node *which);
75  void insertNodeIntoHierarchy(node *newNode);
76  //void transferNode(node *which, node *oldParent, node *newParent, int whichChild);
77  void transferGroup(int group, node *oldParent, node *newParent);
78  void abstractUpEdge(unsigned int absLevel, edge *e);
79  void extractGroupIntoNewNode(node *parent, int group);
80  void mergeGroupIntoNeighbor(node *parent, int group, node *neighbor = 0);
81  bool checkNeighborClique(node *child, node *neighbor);
82  node *findNeighborCliques(node *parent, int group);
84  int getGroupSize(node *parent, int group);
85  node *getNodeInGroup(node *parent, int group);
86 private:
87  unsigned long levelDraw;
88 
89  void buildAbstractions(Graph*);
90  void cleanMemory();
91 
92  std::vector<GLuint> displayLists;
93  // temporary Q for nodes that are modified in the abstraction
94  // we can then process them for changes all at once.
95  std::vector<node *> modifiedNodeQ;
96 };
97 
98 #endif
LoadedCliqueAbstraction::getGroupSize
int getGroupSize(node *parent, int group)
Definition: LoadedCliqueAbstraction.cpp:1430
LoadedCliqueAbstraction::insertNodeIntoHierarchy
void insertNodeIntoHierarchy(node *newNode)
Definition: LoadedCliqueAbstraction.cpp:1586
LoadedCliqueAbstraction::renameNodeInAbstraction
void renameNodeInAbstraction(node *which, unsigned int oldID)
Definition: LoadedCliqueAbstraction.cpp:1837
GraphAbstraction
A generic class for basic operations on Graph abstractions.
Definition: GraphAbstraction.h:63
LoadedCliqueAbstraction::splitNode
void splitNode(node *which, int numGroups)
Definition: LoadedCliqueAbstraction.cpp:1326
LoadedCliqueAbstraction::GetNodeLoc
recVec GetNodeLoc(node *n) const
Definition: LoadedCliqueAbstraction.cpp:158
LoadedCliqueAbstraction::GetNumAbstractGraphs
void GetNumAbstractGraphs(node *from, node *to, std::vector< node * > &fromChain, std::vector< node * > &toChain)
LoadedCliqueAbstraction::loadGraph
Graph * loadGraph(char *fname)
Definition: LoadedCliqueAbstraction.cpp:195
LoadedCliqueAbstraction::abstractGraph
virtual Graph * abstractGraph(Graph *g)
Definition: LoadedCliqueAbstraction.cpp:425
graphMove
Definition: GraphEnvironment.h:34
recVec
A generic vector (essentially the same as a point, but offers normalization)
Definition: GLUtil.h:78
LoadedCliqueAbstraction::buildAbstractions
void buildAbstractions(Graph *)
Definition: LoadedCliqueAbstraction.cpp:396
LoadedCliqueAbstraction::levelDraw
unsigned long levelDraw
Definition: LoadedCliqueAbstraction.h:87
LoadedCliqueAbstraction::AddNode
virtual void AddNode(node *n)
add node to abstraction
Definition: LoadedCliqueAbstraction.cpp:1098
LoadedCliqueAbstraction::RepairAbstraction
void RepairAbstraction()
This must be called after any of the above add/remove operations.
Definition: LoadedCliqueAbstraction.cpp:1235
LoadedCliqueAbstraction::removeNodeFromRepairQ
void removeNodeFromRepairQ(node *n)
Definition: LoadedCliqueAbstraction.cpp:1156
LoadedCliqueAbstraction::VerifyHierarchy
virtual void VerifyHierarchy()
verify that the hierarchy is consistent
Definition: LoadedCliqueAbstraction.cpp:255
LoadedCliqueAbstraction::abstractUpEdge
void abstractUpEdge(unsigned int absLevel, edge *e)
Definition: LoadedCliqueAbstraction.cpp:1751
width
int width
Definition: SFML_HOG.cpp:54
LoadedCliqueAbstraction::cleanMemory
void cleanMemory()
Definition: LoadedCliqueAbstraction.cpp:375
LoadedCliqueAbstraction::h
double h(node *a, node *b)
heuristic cost between any two nodes
Definition: LoadedCliqueAbstraction.cpp:60
LoadedCliqueAbstraction::DrawGraph
void DrawGraph(Graph *g) const
Definition: LoadedCliqueAbstraction.cpp:101
LoadedCliqueAbstraction::modifiedNodeQ
std::vector< node * > modifiedNodeQ
Definition: LoadedCliqueAbstraction.h:95
Graph
A generic Graph class.
Definition: Graph.h:66
LoadedCliqueAbstraction::clearDisplayLists
void clearDisplayLists()
Definition: LoadedCliqueAbstraction.cpp:387
LoadedCliqueAbstraction::extractGroupIntoNewNode
void extractGroupIntoNewNode(node *parent, int group)
Definition: LoadedCliqueAbstraction.cpp:1563
LoadedCliqueAbstraction::mergeGroupIntoNeighbor
void mergeGroupIntoNeighbor(node *parent, int group, node *neighbor=0)
Definition: LoadedCliqueAbstraction.cpp:1515
LoadedCliqueAbstraction::RemoveEdge
void RemoveEdge(edge *e, unsigned int absLevel)
remove edge from abstraction
Definition: LoadedCliqueAbstraction.cpp:1110
LoadedCliqueAbstraction::~LoadedCliqueAbstraction
virtual ~LoadedCliqueAbstraction()
Definition: LoadedCliqueAbstraction.cpp:55
LoadedCliqueAbstraction::OpenGLDraw
void OpenGLDraw() const
Definition: LoadedCliqueAbstraction.cpp:89
LoadedCliqueAbstraction::displayLists
std::vector< GLuint > displayLists
Definition: LoadedCliqueAbstraction.h:92
LoadedCliqueAbstraction::findEdgeParent
edge * findEdgeParent(edge *e, unsigned int absLevel)
Definition: LoadedCliqueAbstraction.cpp:1816
LoadedCliqueAbstraction::LoadedCliqueAbstraction
LoadedCliqueAbstraction(char *)
Construct a new Graph hierarchy.
Definition: LoadedCliqueAbstraction.cpp:40
LoadedCliqueAbstraction::transferGroup
void transferGroup(int group, node *oldParent, node *newParent)
Definition: LoadedCliqueAbstraction.cpp:1679
LoadedCliqueAbstraction::getNodeInGroup
node * getNodeInGroup(node *parent, int group)
Definition: LoadedCliqueAbstraction.cpp:1414
LoadedCliqueAbstraction::ToggleDrawAbstraction
void ToggleDrawAbstraction(int which)
Definition: LoadedCliqueAbstraction.cpp:80
LoadedCliqueAbstraction::RemoveNode
virtual void RemoveNode(node *n)
remove node from abstraction
Definition: LoadedCliqueAbstraction.cpp:1169
GLUtil.h
LoadedCliqueAbstraction::findNeighborCliques
node * findNeighborCliques(node *parent, int group)
Definition: LoadedCliqueAbstraction.cpp:1448
LoadedCliqueAbstraction::DrawLevelConnections
void DrawLevelConnections(node *n) const
Definition: LoadedCliqueAbstraction.cpp:137
LoadedCliqueAbstraction::checkAndCreateParent
void checkAndCreateParent(node *which)
Definition: LoadedCliqueAbstraction.cpp:1656
LoadedCliqueAbstraction::addNodesToParent
void addNodesToParent(Graph *g, node *n, node *parent, int width)
Definition: LoadedCliqueAbstraction.cpp:476
LoadedCliqueAbstraction::resetLocationCache
void resetLocationCache(node *n)
Definition: LoadedCliqueAbstraction.cpp:1790
LoadedCliqueAbstraction::findNodeParent
node * findNodeParent(node *n)
Definition: LoadedCliqueAbstraction.cpp:1804
LoadedCliqueAbstraction::addTunnel
void addTunnel(node *n, Graph *g, node *newNode)
Definition: LoadedCliqueAbstraction.cpp:1027
LoadedCliqueAbstraction::AddEdge
virtual void AddEdge(edge *e, unsigned int absLevel)
add edge to abstraction
Definition: LoadedCliqueAbstraction.cpp:1103
LoadedCliqueAbstraction::cliqueAbstractGraph
virtual Graph * cliqueAbstractGraph(Graph *g)
Definition: LoadedCliqueAbstraction.cpp:500
LoadedCliqueAbstraction::addNodeToRepairQ
void addNodeToRepairQ(node *n)
Definition: LoadedCliqueAbstraction.cpp:1138
LoadedCliqueAbstraction::neighborAbstractGraph
virtual Graph * neighborAbstractGraph(Graph *g, int width=1)
Definition: LoadedCliqueAbstraction.cpp:430
LoadedCliqueAbstraction::Pathable
bool Pathable(node *from, node *to)
is there a legal path between these 2 nodes?
Definition: LoadedCliqueAbstraction.cpp:1055
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
GraphAbstraction.h
LoadedCliqueAbstraction::getChildGroups
int getChildGroups(node *which)
Definition: LoadedCliqueAbstraction.cpp:1272
LoadedCliqueAbstraction
A loaded abstraction based on the reduction of cliques.
Definition: LoadedCliqueAbstraction.h:22
LoadedCliqueAbstraction::checkNeighborClique
bool checkNeighborClique(node *child, node *neighbor)
Definition: LoadedCliqueAbstraction.cpp:1488
edge
Edge class for connections between node in a Graph.
Definition: Graph.h:129