-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (29 loc) · 1013 Bytes
/
main.cpp
File metadata and controls
37 lines (29 loc) · 1013 Bytes
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
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <PolygonSimplification.hpp>
using namespace com::geopipe::PolySimp;
int main(int argc, const char* argv[]) {
int ret;
if((!argc % 2)){
std::cout << argv[0] << " x0 y0 [... xn yn]" << std::endl;
ret = -1;
} else {
typedef const char * (*CStrPair)[2];
CStrPair arg_pairs = (CStrPair)(argv + 1);
std::vector<CGALPoint> problemNodes;
std::transform(arg_pairs, arg_pairs + (argc / 2), std::back_inserter(problemNodes),
[](const char *(arg[2])){
return CGALPoint(std::atof(arg[0]), std::atof(arg[1]));
});
CGALPolygon test(problemNodes.cbegin(), problemNodes.cend());
std::vector<CGALPolygon> fixed = simplifyPolygon(test);
std::cout << "Finished set: " << std::endl;
std::for_each(fixed.cbegin(), fixed.cend(), [](const CGALPolygon &poly){
std::cout << "\t" << poly << " ( is simple? " << poly.is_simple() << " )" << std::endl;
});
ret = 0;
}
return ret;
}