admesh 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/ext/admesh/admesh/AUTHORS +11 -0
  3. data/ext/admesh/admesh/COPYING +339 -0
  4. data/ext/admesh/admesh/ChangeLog +143 -0
  5. data/ext/admesh/admesh/ChangeLog.old +42 -0
  6. data/ext/admesh/admesh/INSTALL +14 -0
  7. data/ext/admesh/admesh/Makefile.am +62 -0
  8. data/ext/admesh/admesh/Makefile.in +1100 -0
  9. data/ext/admesh/admesh/README.md +115 -0
  10. data/ext/admesh/admesh/aclocal.m4 +1183 -0
  11. data/ext/admesh/admesh/admesh-doc.txt +475 -0
  12. data/ext/admesh/admesh/admesh.1 +173 -0
  13. data/ext/admesh/admesh/block.stl +86 -0
  14. data/ext/admesh/admesh/compile +347 -0
  15. data/ext/admesh/admesh/config.guess +1420 -0
  16. data/ext/admesh/admesh/config.h.in +65 -0
  17. data/ext/admesh/admesh/config.sub +1798 -0
  18. data/ext/admesh/admesh/configure +14671 -0
  19. data/ext/admesh/admesh/configure.ac +90 -0
  20. data/ext/admesh/admesh/depcomp +791 -0
  21. data/ext/admesh/admesh/install-sh +527 -0
  22. data/ext/admesh/admesh/libadmesh.pc.in +11 -0
  23. data/ext/admesh/admesh/ltmain.sh +9655 -0
  24. data/ext/admesh/admesh/m4/libtool.m4 +7992 -0
  25. data/ext/admesh/admesh/m4/ltoptions.m4 +384 -0
  26. data/ext/admesh/admesh/m4/ltsugar.m4 +123 -0
  27. data/ext/admesh/admesh/m4/ltversion.m4 +23 -0
  28. data/ext/admesh/admesh/m4/lt~obsolete.m4 +98 -0
  29. data/ext/admesh/admesh/missing +215 -0
  30. data/ext/admesh/admesh/src/admesh.c +425 -0
  31. data/ext/admesh/admesh/src/connect.c +971 -0
  32. data/ext/admesh/admesh/src/normals.c +333 -0
  33. data/ext/admesh/admesh/src/shared.c +262 -0
  34. data/ext/admesh/admesh/src/stl.h +201 -0
  35. data/ext/admesh/admesh/src/stl_io.c +479 -0
  36. data/ext/admesh/admesh/src/stlinit.c +377 -0
  37. data/ext/admesh/admesh/src/util.c +557 -0
  38. data/ext/admesh/extconf.rb +14 -0
  39. data/lib/admesh.rb +40 -0
  40. metadata +84 -0
@@ -0,0 +1,23 @@
1
+ # ltversion.m4 -- version numbers -*- Autoconf -*-
2
+ #
3
+ # Copyright (C) 2004 Free Software Foundation, Inc.
4
+ # Written by Scott James Remnant, 2004
5
+ #
6
+ # This file is free software; the Free Software Foundation gives
7
+ # unlimited permission to copy and/or distribute it, with or without
8
+ # modifications, as long as this notice is preserved.
9
+
10
+ # @configure_input@
11
+
12
+ # serial 3337 ltversion.m4
13
+ # This file is part of GNU Libtool
14
+
15
+ m4_define([LT_PACKAGE_VERSION], [2.4.2])
16
+ m4_define([LT_PACKAGE_REVISION], [1.3337])
17
+
18
+ AC_DEFUN([LTVERSION_VERSION],
19
+ [macro_version='2.4.2'
20
+ macro_revision='1.3337'
21
+ _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22
+ _LT_DECL(, macro_revision, 0)
23
+ ])
@@ -0,0 +1,98 @@
1
+ # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
2
+ #
3
+ # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
4
+ # Written by Scott James Remnant, 2004.
5
+ #
6
+ # This file is free software; the Free Software Foundation gives
7
+ # unlimited permission to copy and/or distribute it, with or without
8
+ # modifications, as long as this notice is preserved.
9
+
10
+ # serial 5 lt~obsolete.m4
11
+
12
+ # These exist entirely to fool aclocal when bootstrapping libtool.
13
+ #
14
+ # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
15
+ # which have later been changed to m4_define as they aren't part of the
16
+ # exported API, or moved to Autoconf or Automake where they belong.
17
+ #
18
+ # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
19
+ # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
20
+ # using a macro with the same name in our local m4/libtool.m4 it'll
21
+ # pull the old libtool.m4 in (it doesn't see our shiny new m4_define
22
+ # and doesn't know about Autoconf macros at all.)
23
+ #
24
+ # So we provide this file, which has a silly filename so it's always
25
+ # included after everything else. This provides aclocal with the
26
+ # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
27
+ # because those macros already exist, or will be overwritten later.
28
+ # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
29
+ #
30
+ # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
31
+ # Yes, that means every name once taken will need to remain here until
32
+ # we give up compatibility with versions before 1.7, at which point
33
+ # we need to keep only those names which we still refer to.
34
+
35
+ # This is to help aclocal find these macros, as it can't see m4_define.
36
+ AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
37
+
38
+ m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
39
+ m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
40
+ m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
41
+ m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
42
+ m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
43
+ m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
44
+ m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
45
+ m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
46
+ m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
47
+ m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
48
+ m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
49
+ m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
50
+ m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
51
+ m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
52
+ m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
53
+ m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
54
+ m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
55
+ m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
56
+ m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
57
+ m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
58
+ m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
59
+ m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
60
+ m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
61
+ m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
62
+ m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
63
+ m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
64
+ m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
65
+ m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
66
+ m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
67
+ m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
68
+ m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
69
+ m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
70
+ m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
71
+ m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
72
+ m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
73
+ m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
74
+ m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
75
+ m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
76
+ m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
77
+ m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
78
+ m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
79
+ m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
80
+ m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
81
+ m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
82
+ m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
83
+ m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
84
+ m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
85
+ m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
86
+ m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
87
+ m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
88
+ m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
89
+ m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
90
+ m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
91
+ m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
92
+ m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
93
+ m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
94
+ m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
95
+ m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
96
+ m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
97
+ m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
98
+ m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
@@ -0,0 +1,215 @@
1
+ #! /bin/sh
2
+ # Common wrapper for a few potentially missing GNU programs.
3
+
4
+ scriptversion=2013-10-28.13; # UTC
5
+
6
+ # Copyright (C) 1996-2013 Free Software Foundation, Inc.
7
+ # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8
+
9
+ # This program is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation; either version 2, or (at your option)
12
+ # any later version.
13
+
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ # As a special exception to the GNU General Public License, if you
23
+ # distribute this file as part of a program that contains a
24
+ # configuration script generated by Autoconf, you may include it under
25
+ # the same distribution terms that you use for the rest of that program.
26
+
27
+ if test $# -eq 0; then
28
+ echo 1>&2 "Try '$0 --help' for more information"
29
+ exit 1
30
+ fi
31
+
32
+ case $1 in
33
+
34
+ --is-lightweight)
35
+ # Used by our autoconf macros to check whether the available missing
36
+ # script is modern enough.
37
+ exit 0
38
+ ;;
39
+
40
+ --run)
41
+ # Back-compat with the calling convention used by older automake.
42
+ shift
43
+ ;;
44
+
45
+ -h|--h|--he|--hel|--help)
46
+ echo "\
47
+ $0 [OPTION]... PROGRAM [ARGUMENT]...
48
+
49
+ Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50
+ to PROGRAM being missing or too old.
51
+
52
+ Options:
53
+ -h, --help display this help and exit
54
+ -v, --version output version information and exit
55
+
56
+ Supported PROGRAM values:
57
+ aclocal autoconf autoheader autom4te automake makeinfo
58
+ bison yacc flex lex help2man
59
+
60
+ Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61
+ 'g' are ignored when checking the name.
62
+
63
+ Send bug reports to <bug-automake@gnu.org>."
64
+ exit $?
65
+ ;;
66
+
67
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68
+ echo "missing $scriptversion (GNU Automake)"
69
+ exit $?
70
+ ;;
71
+
72
+ -*)
73
+ echo 1>&2 "$0: unknown '$1' option"
74
+ echo 1>&2 "Try '$0 --help' for more information"
75
+ exit 1
76
+ ;;
77
+
78
+ esac
79
+
80
+ # Run the given program, remember its exit status.
81
+ "$@"; st=$?
82
+
83
+ # If it succeeded, we are done.
84
+ test $st -eq 0 && exit 0
85
+
86
+ # Also exit now if we it failed (or wasn't found), and '--version' was
87
+ # passed; such an option is passed most likely to detect whether the
88
+ # program is present and works.
89
+ case $2 in --version|--help) exit $st;; esac
90
+
91
+ # Exit code 63 means version mismatch. This often happens when the user
92
+ # tries to use an ancient version of a tool on a file that requires a
93
+ # minimum version.
94
+ if test $st -eq 63; then
95
+ msg="probably too old"
96
+ elif test $st -eq 127; then
97
+ # Program was missing.
98
+ msg="missing on your system"
99
+ else
100
+ # Program was found and executed, but failed. Give up.
101
+ exit $st
102
+ fi
103
+
104
+ perl_URL=http://www.perl.org/
105
+ flex_URL=http://flex.sourceforge.net/
106
+ gnu_software_URL=http://www.gnu.org/software
107
+
108
+ program_details ()
109
+ {
110
+ case $1 in
111
+ aclocal|automake)
112
+ echo "The '$1' program is part of the GNU Automake package:"
113
+ echo "<$gnu_software_URL/automake>"
114
+ echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115
+ echo "<$gnu_software_URL/autoconf>"
116
+ echo "<$gnu_software_URL/m4/>"
117
+ echo "<$perl_URL>"
118
+ ;;
119
+ autoconf|autom4te|autoheader)
120
+ echo "The '$1' program is part of the GNU Autoconf package:"
121
+ echo "<$gnu_software_URL/autoconf/>"
122
+ echo "It also requires GNU m4 and Perl in order to run:"
123
+ echo "<$gnu_software_URL/m4/>"
124
+ echo "<$perl_URL>"
125
+ ;;
126
+ esac
127
+ }
128
+
129
+ give_advice ()
130
+ {
131
+ # Normalize program name to check for.
132
+ normalized_program=`echo "$1" | sed '
133
+ s/^gnu-//; t
134
+ s/^gnu//; t
135
+ s/^g//; t'`
136
+
137
+ printf '%s\n' "'$1' is $msg."
138
+
139
+ configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140
+ case $normalized_program in
141
+ autoconf*)
142
+ echo "You should only need it if you modified 'configure.ac',"
143
+ echo "or m4 files included by it."
144
+ program_details 'autoconf'
145
+ ;;
146
+ autoheader*)
147
+ echo "You should only need it if you modified 'acconfig.h' or"
148
+ echo "$configure_deps."
149
+ program_details 'autoheader'
150
+ ;;
151
+ automake*)
152
+ echo "You should only need it if you modified 'Makefile.am' or"
153
+ echo "$configure_deps."
154
+ program_details 'automake'
155
+ ;;
156
+ aclocal*)
157
+ echo "You should only need it if you modified 'acinclude.m4' or"
158
+ echo "$configure_deps."
159
+ program_details 'aclocal'
160
+ ;;
161
+ autom4te*)
162
+ echo "You might have modified some maintainer files that require"
163
+ echo "the 'autom4te' program to be rebuilt."
164
+ program_details 'autom4te'
165
+ ;;
166
+ bison*|yacc*)
167
+ echo "You should only need it if you modified a '.y' file."
168
+ echo "You may want to install the GNU Bison package:"
169
+ echo "<$gnu_software_URL/bison/>"
170
+ ;;
171
+ lex*|flex*)
172
+ echo "You should only need it if you modified a '.l' file."
173
+ echo "You may want to install the Fast Lexical Analyzer package:"
174
+ echo "<$flex_URL>"
175
+ ;;
176
+ help2man*)
177
+ echo "You should only need it if you modified a dependency" \
178
+ "of a man page."
179
+ echo "You may want to install the GNU Help2man package:"
180
+ echo "<$gnu_software_URL/help2man/>"
181
+ ;;
182
+ makeinfo*)
183
+ echo "You should only need it if you modified a '.texi' file, or"
184
+ echo "any other file indirectly affecting the aspect of the manual."
185
+ echo "You might want to install the Texinfo package:"
186
+ echo "<$gnu_software_URL/texinfo/>"
187
+ echo "The spurious makeinfo call might also be the consequence of"
188
+ echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189
+ echo "want to install GNU make:"
190
+ echo "<$gnu_software_URL/make/>"
191
+ ;;
192
+ *)
193
+ echo "You might have modified some files without having the proper"
194
+ echo "tools for further handling them. Check the 'README' file, it"
195
+ echo "often tells you about the needed prerequisites for installing"
196
+ echo "this package. You may also peek at any GNU archive site, in"
197
+ echo "case some other package contains this missing '$1' program."
198
+ ;;
199
+ esac
200
+ }
201
+
202
+ give_advice "$1" | sed -e '1s/^/WARNING: /' \
203
+ -e '2,$s/^/ /' >&2
204
+
205
+ # Propagate the correct exit status (expected to be 127 for a program
206
+ # not found, 63 for a program that failed due to version mismatch).
207
+ exit $st
208
+
209
+ # Local variables:
210
+ # eval: (add-hook 'write-file-hooks 'time-stamp)
211
+ # time-stamp-start: "scriptversion="
212
+ # time-stamp-format: "%:y-%02m-%02d.%02H"
213
+ # time-stamp-time-zone: "UTC"
214
+ # time-stamp-end: "; # UTC"
215
+ # End:
@@ -0,0 +1,425 @@
1
+ /* ADMesh -- process triangulated solid meshes
2
+ * Copyright (C) 1995, 1996 Anthony D. Martin <amartin@engr.csulb.edu>
3
+ * Copyright (C) 2013, 2014 several contributors, see AUTHORS
4
+ *
5
+ * This program is free software; you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 2 of the License, or
8
+ * (at your option) any later version.
9
+
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+
15
+ * You should have received a copy of the GNU General Public License along
16
+ * with this program; if not, write to the Free Software Foundation, Inc.,
17
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
+ *
19
+ * Questions, comments, suggestions, etc to
20
+ * https://github.com/admesh/admesh/issues
21
+ */
22
+
23
+ #include <stdio.h>
24
+ #include <getopt.h>
25
+ #include <stdlib.h>
26
+
27
+
28
+ #include "stl.h"
29
+ #include "config.h"
30
+
31
+ static void usage(int status, char *program_name);
32
+
33
+ int
34
+ main(int argc, char **argv) {
35
+ stl_file stl_in;
36
+ float tolerance = 0;
37
+ float increment = 0;
38
+ float x_trans;
39
+ float y_trans;
40
+ float z_trans;
41
+ float scale_factor = 0;
42
+ float rotate_x_angle = 0;
43
+ float rotate_y_angle = 0;
44
+ float rotate_z_angle = 0;
45
+ int c;
46
+ char *program_name;
47
+ char *binary_name = NULL;
48
+ char *ascii_name = NULL;
49
+ char *merge_name = NULL;
50
+ char *off_name = NULL;
51
+ char *dxf_name = NULL;
52
+ char *vrml_name = NULL;
53
+ int fixall_flag = 1; /* Default behavior is to fix all. */
54
+ int exact_flag = 0; /* All checks turned off by default. */
55
+ int tolerance_flag = 0; /* Is tolerance specified on cmdline */
56
+ int nearby_flag = 0;
57
+ int remove_unconnected_flag = 0;
58
+ int fill_holes_flag = 0;
59
+ int normal_directions_flag = 0;
60
+ int normal_values_flag = 0;
61
+ int reverse_all_flag = 0;
62
+ int write_binary_stl_flag = 0;
63
+ int write_ascii_stl_flag = 0;
64
+ int generate_shared_vertices_flag = 0;
65
+ int write_off_flag = 0;
66
+ int write_dxf_flag = 0;
67
+ int write_vrml_flag = 0;
68
+ int translate_flag = 0;
69
+ int scale_flag = 0;
70
+ int rotate_x_flag = 0;
71
+ int rotate_y_flag = 0;
72
+ int rotate_z_flag = 0;
73
+ int mirror_xy_flag = 0;
74
+ int mirror_yz_flag = 0;
75
+ int mirror_xz_flag = 0;
76
+ int merge_flag = 0;
77
+ int help_flag = 0;
78
+ int version_flag = 0;
79
+
80
+ int iterations = 2; /* Default number of iterations. */
81
+ int increment_flag = 0;
82
+ char *input_file = NULL;
83
+
84
+ int ret = 0;
85
+
86
+ enum {rotate_x = 1000, rotate_y, rotate_z, merge, help, version,
87
+ mirror_xy, mirror_yz, mirror_xz, scale, translate, reverse_all,
88
+ off_file, dxf_file, vrml_file
89
+ };
90
+
91
+ struct option long_options[] = {
92
+ {"exact", no_argument, NULL, 'e'},
93
+ {"nearby", no_argument, NULL, 'n'},
94
+ {"tolerance", required_argument, NULL, 't'},
95
+ {"iterations", required_argument, NULL, 'i'},
96
+ {"increment", required_argument, NULL, 'm'},
97
+ {"remove-unconnected", no_argument, NULL, 'u'},
98
+ {"fill-holes", no_argument, NULL, 'f'},
99
+ {"normal-directions", no_argument, NULL, 'd'},
100
+ {"normal-values", no_argument, NULL, 'v'},
101
+ {"no-check", no_argument, NULL, 'c'},
102
+ {"reverse-all", no_argument, NULL, reverse_all},
103
+ {"write-binary-stl", required_argument, NULL, 'b'},
104
+ {"write-ascii-stl", required_argument, NULL, 'a'},
105
+ {"write-off", required_argument, NULL, off_file},
106
+ {"write-dxf", required_argument, NULL, dxf_file},
107
+ {"write-vrml", required_argument, NULL, vrml_file},
108
+ {"translate", required_argument, NULL, translate},
109
+ {"scale", required_argument, NULL, scale},
110
+ {"x-rotate", required_argument, NULL, rotate_x},
111
+ {"y-rotate", required_argument, NULL, rotate_y},
112
+ {"z-rotate", required_argument, NULL, rotate_z},
113
+ {"xy-mirror", no_argument, NULL, mirror_xy},
114
+ {"yz-mirror", no_argument, NULL, mirror_yz},
115
+ {"xz-mirror", no_argument, NULL, mirror_xz},
116
+ {"merge", required_argument, NULL, merge},
117
+ {"help", no_argument, NULL, help},
118
+ {"version", no_argument, NULL, version},
119
+ {NULL, 0, NULL, 0}
120
+ };
121
+
122
+ program_name = argv[0];
123
+ while((c = getopt_long(argc, argv, "et:i:m:nufdcvb:a:",
124
+ long_options, (int *) 0)) != EOF) {
125
+ switch(c) {
126
+ case 0: /* If *flag is not null */
127
+ break;
128
+ case 'e':
129
+ exact_flag = 1;
130
+ fixall_flag = 0;
131
+ break;
132
+ case 'n':
133
+ nearby_flag = 1;
134
+ fixall_flag = 0;
135
+ break;
136
+ case 't':
137
+ tolerance_flag = 1;
138
+ tolerance = atof(optarg);
139
+ break;
140
+ case 'i':
141
+ iterations = atoi(optarg);
142
+ break;
143
+ case 'm':
144
+ increment_flag = 1;
145
+ increment = atof(optarg);
146
+ break;
147
+ case 'u':
148
+ remove_unconnected_flag = 1;
149
+ fixall_flag = 0;
150
+ break;
151
+ case 'f':
152
+ fill_holes_flag = 1;
153
+ fixall_flag = 0;
154
+ break;
155
+ case 'd':
156
+ normal_directions_flag = 1;
157
+ fixall_flag = 0;
158
+ break;
159
+ case 'v':
160
+ normal_values_flag = 1;
161
+ fixall_flag = 0;
162
+ break;
163
+ case 'c':
164
+ fixall_flag = 0;
165
+ break;
166
+ case reverse_all:
167
+ reverse_all_flag = 1;
168
+ fixall_flag = 0;
169
+ break;
170
+ case 'b':
171
+ write_binary_stl_flag = 1;
172
+ binary_name = optarg; /* I'm not sure if this is safe. */
173
+ break;
174
+ case 'a':
175
+ write_ascii_stl_flag = 1;
176
+ ascii_name = optarg; /* I'm not sure if this is safe. */
177
+ break;
178
+ case off_file:
179
+ generate_shared_vertices_flag = 1;
180
+ write_off_flag = 1;
181
+ off_name = optarg;
182
+ break;
183
+ case vrml_file:
184
+ generate_shared_vertices_flag = 1;
185
+ write_vrml_flag = 1;
186
+ vrml_name = optarg;
187
+ break;
188
+ case dxf_file:
189
+ write_dxf_flag = 1;
190
+ dxf_name = optarg;
191
+ break;
192
+ case translate:
193
+ translate_flag = 1;
194
+ sscanf(optarg, "%f,%f,%f", &x_trans, &y_trans, &z_trans);
195
+ break;
196
+ case scale:
197
+ scale_flag = 1;
198
+ scale_factor = atof(optarg);
199
+ break;
200
+ case rotate_x:
201
+ rotate_x_flag = 1;
202
+ rotate_x_angle = atof(optarg);
203
+ break;
204
+ case rotate_y:
205
+ rotate_y_flag = 1;
206
+ rotate_y_angle = atof(optarg);
207
+ break;
208
+ case rotate_z:
209
+ rotate_z_flag = 1;
210
+ rotate_z_angle = atof(optarg);
211
+ break;
212
+ case mirror_xy:
213
+ mirror_xy_flag = 1;
214
+ break;
215
+ case mirror_yz:
216
+ mirror_yz_flag = 1;
217
+ break;
218
+ case mirror_xz:
219
+ mirror_xz_flag = 1;
220
+ break;
221
+ case merge:
222
+ merge_flag = 1;
223
+ merge_name = optarg;
224
+ break;
225
+ case help:
226
+ help_flag = 1;
227
+ break;
228
+ case version:
229
+ version_flag = 1;
230
+ break;
231
+ default:
232
+ usage(1, program_name);
233
+ return 1;
234
+ }
235
+ }
236
+
237
+ if(help_flag) {
238
+ usage(0, program_name);
239
+ return 0;
240
+ }
241
+ if(version_flag) {
242
+ printf("ADMesh - version " VERSION "\n");
243
+ return 0;
244
+ }
245
+
246
+ if(optind == argc) {
247
+ printf("No input file name given.\n");
248
+ usage(1, program_name);
249
+ return 1;
250
+ } else {
251
+ input_file = argv[optind];
252
+ }
253
+
254
+ printf("\
255
+ ADMesh version " VERSION ", Copyright (C) 1995, 1996 Anthony D. Martin\n\
256
+ ADMesh comes with NO WARRANTY. This is free software, and you are welcome to\n\
257
+ redistribute it under certain conditions. See the file COPYING for details.\n");
258
+
259
+
260
+ printf("Opening %s\n", input_file);
261
+ stl_open(&stl_in, input_file);
262
+ stl_exit_on_error(&stl_in);
263
+
264
+ if(rotate_x_flag) {
265
+ printf("Rotating about the x axis by %f degrees...\n", rotate_x_angle);
266
+ stl_rotate_x(&stl_in, rotate_x_angle);
267
+ }
268
+ if(rotate_y_flag) {
269
+ printf("Rotating about the y axis by %f degrees...\n", rotate_y_angle);
270
+ stl_rotate_y(&stl_in, rotate_y_angle);
271
+ }
272
+ if(rotate_z_flag) {
273
+ printf("Rotating about the z axis by %f degrees...\n", rotate_z_angle);
274
+ stl_rotate_z(&stl_in, rotate_z_angle);
275
+ }
276
+ if(mirror_xy_flag) {
277
+ printf("Mirroring about the xy plane...\n");
278
+ stl_mirror_xy(&stl_in);
279
+ }
280
+ if(mirror_yz_flag) {
281
+ printf("Mirroring about the yz plane...\n");
282
+ stl_mirror_yz(&stl_in);
283
+ }
284
+ if(mirror_xz_flag) {
285
+ printf("Mirroring about the xz plane...\n");
286
+ stl_mirror_xz(&stl_in);
287
+ }
288
+
289
+ if(scale_flag) {
290
+ printf("Scaling by factor %f...\n", scale_factor);
291
+ stl_scale(&stl_in, scale_factor);
292
+ }
293
+ if(translate_flag) {
294
+ printf("Translating to %f, %f, %f ...\n", x_trans, y_trans, z_trans);
295
+ stl_translate(&stl_in, x_trans, y_trans, z_trans);
296
+ }
297
+ if(merge_flag) {
298
+ printf("Merging %s with %s\n", input_file, merge_name);
299
+ /* Open the file and add the contents to stl_in: */
300
+ stl_open_merge(&stl_in, merge_name);
301
+ }
302
+
303
+ stl_repair(&stl_in,
304
+ fixall_flag,
305
+ exact_flag,
306
+ tolerance_flag,
307
+ tolerance,
308
+ increment_flag,
309
+ increment,
310
+ nearby_flag,
311
+ iterations,
312
+ remove_unconnected_flag,
313
+ fill_holes_flag,
314
+ normal_directions_flag,
315
+ normal_values_flag,
316
+ reverse_all_flag,
317
+ 1);
318
+
319
+
320
+ if(generate_shared_vertices_flag) {
321
+ printf("Generating shared vertices...\n");
322
+ stl_generate_shared_vertices(&stl_in);
323
+ }
324
+
325
+ if(write_off_flag) {
326
+ printf("Writing OFF file %s\n", off_name);
327
+ stl_write_off(&stl_in, off_name);
328
+ if (stl_in.error) {
329
+ stl_clear_error(&stl_in);
330
+ ret = 1;
331
+ }
332
+ }
333
+
334
+ if(write_dxf_flag) {
335
+ printf("Writing DXF file %s\n", dxf_name);
336
+ stl_write_dxf(&stl_in, dxf_name, "Created by ADMesh version " VERSION);
337
+ if (stl_in.error) {
338
+ stl_clear_error(&stl_in);
339
+ ret = 1;
340
+ }
341
+ }
342
+
343
+ if(write_vrml_flag) {
344
+ printf("Writing VRML file %s\n", vrml_name);
345
+ stl_write_vrml(&stl_in, vrml_name);
346
+ if (stl_in.error) {
347
+ stl_clear_error(&stl_in);
348
+ ret = 1;
349
+ }
350
+ }
351
+
352
+ if(write_ascii_stl_flag) {
353
+ printf("Writing ascii file %s\n", ascii_name);
354
+ stl_write_ascii(&stl_in, ascii_name,
355
+ "Processed by ADMesh version " VERSION);
356
+ if (stl_in.error) {
357
+ stl_clear_error(&stl_in);
358
+ ret = 1;
359
+ }
360
+ }
361
+
362
+ if(write_binary_stl_flag) {
363
+ printf("Writing binary file %s\n", binary_name);
364
+ stl_write_binary(&stl_in, binary_name,
365
+ "Processed by ADMesh version " VERSION);
366
+ if (stl_in.error) {
367
+ stl_clear_error(&stl_in);
368
+ ret = 1;
369
+ }
370
+ }
371
+
372
+ stl_stats_out(&stl_in, stdout, input_file);
373
+
374
+ stl_close(&stl_in);
375
+
376
+ if (ret)
377
+ fprintf(stderr, "Some part of the procedure failed, see the above log for more information about what happened.\n");
378
+
379
+ return ret;
380
+ }
381
+
382
+ static void
383
+ usage(int status, char *program_name) {
384
+ if(status != 0) {
385
+ fprintf(stderr, "Try '%s --help' for more information.\n", program_name);
386
+ } else {
387
+ printf("\n");
388
+ printf("ADMesh version " VERSION "\n");
389
+ printf("Copyright (C) 1995, 1996 Anthony D. Martin\n");
390
+ printf("Usage: %s [OPTION]... file\n", program_name);
391
+ printf("\n");
392
+ printf(" --x-rotate=angle Rotate CCW about x-axis by angle degrees\n");
393
+ printf(" --y-rotate=angle Rotate CCW about y-axis by angle degrees\n");
394
+ printf(" --z-rotate=angle Rotate CCW about z-axis by angle degrees\n");
395
+ printf(" --xy-mirror Mirror about the xy plane\n");
396
+ printf(" --yz-mirror Mirror about the yz plane\n");
397
+ printf(" --xz-mirror Mirror about the xz plane\n");
398
+ printf(" --scale=factor Scale the file by factor (multiply by factor)\n");
399
+ printf(" --translate=x,y,z Translate the file to x, y, and z\n");
400
+ printf(" --merge=name Merge file called name with input file\n");
401
+ printf(" -e, --exact Only check for perfectly matched edges\n");
402
+ printf(" -n, --nearby Find and connect nearby facets. Correct bad facets\n");
403
+ printf(" -t, --tolerance=tol Initial tolerance to use for nearby check = tol\n");
404
+ printf(" -i, --iterations=i Number of iterations for nearby check = i\n");
405
+ printf(" -m, --increment=inc Amount to increment tolerance after iteration=inc\n");
406
+ printf(" -u, --remove-unconnected Remove facets that have 0 neighbors\n");
407
+ printf(" -f, --fill-holes Add facets to fill holes\n");
408
+ printf(" -d, --normal-directions Check and fix direction of normals(ie cw, ccw)\n");
409
+ printf(" --reverse-all Reverse the directions of all facets and normals\n");
410
+ printf(" -v, --normal-values Check and fix normal values\n");
411
+ printf(" -c, --no-check Don't do any check on input file\n");
412
+ printf(" -b, --write-binary-stl=name Output a binary STL file called name\n");
413
+ printf(" -a, --write-ascii-stl=name Output an ascii STL file called name\n");
414
+ printf(" --write-off=name Output a Geomview OFF format file called name\n");
415
+ printf(" --write-dxf=name Output a DXF format file called name\n");
416
+ printf(" --write-vrml=name Output a VRML format file called name\n");
417
+ printf(" --help Display this help and exit\n");
418
+ printf(" --version Output version information and exit\n");
419
+ printf("\n");
420
+ printf("The functions are executed in the same order as the options shown here.\n");
421
+ printf("So check here to find what happens if, for example, --translate and --merge\n");
422
+ printf("options are specified together. The order of the options specified on the\n");
423
+ printf("command line is not important.\n");
424
+ }
425
+ }