diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-01-24 17:06:57 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-01-24 17:06:57 +0000 |
commit | b3654bd1ac7d38aaac0550de063158dbdf96522f (patch) | |
tree | 96c1cc52e51aad1bd063e9a5467fc0ca08ee6daa /src/Nerve_GIC/example/graph_off.cpp | |
parent | 3bb99253e96d186bdfb3c42ef112086dcf3157c5 (diff) |
added headers and examples for Nerve GIC
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2002 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 587a3e6748bb2b7313dbd1bd4e81c4a3b01a5efc
Diffstat (limited to 'src/Nerve_GIC/example/graph_off.cpp')
-rw-r--r-- | src/Nerve_GIC/example/graph_off.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Nerve_GIC/example/graph_off.cpp b/src/Nerve_GIC/example/graph_off.cpp new file mode 100644 index 00000000..574d9fc6 --- /dev/null +++ b/src/Nerve_GIC/example/graph_off.cpp @@ -0,0 +1,49 @@ +#include <iostream> +#include <set> +#include <fstream> +#include <vector> +#include <string.h> +#include <sstream> +#include <stdlib.h> +#include <algorithm> + +using namespace std; + +int main (int argc, char **argv) { + + char* const fileoff = argv[1]; ifstream input(fileoff); char ngoff[100]; sprintf(ngoff,"%s_NG", fileoff); ofstream output(ngoff); + char buf[256]; + vector<vector<int> > NG; + + input.getline(buf, 255); // skip "OFF" + int n, m; + input >> n >> m; + input.getline(buf, 255); // skip "0" + + // read vertices + double x,y,z; vector<int> ng; int nn = n; + while(nn-->0) { + input >> x >> z >> y; NG.push_back(ng); + } + + // read triangles + int d, p, q, s; + while (m-->0) { + input >> d >> p >> q >> s; + NG[p].push_back(q); NG[p].push_back(s); + NG[q].push_back(p); NG[q].push_back(s); + NG[s].push_back(q); NG[s].push_back(p); + } + + for(int i = 0; i < n; i++){ + vector<int> ng = NG[i]; + sort(ng.begin(),ng.end()); vector<int>::iterator iter = unique(ng.begin(),ng.end()); ng.resize(distance(ng.begin(),iter)); + int size = ng.size(); + for(int j = 0; j < size; j++) + output << ng[j] << " "; + output << endl; + } + + return 0; + +} |