#ifndef HIERARCHY_H_ #define HIERARCHY_H_ #ifdef WITH_CUDA # include #endif #include #include #include "adjacent-matrix.hpp" #include "config.hpp" #include "serialize.hpp" #define RCPOVERFLOW 2.93873587705571876e-39f using namespace Eigen; namespace qflow { class Hierarchy { public: Hierarchy(); void Initialize(double scale, int with_scale = 0); void DownsampleGraph(const AdjacentMatrix adj, const MatrixXd& V, const MatrixXd& N, const VectorXd& A, MatrixXd& V_p, MatrixXd& N_p, VectorXd& A_p, MatrixXi& to_upper, VectorXi& to_lower, AdjacentMatrix& adj_p); void generate_graph_coloring_deterministic(const AdjacentMatrix& adj, int size, std::vector>& phases); void FixFlip(); int FixFlipSat(int depth, int threshold = 0); void PushDownwardFlip(int depth); void PropagateEdge(); void DownsampleEdgeGraph(std::vector& FQ, std::vector& F2E, std::vector& edge_diff, std::vector& allow_changes, int level); void UpdateGraphValue(std::vector& FQ, std::vector& F2E, std::vector& edge_diff); enum { MAX_DEPTH = 25 }; void SaveToFile(FILE* fp); void LoadFromFile(FILE* fp); void clearConstraints(); void propagateConstraints(); double mScale; int rng_seed; MatrixXi mF; // mF(i, j) i \in [0, 3) ith index in face j VectorXi mE2E; // inverse edge std::vector mAdj; std::vector mV; std::vector mN; std::vector mA; std::vector>> mPhases; // parameters std::vector mQ; std::vector mO; std::vector mToLower; std::vector mToUpper; // mToUpper[h](i, j) \in V; i \in [0, 2); j \in V std::vector mS; std::vector mK; // constraints std::vector mCQ; std::vector mCO; std::vector mCQw; std::vector mCOw; int with_scale; // upper: fine to coarse std::vector> mToUpperFaces; // face correspondance std::vector> mSing; std::vector> mToUpperEdges; // edge correspondance std::vector> mToUpperOrients; // rotation of edges from fine to coarse std::vector> mFQ; // face_edgeOrients std::vector> mF2E; // face_edgeIds std::vector> mE2F; // undirect edges to face ID std::vector > mAllowChanges; std::vector> mEdgeDiff; // face_edgeDiff #ifdef WITH_CUDA std::vector cudaAdj; std::vector cudaAdjOffset; std::vector cudaN; std::vector cudaV; std::vector cudaQ; std::vector cudaO; std::vector> cudaPhases; std::vector cudaToUpper; void CopyToDevice(); void CopyToHost(); #endif }; } // namespace qflow #endif