From 89bfa685e308fec9bdcabc84f5826c59c745a2ac Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 26 Jun 2006 14:10:30 +0000 Subject: [PATCH] merge some examples/Mesh_3 modifications to demo/Surface_mesher --- .gitattributes | 1 + .../demo/Surface_mesher/GNUmakefile | 35 +++++++++++++++++++ .../Surface_mesher/implicit_surface_mesher.C | 24 +++++++------ 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 Surface_mesher/demo/Surface_mesher/GNUmakefile diff --git a/.gitattributes b/.gitattributes index 9d3f8ce204b..0a5e8b172c8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1697,6 +1697,7 @@ Surface_mesh_parameterization/test/Surface_mesh_parameterization/data/cube.off - Surface_mesh_parameterization/test/Surface_mesh_parameterization/data/high_genus.off -text Surface_mesh_parameterization/test/Surface_mesh_parameterization/data/knot2.off -text Surface_mesh_parameterization/test/Surface_mesh_parameterization/data/oni.off -text +Surface_mesher/demo/Surface_mesher/GNUmakefile -text Surface_mesher/demo/Surface_mesher/windows/Mesh.suo -text svneol=unset#unset Surface_mesher/demo/Surface_mesher/windows/res/Mesh.ico -text svneol=unset#unset Surface_mesher/demo/Surface_mesher/windows/res/MeshDoc.ico -text svneol=unset#unset diff --git a/Surface_mesher/demo/Surface_mesher/GNUmakefile b/Surface_mesher/demo/Surface_mesher/GNUmakefile new file mode 100644 index 00000000000..408f5319bf6 --- /dev/null +++ b/Surface_mesher/demo/Surface_mesher/GNUmakefile @@ -0,0 +1,35 @@ +include makefile + +run-targets: $(TARGETS) + for t in $(TARGETS); do \ + ./$$t; \ + done + +.PHONY: run-targets + +#---------------------------------------------------------------------# +# +# dependencies +# +# if you want deps, create a file my_makefile that contains +# -include depends +# +#---------------------------------------------------------------------# + +-include my_makefile + +dep: + rm -f depends; $(MAKE) depends + +.PHONY: dep + +depends: *.C + cat /dev/null > depends + for f in *.C; do \ + echo >> depends; \ + echo >> depends; \ + echo "$${f%.C}$(OBJ_EXT): \\" >> depends; \ + $(CGAL_CXX) $(CXXFLAGS) -M -MG $$f \ + | grep '\.\./\.\..*/include/CGAL' >> depends; \ + done; \ + test -f depends diff --git a/Surface_mesher/demo/Surface_mesher/implicit_surface_mesher.C b/Surface_mesher/demo/Surface_mesher/implicit_surface_mesher.C index 41df68f9768..1ca1293651b 100644 --- a/Surface_mesher/demo/Surface_mesher/implicit_surface_mesher.C +++ b/Surface_mesher/demo/Surface_mesher/implicit_surface_mesher.C @@ -1,5 +1,7 @@ #include // #include + +#include #include #include @@ -49,9 +51,9 @@ double generic_inrimage_function(double x, double y, double z) std::ostream *out = 0; std::string filename = std::string(); std::string function_name = "sphere"; -bool output_to_file = false; +char* argv0 = ""; -void usage(char *argv0, std::string error = "") +void usage(std::string error = "") { if( error != "" ) std:: cerr << "Error: " << error << std::endl; @@ -71,7 +73,7 @@ void usage(char *argv0, std::string error = "") ++it) std::cerr << "--" << it->first << " default value is " << it->second << ".\n"; - exit(1); + exit(EXIT_FAILURE); } void parse_argv(int argc, char** argv, int extra_args = 0) @@ -80,11 +82,11 @@ void parse_argv(int argc, char** argv, int extra_args = 0) { std::string arg = argv[1+extra_args]; if( arg == "-h" || arg == "--help") - usage(argv[0]); + usage(); else if( arg == "-f" ) { if( argc < (3 + extra_args) ) - usage(argv[0], "-f must be followed by a function name!"); + usage("-f must be followed by a function name!"); function_name = argv[2 + extra_args]; parse_argv(argc, argv, extra_args + 2); } @@ -95,14 +97,13 @@ void parse_argv(int argc, char** argv, int extra_args = 0) if( opt_it != double_options.end() ) { if( argc < (3 + extra_args) ) - usage(argv[0], - (arg + " must be followed by a double!").c_str()); + usage((arg + " must be followed by a double!").c_str()); std::stringstream s; double val; s << argv[extra_args + 2]; s >> val; if( !s ) - usage(argv[0], ("Bad double after " + arg + "!").c_str()); + usage(("Bad double after " + arg + "!").c_str()); opt_it->second = val; parse_argv(argc, argv, extra_args + 2); } @@ -113,14 +114,13 @@ void parse_argv(int argc, char** argv, int extra_args = 0) if( opt_it != string_options.end() ) { if( argc < (3 + extra_args) ) - usage(argv[0], - (arg + " must be followed by a string!").c_str()); + usage((arg + " must be followed by a string!").c_str()); std::string s = argv[extra_args + 2]; opt_it->second = s; parse_argv(argc, argv, extra_args + 2); } else - usage(argv[0], ("Invalid option: " + arg + "!").c_str()); + usage(("Invalid option " + arg).c_str()); } } else @@ -135,6 +135,8 @@ void parse_argv(int argc, char** argv, int extra_args = 0) /////////////// Main function /////////////// int main(int argc, char **argv) { + argv0 = argv[0]; + init_parameters(); functions["generic_inrimage"] = &generic_inrimage_function;