merge some examples/Mesh_3 modifications to demo/Surface_mesher

This commit is contained in:
Laurent Rineau 2006-06-26 14:10:30 +00:00
parent 29cede2485
commit 89bfa685e3
3 changed files with 49 additions and 11 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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

View File

@ -1,5 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
// #include <CGAL/Simple_cartesian.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
@ -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;