-
Notifications
You must be signed in to change notification settings - Fork 21
/
dc.cpp
83 lines (69 loc) · 2.64 KB
/
dc.cpp
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
/*
Copyright (C) 2011 Tao Ju
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
(LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "octree.hpp"
#include "PLYReader.hpp"
#include "PLYWriter.hpp"
#include "intersection.hpp"
#include <math.h>
#include <iostream>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
//#define ALLOW_INTERSECTION
/* Parameters
* argv[1]: name of input file (.dcf format)
* argv[2]: name of output file (.ply format)
* argv[3]: (OPTIONAL) name of secondary output file (.ply format)
* when using dual contouring, storing self-intersecting triangles.
*/
int main( int args, char* argv[] )
{
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("simplify", po::value<float>(), "set simplify threshold (float)")
("nointer", "use intersection-free algorithm")
("test", "run intersection test")
;
po::variables_map vm;
po::store(po::parse_command_line(args, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
float simplify_threshold = -1;
if (vm.count("simplify")) {
simplify_threshold = vm["simplify"].as<float>();
std::cout << "Simplify threshold set: " << simplify_threshold << "\n";
} else {
std::cout << "Simplify not set.\n";
}
// Read input file
std::cout << " input file: " << argv[1] << "\n";
Octree* mytree = new Octree( argv[1], simplify_threshold ) ;
if (vm.count("nointer")) {
std::cout << "Intersection-free algorithm! [Ju et al. 2006] \n";
mytree->genContourNoInter2( argv[2] ) ;
} else {
std::cout << "Original algorithm! [Ju et al. 2002] \n";
mytree->genContour( argv[2] ) ;
}
if (vm.count("test")) {
printf("Running intersection test... \n") ;
int num = Intersection::testIntersection( argv[2], argv[3] ); // Pairwise intersection test - may take a while
printf("%d intersections found!\n", num) ;
}
}