example takes input filenames as parameters

This commit is contained in:
Sébastien Loriot 2014-07-17 16:43:37 +02:00
parent 27d34d9e75
commit e49813c5ef
4 changed files with 10 additions and 11 deletions

View File

@ -46,11 +46,11 @@ std::istream& read_soup(
return stream;
}
int main() {
int main(int,char** argv) {
std::vector<Point_3> points;
std::vector< std::vector<std::size_t> > polygons;
std::ifstream input("data/elephant_soup.off");
std::ifstream input(argv[0]);
if ( !input || !read_soup(input, points, polygons)){
std::cerr << "Error: can not read file.";
return 1;
@ -64,7 +64,7 @@ int main() {
CGAL::Polygon_soup_to_polyhedron_3<Polyhedron::HalfedgeDS, Point_3> builder(points, polygons);
poly.delegate(builder);
std::ofstream out("data/elephant_oriented.off");
std::ofstream out("oriented.off");
out << poly;
out.close();
}

View File

@ -27,13 +27,12 @@ void test(const char* file_name) {
std::cerr << file_name << " passed the test." << std::endl;
}
int main() {
std::vector<std::string> files;
int main(int argc, char** argv) {
files.push_back("data/elephant.off");
files.push_back("data/camel.off");
for(std::vector<std::string>::iterator it = files.begin(); it != files.end(); ++it) {
test(it->c_str());
for(int i=1;i<argc;++i) {
test(argv[i]);
}
std::cerr << "All done." << std::endl;
}

View File

@ -127,8 +127,8 @@ void from_file(const char* file_name, std::vector<Point>& points) {
in.close();
}
int main() {
std::ifstream input("data/elephant.off");
int main(int, char** argv) {
std::ifstream input(argv[1]);
Polyhedron poly;
if ( !input || !(input >> poly) || poly.empty() ){
std::cerr << "Error: can not read file.";

View File

@ -16,8 +16,8 @@ typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef Polyhedron::Facet_const_handle Facet_const_handle;
int main() {
std::ifstream input("data/camel.off");
int main(int, char** argv) {
std::ifstream input(argv[1]);
Polyhedron poly;
if ( !input || !(input >> poly) || poly.empty() ){
std::cerr << "Error: can not read file.";