1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <iostream>
#include <unistd.h>
#include "src/rbfcore.h"
#include "src/readers.h"
using namespace std;



void SplitPath(const std::string& fullfilename,std::string &filepath);
void SplitFileName (const std::string& fullfilename,std::string &filepath,std::string &filename,std::string &extname);
RBF_Paras Set_RBF_PARA();
int main(int argc, char** argv)
{
    cout << argc << endl;



    string infilename;
    string outpath, pcname, ext, inpath;

    int n_voxel_line = 100;

    double user_lambda = 0;

    bool is_surfacing = false;
    bool is_outputtime = false;

    int c;
    optind=1;
    while ((c = getopt(argc, argv, "i:o:l:s:t")) != -1) {
        switch (c) {
        case 'i':
            infilename = optarg;
            break;
        case 'o':
            outpath = string(optarg);
            break;
        case 'l':
            user_lambda = atof(optarg);
            break;
        case 's':
            is_surfacing = true;
            n_voxel_line = atoi(optarg);
            break;
        case 't':
            is_outputtime = true;
            break;
        case '?':
            cout << "Bad argument setting!" << endl;
            break;
        }
    }

    if(outpath.empty())SplitFileName(infilename,outpath,pcname,ext);
    else SplitFileName(infilename,inpath,pcname,ext);
    cout<<"input file: "<<infilename<<endl;
    cout<<"output path: "<<outpath<<endl;

    cout<<"user lambda: "<<user_lambda<<endl;
    cout<<"is surfacing: "<<is_surfacing<<endl;

    cout<<"number of voxel per D: "<<n_voxel_line<<endl;


    vector<double>Vs;
    RBF_Core rbf_core;
    RBF_Paras para = Set_RBF_PARA();
    para.user_lamnbda = user_lambda;

    readXYZ(infilename,Vs);
    rbf_core.InjectData(Vs,para);
    rbf_core.BuildK(para);
    rbf_core.InitNormal(para);
    rbf_core.OptNormal(0);

    rbf_core.Write_Hermite_NormalPrediction(outpath+pcname+"_normal", 1);

    if(is_surfacing){
        rbf_core.Surfacing(0,n_voxel_line);
        rbf_core.Write_Surface(outpath+pcname+"_surface");
    }

    if(is_outputtime){
        rbf_core.Print_TimerRecord_Single(outpath+pcname+"_time.txt");
    }








    return 0;
}







RBF_Paras Set_RBF_PARA(){

    RBF_Paras para;
    RBF_InitMethod initmethod = Lamnbda_Search;

    RBF_Kernal Kernal = XCube;
    int polyDeg = 1;
    double sigma = 0.9;
    double rangevalue = 0.001;

    para.Kernal = Kernal;para.polyDeg = polyDeg;para.sigma = sigma;para.rangevalue = rangevalue;
    para.Hermite_weight_smoothness = 0.0;
    para.Hermite_ls_weight = 0;
    para.Hermite_designcurve_weight = 00.0;
    para.Method = RBF_METHOD::Hermite_UnitNormal;


    para.InitMethod = initmethod;

    para.user_lamnbda = 0;

    para.isusesparse = false;


    return para;
}


inline void SplitFileName (const std::string& fullfilename,std::string &filepath,std::string &filename,std::string &extname) {
    int pos;
    pos = fullfilename.find_last_of('.');
    filepath = fullfilename.substr(0,pos);
    extname = fullfilename.substr(pos);
    pos = filepath.find_last_of("\\/");
    filename = filepath.substr(pos+1);
    pos = fullfilename.find_last_of("\\/");
    filepath = fullfilename.substr(0,pos+1);
    //cout<<modname<<' '<<extname<<' '<<filepath<<endl;
}

void SplitPath(const std::string& fullfilename,std::string &filepath){

    std::string filename;
    std::string extname;
    SplitFileName(fullfilename, filepath, filename,extname);
}