MySources/trianglepattterntopology.hpp

50 lines
1.8 KiB
C++
Executable File

#ifndef FLATPATTTERNTOPOLOGY_HPP
#define FLATPATTTERNTOPOLOGY_HPP
#include <boost/graph/adjacency_list.hpp>
#include <unordered_map>
#include <unordered_set>
#include <vcg/space/point2.h>
#include <vector>
using BoostGraph =
boost::adjacency_list<boost::hash_setS, boost::vecS, boost::undirectedS>;
using vertex_t = boost::graph_traits<BoostGraph>::vertex_descriptor;
class FlatPatternTopology {
public:
bool containsArticulationPoints() const;
FlatPatternTopology(const std::vector<size_t> &numberOfNodesPerSlot,
const std::vector<vcg::Point2i> &edges);
static void
constructNodeToSlotMap(const std::vector<size_t> &numberOfNodesPerSlot,
std::unordered_map<size_t, size_t> &nodeToSlot);
static void constructSlotToNodeMap(
const std::unordered_map<size_t, size_t> &nodeToSlot,
std::unordered_map<size_t, std::unordered_set<size_t>> &slotToNode);
FlatPatternTopology();
private:
BoostGraph pattern;
std::vector<size_t> numberOfNodesPerSlot;
std::unordered_map<size_t, size_t> nodeToSlot;
std::unordered_map<size_t, std::unordered_set<size_t>> slotToNode;
std::unordered_map<size_t, size_t> correspondingNode;
void constructCorresponginNodeMap();
/*
* Creates a pattern which is a copy of the input pattern but with added edges
* that result
* */
void printGraph(const BoostGraph &g) const;
static BoostGraph constructRotationallySymmetricPattern(
const BoostGraph &pattern,
const std::unordered_map<size_t, std::unordered_set<size_t>> &slotToNodes,
const std::unordered_map<size_t, size_t> &nodeToSlot,
const std::unordered_map<size_t, size_t> &correspondingNode);
void constructNodeToSlotMap();
void constructSlotToNodeMap();
};
#endif // FLATPATTTERNTOPOLOGY_HPP