admesh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,475 @@
1
+ Note: This manual is slightly out of date. Specifically it doesn't
2
+ mention OFF, VRML, or DXF files. However, there isn't much to know about
3
+ these options. If you just type 'admesh --help' a list of options will be
4
+ printed.
5
+
6
+ This document describes the use of ADMesh version 0.93. ADMesh is a program
7
+ for processing triangulated solid meshes. Currently, ADMesh only reads the
8
+ STL file format that is used for rapid prototyping applications, although it
9
+ can write STL, VRML, OFF, and DXF files.
10
+
11
+ For information about compiling ADMesh, see the file INSTALL. The file
12
+ README contains a brief description of ADMesh along with its features and
13
+ capabilities.
14
+
15
+ ADMesh is Copyrighted software and is distributed under the terms of the GNU
16
+ General Public License. See the file COPYING for license information.
17
+
18
+ Invoking ADMesh
19
+ ===============
20
+
21
+ ADMesh is executed as follows:
22
+ admesh [OPTION]... file
23
+
24
+ By default, ADMesh performs all of the mesh checking and repairing options
25
+ on the input file. This means that is checks exact, nearby,
26
+ remove-unconnected, fill-holes, normal-directions, and normal-values. The
27
+ file type (ASCII or binary) is automatically detected. The input file is
28
+ not modified unless it is specified by the --write option. If the following
29
+ command line was input:
30
+ admesh sphere.stl
31
+ The file sphere.stl would be opened and read, it would be checked and fixed
32
+ if necessary, and the results of processing would be printed out. The
33
+ results would not be saved.
34
+
35
+ The default value for tolerance is the length of the shortest edge of the
36
+ mesh. The default number of iterations is 2, and the default increment is
37
+ 0.01% of the diameter of a sphere that encloses the entire mesh.
38
+
39
+ If any of the options --exact, --nearby, --remove-unconnected, --fill-holes,
40
+ --normal-directions, --reverse-all, --normal-values, or --no-check are
41
+ given, then no other checks besides that one will be done unless they are
42
+ specified or unless they are required by ADMesh before the specified check
43
+ can be done. For example the following command line:
44
+ admesh --remove-unconnected sphere.stl
45
+ would first do an exact check because it is required, and then the
46
+ unconnected facets would be removed. The results would be printed and no
47
+ other checks would be done.
48
+
49
+ Examples
50
+ ========
51
+
52
+ To perform all checks except for nearby, the following command line would be
53
+ used:
54
+ admesh --exact --remove-unconnected --fill-holes \
55
+ --normal-directions --normal-values sphere.stl
56
+
57
+ Actually, since the exact check is required by ADMesh before
58
+ remove-unconnected, and remove-unconnected is required before --fill-holes,
59
+ the above command line could be shortened as follows with the same results:
60
+ admesh --fill-holes --normal-directions --normal-values sphere.stl
61
+
62
+ And again the same results could be achieved using the short options:
63
+ admesh -fudev sphere.stl
64
+ or
65
+ admesh -fdv sphere.stl
66
+
67
+ The following command lines do the same thing:
68
+ admesh sphere.stl
69
+ admesh -fundev sphere.stl
70
+ admesh -f -u -n -d -e -v sphere.stl
71
+ since the -fundev options are implied by default. To eliminate one of the
72
+ checks, just remove the letter of the check to eliminate from the "word"
73
+ 'fundev'.
74
+
75
+ About
76
+
77
+ Option Summary
78
+ ==============
79
+
80
+ ADMesh supports the following options, grouped by type.
81
+
82
+ *Mesh Transformation and Manipulation Options*
83
+ --x-rotate=angle Rotate CCW about x-axis by angle degrees
84
+ --y-rotate=angle Rotate CCW about y-axis by angle degrees
85
+ --z-rotate=angle Rotate CCW about z-axis by angle degrees
86
+ --xy-mirror Mirror about the xy plane
87
+ --yz-mirror Mirror about the yz plane
88
+ --xz-mirror Mirror about the xz plane
89
+ --scale=factor Scale the file by factor (multiply by factor)
90
+ --translate=x,y,z Translate the file to x, y, and z
91
+ --merge=name Merge file called name with input file
92
+
93
+ *Mesh Checking and Repairing Options*
94
+ -e, --exact Only check for perfectly matched edges
95
+ -n, --nearby Find and connect nearby facets. Correct bad facets
96
+ -t, --tolerance=tol Initial tolerance to use for nearby check = tol
97
+ -i, --iterations=i Number of iterations for nearby check = i
98
+ -m, --increment=inc Amount to increment tolerance after iteration=inc
99
+ -u, --remove-unconnected Remove facets that have 0 neighbors
100
+ -f, --fill-holes Add facets to fill holes
101
+ -d, --normal-directions Check and fix direction of normals(ie cw, ccw)
102
+ --reverse-all Reverse the directions of all facets and normals
103
+ -v, --normal-values Check and fix normal values
104
+ -c, --no-check Don't do any check on input file
105
+
106
+ *File Output Options*
107
+ -b, --write-binary-stl=name Output a binary STL file called name
108
+ -a, --write-ascii-stl=name Output an ascii STL file called name
109
+
110
+ *Miscellaneous Options*
111
+ --help Display this help and exit
112
+ --version Output version information and exit
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ Mesh Transformation and Manipulation Options
121
+ ============================================
122
+
123
+ '--x-rotate=angle'
124
+ '--y-rotate=angle'
125
+ '--z-rotate=angle'
126
+ Rotate the entire mesh about the specified axis by the given number of
127
+ degrees. The rotation is counter-clockwise about the axis as seen by
128
+ looking along the positive axis towards the origin, assuming that the
129
+ coordinate system is as follows:
130
+
131
+ y^
132
+ |
133
+ |
134
+ |
135
+ +------->
136
+ / x
137
+ /
138
+ z/
139
+
140
+ '--xy-mirror'
141
+ '--yz-mirror'
142
+ '--xz-mirror'
143
+ Mirror the mesh about the specified plane. Mirroring involves reversing
144
+ the sign of all of the coordinates in a particular axis. For example, to
145
+ mirror a mesh about the xy plane, the signs of all of the z coordinates
146
+ in the mesh are reversed.
147
+
148
+ '--scale=factor'
149
+ Scale the mesh by the given factor. This multiplies all of the
150
+ coordinates by the specified number. This option could be used to change
151
+ the "units" (there are no units explicitly specified in an STL file) of
152
+ the mesh. For example, to change a part from inches to millimeters, just
153
+ use the --scale=25.4 option.
154
+
155
+ '--translate=x,y,z'
156
+ Translate the mesh to the position x,y,z. This moves the minimum x, y,
157
+ and z values of the mesh to the specified position. For example, given a
158
+ mesh that has the following initial minimum and maximum coordinate values:
159
+ Min X = 4.000000, Max X = 5.000000
160
+ Min Y = 1.000000, Max Y = 3.000000
161
+ Min Z = -7.000000, Max Z = -2.000000
162
+ if the option --translate=1,2,3 is specified, the final values will be:
163
+ Min X = 1.000000, Max X = 2.000000
164
+ Min Y = 2.000000, Max Y = 4.000000
165
+ Min Z = 3.000000, Max Z = 8.000000
166
+ The translate option is often used to translate a mesh with arbitrary
167
+ minimum and maximum coordinates to 0,0,0. Usually, translation is also
168
+ required when merging two files.
169
+
170
+ 'merge=name'
171
+ Merge the specified file with the input file. No translation is done, so
172
+ if, for example, a file was merged with itself, the resulting file would
173
+ end up with two meshes exactly the same, occupying exactly the same
174
+ space. So generally, translations need to be done to the files to be
175
+ merged so that when the two meshes are merged into one, the two resulting
176
+ parts are properly spaced. If you know the nature of the parts to be
177
+ merged, it is possible to "nest" one part inside the other. Note,
178
+ however, that no warnings will be given if one part intersects with the
179
+ other.
180
+
181
+ It is possible to place one part against another, with no space in
182
+ between, but you will still end up with two separately defined parts. If
183
+ such a mesh was made on a rapid-prototyping machine, the result would
184
+ depend on the nature of the machine. Machines that use a photopolymer
185
+ would produce a single solid part because the two parts would be "bonded"
186
+ during the build process. Machines that use a cutting process would
187
+ yield two or more parts.
188
+
189
+ A copy of a mesh can be made by using the --merge and --translate options
190
+ at the same time. For example, given a file called block.stl with the
191
+ following size:
192
+ Min X = 0.000000, Max X = 2.000000
193
+ Min Y = 0.000000, Max Y = 2.000000
194
+ Min Z = 0.000000, Max Z = 2.000000
195
+
196
+ to create a file called 2blocks.stl that contains two of the parts
197
+ separated by 1 unit in the x direction, the following command line would
198
+ be used:
199
+ admesh
200
+ --translate=3,0,0 --merge=block.stl --write-binary=2blocks.stl block.stl
201
+
202
+ This would yield a binary STL file called 2blocks.stl with the following
203
+ size:
204
+ Min X = 0.000000, Max X = 5.000000
205
+ Min Y = 0.000000, Max Y = 2.000000
206
+ Min Z = 0.000000, Max Z = 2.000000
207
+
208
+
209
+ Mesh Checking and Repairing Options
210
+ ===================================
211
+
212
+ '-e', '--exact'
213
+ Check each facet of the mesh for its 3 neighbors. Since each facet is a
214
+ triangle, there should be exactly 3 neighboring facets for every facet in
215
+ the mesh. Since the mesh defines a solid, there should be no unconnected
216
+ edges in the mesh. When this option is specified, the 3 neighbors of
217
+ every facet are searched for and, if found, the neighbors are added to an
218
+ internal list that keeps track of the neighbors of each facet. A facet
219
+ is only considered a neighbor if two of its vertices EXACTLY match two of
220
+ the vertices of another facet. That means that there must be 0
221
+ difference between the x, y, and z coordinates of the two vertices of the
222
+ first facet and the two vertices of the second facet.
223
+
224
+ Degenerate facets (facets with two or more vertices equal to each other)
225
+ are removed during the exact check. No other changes are made to the
226
+ mesh. An exact check is always done before any of the other checking and
227
+ repairing options even if --exact isn't specified. There is one
228
+ exception to this rule; no exact check needs to be done before the
229
+ --normal-values option.
230
+
231
+ '-n', '--nearby'
232
+ '-t', '--tolerance=tol'
233
+ '-i', '--iterations=i'
234
+ '-m', '--increment=inc'
235
+ Checks each unconnected facet of the mesh for facets that are almost
236
+ connected but not quite. Due to round-off errors and other factors, it
237
+ is common for a mesh to have facets with neighbors that are very close
238
+ but don't match exactly. Often, this difference is only in the 8th
239
+ decimal place of the vertices, but these facets will not show up as
240
+ neighbors during the exact check. This option finds these nearby
241
+ neighbors and it changes their vertices so that they match exactly. The
242
+ exact check is alway done before the nearby check, so only facets that
243
+ remain unconnected after the exact check are candidates for the nearby
244
+ check.
245
+
246
+ The --tolerance=tol option is used to specify the distance that is
247
+ searched for the neighboring facet. By default, this value is set
248
+ automatically by ADMesh to be the length of the shortest edge of the
249
+ mesh. This value is used because it makes it unlikely for a facet that
250
+ shouldn't be a neighbor to be found and matched as a neighbor. If the
251
+ tolerance is too big, then some facets could end up connected that should
252
+ definitely not be connected. This could create a "mobius part" that is
253
+ not a valid solid. If this occurs, it can be seen by checking the value
254
+ of "Backwards edges" that is printed after processing. (The number of
255
+ backwards edges should be 0 for a valid solid.)
256
+
257
+ The --iterations=i and --increment=inc options are used together to
258
+ gradually connect nearby facets using progressively larger tolerances.
259
+ This helps to prevent incorrect connects but can also allow larger
260
+ tolerances to be used. The --iterations option gives the number of times
261
+ that facets are checked for nearby facets, each time using a larger
262
+ tolerance. The --increment=inc option gives the amount that the
263
+ tolerance is increased after each iteration. The number specified by
264
+ 'inc' is added to the tolerance that was used in the previous iteration.
265
+ If all of the facets are connected, no further nearby checks will be
266
+ done.
267
+
268
+ '-f', '--fill-holes'
269
+
270
+ Fill holes in the mesh by adding facets. This is done after the exact
271
+ check and after nearby check (if any nearby check is done). If there are
272
+ still unconnected facets, then facets will be added to the mesh,
273
+ connecting the unconnected facets, until all of the holes have been
274
+ filled. This is guaranteed to completely completely fix all unconnected
275
+ facets. However, the resulting mesh may or may not be what the user
276
+ expects.
277
+
278
+ '-d', '--normal-directions'
279
+
280
+ Check and fix if necessary the directions of the facets. This only deals
281
+ with whether the vertices of all the facets are oriented clockwise or
282
+ counterclockwise, it doesn't check or modify the value of the normal
283
+ vector. Every facet should have its vertices defined in a
284
+ counterclockwise order when looked at from the outside of the part. This
285
+ option will orient all of the vertices so that they are all facing in the
286
+ same direction. However, it it possible that this option will make all
287
+ of the facets facet inwards instead of outwards. The algorithm tries to
288
+ get a clue of which direction is inside and outside by checking the value
289
+ of the normal vector so the chance is very good that the resulting mesh
290
+ will be correct. However, it doesn't explicitly check to find which
291
+ direction is inside and which is outside. In the future, I might write
292
+ code to explicitly check for the inside and the outside, but until then,
293
+ the current algorithm gets it right most of the time.
294
+
295
+ '--reverse-all'
296
+ Reverses the directions of all of the facets and normals. If the
297
+ --normal-directions option ended up making all of the facets facet
298
+ inwards instead of outwards, then this option can be used to reverse all
299
+ of the facets. It is up to the user to determine if the facets are
300
+ facing inwards and if they need reversing. In future versions of ADMesh,
301
+ this process may be automated. This option also fixes and updates the
302
+ normal vector for each facet.
303
+
304
+ '-v', '--normal-values'
305
+ Checks and fixes if necessary the normal vectors of every facet. The
306
+ normal vector will point outward for a counterclockwise facet. The
307
+ length of the normal vector will be 1.
308
+
309
+ '-c', '--no-check'
310
+ Don't do any checks or modifications to the input file. By default,
311
+ ADMesh performs all processes (exact, nearby, remove_unconnected,
312
+ fill-holes, normal-directions, and normals-values) on the input file. If
313
+ the --no-check option is specified, no checks or modifications will be
314
+ made on the input file. This could be used, for example, to translate an
315
+ ASCII STL file to a binary STL file, with no modifications made. A
316
+ command line such as the following might be used:
317
+ admesh
318
+ --no-check --write-binary-stl=newblock.stl --translate=0,0,0 block.stl
319
+ This would open the file block.stl, would translate it to 0,0,0 no checks
320
+ would be performed and a binary STL file of the translated mesh would be
321
+ written to newblock.stl.
322
+
323
+ '-b', '--write-binary-stl=name'
324
+ '-a,' '--write-ascii-stl=name'
325
+ Write a binary STL file with the name specified. The input file is not
326
+ modified by ADMesh so the only way to preserve any modifications that
327
+ have been made to the input file is to use one of the --write options. If
328
+ the user wants to modify (overwrite) the input file, then the input file
329
+ can also be specified for the --write option. For example, to convert an
330
+ input ASCII STL file called sphere.stl to a binary STL file, overwriting
331
+ the original file, and performing no checks, the following command line
332
+ would be used:
333
+ admesh --write-binary-stl=sphere.stl --no-check sphere.stl
334
+
335
+ '--help'
336
+ Display the possible command line options with a short description, and
337
+ then exit.
338
+
339
+ '--version'
340
+
341
+ Show the version information for ADMesh, and then exit.
342
+
343
+
344
+ ADMesh Output
345
+ =============
346
+
347
+ After ADMesh has processed a mesh, it prints out a page of information about
348
+ that mesh. The output looks like the following:
349
+
350
+ ================= Results produced by ADMesh version 0.95 =================
351
+ Input file : sphere.stl
352
+ File type : Binary STL file
353
+ Header : Processed by ADMesh version 0.95
354
+ ============== Size ==============
355
+ Min X = -1.334557, Max X = 1.370952
356
+ Min Y = -1.377953, Max Y = 1.377230
357
+ Min Z = -1.373225, Max Z = 1.242838
358
+ ========= Facet Status ========== Original ============ Final ====
359
+ Number of facets : 3656 3656
360
+ Facets with 1 disconnected edge : 18 0
361
+ Facets with 2 disconnected edges : 3 0
362
+ Facets with 3 disconnected edges : 0 0
363
+ Total disconnected facets : 21 0
364
+ === Processing Statistics === ===== Other Statistics =====
365
+ Number of parts : 1 Volume : 10.889216
366
+ Degenerate facets : 0
367
+ Edges fixed : 24
368
+ Facets removed : 0
369
+ Facets added : 0
370
+ Facets reversed : 0
371
+ Backwards edges : 0
372
+ Normals fixed : 0
373
+
374
+ Description of Output
375
+ ====================
376
+
377
+ The following describes the output information line by line.
378
+
379
+ Input file : sphere.stl
380
+ The name of the file that was read.
381
+
382
+ File type : Binary STL file
383
+ The type of file. Currently, the only two possibilities are Binary STL
384
+ file and ASCII STL file. ADMesh automatically detect the type of input
385
+ file.
386
+
387
+ Header : Processed by ADMesh version 0.95
388
+ The first 80 characters of the STL file. The first 80 bytes of a binary
389
+ STL file or the first line of an ASCII STL file can contain some text.
390
+ Usually, the CAD system that has created that file, or the last program
391
+ to process that file puts its name in the header. ADMesh puts its own
392
+ string in the header when it saves the file.
393
+
394
+ ============== Size ==============
395
+ Min X = -1.334557, Max X = 1.370952
396
+ Min Y = -1.377953, Max Y = 1.377230
397
+ Min Z = -1.373225, Max Z = 1.242838
398
+ This section gives the boundaries of the mesh. The mesh will fit just
399
+ inside a box of this size.
400
+
401
+ ========= Facet Status ========== Original ============ Final ====
402
+ Number of facets : 3656 3656
403
+ Facets with 1 disconnected edge : 18 0
404
+ Facets with 2 disconnected edges : 3 0
405
+ Facets with 3 disconnected edges : 0 0
406
+ Total disconnected facets : 21 0
407
+ Information about the quality of the mesh before, and after processing by
408
+ ADMesh. The number of facets gives an idea about the complexity and
409
+ accuracy of the mesh. Disconnected facets will fall into 3 categories.
410
+ Some facets will have only one disconnected edge, some will have 2 edges
411
+ disconnected, and some will have all 3 edges disconnected. Of course,
412
+ for a valid solid mesh, there should be 0 disconnected facets.
413
+
414
+ === Processing Statistics ===
415
+ Number of parts : 1
416
+ This is the total number of separate parts in the file. This can be a
417
+ very useful indication of whether your file is correct. Sometimes, the
418
+ user of the CAD system that creates the mesh just puts several pieces
419
+ together next to each other, and then outputs the mesh. This might not
420
+ cause any problems for a rapid prototyping system that uses a
421
+ photopolymer because all of the parts will be "glued" together anyway
422
+ during the build. However, a rapid prototyping machine that is based on
423
+ cutting will cut each one of the parts individually and the result will
424
+ be many parts that need to be glued together. The number of parts is
425
+ counted during --normal-directions, so if the --normal-directions check
426
+ is eliminated, then the number of parts will read 0.
427
+
428
+ Degenerate facets : 0
429
+ Number of degenerate facets in the input file. A degenerate facet is a
430
+ facet that has two or more vertices exactly the same. The resulting
431
+ facet is just a line (if two vertices are the same) or could even be a
432
+ point (if all 3 vertices are the same). These facets add no information
433
+ to the file and are removed by ADMesh during processing.
434
+
435
+ Edges fixed : 24
436
+ The total number of edges that were fixed by moving the vertices slightly
437
+ during the nearby check. This does not include facets that were added by
438
+ --fill-holes.
439
+
440
+ Facets removed : 0
441
+ The total number of facets removed. There are two cases where facets
442
+ might be removed. First, all degenerate facets in the input file are
443
+ removed. Second, if there are any completely unconnected facets (facets
444
+ with 3 disconnected edges) after the exact and nearby checks, then these
445
+ facets will be removed by --remove-unconnected.
446
+
447
+ Facets added : 0
448
+ Number of facets that have been added by ADMesh to the original mesh.
449
+ Facets are only added during --fill-holes. So this number represents the
450
+ number of facets that had to be added to fill all of the holes, if any,
451
+ in the original mesh.
452
+
453
+ Facets reversed : 0
454
+ The number of facets that were reversed during --normal-directions. This
455
+ only relates to the order of the vertices of the facet (CW or CCW), it
456
+ has nothing to do with the value of the normal vector.
457
+
458
+ Backwards edges : 0
459
+ The number of edges that are backwards. After ADMesh has finished all of
460
+ the checks and processing, it verifies the results. If the
461
+ normal-directions check has been done then the NUMBER OF BACKWARDS EDGES
462
+ SHOULD BE 0. If it is not, then a "mobius part" has been created which
463
+ is not a valid solid mesh. In this case the mesh can be processed again,
464
+ but a smaller tolerance on the nearby check should be used or no nearby
465
+ check should be done.
466
+
467
+ Normals fixed : 0
468
+ The number of normal vectors that have been fixed. During the
469
+ normal-values check, ADMesh calculates the value of every facet and
470
+ compares the result with the normal vector from the input file. If the
471
+ result is not within a fixed tolerance, then the normal is said to be
472
+ fixed. Actually, for consistency, every normal vector is rewritten with
473
+ the new calculated normal, even if the original normal was within
474
+ tolerance. However, the normals that were within tolerance are not
475
+ counted by normals fixed.