#ifndef DUST3D_CYCLE_FINDER #define DUST3D_CYCLE_FINDER #include #include #include class CycleFinder { public: CycleFinder(const std::vector &nodePositions, const std::vector> &edges); void find(); const std::vector> &getCycles(); private: size_t m_nodeNum = 0; std::vector m_nodePositions; std::vector> m_edges; std::vector m_edgeLengths; std::map, int> m_edgeLengthMap; std::vector> m_cycles; std::vector m_cycleLengths; std::set> m_cycleEdges; std::set> m_halfEdges; float m_invalidFlatness = 1.0; void removeEdgeFrom(const std::pair &edge, std::vector> *edges, std::vector *edgeLengths); void prepareWeights(); bool validateCycleByFlatness(const std::vector &cycle); int calculateCycleLength(const std::vector &cycle); }; #endif