CycleDetection.h
1 #include "LineElement.h"
2 #include <iostream>
3 #include <stack>
4 
5 #pragma once
6 class CycleDetection
8 {
9 public:
17  CycleDetection(std::vector<LineElement*> elements);
18  ~CycleDetection();
19 
20  std::vector<std::vector<int>> cycles;
21  std::vector<std::vector<int>> graph;
22  std::vector<std::vector<LineElement*>> elementCycles;
23  typedef std::pair<int, int> Edge;
24  std::vector<std::vector<Edge>> edges;
25  std::vector<double> cycleArea;
26 
32  void constructGraph(std::vector<LineElement*> element);
33 
39  void findAllCycles();
40 
49  void findNewCycles(std::vector<int> path);
50 
56  void convertCyclesToEdges();
57 
61  void removeSuperCycles();
62 
74  void sortCycles();
75 
83  void convertEdgesToElements(std::vector<LineElement*> elements);
84 
90  void printCells();
91 
97  void calculateCellArea();
98 
104  void printEdgeCycles(std::vector<std::vector<Edge>> edges);
105 
111  void reverseCycle(int i);
112 
122  bool equals(std::vector<int> a, std::vector<int> b);
123 
130  bool isNew(std::vector<int> path);
131 
139  bool visited(int n, std::vector<int> path);
140 
146  int findSmallestElement(std::vector<int> path);
147 
153  std::vector<std::vector<LineElement*>> getAllCycles();
154 
162  std::vector<LineElement*> getOpenElements(std::vector<LineElement*> elements);
163 
172  std::vector<int> invert(std::vector<int> path);
173 
180  std::vector<int> normalize(std::vector<int> path);
181 
182 };
183 
std::pair< int, int > Edge
Defining an Edge to consist of to vertices (start and end) in the format of int&#39;s.
Definition: CycleDetection.h:23
Performs cycle detection on the cross section, used for determination of cells during thin-wall analy...
Definition: CycleDetection.h:7
void calculateCellArea()
Calculates the area of each cell.
Definition: CycleDetection.cpp:288
void printEdgeCycles(std::vector< std::vector< Edge >> edges)
Prints cycles and their edges.
Definition: CycleDetection.cpp:23
std::vector< std::vector< int > > cycles
Vector containing cycles in vertex form.
Definition: CycleDetection.h:20
void sortCycles()
Sorts cycles vector from largest cycles to the smallest cycles.
Definition: CycleDetection.cpp:189
std::vector< std::vector< int > > graph
Graph that is created from vertices and edges.
Definition: CycleDetection.h:21
bool visited(int n, std::vector< int > path)
Checks if node n is part of the path.
Definition: CycleDetection.cpp:175
bool isNew(std::vector< int > path)
Determines if a cycle is not discovered.
Definition: CycleDetection.cpp:161
std::vector< LineElement * > getOpenElements(std::vector< LineElement * > elements)
Gets all open elements.
Definition: CycleDetection.cpp:277
void findAllCycles()
Finds all cells in a cross-section without duplicates. Calls findNewCycle() from all the nodes in the...
Definition: CycleDetection.cpp:47
void findNewCycles(std::vector< int > path)
Finds new cells not previously found, and stores them as a vector of nodes.
Definition: CycleDetection.cpp:59
int findSmallestElement(std::vector< int > path)
Finds the smallest element in path.
Definition: CycleDetection.cpp:148
void convertEdgesToElements(std::vector< LineElement * > elements)
Converts the edges in cycles, to their corresponding elements.
Definition: CycleDetection.cpp:229
void convertCyclesToEdges()
Converts the cycles from storing nodes, to storing edges.
Definition: CycleDetection.cpp:256
std::vector< double > cycleArea
Vector containing the areas of all the cycles not containing other cycles.
Definition: CycleDetection.h:25
CycleDetection(std::vector< LineElement * > elements)
Constructor.
Definition: CycleDetection.cpp:4
void reverseCycle(int i)
Reverses the cycle.
Definition: CycleDetection.cpp:342
bool equals(std::vector< int > a, std::vector< int > b)
Determines if two vectors are equal, i.e contains the same nodes in the same order.
Definition: CycleDetection.cpp:101
std::vector< std::vector< Edge > > edges
Vector containing edges.
Definition: CycleDetection.h:24
std::vector< int > normalize(std::vector< int > path)
Rotates path so the smallest node is listed first.
Definition: CycleDetection.cpp:132
std::vector< std::vector< LineElement * > > elementCycles
Vector containing only the line elements that are a part of a cell (sub-cycle)
Definition: CycleDetection.h:22
void constructGraph(std::vector< LineElement * > element)
Creates graph from the elements provided.
Definition: CycleDetection.cpp:37
void removeSuperCycles()
Removes all cycles containing other (smaller) cycles.
Definition: CycleDetection.cpp:193
std::vector< std::vector< LineElement * > > getAllCycles()
Gets all cells that have been detected.
Definition: CycleDetection.cpp:273
std::vector< int > invert(std::vector< int > path)
Inverts a path.
Definition: CycleDetection.cpp:119
void printCells()
Prints all the cells found.
Definition: CycleDetection.cpp:350