#ifndef RBFCORE_H #define RBFCORE_H #include #include #include "Solver.h" #include "ImplicitedSurfacing.h" //#include "eigen3/Eigen/Dense" #include #include using namespace std; enum RBF_INPUT{ ON, ONandNORMAL, ALL, INandOUT, }; enum RBF_METHOD{ Variational, Variational_P, LS, LSinterp, Interp, RayleighQuotients, RayleighQuotients_P, RayleighQuotients_I, Hermite, Hermite_UnitNorm, Hermite_UnitNormal, Hermite_Tangent_UnitNorm, Hermite_Tangent_UnitNormal, HandCraft, Hermite_InitializationTest }; enum RBF_InitMethod{ GT_NORMAL, GlobalEigen, GlobalEigenWithMST, GlobalEigenWithGT, LocalEigen, IterativeEigen, ClusterEigen, Lamnbda_Search, GlobalMRF, Voronoi_Covariance, CNN, PCA, RBF_Init_EMPTY }; enum RBF_Kernal{ XCube, ThinSpline, XLinear, Gaussian, }; class RBF_Paras{ public: RBF_METHOD Method; RBF_Kernal Kernal; RBF_InitMethod InitMethod; bool isusesparse; int polyDeg; double sigma; double user_lamnbda; double rangevalue; double sparse_para = 1e-3; double Hermite_weight_smoothness; double Hermite_ls_weight; double Hermite_designcurve_weight; double ClusterCut_percentage; double ClusterCut_LocalMax_percentage; int ClusterVisualMethod; double wDir,wOrt,wFlip,handcraft_sigma; RBF_Paras(RBF_METHOD Method, RBF_Kernal Kernal, int polyDeg, double sigma, double user_lamnbda,double rangevalue):\ Method(Method),Kernal(Kernal),InitMethod(RBF_Init_EMPTY),polyDeg(polyDeg),sigma(sigma),user_lamnbda(user_lamnbda),rangevalue(rangevalue),Hermite_weight_smoothness(0){} RBF_Paras(){} }; class RBF_Core{ public: int npt; int polyDeg = 2; int bsize; bool isinv = true; bool isnewformula = true; double User_Lamnbda; RBF_Kernal kernal; RBF_METHOD curMethod; RBF_InitMethod curInitMethod; double rangevalue = 0.2; double maxvalue = 10000; vectorpts; vectornormals; vectortangents; vectoredges; vectorlabels; private: vectorinitnormals; vectorinitnormals_uninorm; public: vectornewnormals; public: vectorcoff_cos; vectorcoff_sin; public: vectorfinalMesh_v; vectorfinalMesh_fv; public: arma::mat M; arma::mat N; arma::vec a; arma::vec b; arma::mat Minv; arma::mat P; arma::mat K; arma::mat bprey; arma::mat saveK; arma::mat saveK_finalH; arma::mat finalH; arma::mat RQ; arma::mat bigM; arma::mat bigMinv; arma::mat Ninv; arma::mat K00; arma::mat K01; arma::mat K11; arma::mat dI; bool isuse_sparse = false; double sparse_para = 1e-3; public: unordered_mapmp_RBF_INITMETHOD; unordered_mapmp_RBF_METHOD; unordered_mapmp_RBF_Kernal; public: double (*Kernal_Function)(const double x); double (*Kernal_Function_2p)(const double *p1, const double *p2); double (*P_Function_2p)(const double *p1, const double *p2); public: bool isNewApprox; bool isHermite; double Hermite_weight_smoothness; double Hermite_ls_weight_inject, User_Lamnbda_inject; double Hermite_designcurve_weight; double ls_coef; void (*Kernal_Gradient_Function_2p)(const double *p1, const double *p2, double *G); void (*Kernal_Hessian_Function_2p)(const double *p1, const double *p2, double *H); private: vectorlocal_eigenBe, local_eigenEd, eigenBe, eigenEd, gtBe, gtEd; private: vector >lamnbdaGlobal_Be,lamnbdaGlobal_Ed; vectorlamnbda_list_sa; private: unordered_map > >mp_RBF_InitNormal; unordered_map > >mp_RBF_OptNormal; public: RBF_Core(); RBF_Core(RBF_Kernal kernal); void Init(RBF_Kernal kernal); public: double Dist_Function(const double x, const double y, const double z); inline double Dist_Function(const double *p); public: static double Dist_Function(const R3Pt &in_pt); //static FT Dist_Function(const Point_3 in_pt); int n_evacalls; public: void SetThis(); public: void SetSigma(double x); public: void NormalRecification(double maxlen, vector &nors); public: void Set_HermiteRBF(vector&pts); int Solve_HermiteRBF(vector&vn); public: void Set_Hermite_PredictNormal(vector&pts); public: int Solve_Hermite_PredictNormal_UnitNorm(); int Lamnbda_Search_GlobalEigen(); public: int Solve_Hermite_PredictNormal_UnitNormal(); public: void Print_LamnbdaSearchTest(string fname); public: void Set_RBFCoef(arma::vec &y); void Set_Actual_Hermite_LSCoef(double hermite_ls); void Set_HermiteApprox_Lamnda(double hermite_ls); void Set_Actual_User_LSCoef(double user_ls); void Set_User_Lamnda_ToMatrix(double user_ls); void Set_SparsePara(double spa); public: bool Write_Hermite_NormalPrediction(string fname,int mode); bool Write_Hermite_MST(string fname); void WriteSeletivePLY(string fname, vector&allnormals, vector&pickInd); void SetInitnormal_Uninorm(); void ClearSavedIterBatchInit(); void SaveIterBatchInit(vector&allnormals, vector&allnormals_uninorm, vector&pickInd); void Write_Surface(string fname); public: int Opt_Hermite_PredictNormal_UnitNormal(); public: int ThreeStep(vector &pts, vector &labels, vector &normals, vector &tangents, vector &edges, RBF_Paras para); int AllStep(vector &pts, vector &labels, vector &normals, vector &tangents, vector &edges, RBF_Paras para); int InjectData(vector &pts, vector &labels, vector &normals, vector &tangents, vector &edges, RBF_Paras para); int InjectData(vector &pts, RBF_Paras para); void BuildK(RBF_Paras para); void InitNormal(RBF_Paras para); void OptNormal(int method); void Surfacing(int method, int n_voxels_1d); void BuildCoherentGraph(); void BatchInitEnergyTest(vector &pts, vector &labels, vector &normals, vector &tangents, vector &edges, RBF_Paras para); public: vector* ExportPts(); vector* ExportPtsNormal(int normal_type); vector* ExportInitNormal(int kmethod, RBF_InitMethod init_type); vector* ExportOptNormal(int kmethod, RBF_InitMethod init_type); public: Solution_Struct sol; vectorrecord_partition; vectorrecord_partition_name; vectornpoints; vectorrecord_initmethod; vectorrecord_method; vectorrecord_kernal; vectorrecord_initenergy; vectorrecord_energy; vectorrecord_time; double setup_time, init_time, solve_time, callfunc_time,invM_time, setK_time, surf_time; vectorsetup_timev, init_timev, solve_timev, callfunc_timev,invM_timev,setK_timev; void Record(); void Record(RBF_METHOD method, RBF_Kernal kernal, Solution_Struct &rsol, double time); void AddPartition(string pname); void Print_Record(); void Print_TimerRecord(string fname); void Clear_TimerRecord(); void Print_Record_Init(); void Print_TimerRecord_Single(string fname); }; #endif // RBFCORE_H