master
Jon Nordby 2014-07-04 17:09:46 +02:00
commit 1d75fccd12
221 zmienionych plików z 40922 dodań i 0 usunięć

111
Makefile 100644
Wyświetl plik

@ -0,0 +1,111 @@
# The lines below extract out program names from the cmake cache
# This is used to automatically generate a documentation page.
C_ = $(shell sed -n -e 's/;/ /g' \
-e 's/SOLVER_EXECUTABLES:STRING=//gp' \
-e 's/PROGRAMS:STRING=//gp' \
build/CMakeCache.txt)
C = $(addprefix bin/, $(C_))
Python_ = $(shell sed -n -e 's/;/ /g' \
-e 's/PYs:STRING=//gp' \
build/CMakeCache.txt)
Python = $(addprefix bin/, $(Python_))
scripts_ = $(shell sed -n -e 's/;/ /g' \
-e 's/SCRIPTS:STRING=//gp' \
build/CMakeCache.txt)
scripts = $(addprefix bin/, $(scripts_))
GUIs_ = $(shell sed -n -e 's/;/ /g' \
-e 's/GUIs:STRING=//gp' \
build/CMakeCache.txt)
GUIs = $(addprefix bin/, $(GUIs_))
PWD := $(shell pwd)
help:
@echo "Makefile options:"
@echo " make fab Compile all files and copy scripts from src to bin"
@echo " make doc Saves command names and docstrings into commands.html"
@echo " make zip Bundles relevant files in fab.zip"
@echo " make dist Copies files to Web directory"
@echo " make install Copies files to /usr/local/bin"
@echo " make clean Removes compiled executables and scripts from bin"
@echo " make wxpython2.9 Downloads, compiles, and installs wxpython 2.9.4.1"
@echo " (Linux only)"
fab:
@echo "Building with CMake"
@mkdir -p build
@cd build; \
cmake ../src; \
make -j4; \
make install | sed "s@$(PWD)/src/../@@g"
doc: commands.html
commands.html: fab
@# Dump all of the command names
@echo " Storing command names"
@echo "<html>\n<body>\n<pre>\ncommands:" > commands.html
@for name in $(C) $(scripts) $(GUIs); do \
echo " "$$name >> commands.html; \
done
@echo "" >> commands.html
@# Dump command docstrings
@echo " Storing command docstrings"
@for name in $(C) $(scripts) ; do \
./$$name >> commands.html; \
echo "" >> commands.html; \
done
zip: commands.html
rm -f fab_src.zip
rm -rf src/apps/dist
rm -rf src/apps/build
# @echo "Copying revision number to kokopelli About panel"
# @if which hg &>/dev/null && hg summary &> /dev/null; \
# then \
# sed "s/CHANGESET = .*/CHANGESET = '`hg id --num`:`hg id --id`'/g" \
# src/guis/koko/__init__.py > tmp; \
# mv tmp src/guis/koko/__init__.py; \
# fi
zip -r fab_src.zip commands.html Makefile src
# @sed "s/CHANGESET = .*/CHANGESET = None/g" \
# src/guis/koko/__init__.py > tmp; \
# mv tmp src/guis/koko/__init__.py; \
dist: zip
cp fab_src.zip ../../Web/fab_src.zip
cp commands.html ../../Web/
sed -e "s/Snapshot from [^\)]*/Snapshot from `date '+%B %d, %Y, %I:%M%p'`/g" \
../../Web/downloads.html > ../../Web/_downloads.html
mv ../../Web/_downloads.html ../../Web/downloads.html
install: fab
@echo "Installing executables and scripts to /usr/local/bin"
@if [ -e "/usr/local/bin/fab_send" ]; \
then \
mv /usr/local/bin/fab_send /usr/local/bin/fab_send.old; \
fi
@cp -r bin/* /usr/local/bin/
@if [ -e "/usr/local/bin/fab_send.old" ]; \
then \
mv /usr/local/bin/fab_send /usr/local/bin/fab_send.new; \
mv /usr/local/bin/fab_send.old /usr/local/bin/fab_send; \
echo "Note:"; \
echo " Pre-existing fab_send has not been overwritten, and"; \
echo " the new version of fab_send has been named fab_send.new"; \
fi
clean:
@echo "Deleting build directory"
@rm -rf build

447
commands.html 100644
Wyświetl plik

@ -0,0 +1,447 @@
<html>
<body>
<pre>
commands:
bin/vol_gif
bin/vol_stl
bin/gif_info
bin/gif_png
bin/gif_stl
bin/stl_info
bin/stl_png
bin/stl_path
bin/png_size
bin/png_scale
bin/png_distances
bin/png_offset
bin/png_grb
bin/png_drl
bin/png_path
bin/png_halftone
bin/svg_path
bin/path_eps
bin/path_dxf
bin/path_png
bin/path_rml
bin/path_sbp
bin/path_g
bin/path_camm
bin/path_epi
bin/path_uni
bin/path_oms
bin/path_ord
bin/path_join
bin/path_array
bin/path_info
bin/path_time
bin/math_png
bin/math_dot
bin/math_stl
bin/math_svg
bin/cad_png
bin/cad_view
bin/path_view
bin/rml_move
bin/fab_send
bin/fab_update
bin/cad_math
bin/math_png_py
bin/math_stl_py
bin/png_tile
bin/eagle_png
bin/fab
bin/fab.html
bin/fabserver
bin/make_cad_png
bin/make_cad_eps
bin/make_cad_stl
bin/make_cad_camm
bin/make_cad_rml
bin/make_cad_epi
bin/make_cad_uni
bin/make_cad_sbp
bin/make_cad_g
bin/make_cad_ord
bin/make_cad_grb
bin/make_cad_drl
bin/make_math_camm
bin/make_math_epi
bin/make_math_g
bin/make_math_ord
bin/make_math_eps
bin/make_math_uni
bin/make_math_rml
bin/make_math_sbp
bin/make_math_grb
bin/make_math_drl
bin/make_png_png
bin/make_png_eps
bin/make_png_epi
bin/make_png_uni
bin/make_png_grb
bin/make_png_epi_halftone
bin/make_png_uni_halftone
bin/make_png_rml
bin/make_png_sbp
bin/make_png_ord
bin/make_png_camm
bin/make_png_plt
bin/make_png_g
bin/make_png_drl
bin/make_png_oms
bin/make_stl_png
bin/make_stl_rml
bin/make_stl_sbp
bin/make_stl_g
bin/make_svg_camm
bin/make_svg_epi
bin/make_svg_uni
bin/make_svg_oms
bin/make_svg_g
bin/make_svg_rml
bin/make_svg_sbp
bin/make_svg_ord
bin/make_png_snap
bin/make_cad_snap
bin/make_stl_snap
bin/make_svg_snap
bin/make_png_eps_halftone
bin/make_cad_dxf
bin/make_math_dxf
bin/make_math_stl
bin/make_png_dxf
bin/make_gif_stl
bin/cad_ui
bin/rml_send_gui
command line: vol_gif in.vol out.gif nx ny nz [format [type [arg [size [dx dy dz [x0 y0 z0 [rx ry rz]]]]]]]
in.vol = input volume file
out.gif = output GIF file
nx,ny,nz = x,y,z input voxel number
format = 'f' for float 32, 'i' for uint16_t (default 'f')
type = 's' for section, 'h' for height (default 's')
arg = gamma for 's', threshold for 'h' (default 1)
size = mm per voxel (default 1)
dx,dy,dz = x,y,z output voxel number (default all)
x0,y0,z0 = x,y,z output voxel origin (default 0)
to be implemented: rx,ry,rz = view rotation angles (degrees; default 0)
command line: vol_stl in.vol out.stl nx ny nz [format [threshold [size [points [angle]]]]]
in.vol = input VOL file
out.stl = output STL file
nx,ny,nz = x,y,z input voxel number
format = 'f' for float 32, 'i' for uint16_t (default 'f')
threshold: surface intensity threshold (0 = min, 1 = max, default 0.5))
size = voxel size (mm, default from file))
points = points to interpolate per point (default 0)
to be implemented: angle = minimum relative face angle to decimate vertices (default 0)
command line: gif_info in.gif
in.gif = input GIF file
command line: gif_png in.gif out.png [type [arg [points [size [rx ry rz]]]]]
in.gif = input gif file
out.png = output PNG file
type = 'z' of density, 'h' for height (default z)
arg = type argument
'z': gamma (default 1)
'h': threshold (0 = min, 1 = max, default 0.5)
points = points to interpolate per point (linear, default 0)
size = voxel size (mm, default from file))
to be implemented: rx,ry,rz = x,y,z rotation angles (degrees; default 0)
command line: gif_stl in.gif out.stl [threshold [size [points [angle]]]]
in.gif = input GIF section file
out.stl = output STL file
threshold: surface intensity threshold (0 = min, 1 = max, default 0.5))
size = voxel size (mm, default from file))
points = points to interpolate per point (default 0)
to be implemented: angle = minimum relative face angle to decimate vertices (default 0)
command line: stl_info in.stl
in.stl = input binary STL file
command line: stl_png in.stl out.png [units [resolution [axis]]]
in.stl = input binary STL file
out.png = output PNG file
units = file units (optional, mm/unit, default 1)
resolution = image resolution (optional, pixels/mm, default 10)
axis = projection axis (optional, top or bottom, x|X|y|Y|z|Z, default z)
command line: stl_path in.stl out.path [units [resolution]]]
in.stl = input binary STL file
out.png = output PNG file
units = file units (optional, mm/unit, default 1)
resolution = image resolution (optional, pixels/mm, default 10)
command line: png_size in.png [dx [dy]]
in.png = input PNG file
dx = set width (optional, mm)
dy = set height (optional, mm)
command line: png_scale in.png out.png low high
in.png = input PNG file
out.png = output PNG file
low = rescaled intensity minimum (0-1)
high = rescaled intensity maximum (0-1)
command line: png_distances in.png out.png [intensity [distances]]
in.png = input PNG file
out.png = input PNG file
intensity = intensity level to slice (optional, 0-1, default 0.5)
distances = show distances (optional, 0/1, default 1)
command line: png_offset in.png out.png [intensity [distance]]
in.png = input PNG file
out.png = input PNG file
intensity = intensity level to slice (optional, 0-1, default 0.5)
distance = distance to offset (optional, mm, default 0)
command line: png_grb in.png out.grb
in.png = input PNG file
out.grb = output Gerber (RS-274X) file
command line: png_drl in.png out.drl
in.png = input PNG file
out.drl = output Excellon file
command line: png_path in.png out.path [error [offset_diameter [offset_number [offset_overlap [intensity_top [intensity_bottom [z_top [z_bottom [z_thickness [xz [yz [xy [type [clearance_length clearance_diameter]]]]]]]]]]]]]]
in.png = input PNG file
out.path = output path file
error = allowable vector fit deviation (optional, pixels, default 1.1)
offset_diameter = diameter to offset (optional, mm, default 0)
offset_number = number of contours to offset (optional, -1 to fill all, default 1)
offset_overlap = tool offset overlap fraction (optional, 0 (no overlap) - 1 (complete overlap, default 0.5))
intensity_top = top slice intensity (optional, 0-1, default 0.5)
intensity_bottom = bottom slice intensity (optional, 0-1, default intensity_top)
z_top = top slice z value (optional, mm, default 0)
z_bottom = bottom slice z value (optional, mm, default z_top)
z_thickness = slice z thickness (optional, mm, default z_top-z_bottom)
xz = xz finish (optional, 1=yes, default 0
yz = yz finish (optional, 1=yes, default 0
xy = xy path (optional, 1=yes, default 1
type = finish tool type (optional, f=flat end, b=ball end, default f
clearance_length = finish tool clearance length (optional, mm, 0 = no limit, default 0
clearance_diameter = finish tool clearance diameter (optional, mm, default offset_diameter
command line: png_halftone in.png out.path [threshold [points [size [spacing [offset [invert]]]]]]
in.png = input PNG file
out.path = output path file
threshold = minimum spot radius (optional, pixels default 1)
points = points per spot (optional, default 8)
size = maximum spot size (optional, mm, default 1)
spacing = spot spacing (optional, 1 = size, default 1)
offset = row offset (optional, 1 = size, default 0.5)
offset = row offset (optional, 1 = size, default 0.5)
invert = invert image (0 = no (default), 1 = yes)
command line: svg_path in.svg out.path [scale [points [resolution [zmin [zmax]]]]]
in.svg = input binary SVG file
out.path = output path file
scale = scale factor (optional, default 1.0)
points = points per curve segment (optional, default 25)
resolution = path x resolution (optional, default 10000)
zmin = path min intensity z (optional, mm, default 0)
zmax = path max intensity z (optional, mm, default zmin)
command line: path_eps in.path out.eps [view]
in.path = input path file
out.eps= output PostScript file
view = view projection(s) (optional, z|3, default z)
command line: path_dxf in.path out.dxf
in.path = input path file
out.dxf = output DXF file
command line: path_png in.path out.png
in.path = input path file
out.png = output PNG file
command line: path_rml in.path out.rml [speed [direction [jog [xmin ymin [zmin]]]]]
in.path = input path file
out.rml = output Roland Modela file
speed = cutting speed (optional, mm/s, default 4)
direction = machining direction (optional, 0 conventional/1 climb, default 1)
jog = jog height (optional, mm, default 1)
xmin = left position (optional, mm, default path value)
ymin = front position (optional, mm, default path value)
zmin = bottom position (optional, -mm, default path value)
command line: path_sbp in.path out.sbp [direction [spindle_speed [xy_speed z_speed [xy_jog_speed z_jog_speed z_jog [units]]]]]]
in.path = input path file
out.sbp = output ShopBot file
direction = machining direction (optional, 0 conventional/1 climb, default 0)
spindle_speed = spindle speed (optional, if control installed, RPM, default 12000)
xy_speed = xy cutting speed (optional, mm/s, default 30)
z_speed = z cutting speed (optional, mm/s, default 30)
xy_jog_speed = xy jog speed (optional, mm/s, default 150)
z_jog_speed = z jog speed (optional, mm/s, default 150)
z_jog = z jog height (optional, mm, default 25)
units = mm per file unit (optional, default 25.4)
command line: path_g in.path out.g [direction [z_jog [feed [z_feed [spindle [tool [coolant]]]]]]
in.path = input path file
out.g = output G-code file
direction = machining direction (optional, 0 conventional/1 climb, default 0)
z_jog = z jog height (optional, mm, default 25)
feed = feed rate (optional, mm/s, default 100)
z_feed = z plunge rate (optional, mm/s, default xy feed rate)
spindle = spindle speed (optional, RPM, default 5000)
tool = tool number (optional, default 1)
coolant = coolant on/off (optional, 0=off/1=on, default 1)
command line: path_camm in.path out.camm [force [velocity [x y [location]]]]
in.path = input path file
out.camm = output Roland vinylcutter file
force = cutting force (optional, grams, default 45)
velocity = cutting speed (optional, cm/s, default 2)
x = origin x (optional, mm, default 0)
y = origin y (optional, mm, default 0)
location = origin location (optional, bottom left:l, bottom right:r, top left:L, top right:R, default l)
command line: path_epi in.path out.epi [power [speed [focus [x y [ location [rate [max_power]]]]]]]
in.path = input path file
out.epi= output Epilog lasercutter file
power = percent power, for minimum z value (optional, 0-100, default 50)
speed = percent speed (optional, 0-100, default 50)
focus = autofocus (optional, 0=off | 1=on, default on)
x = origin x (optional, mm, default 0 = left side of bed)
y = origin y (optional, mm, default 0 = back side of bed, front positive)
location = origin location (optional, bottom left:l, bottom right:r, top left:L, top right:R, default l)
rate = pulse rate (optional, frequency, default 2500)
max_power = percent power, for maximum z value (optional, 0-100, default power)
command line: path_uni in.path out.uni [power [speed [xmin ymin [rate [max_power]]]]]
in.path = input path file
out.uni= output Universal lasercutter file
power = percent power (optional, 0-100, default 100)
speed = percent speed (optional, 0-100, default 100)
xmin = left position (optional, mm, default path, 0 = left side of bed)
ymin = front position (optional, mm, default path, 0 = back, front positive)
rate = pulse rate (optional, frequency, default 500)
max_power = maximum power for maximum z value (optional, 0-100, default 100)
command line: path_oms in.path out.oms [velocity [acceleration [period]]]
in.path = input path file
out.oms = output Resonetics excimer micromachining center file
velocity (default 0.1)
acceleration (default 5.0)
period (usec, default 10000)
command line: path_ord in.path out.ord [lead [quality [xstart ystart]]]
in.path = input path file
out.ord = output Omax waterjet file
lead = lead in/out (optional, mm, default 2)
quality = cut quality (optional, default -3)
xstart,ystart = start position (optional, mm, default path start)
command line: path_join in1.path in2.path out.path [dx [dy]]
in1.path = first input path file
in2.path = second input path file
out.path = joined output path file
dx = in1 horizontal offset (optional, mm, default 0)
dy = in1 vertical offset (optional, mm, default dx)
command line: path_array in.path out.path nx ny [dx [dy]]
in.path = input path file
out.path = output path file
nx = number of horizonal array elements
ny = number of vertical array elements
dx = array element horizontal spacing (optional, mm, default 0)
dy = array element vertical spacing (optional, mm, default dx)
command line: path_info in.path
in.path = input path file
command line: path_time in.path move_speed [jog_height [jog_speed [plunge_speed]]]
in.path = input path file
move_speed = speed of path segments (mm/s)
jog_height = height between path segments (mm, optional, default 0)
jog_speed = speed between path segments (mm/s, optional, default move_speed)
plunge_speed = speed from jog to move (mm/s, optional, default move_speed)
command line: math_png in.math out.png [resolution [slices]]
in.math = input math string file
out.png = output PNG image
resolution = pixels per mm (optional, default 10)
slices = number of z slices (optional, default full)
command line: math_dot in.math out.dot
in.math = input math string file
out.dot = output dot file
command line: math_stl in.math out.stl [resolution [quality]]
in.math = input math string file
out.png = output PNG image
resolution = voxels per mm (optional, default 10)
quality = voxel interpolation level (default 8)
command line: math_svg in.math out.svg [resolution [slices [error [quality]]]]
in.math = input math string file
out.png = output PNG image
resolution = voxels per mm (default: 10)
slices = z slices (defaults: 1 for 2D models, 10 for 3D models)
error = maximum decimation error (in mm^2)
quality = voxel interpolation level (default: 8)
Note: output svgs are at 72 dpi.
command line: cad_png in.cad [args]
in.cad = input .cad file
args = math_png arguments (optional)
command line: cad_view in.cad [args]
in.cad = input .cad file
args = math_png arguments (optional)
image viewer = eog
command line: path_view in.path [view [viewer]]
in.path = input path file
view = view projection(s) (optional, z|3, default z)
viewer = PostScript viewer [default evince]
command line: rml_move x y
x,y, = position to move to (mm)
command line: fab_send [file]
file = file to send
file type commands:
{'.eps': 'inkscape "$file"', '.drl': 'gerbv "$file"', '.camm': 'printer=vinyl; lpr -P$printer "$file"', '.uni': 'port=/dev/lp0; cat "$file" > $port', '.epi': 'printer=laser; lprm -P$printer -; lpr -P$printer "$file"', '.sbp': 'gedit "$file"', '.rml': 'port=/dev/ttyUSB0; rml_send_gui "$file" $port', '.g': 'gedit "$file"', '.oms': 'gedit "$file"', '.dxf': 'gedit "$file"', '.stl': 'meshlab "$file"', '.plt': 'gedit "$file"', '.ord': 'gedit "$file"', '.grb': 'gerbv "$file"'}
command line: fab_update [check|install]
check will inform you if a newer version of the fab modules is available.
install will install a newer version of the fab modules, if applicable.
command line: cad_math in.cad out.math [args]
in.cad = input design file
out.math = output math string file
args = arguments to cad script
(delivered in sys.argv)
command line: math_png_py in.math out.png [resolution [number [view [rx ry rx]]]]
in.math = input math string file
out.png = output PNG image
resolution = pixels per mm (optional, default 10)
number = number of z slices to evaluate (optional, default 1)
view = view projection(s) (optional, z|3, default z)
rx ry rz = 3D view angle (optional, degrees, default 70 0 20)
[This command is deprecated; use math_png instead.]
command line: math_stl in.math out.stl [resolution]
in.math = input math string file
out.stl = output STL image
resolution = pixels per mm (optional, default 1)
command line: png_tile rows cols file1.png file2.png ...
rows = number of horizontal copies
cols = number of vertical copies
file1.png to fileN.png = files to tile
command line: eagle_png [options] target.brd
target.brd = EAGLE brd file to render
The board outline should be a solid polygon on the 'milling' layer
Internal cutouts should be solid shapes on the 'holes' layer
Valid options:
--resolution NUM : sets output image resolution
--doublesided : forces double-sided mode

10
src/CMakeLists.txt 100644
Wyświetl plik

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.6)
project(fabmod)
set(CMAKE_BUILD_TYPE Release)
add_subdirectory(core)
add_subdirectory(solver)
add_subdirectory(scripts)
add_subdirectory(guis)
add_subdirectory(py)

15
src/apps/README 100644
Wyświetl plik

@ -0,0 +1,15 @@
kokopelli:
This is a bundled version of kokopelli, an unusual CAD package.
It should be considered alpha software. Use at your own risk.
Online:
kokopelli is usually distributed as part of the fab modules,
found online at http://kokompe.cba.mit.edu
License:
kokopelli is freely available for for experimental and personal use;
license for commercial sale is available from MIT.
Contact:
Matt Keeter
matt.keeter@cba.mit.edu

62
src/apps/bundle.py 100755
Wyświetl plik

@ -0,0 +1,62 @@
#!/usr/bin/env python
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
import shutil
import os
import stat
import subprocess
import glob
# Trick to make this run properly
import sys
sys.argv += ['py2app']
subprocess.call(['make','fab'], cwd='../..')
# Delete old build stuff
try: shutil.rmtree('build')
except OSError: pass
try: shutil.rmtree('koko')
except OSError: pass
try: os.remove('kokopelli.py')
except OSError: pass
# This is the pythons script that we're bundling into an application.
shutil.copy('../../bin/kokopelli','kokopelli.py')
shutil.copytree('../../bin/koko','koko')
APP = ['kokopelli.py']
DATA_FILES = glob.glob('../bin/koko/lib/*.py') + ['cba_icon.png']
OPTIONS = {'argv_emulation': True,
'iconfile':'cba.icns'}
# Run py2app to bundle everything.
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
# Copy libtree
os.mkdir('dist/kokopelli.app/Contents/lib')
shutil.copy('../../lib/libfab.dylib',
'dist/kokopelli.app/Contents/lib/libfab.dylib')
# Copy the readme and examples into the distribution directory, then zip it up
shutil.copy('README','dist')
shutil.copy('../../../../Web/examples.zip', 'dist/examples.zip')
os.system('cd dist; unzip examples.zip; rm -rf __MACOSX;'+
'zip -r kokopelli.zip kokopelli.app README examples')
shutil.rmtree('build')
shutil.rmtree('koko')
shutil.os.remove('kokopelli.py')

BIN
src/apps/cba.icns 100644

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 9.2 KiB

Wyświetl plik

@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 2.6)
set(PROGRAMS vol_gif vol_stl gif_info gif_png gif_stl stl_info stl_png stl_path
png_size png_scale png_distances png_offset png_grb png_drl
png_path png_halftone svg_path
path_eps path_dxf path_png path_rml path_sbp path_g path_camm
path_epi path_uni path_oms path_ord
path_join path_array path_info path_time
CACHE STRING "Core program list")
find_package(PNG REQUIRED)
find_package(GIF REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
include_directories(${GIF_INCLUDE_DIR})
#set(CMAKE_C_FLAGS "-Wall -g")
set(CMAKE_C_FLAGS "-Wall -O3")
add_library(fabcore STATIC fab.c)
foreach(program ${PROGRAMS})
add_executable(${program} ${program}.c)
target_link_libraries(${program} fabcore ${PNG_LIBRARY} ${GIF_LIBRARY} m)
endforeach(program)
if( ${CMAKE_PROJECT_NAME} MATCHES fabmod )
install(TARGETS ${PROGRAMS} DESTINATION ${PROJECT_SOURCE_DIR}/../bin)
endif( ${CMAKE_PROJECT_NAME} MATCHES fabmod )

Wyświetl plik

@ -0,0 +1,52 @@
//
// array_direction.c
// find array edge directions
// array_direction in.array out.array threshold
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
int main(int argc, char **argv) {
//
// variables
//
struct fab_vars v;
init_vars(&v);
int threshold;
//
// command line args
//
if (argc != 4) {
printf("command line: array_direction in.array out.array threshold\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// threshold
//
sscanf(argv[3],"%d",&threshold);
fab_threshold(&v,threshold);
//
// set directions
//
fab_directions(&v);
//
// write array
//
fab_write_array(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,71 @@
//
// array_distances.c
// find distances from edges
// array_distances in.array out.array threshold
//
// Neil Gershenfeld
// CBA MIT 8/5/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,threshold;
float distance;
//
// command line args
//
if (argc != 4) {
printf("command line: array_distances in.array out.array threshold\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// threshold
//
sscanf(argv[3],"%d",&threshold);
fab_threshold(&v,threshold);
//
// find edges
//
fab_edges(&v);
//
// find edge distances
//
fab_distances(&v);
//
// put distances into array
//
for (y = 0; y < v.ny; ++y) {
for (x = 0; x < v.nx; ++x) {
if (v.xptr[y][x] != -1) {
distance = sqrt((v.xptr[y][x]-x)*(v.xptr[y][x]-x)
+ (v.yptr[y][x]-y)*(v.yptr[y][x]-y));
v.array[y][x] = (int) distance;
}
else
v.array[y][x] = 128;
}
}
//
// write array
//
fab_write_array(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,52 @@
//
// array_edges.c
// find edges in array
// array_edges in.array out.array threshold
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
int main(int argc, char **argv) {
//
// variables
//
struct fab_vars v;
init_vars(&v);
int threshold;
//
// command line args
//
if (argc != 4) {
printf("command line: array_edges in.array out.array threshold\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// threshold
//
sscanf(argv[3],"%d",&threshold);
fab_threshold(&v,threshold);
//
// find edges
//
fab_edges(&v);
//
// write array
//
fab_write_array(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,39 @@
//
// array_info.c
// read and print array info
//
// Neil Gershenfeld
// CBA MIT 8/5/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,threshold;
float distance;
//
// command line args
//
if (argc != 2) {
printf("command line: array_info in.array\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
}

Wyświetl plik

@ -0,0 +1,67 @@
//
// array_offset.c
// offset array
// array_offset in.array out.array threshold distance
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,threshold,count;
float distance;
//
// command line args
//
if (argc != 5) {
printf("command line: array_offset in.array out.array threshold distance\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// threshold
//
sscanf(argv[3],"%d",&threshold);
fab_threshold(&v,threshold);
//
// find edges
//
fab_edges(&v);
//
// find edge distances
//
fab_distances(&v);
//
// offset
//
distance = atof(argv[4]);
count = fab_offset(&v,distance);
printf("%d points remain\n",count);
//
// set edge directions
//
fab_directions(&v);
//
// write array
//
fab_write_array(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,43 @@
//
// array_png.c
// converted array to a PNG image
// array_png.c in.array out.png
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
// z layers
//
#include "fab.h"
int main(int argc, char **argv) {
//
// variables
//
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (argc != 3) {
printf("command line: array_png.c in.array out.png\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// write PNG
//
fab_write_png(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,48 @@
//
// array_slice.c
// slice array
// array_slice in.array out.array threshold
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
int main(int argc, char **argv) {
//
// variables
//
struct fab_vars v;
init_vars(&v);
int threshold;
//
// command line args
//
if (argc != 4) {
printf("command line: array_slice in.array out.array threshold\n");
exit(-1);
}
//
// read lattice
//
fab_read_array(&v,argv[1]);
//
// threshold
//
sscanf(argv[3],"%d",&threshold);
fab_threshold(&v,threshold);
//
// write state slice
//
fab_write_array(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,47 @@
//
// array_states_png.c
// converted array states to a PNG image
// array_states png.c in.array out.png
//
// Neil Gershenfeld
// CBA MIT 7/30/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
// z layers
//
#include "fab.h"
int main(int argc, char **argv) {
//
// variables
//
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (argc != 3) {
printf("command line: array_states_png.c in.array out.png\n");
exit(-1);
}
//
// read array
//
fab_read_array(&v,argv[1]);
//
// shade states
//
fab_shade_states(&v);
//
// write PNG
//
fab_write_png(&v,argv[2]);
}

2376
src/core/fab.c 100644

Plik diff jest za duży Load Diff

150
src/core/fab.h 100644
Wyświetl plik

@ -0,0 +1,150 @@
//
// fab.h
// fab modules header
//
// Neil Gershenfeld 7/4/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <png.h>
#include <gif_lib.h>
#include <inttypes.h>
#define fab_big 1e10
//
// data structures
//
struct fab_vars {
unsigned char empty;
unsigned char interior;
unsigned char edge;
unsigned char north;
unsigned char south;
unsigned char east;
unsigned char west;
unsigned char stop;
unsigned char corner;
unsigned char corner2;
unsigned char direction;
unsigned int nx,ny,nz;
unsigned int bit_depth;
unsigned int word_size;
double dx,dy,dz;
double xmin,ymin,zmin;
uint32_t **array;
uint32_t **distances,**g,**h; // for distance transform
uint32_t *starts,*minimums; // "
uint32_t **ddx,**ddy; // testing
struct fab_path_type *path;
struct fab_mesh_type *mesh;
png_bytep *row_pointers;
png_structp png_ptr;
png_infop info_ptr;
};
struct fab_path_type {
struct fab_path_segment_type *first,*segment,*last;
int dof;
};
struct fab_path_segment_type {
struct fab_path_segment_type *previous,*next;
struct fab_path_point_type *first,*point,*last;
};
struct fab_path_point_type {
struct fab_path_point_type *previous,*next;
struct fab_path_axis_type *first,*axis,*last;
};
struct fab_path_axis_type {
struct fab_path_axis_type *previous,*next;
int value;
};
struct fab_mesh_type {
struct fab_mesh_triangle_type *first,*triangle,*last;
float min[3];
float max[3];
int number;
};
struct fab_mesh_triangle_type {
struct fab_mesh_triangle_type *previous,*next;
float normal[3],v0[3],v1[3],v2[3];
int attribute;
};
//
// function prototypes
//
//
// initialization
//
void init_vars(struct fab_vars *v);
//
// input
//
void fab_read_stl(struct fab_vars *v, char *input_file_name);
//void fab_read_svg(struct fab_vars *v, char *input_file_name);
void fab_read_png(struct fab_vars *v, char *input_file_name);
void fab_read_array(struct fab_vars *v, char *input_file_name);
void fab_read_path(struct fab_vars *v, char *input_file_name);
//
// output
//
void fab_write_png_K(struct fab_vars *v, char *output_file_name);
void fab_write_array(struct fab_vars *v, char *output_file_name);
void fab_write_path(struct fab_vars *v, char *output_file_name);
//
// shading
//
void fab_shade_states(struct fab_vars *v);
void fab_shade_line(struct fab_vars *v, int x0, int y0, int x1, int y1, int intensity);
void fab_shade_path(struct fab_vars *v);
void fab_shade_path_displace(struct fab_vars *v);
void fab_shade_mesh(struct fab_vars *v, float units, float resolution, char axis);
void fab_shade_triangle(struct fab_vars *v, float units, int S, int X, int Y, int Z);
//
// array operations
//
void fab_png_array(struct fab_vars *v);
void fab_rescale(struct fab_vars *v, float min, float max);
int fab_edges(struct fab_vars *v);
void fab_threshold(struct fab_vars *v, float threshold);
void fab_distances(struct fab_vars *v);
int fab_offset(struct fab_vars *v, float distance);
void fab_directions(struct fab_vars *v);
//
// mesh operations
//
void fab_mesh_path(struct fab_vars *v, float units, float resolution);
//
// path operations
//
void fab_follow(struct fab_vars *v, float error, int y, int x, int z);
void fab_path_start(struct fab_vars *v, int dof);
void fab_path_segment(struct fab_vars *v);
void fab_path_point(struct fab_vars *v);
void fab_path_axis(struct fab_vars *v, int value);
void fab_path_join(struct fab_vars *vin1, struct fab_vars *vin2, struct fab_vars *vout, float dx, float dy);
void fab_path_cat(struct fab_vars *vin1, struct fab_vars *vin2, struct fab_vars *vout);
void fab_path_append(struct fab_vars *vin1, struct fab_vars *vin2);
void fab_path_array(struct fab_vars *vin, struct fab_vars *vout, int nx, int ny, float dx, float dy);
void fab_vectorize(struct fab_vars *v, float error, int z);
void fab_halftone(struct fab_vars *v, float threshold, int points, float size, float spacing, float offset, int invert);

120
src/core/gif_info.c 100644
Wyświetl plik

@ -0,0 +1,120 @@
//
// gif_info.c
// report .gif info
//
// Neil Gershenfeld 3/24/14
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#define MAX_LINE 10000
#include "fab.h"
int main(int argc, char **argv) {
//
// local vars
//
GifFileType *GIFfile;
GifRecordType GIFtype;
GifByteType *GIFextension;
GifPixelType *GIFline;
int x,y,i,n,imin,imax;
int image_width,image_height,image_count,color_resolution,GIFcode,ret;
float voxel_size;
char comment[256];
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (!(argc == 2)) {
printf("command line: gif_info in.gif\n");
printf(" in.gif = input GIF file\n");
exit(-1);
}
voxel_size = -1;
image_width = -1;
image_height = -1;
image_count = -1;
//
// scan the file
//
printf("read %s\n",argv[1]);
color_resolution = -1;
GIFfile = DGifOpenFileName(argv[1]);
if (GIFfile == NULL) {
printf("gif_info: oops -- can not open %s\n",argv[1]);
exit(-1);
}
GIFline = malloc(MAX_LINE*sizeof(GifPixelType));
imin = 256;
imax = 0;
do {
DGifGetRecordType(GIFfile,&GIFtype);
switch (GIFtype) {
case IMAGE_DESC_RECORD_TYPE:
DGifGetImageDesc(GIFfile);
image_width = GIFfile->SWidth;
image_height = GIFfile->SHeight;
image_count = GIFfile->ImageCount;
color_resolution = GIFfile->SColorResolution;
for (y = 0; y < GIFfile->SHeight; ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_info: oops -- error reading line\n");
exit(-1);
}
for (x = 0; x < GIFfile->SWidth; ++x) {
if (GIFline[x] < imin) imin = GIFline[x];
if (GIFline[x] > imax) imax = GIFline[x];
}
}
break;
case EXTENSION_RECORD_TYPE:
DGifGetExtension(GIFfile,&GIFcode,&GIFextension);
if (GIFcode == COMMENT_EXT_FUNC_CODE) {
n = GIFextension[0];
for (i = 1; i <= n; ++i)
comment[i-1] = GIFextension[i];
comment[n] = 0;
if (voxel_size == -1)
sscanf(comment,"mm per pixel: %f;",&voxel_size);
}
while (GIFextension != NULL)
DGifGetExtensionNext(GIFfile,&GIFextension);
break;
case SCREEN_DESC_RECORD_TYPE:
DGifGetScreenDesc(GIFfile);
break;
case TERMINATE_RECORD_TYPE:
break;
case UNDEFINED_RECORD_TYPE:
printf("gif_info: oops -- undefined GIF record type\n");
exit(-1);
break;
}
} while (GIFtype != TERMINATE_RECORD_TYPE);
if (GIFfile == NULL) {
printf("gif_info: oops -- can not open %s\n",argv[1]);
exit(-1);
}
if (voxel_size == -1) {
voxel_size = 1.0;
printf(" no pixel size found, assuming 1 mm\n");
}
printf(" voxel size (mm): %f, color resolution (bits): %d\n",voxel_size,color_resolution);
printf(" intensity min: %d max: %d\n",imin,imax);
printf(" number of images: %d, image width %d, image height %d\n",image_count,image_width,image_height);
//
// exit
//
DGifCloseFile(GIFfile);
exit(0);
}

346
src/core/gif_png.c 100644
Wyświetl plik

@ -0,0 +1,346 @@
//
// gif_png.c
// .gif to .png
//
// Neil Gershenfeld 9/20/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#define MAX_LINE 10000
#define BIG 1e10
#include "fab.h"
int main(int argc, char **argv) {
//
// local vars
//
GifFileType *GIFfile;
GifRecordType GIFtype;
GifByteType *GIFextension;
GifPixelType *GIFline;
uint32_t **lower_array,**upper_array;
double **image_array;
double f,fmin,fmax;
int x,y,z,h,i,j,k,n,p;
int imin,imax,image_width,image_height,image_count,color_resolution,GIFcode,ret;
float pixel_size,arg,threshold,rx,ry,rz;
char type,comment[256];
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6) || (argc == 7) || (argc == 10))) {
printf("command line: gif_png in.gif out.png [type [arg [points [size [rx ry rz]]]]]\n");
printf(" in.gif = input gif file\n");
printf(" out.png = output PNG file\n");
printf(" type = 'z' of density, 'h' for height (default z)\n");
printf(" arg = type argument\n");
printf(" 'z': gamma (default 1)\n");
printf(" 'h': threshold (0 = min, 1 = max, default 0.5)\n");
printf(" points = points to interpolate per point (linear, default 0)\n");
printf(" size = voxel size (mm, default from file))\n");
printf(" to be implemented: rx,ry,rz = x,y,z rotation angles (degrees; default 0)\n");
exit(-1);
}
type = 'z';
p = 0;
rx = ry = rz = 0;
pixel_size = -1;
image_width = -1;
image_height = -1;
if (argc >= 4) {
sscanf(argv[3],"%c",&type);
if (!((type == 'z') || (type == 'h'))) {
printf("gif_png: oops -- type must be 'z' or 'h'\n");
exit(-1);
}
}
if (type == 'z') arg = 1.0;
else if (type == 'h') arg = 0.5;
if (argc >= 5)
sscanf(argv[4],"%f",&arg);
if (argc >= 6)
sscanf(argv[5],"%d",&p);
if (argc >= 7)
sscanf(argv[6],"%f",&pixel_size);
if (argc >= 10) {
sscanf(argv[7],"%f",&rx);
sscanf(argv[8],"%f",&ry);
sscanf(argv[9],"%f",&rz);
}
//
// scan the file
//
printf("read %s\n",argv[1]);
imin = 256;
imax = 0;
color_resolution = -1;
GIFfile = DGifOpenFileName(argv[1]);
if (GIFfile == NULL) {
printf("gif_png: oops -- can not open %s\n",argv[1]);
exit(-1);
}
GIFline = malloc(MAX_LINE*sizeof(GifPixelType));
do {
DGifGetRecordType(GIFfile,&GIFtype);
switch (GIFtype) {
case IMAGE_DESC_RECORD_TYPE:
DGifGetImageDesc(GIFfile);
image_width = GIFfile->SWidth;
image_height = GIFfile->SHeight;
image_count = GIFfile->ImageCount;
color_resolution = GIFfile->SColorResolution;
for (y = 0; y < GIFfile->SHeight; ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_png: oops -- error reading line\n");
exit(-1);
}
for (x = 0; x < GIFfile->SWidth; ++x) {
if (GIFline[x] < imin) imin = GIFline[x];
if (GIFline[x] > imax) imax = GIFline[x];
}
}
break;
case EXTENSION_RECORD_TYPE:
DGifGetExtension(GIFfile,&GIFcode,&GIFextension);
if (GIFcode == COMMENT_EXT_FUNC_CODE) {
n = GIFextension[0];
for (i = 1; i <= n; ++i)
comment[i-1] = GIFextension[i];
comment[n] = 0;
if (pixel_size == -1)
sscanf(comment,"mm per pixel: %f;",&pixel_size);
}
while (GIFextension != NULL)
DGifGetExtensionNext(GIFfile,&GIFextension);
break;
case SCREEN_DESC_RECORD_TYPE:
DGifGetScreenDesc(GIFfile);
break;
case TERMINATE_RECORD_TYPE:
break;
case UNDEFINED_RECORD_TYPE:
printf("gif_png: oops -- undefined GIF record type\n");
exit(-1);
break;
}
} while (GIFtype != TERMINATE_RECORD_TYPE);
if (GIFfile == NULL) {
printf("gif_png: oops -- can not open %s\n",argv[1]);
exit(-1);
}
if (pixel_size == -1) {
pixel_size = 1.0;
printf(" no pixel size found, assuming 1 mm\n");
}
printf(" pixel size (mm): %f, color resolution (bits): %d\n",pixel_size,color_resolution);
printf(" intensity min: %d max: %d\n",imin,imax);
printf(" number of images: %d, image width %d, image height %d\n",image_count,image_width,image_height);
//
// set threshold
//
if (type == 'h')
threshold = imin + arg*(imax-imin);
//
// check and set limits
//
v.nx = image_width + (image_width-1)*p;
v.ny = image_height + (image_height-1)*p;
v.nz = image_count + (image_count-1)*p;
v.dx = v.nx*pixel_size;
v.dy = v.ny*pixel_size;
v.dz = v.nz*pixel_size;
v.xmin = 0;
v.ymin = 0;
v.zmin = 0;
//
// allocate arrays
//
lower_array = malloc(image_height*sizeof(uint32_t *));
for (y = 0; y < image_height; ++y) {
lower_array[y] = malloc(image_width*sizeof(uint32_t));
for (x = 0; x < image_width; ++x)
lower_array[y][x] = 0;
}
upper_array = malloc(image_height*sizeof(uint32_t *));
for (y = 0; y < image_height; ++y) {
upper_array[y] = malloc(image_width*sizeof(uint32_t));
for (x = 0; x < image_width; ++x)
upper_array[y][x] = 0;
}
image_array = malloc(v.ny*sizeof(double *));
for (y = 0; y < v.ny; ++y) {
image_array[y] = malloc(v.nx*sizeof(double));
for (x = 0; x < v.nx; ++x)
image_array[y][x] = 0;
}
v.array = malloc(v.ny*sizeof(uint32_t *));
for (y = 0; y < v.ny; ++y) {
v.array[y] = malloc(v.nx*sizeof(uint32_t));
for (x = 0; x < v.nx; ++x)
v.array[y][x] = 0;
}
//
// read the file
//
DGifCloseFile(GIFfile);
GIFfile = DGifOpenFileName(argv[1]);
if (GIFfile == NULL) {
printf("gif_png: oops -- can not open %s\n",argv[1]);
exit(-1);
}
z = 0;
do {
DGifGetRecordType(GIFfile,&GIFtype);
switch (GIFtype) {
case IMAGE_DESC_RECORD_TYPE:
//
// read image
//
DGifGetImageDesc(GIFfile);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",z);
if (z == 0) {
//
// read first layer
//
for (y = 0; y < image_height; ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_png: oops -- error reading first line\n");
exit(-1);
}
for (x = 0; x < image_width; ++x)
upper_array[y][x] = GIFline[x];
}
}
else {
//
// read next layer
//
for (y = 0; y < image_height; ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_png: oops -- error reading line\n");
exit(-1);
}
for (x = 0; x < image_width; ++x) {
lower_array[y][x] = upper_array[y][x];
upper_array[y][x] = GIFline[x];
}
}
if (p == 0) {
//
// no interpolation, loop over layer voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
if (type == 'z') {
image_array[y][x] += lower_array[y][x];
}
else if (type == 'h') {
if ((lower_array[y][x] >= threshold) && (upper_array[y][x] < threshold))
image_array[y][x] = z + (lower_array[y][x]-threshold)/(lower_array[y][x]-upper_array[y][x]);
}
}
}
}
else {
//
// yes interpolation, loop over layer sub-voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
for (i = 0; i <= p; ++i) {
for (j = 0; j <= p; ++j) {
for (k = 0; k <= p; ++k) {
f = lower_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ upper_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0));
if (type == 'z') {
image_array[(1+p)*y+j][(1+p)*x+i] += f;
}
else if (type == 'h') {
h = (1+p)*z+k;
if ((f > threshold) && (h > image_array[(1+p)*y+j][(1+p)*x+i]))
image_array[(1+p)*y+j][(1+p)*x+i] = h;
}
}
}
}
}
}
}
}
z += 1;
break;
case EXTENSION_RECORD_TYPE:
DGifGetExtension(GIFfile,&GIFcode,&GIFextension);
while (GIFextension != NULL)
DGifGetExtensionNext(GIFfile,&GIFextension);
break;
case SCREEN_DESC_RECORD_TYPE:
DGifGetScreenDesc(GIFfile);
break;
case TERMINATE_RECORD_TYPE:
break;
case UNDEFINED_RECORD_TYPE:
printf("gif_png: oops -- undefined GIF record type\n");
exit(-1);
break;
}
} while (GIFtype != TERMINATE_RECORD_TYPE);
printf("\n");
//
// scale image and copy to PNG array
//
if (type == 'z') {
fmin = BIG;
fmax = 0;
for (x = 0; x < v.nx; ++x) {
for (y = 0; y < v.ny; ++y) {
if (image_array[y][x] > fmax) fmax = image_array[y][x];
if (image_array[y][x] < fmin) fmin = image_array[y][x];
}
}
if (arg == 1) {
for (x = 0; x < v.nx; ++x)
for (y = 0; y < v.ny; ++y)
v.array[y][x] = 65536*(image_array[y][x]-fmin)/(fmax-fmin);
}
else {
for (x = 0; x < v.nx; ++x)
for (y = 0; y < v.ny; ++y)
v.array[y][x] = 65536*pow((image_array[y][x]-fmin)/(fmax-fmin),arg);
}
}
else if (type == 'h') {
for (x = 0; x < v.nx; ++x)
for (y = 0; y < v.ny; ++y)
v.array[y][x] = 65536*image_array[y][x]/(v.nz-1.0);
}
//
// write PNG
//
v.bit_depth = 16;
fab_write_png_K(&v,argv[2]);
//
// exit
//
DGifCloseFile(GIFfile);
exit(0);
}

717
src/core/gif_stl.c 100644
Wyświetl plik

@ -0,0 +1,717 @@
//
// gif_stl.c
// .gif to .stl
//
// Neil Gershenfeld 12/11/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#define MAX_LINE 10000
#include "fab.h"
/*
vertices:
---
6 7
4 5
---
2 3
0 1
---
edges:
---
k
l j
i
---
h g
e f
---
c
d b
a
---
*/
//
// rotate_x
// rotate rule around x and add
//
void rotate_x(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[4] << 0)
+(b[5] << 1)
+(b[0] << 2)
+(b[1] << 3)
+(b[6] << 4)
+(b[7] << 5)
+(b[2] << 6)
+(b[3] << 7);
for (i
= 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'c'; break;
case 'b': rules[*index][i] = 'g'; break;
case 'c': rules[*index][i] = 'k'; break;
case 'd': rules[*index][i] = 'h'; break;
case 'e': rules[*index][i] = 'd'; break;
case 'f': rules[*index][i] = 'b'; break;
case 'g': rules[*index][i] = 'j'; break;
case 'h': rules[*index][i] = 'l'; break;
case 'i': rules[*index][i] = 'a'; break;
case 'j': rules[*index][i] = 'f'; break;
case 'k': rules[*index][i] = 'i'; break;
case 'l': rules[*index][i] = 'e'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// rotate_y
// rotate rule around y and add
//
void rotate_y(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[1] << 0)
+(b[5] << 1)
+(b[3] << 2)
+(b[7] << 3)
+(b[0] << 4)
+(b[4] << 5)
+(b[2] << 6)
+(b[6] << 7);
for (i = 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'e'; break;
case 'b': rules[*index][i] = 'd'; break;
case 'c': rules[*index][i] = 'h'; break;
case 'd': rules[*index][i] = 'l'; break;
case 'e': rules[*index][i] = 'i'; break;
case 'f': rules[*index][i] = 'a'; break;
case 'g': rules[*index][i] = 'c'; break;
case 'h': rules[*index][i] = 'k'; break;
case 'i': rules[*index][i] = 'f'; break;
case 'j': rules[*index][i] = 'b'; break;
case 'k': rules[*index][i] = 'g'; break;
case 'l': rules[*index][i] = 'j'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// rotate_z
// rotate rule around z and add
//
void rotate_z(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[2] << 0)
+(b[0] << 1)
+(b[3] << 2)
+(b[1] << 3)
+(b[6] << 4)
+(b[4] << 5)
+(b[7] << 6)
+(b[5] << 7);
for (i = 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'b'; break;
case 'b': rules[*index][i] = 'c'; break;
case 'c': rules[*index][i] = 'd'; break;
case 'd': rules[*index][i] = 'a'; break;
case 'e': rules[*index][i] = 'f'; break;
case 'f': rules[*index][i] = 'g'; break;
case 'g': rules[*index][i] = 'h'; break;
case 'h': rules[*index][i] = 'e'; break;
case 'i': rules[*index][i] = 'j'; break;
case 'j': rules[*index][i] = 'k'; break;
case 'k': rules[*index][i] = 'l'; break;
case 'l': rules[*index][i] = 'i'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// print_rules
// print the rule table
//
void print_rules(char rules[255][20]) {
int i,b;
printf("76543210\n");
for (i = 0; i < 256; ++i) {
for (b = 7; b >= 0; --b) {
printf("%d",(i & (1 << b)) >> b);
}
printf(" %d %s\n",i,rules[i]);
}
}
// add_rules
// add a rule and its variants to the table
//
void add_rules(char rules[255][20], int index, char *edges) {
int i,j,k,l;
strcpy(rules[index],edges);
for (i=0; i<4; ++i) {
for (j=0; j<4; ++j) {
for (k=0; k<4; ++k) {
rotate_x(rules,&index);
}
rotate_y(rules,&index);
}
rotate_z(rules,&index);
}
}
//
// init_rules
// create the rule table
//
void init_rules(char rules[255][20]) {
int i,j;
for (i = 0; i < 256; ++i)
for (j = 0; j < 20; ++j)
rules[i][j] = 0;
add_rules(rules,0b00000000,""); // 0
add_rules(rules,0b11111111,""); // ~0
add_rules(rules,0b00000001,"eda"); // 1
add_rules(rules,0b11111110,"ade"); // ~1
add_rules(rules,0b00000011,"fed dbf"); // 2
add_rules(rules,0b11111100,"def fbd"); // ~2
add_rules(rules,0b00100001,"eda jif"); // 3
add_rules(rules,0b11011110,"ade fij"); // ~3
add_rules(rules,0b10000001,"eda gkj"); // 4
add_rules(rules,0b01111110,"ade jkg"); // ~4
add_rules(rules,0b00001110,"fhg fdh fad"); // 5
add_rules(rules,0b11110001,"ghf hdf daf"); // ~5
add_rules(rules,0b10000011,"fed fdb gkj"); // 6
add_rules(rules,0b01111100,"def bdf jkg"); // ~6
add_rules(rules,0b10010010,"bfa ile gkj"); // 7
add_rules(rules,0b01101101,"afb eli jkg"); // ~7
add_rules(rules,0b00001111,"ehg feg"); // 8
add_rules(rules,0b11110000,"ghe gef"); // ~8
add_rules(rules,0b01001101,"elk eka akg agb"); // 9
add_rules(rules,0b10110010,"kle ake gka bga"); // ~9
add_rules(rules,0b10011001,"ild ida ckj cjb"); // 10
add_rules(rules,0b01100110,"dli adi jkc bjc"); // ~10
add_rules(rules,0b10001101,"hkj hja hae ajb"); // 11
add_rules(rules,0b01110010,"jkh ajh eah bja"); // ~11
add_rules(rules,0b00011110,"ile hgf hfd dfa"); // 12
add_rules(rules,0b11100001,"eli fgh dfh afd"); // ~12
add_rules(rules,0b01101001,"eda bcg lkh jif"); // 13
add_rules(rules,0b10010110,"ade gcb hkl fij"); // ~13
add_rules(rules,0b01001110,"lkg lga lad agf"); // 14
add_rules(rules,0b10110001,"gkl agl dal fga"); // ~14
}
//
// vertex
// add a triangle vertex
//
void vertex(char c, int x, int y, int z, float voxel_size, float t, uint32_t *w, float *array) {
switch(c) {
case 'a':
array[0] = x+(w[0]-t)/(w[0]-((float) w[1]));
array[1] = y;
array[2] = z;
break;
case 'b':
array[0] = x+1;
array[1] = y+(w[1]-t)/(w[1]-((float) w[3]));
array[2] = z;
break;
case 'c':
array[0] = x+(w[2]-t)/(w[2]-((float) w[3]));
array[1] = y+1;
array[2] = z;
break;
case 'd':
array[0] = x;
array[1] = y+(w[0]-t)/(w[0]-((float) w[2]));
array[2] = z;
break;
case 'e':
array[0] = x;
array[1] = y;
array[2] = z+(w[0]-t)/(w[0]-((float) w[4]));
break;
case 'f':
array[0] = x+1;
array[1] = y;
array[2] = z+(w[1]-t)/(w[1]-((float) w[5]));
break;
case 'g':
array[0] = x+1;
array[1] = y+1;
array[2] = z+(w[3]-t)/(w[3]-((float) w[7]));
break;
case 'h':
array[0] = x;
array[1] = y+1;
array[2] = z+(w[2]-t)/(w[2]-((float) w[6]));
break;
case 'i':
array[0] = x+(w[4]-t)/(w[4]-((float) w[5]));
array[1] = y;
array[2] = z+1;
break;
case 'j':
array[0] = x+1;
array[1] = y+(w[5]-t)/(w[5]-((float) w[7]));
array[2] = z+1;
break;
case 'k':
array[0] = x+(w[6]-t)/(w[6]-((float) w[7]));
array[1] = y+1;
array[2] = z+1;
break;
case 'l':
array[0] = x;
array[1] = y+(w[4]-t)/(w[4]-((float) w[6]));
array[2] = z+1;
break;
}
array[0] = voxel_size*array[0];
array[1] = voxel_size*array[1];
array[2] = voxel_size*array[2];
}
//
// triangulate
// triangulate voxel at lattice site x,y,z with vertex weights w
//
void triangulate(int x, int y, int z, float voxel_size, float t, uint32_t *w, char rules[255][20], struct fab_vars *v) {
int i,index;
char c;
//
// set index code
//
index = ((w[0] >= t) ? 0 : 1)
+ ((w[1] >= t) ? 0 : 2)
+ ((w[2] >= t) ? 0 : 4)
+ ((w[3] >= t) ? 0 : 8)
+ ((w[4] >= t) ? 0 : 16)
+ ((w[5] >= t) ? 0 : 32)
+ ((w[6] >= t) ? 0 : 64)
+ ((w[7] >= t) ? 0 : 128);
//
// add triangles for rule
//
i = 0;
while (1) {
//
// loop over rule chars
//
c = rules[index][i];
if (c == 0)
//
// end of rule
//
break;
else if (c == ' ') {
//
// space between rules
//
i += 1;
continue;
}
else {
//
// create triangle for rule
//
v->mesh->last = malloc(sizeof(struct fab_mesh_triangle_type));
v->mesh->last->previous = v->mesh->triangle;
v->mesh->triangle->next = v->mesh->last;
v->mesh->triangle = v->mesh->last;
v->mesh->triangle->next = 0;
v->mesh->triangle->attribute = 0;
v->mesh->triangle->normal[0] = v->mesh->triangle->normal[1] = v->mesh->triangle->normal[2] = 0;
//
// add vertices for rule
//
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v0);
i += 1;
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v1);
i += 1;
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v2);
i += 1;
}
}
}
void fab_write_stl(struct fab_vars *v, char *output_file_name) {
//
// write mesh as STL
//
FILE *output_file;
char buf[80];
uint32_t count;
//
// open output file
//
output_file = fopen(output_file_name, "wb");
if (output_file == 0) {
printf("fab.c: oops -- can't open %s\n",output_file_name);
exit(-1);
}
//
// write header
//
fwrite(buf,80,1,output_file);
//
// write count
//
count = 0;
v->mesh->triangle = v->mesh->first;
while (v->mesh->triangle->next != 0) {
v->mesh->triangle = v->mesh->triangle->next;
count += 1;
}
fwrite(&count,4,1,output_file);
//
// write triangles
//
v->mesh->triangle = v->mesh->first;
while (v->mesh->triangle->next != 0) {
v->mesh->triangle = v->mesh->triangle->next;
fwrite(v->mesh->triangle->normal,4,3,output_file);
fwrite(v->mesh->triangle->v0,4,3,output_file);
fwrite(v->mesh->triangle->v1,4,3,output_file);
fwrite(v->mesh->triangle->v2,4,3,output_file);
fwrite(&(v->mesh->triangle->attribute),2,1,output_file);
}
//
// return
//
printf("wrote %d triangles to %s\n",count,output_file_name);
fclose(output_file);
}
float interp(int x,int y,int i,int j,int k,uint32_t **lower_array,uint32_t **upper_array,int p) {
//
// trilinear interpolation within a voxel
//
return (lower_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ upper_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0)));
}
int main(int argc, char **argv) {
//
// local vars
//
GifFileType *GIFfile;
GifRecordType GIFtype;
GifByteType *GIFextension;
GifPixelType *GIFline;
uint32_t w[8],**lower_array,**upper_array;
int x,y,z,i,j,k,n,p,imin,imax;
int image_width,image_height,image_count,color_resolution,GIFcode,ret;
float threshold,voxel_size;
char comment[256],rules[255][20];
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6))) {
printf("command line: gif_stl in.gif out.stl [threshold [size [points [angle]]]]\n");
printf(" in.gif = input GIF section file\n");
printf(" out.stl = output STL file\n");
printf(" threshold: surface intensity threshold (0 = min, 1 = max, default 0.5))\n");
printf(" size = voxel size (mm, default from file))\n");
printf(" points = points to interpolate per point (default 0)\n");
printf(" to be implemented: angle = minimum relative face angle to decimate vertices (default 0)\n");
exit(-1);
}
p = 0;
threshold = 0.5;
voxel_size = -1;
image_width = -1;
image_height = -1;
image_count = -1;
if (argc >= 4)
sscanf(argv[3],"%f",&threshold);
if (argc >= 5)
sscanf(argv[4],"%f",&voxel_size);
if (argc >= 6)
sscanf(argv[5],"%d",&p);
//
// initialize the rule table
//
init_rules(rules);
//
// scan the file
//
printf("read %s\n",argv[1]);
color_resolution = -1;
GIFfile = DGifOpenFileName(argv[1]);
if (GIFfile == NULL) {
printf("gif_stl: oops -- can not open %s\n",argv[1]);
exit(-1);
}
GIFline = malloc(MAX_LINE*sizeof(GifPixelType));
imin = 256;
imax = 0;
do {
DGifGetRecordType(GIFfile,&GIFtype);
switch (GIFtype) {
case IMAGE_DESC_RECORD_TYPE:
DGifGetImageDesc(GIFfile);
image_width = GIFfile->SWidth;
image_height = GIFfile->SHeight;
image_count = GIFfile->ImageCount;
color_resolution = GIFfile->SColorResolution;
for (y = 0; y < GIFfile->SHeight; ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_stl: oops -- error reading line\n");
exit(-1);
}
for (x = 0; x < GIFfile->SWidth; ++x) {
if (GIFline[x] < imin) imin = GIFline[x];
if (GIFline[x] > imax) imax = GIFline[x];
}
}
break;
case EXTENSION_RECORD_TYPE:
DGifGetExtension(GIFfile,&GIFcode,&GIFextension);
if (GIFcode == COMMENT_EXT_FUNC_CODE) {
n = GIFextension[0];
for (i = 1; i <= n; ++i)
comment[i-1] = GIFextension[i];
comment[n] = 0;
if (voxel_size == -1)
sscanf(comment,"mm per pixel: %f;",&voxel_size);
}
while (GIFextension != NULL)
DGifGetExtensionNext(GIFfile,&GIFextension);
break;
case SCREEN_DESC_RECORD_TYPE:
DGifGetScreenDesc(GIFfile);
break;
case TERMINATE_RECORD_TYPE:
break;
case UNDEFINED_RECORD_TYPE:
printf("gif_stl: oops -- undefined GIF record type\n");
exit(-1);
break;
}
} while (GIFtype != TERMINATE_RECORD_TYPE);
if (GIFfile == NULL) {
printf("gif_stl: oops -- can not open %s\n",argv[1]);
exit(-1);
}
if (voxel_size == -1) {
voxel_size = 1.0;
printf(" no pixel size found, assuming 1 mm\n");
}
printf(" voxel size (mm): %f, color resolution (bits): %d\n",voxel_size,color_resolution);
printf(" intensity min: %d max: %d\n",imin,imax);
printf(" number of images: %d, image width %d, image height %d\n",image_count,image_width,image_height);
//
// set threshold
//
threshold = imin + threshold*(imax-imin);
//
// add empty border
//
image_width += 2;
image_height += 2;
image_count += 2;
//
// allocate arrays
//
lower_array = malloc(image_height*sizeof(uint32_t *));
for (y = 0; y < image_height; ++y) {
lower_array[y] = malloc(image_width*sizeof(uint32_t));
for (x = 0; x < image_width; ++x)
lower_array[y][x] = 0;
}
upper_array = malloc(image_height*sizeof(uint32_t *));
for (y = 0; y < image_height; ++y) {
upper_array[y] = malloc(image_width*sizeof(uint32_t));
for (x = 0; x < image_width; ++x)
upper_array[y][x] = 0;
}
//
// read the file
//
DGifCloseFile(GIFfile);
GIFfile = DGifOpenFileName(argv[1]);
if (GIFfile == NULL) {
printf("gif_stl: oops -- can not open %s\n",argv[1]);
exit(-1);
}
z = 0;
v.mesh = malloc(sizeof(struct fab_mesh_type));
v.mesh->triangle = malloc(sizeof(struct fab_mesh_triangle_type));
v.mesh->first = v.mesh->triangle;
v.mesh->last = v.mesh->triangle;
v.mesh->triangle->previous = v.mesh->triangle->next = 0;
do {
DGifGetRecordType(GIFfile,&GIFtype);
switch (GIFtype) {
case IMAGE_DESC_RECORD_TYPE:
//
// read image
//
DGifGetImageDesc(GIFfile);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",z);
//
// read layer
//
for (y = 0; y < (image_height-2); ++y) {
ret = DGifGetLine(GIFfile,GIFline,GIFfile->SWidth);
if (ret != GIF_OK) {
printf("gif_stl: oops -- error reading line\n");
exit(-1);
}
for (x = 0; x < (image_width-2); ++x) {
lower_array[y+1][x+1] = upper_array[y+1][x+1];
upper_array[y+1][x+1] = GIFline[x];
}
}
if (p == 0) {
//
// no interpolation, loop over layer voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
w[0] = lower_array[y][x];
w[1] = lower_array[y][x+1];
w[2] = lower_array[y+1][x];
w[3] = lower_array[y+1][x+1];
w[4] = upper_array[y][x];
w[5] = upper_array[y][x+1];
w[6] = upper_array[y+1][x];
w[7] = upper_array[y+1][x+1];
triangulate(x,y,z,voxel_size,threshold,w,rules,&v);
}
}
}
else {
//
// yes interpolation, loop over layer sub-voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
for (i = 0; i <= p; ++i) {
for (j = 0; j <= p; ++j) {
for (k = 0; k <= p; ++k) {
w[0] = interp(x,y,i,j,k,lower_array,upper_array,p);
w[1] = interp(x,y,i+1,j,k,lower_array,upper_array,p);
w[2] = interp(x,y,i,j+1,k,lower_array,upper_array,p);
w[3] = interp(x,y,i+1,j+1,k,lower_array,upper_array,p);
w[4] = interp(x,y,i,j,k+1,lower_array,upper_array,p);
w[5] = interp(x,y,i+1,j,k+1,lower_array,upper_array,p);
w[6] = interp(x,y,i,j+1,k+1,lower_array,upper_array,p);
w[7] = interp(x,y,i+1,j+1,k+1,lower_array,upper_array,p);
triangulate((1+p)*x+i,(1+p)*y+j,(1+p)*z+k,voxel_size,threshold,w,rules,&v);
}
}
}
}
}
}
z += 1;
break;
case EXTENSION_RECORD_TYPE:
DGifGetExtension(GIFfile,&GIFcode,&GIFextension);
while (GIFextension != NULL)
DGifGetExtensionNext(GIFfile,&GIFextension);
break;
case SCREEN_DESC_RECORD_TYPE:
DGifGetScreenDesc(GIFfile);
break;
case TERMINATE_RECORD_TYPE:
break;
case UNDEFINED_RECORD_TYPE:
printf("gif_stl: oops -- undefined GIF record type\n");
exit(-1);
break;
}
} while (GIFtype != TERMINATE_RECORD_TYPE);
//
// add empty top layer
//
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",z);
for (y = 0; y < (image_height-2); ++y) {
for (x = 0; x < (image_width-2); ++x) {
lower_array[y+1][x+1] = upper_array[y+1][x+1];
upper_array[y+1][x+1] = 0;
}
}
if (p == 0) {
//
// no interpolation, loop over layer voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
w[0] = lower_array[y][x];
w[1] = lower_array[y][x+1];
w[2] = lower_array[y+1][x];
w[3] = lower_array[y+1][x+1];
w[4] = upper_array[y][x];
w[5] = upper_array[y][x+1];
w[6] = upper_array[y+1][x];
w[7] = upper_array[y+1][x+1];
triangulate(x,y,z,voxel_size,threshold,w,rules,&v);
}
}
}
else {
//
// yes interpolation, loop over layer sub-voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
for (i = 0; i <= p; ++i) {
for (j = 0; j <= p; ++j) {
for (k = 0; k <= p; ++k) {
w[0] = interp(x,y,i,j,k,lower_array,upper_array,p);
w[1] = interp(x,y,i+1,j,k,lower_array,upper_array,p);
w[2] = interp(x,y,i,j+1,k,lower_array,upper_array,p);
w[3] = interp(x,y,i+1,j+1,k,lower_array,upper_array,p);
w[4] = interp(x,y,i,j,k+1,lower_array,upper_array,p);
w[5] = interp(x,y,i+1,j,k+1,lower_array,upper_array,p);
w[6] = interp(x,y,i,j+1,k+1,lower_array,upper_array,p);
w[7] = interp(x,y,i+1,j+1,k+1,lower_array,upper_array,p);
triangulate((1+p)*x+i,(1+p)*y+j,(1+p)*z+k,voxel_size,threshold,w,rules,&v);
}
}
}
}
}
}
printf("\n");
//
// write STL
//
fab_write_stl(&v,argv[2]);
//
// exit
//
DGifCloseFile(GIFfile);
exit(0);
}

Wyświetl plik

@ -0,0 +1,69 @@
//
// path_array.c
// array path
//
// Neil Gershenfeld
// CBA MIT 10/6/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars vin;
init_vars(&vin);
struct fab_vars vout;
init_vars(&vout);
int nx,ny;
float dx,dy;
//
// command line args
//
if (!((argc == 5) || (argc == 6) || (argc == 7))) {
printf("command line: path_array in.path out.path nx ny [dx [dy]]\n");
printf(" in.path = input path file\n");
printf(" out.path = output path file\n");
printf(" nx = number of horizonal array elements\n");
printf(" ny = number of vertical array elements\n");
printf(" dx = array element horizontal spacing (optional, mm, default 0)\n");
printf(" dy = array element vertical spacing (optional, mm, default dx)\n");
exit(-1);
}
if (argc == 5) {
sscanf(argv[3],"%d",&nx);
sscanf(argv[4],"%d",&ny);
dx = 0;
dy = dx;
}
if (argc == 6) {
sscanf(argv[3],"%d",&nx);
sscanf(argv[4],"%d",&ny);
sscanf(argv[5],"%f",&dx);
dy = dx;
}
else if (argc == 7) {
sscanf(argv[3],"%d",&nx);
sscanf(argv[4],"%d",&ny);
sscanf(argv[5],"%f",&dx);
sscanf(argv[6],"%f",&dy);
}
//
// read path
//
fab_read_path(&vin,argv[1]);
//
// array path
//
fab_path_array(&vin,&vout,nx,ny,dx,dy);
//
// write path
//
fab_write_path(&vout,argv[2]);
}

Wyświetl plik

@ -0,0 +1,128 @@
//
// path_camm.c
// convert path to Roland vinylcutter .camm
//
// Neil Gershenfeld
// CBA MIT 9/1/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_camm(struct fab_vars *v, char *output_file_name, float force, float velocity, float ox, float oy, char loc) {
//
// write path to Roland vinylcutter file
//
FILE *output_file;
int x,y,nsegs=0,npts=0;
float scale,xoffset,yoffset;
output_file = fopen(output_file_name,"w");
fprintf(output_file,"PA;PA;!ST1;!FS%f;VS%f;\n",force,velocity);
scale = 40.0*v->dx/(v->nx-1.0); // 40/mm
if (loc == 'l') {
xoffset = 40.0*(ox);
yoffset = 40.0*(oy);
}
else if (loc == 'r') {
xoffset = 40.0*(ox - v->dx);
yoffset = 40.0*(oy);
}
else if (loc == 'L') {
xoffset = 40.0*(ox);
yoffset = 40.0*(oy - v->dy);
}
else if (loc == 'R') {
xoffset = 40.0*(ox - v->dx);
yoffset = 40.0*(oy - v->dy);
}
v->path->segment = v->path->last;
while (1) {
//
// follow segments
//
v->path->segment->point = v->path->segment->first;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
fprintf(output_file,"PU%d,%d;\n",x,y); // move up to start point
fprintf(output_file,"PU%d,%d;\n",x,y); // hack: repeat in case comm dropped
fprintf(output_file,"PD%d,%d;\n",x,y); // move down
fprintf(output_file,"PD%d,%d;\n",x,y); // hack: repeat in case comm dropped
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
fprintf(output_file,"PD%d,%d;\n",x,y); // move down
fprintf(output_file,"PD%d,%d;\n",x,y); // hack: repeat in case comm dropped
npts += 1;
}
//fprintf(output_file,"\n",x,y);
if (v->path->segment->previous == 0)
break;
v->path->segment = v->path->segment->previous;
}
fprintf(output_file,"PU0,0;\n"); // pen up to origin
fprintf(output_file,"PU0,0;\n"); // hack: repeat in case comm dropped
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float ox,oy,force,velocity;
char loc;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 7) || (argc == 8))) {
printf("command line: path_camm in.path out.camm [force [velocity [x y [location]]]]\n");
printf(" in.path = input path file\n");
printf(" out.camm = output Roland vinylcutter file\n");
printf(" force = cutting force (optional, grams, default 45)\n");
printf(" velocity = cutting speed (optional, cm/s, default 2)\n");
printf(" x = origin x (optional, mm, default 0)\n");
printf(" y = origin y (optional, mm, default 0)\n");
printf(" location = origin location (optional, bottom left:l, bottom right:r, top left:L, top right:R, default l)\n");
exit(-1);
}
force = 45;
velocity = 2;
ox = 0;
oy = 0;
loc = 'l';
if (argc >= 4) {
sscanf(argv[3],"%f",&force);
}
if (argc >= 5) {
sscanf(argv[4],"%f",&velocity);
}
if (argc >= 7) {
sscanf(argv[5],"%f",&ox);
sscanf(argv[6],"%f",&oy);
}
if (argc >= 8) {
sscanf(argv[7],"%c",&loc);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write .epi
//
fab_write_camm(&v,argv[2],force,velocity,ox,oy,loc);
}

149
src/core/path_dxf.c 100644
Wyświetl plik

@ -0,0 +1,149 @@
//
// path_dxf.c
// convert path to DXF
// todo: 3D paths
//
// Neil Gershenfeld
// CBA MIT 8/25/12
//
// (c) Massachusetts Institute of Technology 2012
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_dxf(struct fab_vars *v, char *output_file_name) {
//
// write path to DXF file
//
int x,y,z;
float x0,y0,z0,x1,y1,z1;
FILE *output_file;
int nsegs=0, npts=0;
float scale,units;
units = 1/25.4;
scale = v->dx/(v->nx-1.0);
output_file = fopen(output_file_name,"w");
fprintf(output_file,"999\nDXF written by fab modules path_dxf\n");
fprintf(output_file,"0\nSECTION\n");
fprintf(output_file,"2\nHEADER\n");
fprintf(output_file,"9\n$ACADVER\n1\nAC1009\n");
fprintf(output_file,"9\n$EXTMIN\n");
fprintf(output_file,"10\n%f\n",units*v->xmin);
fprintf(output_file,"20\n%f\n",units*v->ymin);
if (v->path->dof == 3)
fprintf(output_file,"30\n%f\n",units*(v->zmin));
fprintf(output_file,"9\n$EXTMAX\n");
fprintf(output_file,"10\n%f\n",units*(v->xmin+v->dx));
fprintf(output_file,"20\n%f\n",units*(v->ymin+v->dy));
if (v->path->dof == 3)
fprintf(output_file,"30\n%f\n",units*(v->zmin+v->dz));
fprintf(output_file,"0\nENDSEC\n");
/*
fprintf(output_file,"0\nSECTION\n");
fprintf(output_file,"2\nTABLES\n");
fprintf(output_file,"0\nTABLE\n");
fprintf(output_file,"2\nLTYPE\n70\n1\n");
fprintf(output_file,"0\nLTYPE\n");
fprintf(output_file,"2\nCONTINUOUS\n");
fprintf(output_file,"70\n64\n3\n");
fprintf(output_file,"Solid line\n");
fprintf(output_file,"72\n65\n73\n0\n40\n0.000000\n");
fprintf(output_file,"0\nENDTAB\n");
fprintf(output_file,"0\nTABLE\n2\nLAYER\n70\n1\n");
fprintf(output_file,"0\nLAYER\n2\ndefault\n70\n64\n62\n7\n6\n");
fprintf(output_file,"CONTINUOUS\n0\nENDTAB\n");
fprintf(output_file,"0\nENDSEC\n");
fprintf(output_file,"0\nSECTION\n");
fprintf(output_file,"2\nBLOCKS\n");
fprintf(output_file,"0\nENDSEC\n");
*/
fprintf(output_file,"0\nSECTION\n");
fprintf(output_file,"2\nENTITIES\n");
v->path->segment = v->path->first;
while (1) {
//
// follow segments
//
v->path->segment->point = v->path->segment->first;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
if (v->path->dof == 3)
z = v->path->segment->point->first->next->next->value;
x0 = units*(v->xmin+scale*x);
y0 = units*(v->ymin+scale*y);
if (v->path->dof == 3)
z0 = units*(v->zmin+scale*z);
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
if (v->path->dof == 3)
z = v->path->segment->point->first->next->next->value;
x1 = units*(v->xmin+scale*x);
y1 = units*(v->ymin+scale*y);
if (v->path->dof == 3)
z1 = units*(v->zmin+scale*z);
fprintf(output_file,"0\nLINE\n");
fprintf(output_file,"10\n%f\n",x0);
fprintf(output_file,"20\n%f\n",y0);
if (v->path->dof == 3)
fprintf(output_file,"30\n%f\n",z0);
fprintf(output_file,"11\n%f\n",x1);
fprintf(output_file,"21\n%f\n",y1);
if (v->path->dof == 3)
fprintf(output_file,"31\n%f\n",z1);
x0 = x1;
y0 = y1;
if (v->path->dof == 3)
z0 = z1;
npts += 1;
}
if (v->path->segment->next == 0)
break;
v->path->segment = v->path->segment->next;
}
fprintf(output_file,"0\nENDSEC\n");
fprintf(output_file,"0\nEOF\n");
fclose(output_file);
printf("write %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
struct fab_vars vnew;
init_vars(&vnew);
char view;
int x,y,z,nz,dz;
float scale;
//
// command line args
//
if (!(argc == 3)) {
printf("command line: path_dxf in.path out.dxf\n");
printf(" in.path = input path file\n");
printf(" out.dxf = output DXF file\n");
exit(-1);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write dxf
//
fab_write_dxf(&v,argv[2]);
}

182
src/core/path_epi.c 100644
Wyświetl plik

@ -0,0 +1,182 @@
//
// path_epi.c
// convert path to Epilog lasercutter .epi
//
// Neil Gershenfeld 8/18/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include "fab.h"
void fab_write_epi(struct fab_vars *v, char *output_file_name, int power, int speed, int focus, float ox, float oy, char loc, int rate, int max_power) {
//
// write path to Epilog lasercutter file
//
FILE *output_file;
int i,x,y,z,current_z,layer_power,nsegs=0,npts=0;
float scale,xoffset,yoffset;
output_file = fopen(output_file_name,"w");
scale = 600.0*v->dx/(25.4*(v->nx-1.0)); // 600 DPI
if (loc == 'l') {
xoffset = 600.0*(ox)/25.4;
yoffset = 600.0*(oy - v->dy)/25.4;
}
else if (loc == 'r') {
xoffset = 600.0*(ox - v->dx)/25.4;
yoffset = 600.0*(oy - v->dy)/25.4;
}
else if (loc == 'L') {
xoffset = 600.0*(ox)/25.4;
yoffset = 600.0*(oy)/25.4;
}
else if (loc == 'R') {
xoffset = 600.0*(ox - v->dx)/25.4;
yoffset = 600.0*(oy)/25.4;
}
if (focus == 0)
//
// init with autofocus off
//
fprintf(output_file,"%%-12345X@PJL JOB NAME=%s\r\nE@PJL ENTER LANGUAGE=PCL\r\n&y0A&l0U&l0Z&u600D*p0X*p0Y*t600R*r0F&y50P&z50S*r6600T*r5100S*r1A*rC%%1BIN;XR%d;YP%d;ZS%d;\n",output_file_name,rate,power,speed);
else
//
// init with autofocus on
//
fprintf(output_file,"%%-12345X@PJL JOB NAME=%s\r\nE@PJL ENTER LANGUAGE=PCL\r\n&y1A&l0U&l0Z&u600D*p0X*p0Y*t600R*r0F&y50P&z50S*r6600T*r5100S*r1A*rC%%1BIN;XR%d;YP%d;ZS%d;\n",output_file_name,rate,power,speed);
current_z = 0;
fprintf(output_file,"YP%d;\n",power);
v->path->segment = v->path->last;
while (1) {
//
// follow segments in reverse order
//
v->path->segment->point = v->path->segment->first;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * v->path->segment->point->first->next->value;
if (v->path->dof >= 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
layer_power = power + (max_power-power) * z / (v->nz - 1.0);
fprintf(output_file,"YP%d;\n",layer_power);
current_z = z;
}
}
if (x < 0) x = 0;
if (y < 0) y = 0;
fprintf(output_file,"PU%d,%d;",x,y);
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * v->path->segment->point->first->next->value;
if (v->path->dof >= 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
layer_power = power + (max_power-power) * z / (v->nz - 1.0);
fprintf(output_file,"YP%d;\n",layer_power);
current_z = z;
}
}
if (x < 0) x = 0;
if (y < 0) y = 0;
fprintf(output_file,"PD%d,%d;",x,y);
npts += 1;
}
fprintf(output_file,"\n");
if (v->path->segment == v->path->first)
break;
v->path->segment = v->path->segment->previous;
}
fprintf(output_file,"%%0B%%1BPUE%%-12345X@PJL EOJ \r\n");
//
// end-of-file padding hack from Epilog print driver
//
for (i = 0; i < 10000; ++i)
fprintf(output_file," ");
// fprintf(output_file,"%c",26); // ^z
//
// close and return
//
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
int main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int power,max_power,speed,focus,rate;
float ox,oy;
char loc;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6) || (argc == 8) || (argc == 9) || (argc == 10) || (argc == 11))) {
printf("command line: path_epi in.path out.epi [power [speed [focus [x y [ location [rate [max_power]]]]]]]\n");
printf(" in.path = input path file\n");
printf(" out.epi= output Epilog lasercutter file\n");
printf(" power = percent power, for minimum z value (optional, 0-100, default 50)\n");
printf(" speed = percent speed (optional, 0-100, default 50)\n");
printf(" focus = autofocus (optional, 0=off | 1=on, default on)\n");
printf(" x = origin x (optional, mm, default 0 = left side of bed)\n");
printf(" y = origin y (optional, mm, default 0 = back side of bed, front positive)\n");
printf(" location = origin location (optional, bottom left:l, bottom right:r, top left:L, top right:R, default l)\n");
printf(" rate = pulse rate (optional, frequency, default 2500)\n");
printf(" max_power = percent power, for maximum z value (optional, 0-100, default power)\n");
exit(-1);
}
power = 50;
speed = 50;
focus = 1;
ox = 0;
oy = 0;
loc = 'l';
rate = 2500;
max_power = power;
if (argc >= 4) {
sscanf(argv[3],"%d",&power);
}
if (argc >= 5) {
sscanf(argv[4],"%d",&speed);
}
if (argc >= 6) {
sscanf(argv[5],"%d",&focus);
}
if (argc >= 8) {
sscanf(argv[6],"%f",&ox);
sscanf(argv[7],"%f",&oy);
}
if (argc >= 9) {
sscanf(argv[8],"%c",&loc);
}
if (argc >= 10) {
sscanf(argv[9],"%d",&rate);
}
if (argc >= 11) {
sscanf(argv[10],"%d",&max_power);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write .epi
//
fab_write_epi(&v,argv[2],power,speed,focus,ox,oy,loc,rate,max_power);
}

182
src/core/path_eps.c 100644
Wyświetl plik

@ -0,0 +1,182 @@
//
// path_eps.c
// convert .path to .eps
//
// Neil Gershenfeld 7/4/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include "fab.h"
void fab_write_eps(struct fab_vars *v, char *output_file_name) {
//
// write path to PostScript file
//
int x,y,z,current_z;
float margin = 0.5; // lower left margin, in inches
float gray;
FILE *output_file;
int nsegs=0, npts=0;
float scale;
output_file = fopen(output_file_name,"w");
fprintf(output_file,"%%! path_eps output\n");
fprintf(output_file,"%%%%BoundingBox: %f %f %f %f\n",72.0*margin,72.0*margin,
72.0*(margin+v->dx/25.4),72.0*(margin+v->dy/25.4));
fprintf(output_file,"/m {moveto} def\n");
fprintf(output_file,"/l {lineto} def\n");
fprintf(output_file,"/g {setgray} def\n");
fprintf(output_file,"/s {stroke} def\n");
fprintf(output_file,"72 72 scale\n");
fprintf(output_file,"%f %f translate\n",margin,margin);
fprintf(output_file,"1 setlinewidth\n");
scale = v->dx/(25.4*(v->nx-1.0));
fprintf(output_file,"%f %f scale\n",scale,scale);
current_z = 0;
fprintf(output_file,"0 g\n");
v->path->segment = v->path->first;
while (1) {
//
// follow segments
//
v->path->segment->point = v->path->segment->first;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
if (v->path->dof == 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
gray = 0.9 * z / (v->nz - 1.0);
fprintf(output_file,"%.3f g\n",gray);
current_z = z;
}
}
fprintf(output_file,"%d %d m\n",x,y);
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
fprintf(output_file,"%d %d l\n",x,y);
if (v->path->dof == 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
gray = 0.9 * 0.5 * (z + current_z) / (v->nz - 1.0);
fprintf(output_file,"s %.3f g %d %d m\n",gray,x,y);
current_z = z;
}
}
npts += 1;
}
fprintf(output_file,"s\n");
if (v->path->segment->next == 0)
break;
v->path->segment = v->path->segment->next;
}
//fprintf(output_file,"showpage\n");
fclose(output_file);
printf("write %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
struct fab_vars vnew;
init_vars(&vnew);
char view;
int x,y,z,nz,dz;
float scale;
//
// command line args
//
if (!((argc == 3) || (argc == 4))) {
printf("command line: path_eps in.path out.eps [view]\n");
printf(" in.path = input path file\n");
printf(" out.eps= output PostScript file\n");
printf(" view = view projection(s) (optional, z|3, default z)\n");
exit(-1);
}
view = 'z';
if (argc == 4)
view = argv[3][0];
//
// read path
//
fab_read_path(&v,argv[1]);
//
// check view
//
if (view == 'z') {
//
// write eps
//
fab_write_eps(&v,argv[2]);
}
else if (view == '3') {
if (v.path->dof < 3) {
printf("path_eps: oops -- path not 3D\n");
exit(-1);
}
nz = v.nx * v.dz / v.dx;
scale = ((float) nz) / v.nz;
vnew.nx = v.nx + nz;
vnew.ny = v.ny + nz;
vnew.nz = v.nz;
vnew.dx = v.dx + v.dz;
vnew.dy = v.dy + v.dz;
vnew.dz = v.dz;
vnew.xmin = v.xmin;
vnew.ymin = v.ymin;
vnew.zmin = v.zmin;
fab_path_start(&vnew,v.path->dof);
//
// follow path
//
v.path->segment = v.path->first;
while (1) {
//
// follow segments
//
v.path->segment->point = v.path->segment->first;
fab_path_segment(&vnew);
while (1) {
//
// follow points
//
fab_path_point(&vnew);
z = v.path->segment->point->first->next->next->value;
dz = nz - scale*z;
y = dz + v.path->segment->point->first->next->value;
x = dz + v.path->segment->point->first->value;
fab_path_axis(&vnew,x);
fab_path_axis(&vnew,y);
fab_path_axis(&vnew,z);
if (v.path->segment->point->next == 0)
break;
v.path->segment->point = v.path->segment->point->next;
}
if (v.path->segment->next == 0)
break;
v.path->segment = v.path->segment->next;
}
//
// write eps
//
fab_write_eps(&vnew,argv[2]);
}
}

273
src/core/path_g.c 100644
Wyświetl plik

@ -0,0 +1,273 @@
//
// path_g.c
// convert path to G codes
//
// Neil Gershenfeld, David Carr
// CBA MIT 8/10/11
//
// (c) Massachusetts Institute of Technology 2011
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_g(struct fab_vars *v, char *output_file_name, int direction, float z_jog, float feed_rate, float z_feed_rate, float spindle_speed, int tool, int coolant) {
//
// write path to G-code file
//
FILE *output_file;
int i,nsegs=0,npts=0;
float units,xscale,yscale,zscale,x,y,z,xoffset,yoffset,zoffset;
output_file = fopen(output_file_name,"w");
units = 1.0/25.4; // inches
xscale = units*v->dx/(v->nx-1.0);
yscale = units*v->dy/(v->ny-1.0);
if (v->nz > 1)
zscale = units*v->dz/v->nz;
else
zscale = 0;
xoffset = units*v->xmin;
yoffset = units*v->ymin;
zoffset = units*v->zmin;
z_jog = units*z_jog;
feed_rate = 60*units*feed_rate; // feed rate in inches per minute
z_feed_rate = 60*units*z_feed_rate;
//
// Write G code header
//
//fprintf(output_file, "; G-Code generated by MIT CBA fab modules\n");
fprintf(output_file, "%%\n"); // tape start
//fprintf(output_file, "; http://kokompe.cba.mit.edu/dist\n\n");
// Clear all state: XY plane, inch mode, cancel diameter compensation, cancel length offset
// coordinate system 1, cancel motion, non-incremental motion, feed/minute mode
fprintf(output_file,"G17\n");
fprintf(output_file,"G20\n");
fprintf(output_file,"G40\n");
fprintf(output_file,"G49\n");
fprintf(output_file,"G54\n");
fprintf(output_file,"G80\n");
fprintf(output_file,"G90\n");
fprintf(output_file,"G94\n");
fprintf(output_file,"T%dM06\n",tool); // tool selection, tool change
fprintf(output_file,"F%0.4f\n",feed_rate); // feed rate
fprintf(output_file,"S%0.4f\n",spindle_speed); // spindle speed
if (coolant == 1)
fprintf(output_file,"M08\n"); // coolant on
fprintf(output_file,"G00Z%0.4f\n",z_jog); // move up before starting spindle
fprintf(output_file,"M03\n"); // spindle on clockwise
fprintf(output_file,"G04 P1\n"); // give spindle 1 second to spin up
//
// follow segments in reverse order (mill boundaries last)
//
v->path->segment = v->path->last;
while (1) {
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->last;
else
//
// climb
//
v->path->segment->point = v->path->segment->first;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
//
// move to first point
//
fprintf(output_file,"G00X%0.4fY%0.4fZ%0.4f\n",x,y,z_jog);
//
// move down
//
if (v->path->dof == 2) {
fprintf(output_file,"G01Z%0.4f F%0.4f\n",zoffset,z_feed_rate);
fprintf(output_file,"F%0.4f\n",feed_rate); //restore XY feed rate
}
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"G01Z%0.4f F%0.4f\n",z,z_feed_rate);
fprintf(output_file,"F%0.4f\n",feed_rate);
}
else {
printf("path_g: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
nsegs += 1;
while (1) {
//
// check if last point
//
if (direction == 0) {
//
// conventional
//
if (v->path->segment->point->previous == 0) {
fprintf(output_file,"Z%0.4f\n",z_jog);
break;
}
}
else {
//
// climb
//
if (v->path->segment->point->next == 0) {
fprintf(output_file,"Z%0.4f\n",z_jog);
break;
}
}
//
// move to next point
//
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->point->previous;
else
//
// climb
//
v->path->segment->point = v->path->segment->point->next;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 2)
fprintf(output_file,"X%0.4fY%0.4f\n",x,y);
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"X%0.4fY%0.4fZ%0.4f\n",x,y,z);
}
else {
printf("path_g: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
npts += 1;
}
//
// check for previous segment
//
if (v->path->segment->previous == 0)
break;
v->path->segment = v->path->segment->previous;
}
//
// close and return
//
fprintf(output_file,"G00Z%0.4f\n",z_jog); // move up before stopping spindle
fprintf(output_file,"M05\n"); // spindle stop
if (coolant == 1)
fprintf(output_file,"M09\n"); // coolant off
fprintf(output_file,"M30\n"); // program end and reset
fprintf(output_file, "%%\n"); // tape end
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float z_jog,feed_rate,z_feed_rate,spindle_speed;
int direction,tool,coolant;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6) || (argc == 7) || (argc == 8) || (argc == 9) || (argc == 10))) {
printf("command line: path_g in.path out.g [direction [z_jog [feed [z_feed [spindle [tool [coolant]]]]]]\n");
printf(" in.path = input path file\n");
printf(" out.g = output G-code file\n");
printf(" direction = machining direction (optional, 0 conventional/1 climb, default 0)\n");
printf(" z_jog = z jog height (optional, mm, default 25)\n");
printf(" feed = feed rate (optional, mm/s, default 100)\n");
printf(" z_feed = z plunge rate (optional, mm/s, default xy feed rate)\n");
printf(" spindle = spindle speed (optional, RPM, default 5000)\n");
printf(" tool = tool number (optional, default 1)\n");
printf(" coolant = coolant on/off (optional, 0=off/1=on, default 1)\n");
exit(-1);
}
if (argc == 3) {
direction = 0;
z_jog = 25.0;
feed_rate = 5.0;
z_feed_rate = feed_rate;
spindle_speed = 5000.0;
tool = 1;
coolant = 1;
}
else if (argc == 4) {
sscanf(argv[3],"%d",&direction);
z_jog = 25.0;
feed_rate = 5.0;
z_feed_rate = feed_rate;
spindle_speed = 5000.0;
tool = 1;
coolant = 1;
}
else if (argc == 5) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
feed_rate = 5.0;
z_feed_rate = feed_rate;
spindle_speed = 5000.0;
tool = 1;
coolant = 1;
}
else if (argc == 6) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
sscanf(argv[5],"%f",&feed_rate);
z_feed_rate = feed_rate;
spindle_speed = 5000.0;
tool = 1;
coolant = 1;
}
else if (argc == 7) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
sscanf(argv[5],"%f",&feed_rate);
sscanf(argv[6],"%f",&z_feed_rate);
spindle_speed = 5000.0;
tool = 1;
coolant = 1;
}
else if (argc == 8) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
sscanf(argv[5],"%f",&feed_rate);
sscanf(argv[6],"%f",&z_feed_rate);
sscanf(argv[7],"%f",&spindle_speed);
tool = 1;
coolant = 1;
}
else if (argc == 9) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
sscanf(argv[5],"%f",&feed_rate);
sscanf(argv[6],"%f",&z_feed_rate);
sscanf(argv[7],"%f",&spindle_speed);
sscanf(argv[8],"%d",&tool);
coolant = 1;
}
else if (argc == 10) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%f",&z_jog);
sscanf(argv[5],"%f",&feed_rate);
sscanf(argv[6],"%f",&z_feed_rate);
sscanf(argv[7],"%f",&spindle_speed);
sscanf(argv[8],"%d",&tool);
sscanf(argv[9],"%d",&coolant);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write G codes
//
fab_write_g(&v,argv[2],direction,z_jog,feed_rate,z_feed_rate,spindle_speed,tool,coolant);
}

Wyświetl plik

@ -0,0 +1,41 @@
//
// path_info.c
// report .path info
//
// Neil Gershenfeld 10/3/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
// todo
// gradient intensity
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float units,resolution;
char axis;
//
// command line args
//
if (argc != 2) {
printf("command line: path_info in.path\n");
printf(" in.path = input path file\n");
exit(-1);
}
//
// read path
//
fab_read_path(&v,argv[1]);
}

Wyświetl plik

@ -0,0 +1,64 @@
//
// path_join.c
// join paths
//
// Neil Gershenfeld
// CBA MIT 11/6/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars vin1;
init_vars(&vin1);
struct fab_vars vin2;
init_vars(&vin2);
struct fab_vars vout;
init_vars(&vout);
float dx,dy;
//
// command line args
//
if (!((argc == 4) || (argc == 5) || (argc == 6))) {
printf("command line: path_join in1.path in2.path out.path [dx [dy]]\n");
printf(" in1.path = first input path file\n");
printf(" in2.path = second input path file\n");
printf(" out.path = joined output path file\n");
printf(" dx = in1 horizontal offset (optional, mm, default 0)\n");
printf(" dy = in1 vertical offset (optional, mm, default dx)\n");
exit(-1);
}
if (argc == 4) {
dx = 0;
dy = dx;
}
if (argc == 5) {
sscanf(argv[4],"%f",&dx);
dy = dx;
}
else if (argc == 6) {
sscanf(argv[4],"%f",&dx);
sscanf(argv[5],"%f",&dy);
}
//
// read paths
//
fab_read_path(&vin1,argv[1]);
fab_read_path(&vin2,argv[2]);
//
// append path
//
fab_path_join(&vin1,&vin2,&vout,dx,dy);
//
// write path
//
fab_write_path(&vout,argv[3]);
}

120
src/core/path_oms.c 100644
Wyświetl plik

@ -0,0 +1,120 @@
//
// path_oms.c
// convert path to Resonetics excimer micromachining center .oms
//
// Neil Gershenfeld
// CBA MIT 6/4/13
//
// (c) Massachusetts Institute of Technology 2013
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_oms(struct fab_vars *v, char *output_file_name, float velocity, float acceleration, int period) {
//
// write path to Epilog lasercutter file
//
FILE *output_file;
float x,y,scale,xoffset,yoffset;
float slew_velocity = 1.0;
float slew_acceleration = 5.0;
int npts=0,nsegs=0;
int settle = 100;
scale = v->dx/(v->nx-1.0); // mm
xoffset = v->xmin;
yoffset = v->ymin;
output_file = fopen(output_file_name,"w");
fprintf(output_file,"AA LP0,0,0,0,0\n"); // set origin
fprintf(output_file,"PP%d\n",period); // set pulse period (in us)
v->path->segment = v->path->first;
while (1) {
//
// follow segments
//
v->path->segment->point = v->path->segment->first;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
//fprintf(output_file,"VL%.1f,%.1f\n",slew_velocity,slew_velocity);
// redundantly include pulses/s in VL
fprintf(output_file,"VL%.1f,%.1f,,%.0f\n",slew_velocity,slew_velocity,1.0e6/period);
fprintf(output_file,"AC%.1f,%.1f\n",slew_acceleration,slew_acceleration);
fprintf(output_file,"MA%f,%f\n",x,y);
//fprintf(output_file,"VL%.1f,%.1f\n",velocity,velocity);
// redundantly include pulses/s in VL
fprintf(output_file,"VL%.1f,%.1f,,%.0f\n",velocity,velocity,1.0e6/period);
fprintf(output_file,"AC%.1f,%.1f\n",acceleration,acceleration);
fprintf(output_file,"WT%d\n",settle);
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
fprintf(output_file,"CutAbs %f,%f\n",x,y);
npts += 1;
}
if (v->path->segment->next == 0)
break;
v->path->segment = v->path->segment->next;
}
fprintf(output_file,"END\n");
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float velocity, acceleration;
int period;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6))) {
printf("command line: path_oms in.path out.oms [velocity [acceleration [period]]]\n");
printf(" in.path = input path file\n");
printf(" out.oms = output Resonetics excimer micromachining center file\n");
printf(" velocity (default 0.1)\n");
printf(" acceleration (default 5.0)\n");
printf(" period (usec, default 10000)\n");
exit(-1);
}
if (argc == 3) {
velocity = 0.1;
acceleration = 5.0;
period = 10000;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&velocity);
acceleration = 5.0;
period = 10000;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&velocity);
sscanf(argv[4],"%f",&acceleration);
period = 10000;
}
else if (argc == 6) {
sscanf(argv[3],"%f",&velocity);
sscanf(argv[4],"%f",&acceleration);
sscanf(argv[5],"%d",&period);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write .oms
//
fab_write_oms(&v,argv[2],velocity,acceleration,period);
}

164
src/core/path_ord.c 100644
Wyświetl plik

@ -0,0 +1,164 @@
//
// path_ord.c
// convert path to Omax waterjet .ord
//
// Neil Gershenfeld
// CBA MIT 10/5/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
#define nostart -10000
void fab_write_ord(struct fab_vars *v, char *output_file_name, float lead, int quality, float xstart, float ystart) {
//
// write path to ShopBot file
//
FILE *output_file;
int i,nsegs=0,npts=0;
float units,xscale,yscale,x,y,xmin,ymin,x0,y0,x1,y1,xoffset,yoffset,xlead,ylead,dx,dy,norm_x,norm_y,norm;
output_file = fopen(output_file_name,"w");
units = 1.0/25.4; // inches
xscale = units*v->dx/(v->nx-1.0);
yscale = units*v->dy/(v->ny-1.0);
xoffset = units*v->xmin;
yoffset = units*v->ymin;
lead = units*lead;
//
// write start if supplied
//
if (xstart != nostart) {
xstart = units*xstart;
ystart = units*ystart;
fprintf(output_file,"%f, %f, 0, 0\n",xstart,ystart); // rapid traverse from lead-out
}
//
// follow segments in reverse order
//
v->path->segment = v->path->last;
while (1) {
//
// follow points in forward order
//
v->path->segment->point = v->path->segment->first;
//
// calculate and write lead-in perpendicular to segment start
//
x0 = xoffset + xscale * v->path->segment->point->first->value;
y0 = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
x1 = xoffset + xscale * v->path->segment->point->next->first->value;
y1 = yoffset + yscale * (v->ny - v->path->segment->point->next->first->next->value);
dx = x1 - x0;
dy = y1 - y0;
norm_x = -dy;
norm_y = dx;
norm = sqrt(norm_x*norm_x + norm_y*norm_y);
norm_x = norm_x/norm;
norm_y = norm_y/norm;
xlead = x0 + norm_x*lead;
ylead = y0 + norm_y*lead;
fprintf(output_file,"%f, %f, 0, -9\n",xlead,ylead); // lead-in
fprintf(output_file,"%f, %f, 0, %d\n",x0,y0,quality); // first point
nsegs += 1;
while (1) {
if (v->path->segment->point->next == 0) {
//
// no next point in segment, write lead-out
//
x0 = xoffset + xscale * v->path->segment->point->previous->first->value;
y0 = yoffset + yscale * (v->ny - v->path->segment->point->previous->first->next->value);
x1 = xoffset + xscale * v->path->segment->point->first->value;
y1 = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
dx = x1 - x0;
dy = y1 - y0;
norm_x = -dy;
norm_y = dx;
norm = sqrt(norm_x*norm_x + norm_y*norm_y);
norm_x = norm_x/norm;
norm_y = norm_y/norm;
xlead = x1 + norm_x*lead;
ylead = y1 + norm_y*lead;
fprintf(output_file,"%f, %f, 0, 0\n",xlead,ylead); // rapid traverse from lead-out
break;
}
v->path->segment->point = v->path->segment->point->next;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->segment->point->next != 0)
fprintf(output_file,"%f, %f, 0, %d\n",x,y,quality);
else
fprintf(output_file,"%f, %f, 0, -9\n",x,y); // lead-out next
npts += 1;
}
//
// check for previous segment
//
if (v->path->segment->previous == 0)
break;
v->path->segment = v->path->segment->previous;
}
//
// close and return
//
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float lead,xstart,ystart;
int quality;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 7))) {
printf("command line: path_ord in.path out.ord [lead [quality [xstart ystart]]]\n");
printf(" in.path = input path file\n");
printf(" out.ord = output Omax waterjet file\n");
printf(" lead = lead in/out (optional, mm, default 2)\n");
printf(" quality = cut quality (optional, default -3)\n");
printf(" xstart,ystart = start position (optional, mm, default path start)\n");
exit(-1);
}
if (argc == 3) {
lead = 2.0;
quality = -3;
xstart = nostart;
ystart = nostart;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&lead);
quality = -3;
xstart = nostart;
ystart = nostart;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&lead);
sscanf(argv[4],"%d",&quality);
xstart = nostart;
ystart = nostart;
}
else if (argc == 7) {
sscanf(argv[3],"%f",&lead);
sscanf(argv[4],"%d",&quality);
sscanf(argv[5],"%f",&xstart);
sscanf(argv[6],"%f",&ystart);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write .ord
//
fab_write_ord(&v,argv[2],lead,quality,xstart,ystart);
}

Wyświetl plik

@ -0,0 +1,45 @@
//
// path_png.c
// convert path to PNG
//
// Neil Gershenfeld
// CBA MIT 2/26/11
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,intensity,number,n,count,count_sum;
float distance,error,z;
//
// command line args
//
if (argc != 3) {
printf("command line: path_png in.path out.png\n");
printf(" in.path = input path file\n");
printf(" out.png = output PNG file\n");
exit(-1);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// shade path with z displacement
//
fab_shade_path_displace(&v);
//
// write PNG
//
fab_write_png_K(&v,argv[2]);
}

196
src/core/path_rml.c 100644
Wyświetl plik

@ -0,0 +1,196 @@
//
// path_rml.c
// convert path to Roland Modela .rml
//
// Neil Gershenfeld
// CBA MIT 9/6/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_rml(struct fab_vars *v, char *output_file_name, float speed, int direction, float z_up) {
//
// write path to Roland Modela file
//
FILE *output_file;
int i,x,y,z,iz_down,iz_up,nsegs=0,npts=0;
float xscale,yscale,zscale,xoffset,yoffset,zoffset;
output_file = fopen(output_file_name,"w");
fprintf(output_file,"PA;PA;"); // plot absolute
fprintf(output_file,"VS%.1f;!VZ%.1f;",speed,speed);
xscale = 40.0*v->dx/(v->nx-1.0); // 40/mm
yscale = 40.0*v->dy/(v->ny-1.0); // 40/mm
if (v->nz > 1)
zscale = 40.0*v->dz/v->nz; // 40/mm
else
zscale = 0;
xoffset = 40.0*v->xmin;
yoffset = 40.0*v->ymin;
zoffset = 40.0*v->zmin;
iz_up = 40.0*z_up;
iz_down = zoffset;
fprintf(output_file,"!PZ%d,%d;",iz_down,iz_up); // set z down, jog
fprintf(output_file,"!MC1;\n"); // turn motor on
//
// follow segments in reverse order (mill boundaries last)
//
v->path->segment = v->path->last;
while (1) {
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->last;
else
//
// climb
//
v->path->segment->point = v->path->segment->first;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
//
// move up to first point
//
fprintf(output_file,"PU%d,%d;\n",x,y);
//
// move down
//
if (v->path->dof == 2) {
fprintf(output_file,"PD%d,%d;\n",x,y);
}
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"Z%d,%d,%d;\n",x,y,z);
}
else {
printf("path_rml: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
nsegs += 1;
while (1) {
//
// check if last point
//
if (direction == 0) {
//
// conventional
//
if (v->path->segment->point->previous == 0) {
fprintf(output_file,"PU%d,%d;\n",x,y);
break;
}
}
else {
//
// climb
//
if (v->path->segment->point->next == 0) {
fprintf(output_file,"PU%d,%d;\n",x,y);
break;
}
}
//
// move to next point
//
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->point->previous;
else
//
// climb
//
v->path->segment->point = v->path->segment->point->next;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 2) {
fprintf(output_file,"PD%d,%d;\n",x,y);
}
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"Z%d,%d,%d;\n",x,y,z);
}
else {
printf("path_rml: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
npts += 1;
}
//
// check for previous segment
//
//fprintf(output_file,"\n",x,y);
if (v->path->segment->previous == 0)
break;
v->path->segment = v->path->segment->previous;
}
//
// pad end of file with motor off commands for Modela buffering bug
//
for (i = 0; i < 1000; ++i)
fprintf(output_file,"!MC0;");
//
// return to home
//
fprintf(output_file,"\nH;\n");
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float speed,z_up;
int direction;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6) || (argc == 7) || (argc == 8) || (argc == 9))) {
printf("command line: path_rml in.path out.rml [speed [direction [jog [xmin ymin [zmin]]]]]\n");
printf(" in.path = input path file\n");
printf(" out.rml = output Roland Modela file\n");
printf(" speed = cutting speed (optional, mm/s, default 4)\n");
printf(" direction = machining direction (optional, 0 conventional/1 climb, default 1)\n");
printf(" jog = jog height (optional, mm, default 1)\n");
printf(" xmin = left position (optional, mm, default path value)\n");
printf(" ymin = front position (optional, mm, default path value)\n");
printf(" zmin = bottom position (optional, -mm, default path value)\n");
exit(-1);
}
speed = 4;
direction = 1;
z_up = 1;
if (argc >= 4)
sscanf(argv[3],"%f",&speed);
if (argc >= 5)
sscanf(argv[4],"%d",&direction);
if (argc >= 6)
sscanf(argv[5],"%f",&z_up);
//
// read path
//
fab_read_path(&v,argv[1]);
//
// check origin
//
if (argc >= 7)
sscanf(argv[6],"%lf",&v.xmin);
if (argc >= 8)
sscanf(argv[7],"%lf",&v.ymin);
if (argc >= 9)
sscanf(argv[8],"%lf",&v.zmin);
//
// write .rml
//
fab_write_rml(&v,argv[2],speed,direction,z_up);
}

238
src/core/path_sbp.c 100644
Wyświetl plik

@ -0,0 +1,238 @@
//
// path_sbp.c
// convert path to ShopBot .sbp
//
// Neil Gershenfeld
// CBA MIT 10/1/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_sbp(struct fab_vars *v, char *output_file_name, int direction, int spindle_speed, float xy_speed, float z_speed, float xy_jog_speed, float z_jog_speed, float z_jog, float units) {
//
// write path to ShopBot file
//
FILE *output_file;
int i,nsegs=0,npts=0;
float xscale,yscale,zscale,x,y,z,xoffset,yoffset,zoffset;
output_file = fopen(output_file_name,"w");
fprintf(output_file,"SA\r\n"); // set to absolute distances
fprintf(output_file,"TR,%d,1\r\n",spindle_speed); // set spindle speed
fprintf(output_file,"SO,1,1\r\n"); // set output number 1 to on
fprintf(output_file,"pause,2\r\n"); // let spindle come up to speed
xscale = v->dx/(v->nx-1.0)/units;
yscale = v->dy/(v->ny-1.0)/units;
if (v->nz > 1)
zscale = v->dz/(units*v->nz);
else
zscale = 0;
xoffset = v->xmin/units;
yoffset = v->ymin/units;
zoffset = v->zmin/units;
xy_speed = xy_speed/units;
z_speed = z_speed/units;
xy_jog_speed = xy_jog_speed/units;
z_jog_speed = z_jog_speed/units;
z_jog = z_jog/units;
fprintf(output_file,"MS,%f,%f\r\n",xy_speed,z_speed); // set xy,z speed
fprintf(output_file,"JS,%f,%f\r\n",xy_jog_speed,z_jog_speed); // set jog xy,z speed
fprintf(output_file,"JZ,%f\r\n",z_jog); // move up
//
// follow segments in reverse order (mill boundaries last)
//
v->path->segment = v->path->last;
while (1) {
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->last;
else
//
// climb
//
v->path->segment->point = v->path->segment->first;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
//
// move to first point
//
fprintf(output_file,"J2,%f,%f\r\n",x,y);
//
// move down
//
if (v->path->dof == 2)
fprintf(output_file,"MZ,%f\r\n",zoffset);
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"M3,%f,%f,%f\r\n",x,y,z);
}
else {
printf("path_sbp: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
nsegs += 1;
while (1) {
//
// check if last point
//
if (direction == 0) {
//
// conventional
//
if (v->path->segment->point->previous == 0) {
fprintf(output_file,"MZ,%f\r\n",z_jog);
break;
}
}
else {
//
// climb
//
if (v->path->segment->point->next == 0) {
fprintf(output_file,"MZ,%f\r\n",z_jog);
break;
}
}
//
// move to next point
//
if (direction == 0)
//
// conventional
//
v->path->segment->point = v->path->segment->point->previous;
else
//
// climb
//
v->path->segment->point = v->path->segment->point->next;
x = xoffset + xscale * v->path->segment->point->first->value;
y = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 2)
fprintf(output_file,"M2,%f,%f\r\n",x,y);
else if (v->path->dof == 3) {
z = zoffset + zscale * v->path->segment->point->first->next->next->value;
fprintf(output_file,"M3,%f,%f,%f\r\n",x,y,z);
}
else {
printf("path_sbp: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
npts += 1;
}
//
// check for previous segment
//
if (v->path->segment->previous == 0)
break;
v->path->segment = v->path->segment->previous;
}
//
// close and return
//
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
int main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float xy_speed, z_speed, xy_jog_speed, z_jog_speed, z_jog, units;
int direction,spindle_speed;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 7) || (argc == 10) || (argc == 11))) {
printf("command line: path_sbp in.path out.sbp [direction [spindle_speed [xy_speed z_speed [xy_jog_speed z_jog_speed z_jog [units]]]]]]\n");
printf(" in.path = input path file\n");
printf(" out.sbp = output ShopBot file\n");
printf(" direction = machining direction (optional, 0 conventional/1 climb, default 0)\n");
printf(" spindle_speed = spindle speed (optional, if control installed, RPM, default 12000)\n");
printf(" xy_speed = xy cutting speed (optional, mm/s, default 30)\n");
printf(" z_speed = z cutting speed (optional, mm/s, default 30)\n");
printf(" xy_jog_speed = xy jog speed (optional, mm/s, default 150)\n");
printf(" z_jog_speed = z jog speed (optional, mm/s, default 150)\n");
printf(" z_jog = z jog height (optional, mm, default 25)\n");
printf(" units = mm per file unit (optional, default 25.4)\n");
exit(-1);
}
if (argc == 3) {
direction = 0;
spindle_speed = 12000;
xy_speed = 30;
z_speed = 30;
xy_jog_speed = 150;
z_jog_speed = 150;
z_jog = 25;
units = 25.4;
}
else if (argc == 4) {
sscanf(argv[3],"%d",&direction);
spindle_speed = 12000;
xy_speed = 30;
z_speed = 30;
xy_jog_speed = 150;
z_jog_speed = 150;
z_jog = 25;
units = 25.4;
}
else if (argc == 5) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%d",&spindle_speed);
xy_speed = 30;
z_speed = 30;
xy_jog_speed = 150;
z_jog_speed = 150;
z_jog = 25;
units = 25.4;
}
else if (argc == 7) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%d",&spindle_speed);
sscanf(argv[5],"%f",&xy_speed);
sscanf(argv[6],"%f",&z_speed);
xy_jog_speed = 150;
z_jog_speed = 150;
z_jog = 25;
units = 25.4;
}
else if (argc == 10) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%d",&spindle_speed);
sscanf(argv[5],"%f",&xy_speed);
sscanf(argv[6],"%f",&z_speed);
sscanf(argv[7],"%f",&xy_jog_speed);
sscanf(argv[8],"%f",&z_jog_speed);
sscanf(argv[9],"%f",&z_jog);
units = 25.4;
}
else if (argc == 11) {
sscanf(argv[3],"%d",&direction);
sscanf(argv[4],"%d",&spindle_speed);
sscanf(argv[5],"%f",&xy_speed);
sscanf(argv[6],"%f",&z_speed);
sscanf(argv[7],"%f",&xy_jog_speed);
sscanf(argv[8],"%f",&z_jog_speed);
sscanf(argv[9],"%f",&z_jog);
sscanf(argv[10],"%f",&units);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// write .sbp
//
fab_write_sbp(&v,argv[2],direction,spindle_speed,xy_speed,z_speed,xy_jog_speed,z_jog_speed,z_jog,units);
return 0;
}

Wyświetl plik

@ -0,0 +1,174 @@
//
// path_time.c
// estimate path time
//
// Neil Gershenfeld 10/29/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include "fab.h"
void fab_find_time(struct fab_vars *v, float units, float move, float height, float jog, float plunge, float *time, int *segments, int *points) {
float xscale, yscale, zscale;
float xoffset, yoffset, zoffset;
float xold, yold, zold, xnew, ynew, znew;
if ((v->path->dof < 2) || (v->path->dof > 3)) {
printf("path_time: path degrees of freedom must be 2 or 3\n");
exit(-1);
}
xoffset = v->xmin/units;
yoffset = v->ymin/units;
xscale = v->dx/(v->nx-1.0)/units;
yscale = v->dy/(v->ny-1.0)/units;
if (v->path->dof == 3) {
zoffset = v->zmin/units;
if (v->nz > 1)
zscale = v->dz/(units*v->nz);
else
zscale = 0;
}
//
// start at origin
//
xold = 0;
yold = 0;
zold = 0;
*time = 0;
*segments = 0;
*points = 0;
//
// follow segments
//
v->path->segment = v->path->first;
while (1) {
*segments += 1;
//
// follow segment points
//
v->path->segment->point = v->path->segment->first;
*points += 1;
xnew = xoffset + xscale * v->path->segment->point->first->value;
ynew = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
znew = height;
//
// jog to first point
//
*time += sqrt((xnew-xold)*(xnew-xold)+(ynew-yold)*(ynew-yold))/jog;
xold = xnew;
yold = ynew;
//
// plunge to first point
//
if (v->path->dof == 3) {
znew = zoffset + zscale * v->path->segment->point->first->next->next->value;
*time += sqrt((znew-zold)*(znew-zold))/plunge;
zold = znew;
}
while (1) {
//
// check if last point
//
if (v->path->segment->point->next == 0) {
znew = height;
*time += sqrt((znew-zold)*(znew-zold))/plunge;
zold = znew;
break;
}
//
// move to next point
//
v->path->segment->point = v->path->segment->point->next;
*points += 1;
xnew = xoffset + xscale * v->path->segment->point->first->value;
ynew = yoffset + yscale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 2) {
*time += sqrt((xnew-xold)*(xnew-xold)+(ynew-yold)*(ynew-yold))/move;
xold = xnew;
yold = ynew;
}
else if (v->path->dof == 3) {
znew = zoffset + zscale * v->path->segment->point->first->next->next->value;
*time += sqrt((xnew-xold)*(xnew-xold)+(ynew-yold)*(ynew-yold)+(znew-zold)*(znew-zold))/move;
xold = xnew;
yold = ynew;
zold = znew;
}
}
//
// check for next segment
//
if (v->path->segment->next == 0)
break;
v->path->segment = v->path->segment->next;
*segments += 1;
}
//
// return
//
return;
}
int main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float units, move, height, jog, plunge, time;
int segments, points;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6))) {
printf("command line: path_time in.path move_speed [jog_height [jog_speed [plunge_speed]]]\n");
printf(" in.path = input path file\n");
printf(" move_speed = speed of path segments (mm/s)\n");
printf(" jog_height = height between path segments (mm, optional, default 0)\n");
printf(" jog_speed = speed between path segments (mm/s, optional, default move_speed)\n");
printf(" plunge_speed = speed from jog to move (mm/s, optional, default move_speed)\n");
exit(-1);
}
if (argc == 3) {
sscanf(argv[2],"%f",&move);
height = 0;
jog = move;
plunge = move;
}
else if (argc == 4) {
sscanf(argv[2],"%f",&move);
sscanf(argv[3],"%f",&height);
jog = move;
plunge = move;
}
else if (argc == 5) {
sscanf(argv[2],"%f",&move);
sscanf(argv[3],"%f",&height);
sscanf(argv[4],"%f",&jog);
plunge = move;
}
else if (argc == 6) {
sscanf(argv[2],"%f",&move);
sscanf(argv[3],"%f",&height);
sscanf(argv[4],"%f",&jog);
sscanf(argv[5],"%f",&plunge);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// calculate time
//
fab_find_time(&v,1.0,move,height,jog,plunge,&time,&segments,&points);
//
// report and return
//
printf("path time: %.0f seconds, %.1f minutes, %.2f hours\n",time,time/60.0,time/(60.0*60.0));
}

166
src/core/path_uni.c 100644
Wyświetl plik

@ -0,0 +1,166 @@
//
// path_uni.c
// convert path to Universal lasercutter .uni
//
// Neil Gershenfeld
// CBA MIT 9/21/11
//
// (c) Massachusetts Institute of Technology 2011
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_uni(struct fab_vars *v, char *output_file_name, int power, int max_power, int speed, int rate) {
//
// write path to Universal lasercutter file
//
FILE *output_file;
int x,y,z,current_z,layer_power,nsegs=0,npts=0;
unsigned char ppi,speed_hi,speed_lo,power_hi,power_lo;
float scale,xoffset,yoffset;
//
output_file = fopen(output_file_name,"w");
scale = 1000.0*v->dx/(25.4*(v->nx-1.0)); // 1000 DPI
xoffset = 1000.0*v->xmin/25.4;
yoffset = 1000.0*v->ymin/25.4;
fprintf(output_file,"Z"); // initialize
fprintf(output_file,"t%s~;",output_file_name); // title
fprintf(output_file,"IN;DF;PS0;DT~"); // initialize
ppi = rate/10;
fprintf(output_file,"s%c",ppi); // PPI
speed_hi = (648*speed)/256;
speed_lo = (648*speed)%256;
fprintf(output_file,"v%c%c",speed_hi,speed_lo); // speed
power_hi = (320*power)/256;
power_lo = (320*power)%256;
fprintf(output_file,"p%c%c",power_hi,power_lo); // power
fprintf(output_file,"a%c",2); // air assist on high
current_z = 0;
v->path->segment = v->path->last;
while (1) {
//
// follow segments in reverse order
//
v->path->segment->point = v->path->segment->first;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
layer_power = power + (max_power-power) * z / (v->nz - 1.0);
power_hi = (320*layer_power)/256;
power_lo = (320*layer_power)%256;
fprintf(output_file,"p%c%c",power_hi,power_lo); // power
current_z = z;
}
}
fprintf(output_file,"PU;PA%d,%d;PD;",x,y);
nsegs += 1;
while (1) {
//
// follow points
//
if (v->path->segment->point->next == 0)
break;
v->path->segment->point = v->path->segment->point->next;
x = xoffset + scale * v->path->segment->point->first->value;
y = yoffset + scale * (v->ny - v->path->segment->point->first->next->value);
if (v->path->dof == 3) {
z = v->path->segment->point->first->next->next->value;
if (z != current_z) {
layer_power = power + (max_power-power) * z / (v->nz - 1.0);
fprintf(output_file,"YP%d;\n",layer_power);
current_z = z;
}
}
fprintf(output_file,"PA%d,%d;",x,y);
npts += 1;
}
fprintf(output_file,"\n",x,y);
if (v->path->segment == v->path->first)
break;
v->path->segment = v->path->segment->previous;
}
fprintf(output_file,"e"); // end of file
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" segments: %d, points: %d\n",nsegs,npts);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int power,max_power,speed,focus,rate;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 7) || (argc == 8) || (argc == 9))) {
printf("command line: path_uni in.path out.uni [power [speed [xmin ymin [rate [max_power]]]]]\n");
printf(" in.path = input path file\n");
printf(" out.uni= output Universal lasercutter file\n");
printf(" power = percent power (optional, 0-100, default 100)\n");
printf(" speed = percent speed (optional, 0-100, default 100)\n");
printf(" xmin = left position (optional, mm, default path, 0 = left side of bed)\n");
printf(" ymin = front position (optional, mm, default path, 0 = back, front positive)\n");
printf(" rate = pulse rate (optional, frequency, default 500)\n");
printf(" max_power = maximum power for maximum z value (optional, 0-100, default 100)\n");
exit(-1);
}
if (argc == 3) {
power = 100;
speed = 100;
rate = 500;
max_power = 100;
}
else if (argc == 4) {
sscanf(argv[3],"%d",&power);
speed = 100;
rate = 500;
max_power = 100;
}
else if (argc == 5) {
sscanf(argv[3],"%d",&power);
sscanf(argv[4],"%d",&speed);
rate = 500;
max_power = 100;
}
else if (argc == 7) {
sscanf(argv[3],"%d",&power);
sscanf(argv[4],"%d",&speed);
rate = 500;
max_power = 100;
}
else if (argc == 8) {
sscanf(argv[3],"%d",&power);
sscanf(argv[4],"%d",&speed);
sscanf(argv[7],"%d",&rate);
max_power = 100;
}
else if (argc == 9) {
sscanf(argv[3],"%d",&power);
sscanf(argv[4],"%d",&speed);
sscanf(argv[7],"%d",&rate);
sscanf(argv[8],"%d",&max_power);
}
//
// read path
//
fab_read_path(&v,argv[1]);
//
// origin
//
if ((argc == 7) || (argc == 8) || (argc == 9)) {
sscanf(argv[5],"%lf",&v.xmin);
sscanf(argv[6],"%lf",&v.ymin);
}
//
// write .epi
//
fab_write_uni(&v,argv[2],power,max_power,speed,rate);
}

Wyświetl plik

@ -0,0 +1,77 @@
//
// png_distances.c
// find distances from edges in PNG
//
// Neil Gershenfeld
// CBA MIT 7/24/11
//
// (c) Massachusetts Institute of Technology 2011
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,distances;
float intensity,distance;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5))) {
printf("command line: png_distances in.png out.png [intensity [distances]]\n");
printf(" in.png = input PNG file\n");
printf(" out.png = input PNG file\n");
printf(" intensity = intensity level to slice (optional, 0-1, default 0.5)\n");
printf(" distances = show distances (optional, 0/1, default 1)\n");
exit(-1);
}
if (argc == 3) {
intensity = 0.5;
distances = 1;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&intensity);
distances = 1;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&intensity);
sscanf(argv[4],"%d",&distances);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// threshold
//
fab_threshold(&v,intensity);
//
// find distances
//
if (distances == 1) {
printf(" find distances\n");
fab_distances(&v);
//
// copy distances to image array
//
for (y = 0; y < v.ny; ++y)
for (x = 0; x < v.nx; ++x)
v.array[y][x] = v.distances[y][x];
}
//
// scale
//
v.bit_depth = 16;
fab_rescale(&v,0,1);
//
// write PNG
//
fab_write_png_K(&v,argv[2]);
}

267
src/core/png_drl.c 100644
Wyświetl plik

@ -0,0 +1,267 @@
/*
% Rewind and Stop
X#Y# Move and Drill
T# Tool Selection
M30 End of Program
M00 End of Program
R#X#Y# Repeat Hole
G05, G81 Select Drill Mode
G90 Absolute Mode
G91 Incremental Mode
G92 X#Y# Set Zero
G93 X#Y# Set Zero
M48 Program Header to first "%"
M72 English-Imperial Mode
*/
/*
% Rewind and Stop
X#Y# Move and Drill
T# Tool Selection
M30 End of Program
M00 End of Program
M25 Beginning of Pattern
M31 Beginning of Pattern
M01 End of Pattern
M02 X#Y# Repeat Pattern
R#M02X#Y# Multiple Repeat Pattern
M02 X#Y# M70 Swap Axis
M02 X#Y# M80 Mirror Image X Axis
M02 X#Y# M90 Mirror Image Y Axis
M08 End of Step and Repeat
N# Block Sequence Number
/ Block Delete
R#X#Y# Repeat Hole
G05, G81 Select Drill Mode
G04 X# Variable Dwell (ignored)
G90 Absolute Mode
G91 Incremental Mode
G92 X#Y# Set Zero
G93 X#Y# Set Zero
M48 Program Header to first "%"
M47 Operator Message CRT Display
M71 Metric Mode
M72 English-Imperial Mode
Snn Spindle Speed (RPM)
Fnn Z axis feed speed (IPM)
*/
/*
M48 Program Header
M72, LZ English measurement Leading 0's
T03C0.038 T03 .0380"
T04C0.125 T04 .1250"
T06C0.046 T06 .0460"
T12C0.063 T12 .0630"
T16C0.250 T16 .2500"
% Rewind and Stop (start of drill data)
T03 Drill COMMAND GET TOOL 3
X00581Y0122 Drill location with TOOL 3
T06 Drill COMMAND GET TOOL 6
X01657Y03295 Drill location with TOOL 6
T12 Drill COMMAND GET TOOL 12
X00585Y03311 Drill location with TOOL 12
T04 Drill COMMAND GET TOOL 4
X00873Y02691 Drill location with TOOL 4
T16 Drill COMMAND GET TOOL 16
X00625Y02191 Drill location with TOOL 16
T00 Drill COMMAND UNLOAD TOOL
M30 End of Program
*/
//
// png_drl.c
// PNG to Excellon
//
// Neil Gershenfeld
// CBA MIT 11/22/12
//
// (c) Massachusetts Institute of Technology 2012
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
#define MAX_HOLES 100000
#define TOLERANCE 0.01 // hole drill match percent tolerance
void fab_write_drl(struct fab_vars *v, char *output_file_name) {
FILE *output_file;
int x,y,edges,points,hole,holes,drill,drills,index[MAX_HOLES];
float units,scale;
float x0[MAX_HOLES],y0[MAX_HOLES],r[MAX_HOLES],d[MAX_HOLES];
output_file = fopen(output_file_name,"w");
//
// threshold array
//
fab_threshold(v,0.5);
//
// find edges
//
edges = fab_edges(v);
if (edges == 0) {
printf("png_drl: oops -- no edges\n");
exit(-1);
}
//
// set edge directions
//
fab_directions(v);
//
// follow edges
//
fab_path_start(v,2);
fab_vectorize(v,1,0);
//
//
//
units = 1.0/25.4; // inches
scale = units*v->dx/(v->nx-1.0);
//
// follow segments to find holes
//
v->path->segment = v->path->first;
hole = 0;
while (1) {
//
// find hole centers
//
v->path->segment->point = v->path->segment->first;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
x0[hole] = x;
y0[hole] = y;
points = 1;
while (1) {
if (v->path->segment->point->next == 0) {
x0[hole] = x0[hole] / points;
y0[hole] = y0[hole] / points;
break;
}
v->path->segment->point = v->path->segment->point->next;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
x0[hole] += x;
y0[hole] += y;
points += 1;
}
//
// find hole radii
//
v->path->segment->point = v->path->segment->first;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
r[hole] = sqrt((x-x0[hole])*(x-x0[hole])+(y-y0[hole])*(y-y0[hole]));
points = 1;
while (1) {
if (v->path->segment->point->next == 0) {
x0[hole] = scale * x0[hole];
y0[hole] = scale * y0[hole];
r[hole] = scale * r[hole] / points;
break;
}
v->path->segment->point = v->path->segment->point->next;
x = v->path->segment->point->first->value;
y = v->ny - v->path->segment->point->first->next->value;
r[hole] += sqrt((x-x0[hole])*(x-x0[hole])+(y-y0[hole])*(y-y0[hole]));
points += 1;
}
hole += 1;
if (v->path->segment->next == 0) {
break;
}
v->path->segment = v->path->segment->next;
}
holes = hole;
//
// find unique drills
//
drills = 0;
for (hole = 0; hole < holes; ++hole) {
drill = 0;
while (1) {
if (drill == drills) {
drills += 1;
d[drill] = 2*r[hole];
index[hole] = drill;
break;
}
if ((fabs(d[drill] - 2*r[hole])/d[drill]) < TOLERANCE) {
index[hole] = drill;
break;
}
drill += 1;
}
}
//
// write header
//
fprintf(output_file,"M48\n"); // program header
fprintf(output_file,"M72, LZ\n"); // inches, leading zeros
//
// write drills
//
for (drill = 0; drill < drills; ++drill) {
fprintf(output_file,"T%.2dC%.3f\n",(1+drill),d[drill]);
}
//
// write holes
//
fprintf(output_file,"%%\n"); // rewind and stop (start hole data)
for (hole = 0; hole < holes; ++hole) {
fprintf(output_file,"T%.2d\n",(1+index[hole])); // tool
x = 10000*x0[hole];
y = 10000*y0[hole];
fprintf(output_file,"X%.6dY%.6d\n",x,y); // location
}
/*
T06 Drill COMMAND GET TOOL 6
X01657Y03295 Drill location with TOOL 6
T12 Drill COMMAND GET TOOL 12
X00585Y03311 Drill location with TOOL 12
T04 Drill COMMAND GET TOOL 4
X00873Y02691 Drill location with TOOL 4
T16 Drill COMMAND GET TOOL 16
X00625Y02191 Drill location with TOOL 16
T00 Drill COMMAND UNLOAD TOOL
*/
//
// close file
//
fprintf(output_file,"M30\n"); // end of program
fclose(output_file);
printf("wrote %s\n",output_file_name);
printf(" holes: %d, drills: %d\n",holes,drills);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if ((argc < 3) || (argc > 3)) {
printf("command line: png_drl in.png out.drl\n");
printf(" in.png = input PNG file\n");
printf(" out.drl = output Excellon file\n");
exit(-1);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// copy image to array
//
fab_png_array(&v);
//
// write array to Excellon
//
fab_write_drl(&v,argv[2]);
//
// exit
//
exit(0);
}

66
src/core/png_ex.c 100644
Wyświetl plik

@ -0,0 +1,66 @@
#include <stdlib.h>
#include <stdio.h>
#include <png.h>
int x, y;
int width, height;
png_byte color_type;
png_byte bit_depth;
png_structp png_ptr;
png_infop info_ptr;
png_bytep * row_pointers;
void read_png_file(char* file_name) {
FILE *fp = fopen(file_name, "rb");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL,NULL,NULL);
info_ptr = png_create_info_struct(png_ptr);
png_init_io(png_ptr, fp);
png_read_info(png_ptr, info_ptr);
width = info_ptr->width;
height = info_ptr->height;
color_type = info_ptr->color_type;
bit_depth = info_ptr->bit_depth;
printf("width %d height %d color %d bit %d\n",
width,height,color_type,bit_depth);
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
for (y=0; y<height; y++)
row_pointers[y] = (png_byte*) malloc(info_ptr->rowbytes);
png_read_image(png_ptr, row_pointers);
fclose(fp);
}
void write_png_file(char* file_name) {
FILE *fp = fopen(file_name, "wb");
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL,NULL,NULL);
info_ptr = png_create_info_struct(png_ptr);
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, width, height,
bit_depth, color_type, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png_ptr, info_ptr);
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, NULL);
fclose(fp);
}
void process_file(void) {
png_byte *ptr;
for (y = 0; y < height; y++)
for (x = 0; x < width; x++) {
ptr = &(row_pointers[y][x*3]);
ptr[0] = 255;
ptr[1] = ptr[2];
}
}
int main(int argc, char **argv) {
if (argc != 3) {
printf("Usage: program_name <file_in> <file_out>\n");
exit(0);
}
read_png_file(argv[1]);
process_file();
write_png_file(argv[2]);
}

125
src/core/png_grb.c 100644
Wyświetl plik

@ -0,0 +1,125 @@
//
// png_grb.c
// PNG to Gerber (RS-274X)
//
// Neil Gershenfeld
// CBA MIT 11/22/12
//
// (c) Massachusetts Institute of Technology 2012
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
void fab_write_grb(struct fab_vars *v, char *output_file_name) {
FILE *output_file;
int i,j,k,x,y,width,height;
float units,dx,dy,xmin,ymin;
output_file = fopen(output_file_name,"w");
//
// write header
//
fprintf(output_file,"%%FSLAX24Y24*%%\n"); // leading zeros omitted, absolute coordinates, 2.4
fprintf(output_file,"%%MOIN*%%\n"); // inches units
fprintf(output_file,"%%OFA0B0*%%\n"); // no offset
//
// write apertures
//
units = 1.0/25.4; // inches
dx = units*v->dx/(v->nx-1.0);
dy = units*v->dy/(v->ny-1.0);
xmin = units*v->xmin;
ymin = units*v->ymin;
for (i = 1; i <= 10; ++i) {
for (j = 1; j <= 10; ++j) {
fprintf(output_file,"%%ADD%dR,%.4fX%.4f*%%\n",i*10+j,j*dx,i*dy);
}
}
//
// write flashes
//
for (i = (v->ny-1); i >= 0; --i) {
for (j = 0; j < v->nx; ++j) {
//
// find next starting pixel
//
if (v->array[i][j] > 0) {
//
// find width
//
v->array[i][j] = 0;
width = 1;
while ((width < 10) && ((j+width) < v->nx)){
if (v->array[i][j+width] != 0) {
v->array[i][j+width] = 0;
width += 1;
}
else
break;
}
//
// find height
//
height = 1;
while ((height < 10) && ((i-height) >= 0)){
for (k = 0; k < width; ++k) {
if (v->array[i-height][j+k] == 0)
goto height_continue;
}
for (k = 0; k < width; ++k)
v->array[i-height][j+k] = 0;
height += 1;
}
height_continue:
//
// flash it
//
x = 10000*(xmin+dx*(j+width/2.0));
y = 10000*(ymin+dy*(v->ny-1-i+height/2.0));
fprintf(output_file,"D%d*\n",height*10+width);
fprintf(output_file,"X%dY%dD03*\n",x,y);
}
}
}
//
// close file
//
fprintf(output_file,"M02*\n"); // end of file
fclose(output_file);
printf("wrote %s\n",output_file_name);
}
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if ((argc < 3) || (argc > 3)) {
printf("command line: png_grb in.png out.grb\n");
printf(" in.png = input PNG file\n");
printf(" out.grb = output Gerber (RS-274X) file\n");
exit(-1);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// copy image to array
//
fab_png_array(&v);
//
// write array to Gerber
//
fab_write_grb(&v,argv[2]);
//
// exit
//
exit(0);
}

Wyświetl plik

@ -0,0 +1,108 @@
//
// png_halftone.c
// halftone PNG to path
//
// Neil Gershenfeld
// CBA MIT 9/9/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int points, invert;
float threshold, size, spacing, offset;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6) || (argc == 7) || (argc == 8) || (argc == 9))) {
printf("command line: png_halftone in.png out.path [threshold [points [size [spacing [offset [invert]]]]]]\n");
printf(" in.png = input PNG file\n");
printf(" out.path = output path file\n");
printf(" threshold = minimum spot radius (optional, pixels default 1)\n");
printf(" points = points per spot (optional, default 8)\n");
printf(" size = maximum spot size (optional, mm, default 1)\n");
printf(" spacing = spot spacing (optional, 1 = size, default 1)\n");
printf(" offset = row offset (optional, 1 = size, default 0.5)\n");
printf(" offset = row offset (optional, 1 = size, default 0.5)\n");
printf(" invert = invert image (0 = no (default), 1 = yes)\n");
exit(-1);
}
if (argc == 3) {
threshold = 1.0;
points = 8;
size = 1.0;
spacing = 1.0;
offset = 0.5;
invert = 0;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&threshold);
points = 8;
size = 1.0;
spacing = 1.0;
offset = 0.5;
invert = 0;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&threshold);
sscanf(argv[4],"%d",&points);
size = 1.0;
spacing = 1.0;
offset = 0.5;
invert = 0;
}
else if (argc == 6) {
sscanf(argv[3],"%f",&threshold);
sscanf(argv[4],"%d",&points);
sscanf(argv[5],"%f",&size);
spacing = 1.0;
offset = 0.5;
invert = 0;
}
else if (argc == 7) {
sscanf(argv[3],"%f",&threshold);
sscanf(argv[4],"%d",&points);
sscanf(argv[5],"%f",&size);
sscanf(argv[6],"%f",&spacing);
offset = 0.5;
invert = 0;
}
else if (argc == 8) {
sscanf(argv[3],"%f",&threshold);
sscanf(argv[4],"%d",&points);
sscanf(argv[5],"%f",&size);
sscanf(argv[6],"%f",&spacing);
sscanf(argv[7],"%f",&offset);
invert = 0;
}
else if (argc == 9) {
sscanf(argv[3],"%f",&threshold);
sscanf(argv[4],"%d",&points);
sscanf(argv[5],"%f",&size);
sscanf(argv[6],"%f",&spacing);
sscanf(argv[7],"%f",&offset);
sscanf(argv[8],"%d",&invert);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// halftone
//
fab_halftone(&v,threshold,points,size,spacing,offset,invert);
//
// write path
//
fab_write_path(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,85 @@
//
// png_offset.c
// offset PNG
// png_offset in.png out.png threshold distance
//
// Neil Gershenfeld
// CBA MIT 9/11/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// pipe I/O
// variable bit depth
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
int x,y,count;
float intensity,distance;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5))) {
printf("command line: png_offset in.png out.png [intensity [distance]]\n");
printf(" in.png = input PNG file\n");
printf(" out.png = input PNG file\n");
printf(" intensity = intensity level to slice (optional, 0-1, default 0.5)\n");
printf(" distance = distance to offset (optional, mm, default 0)\n");
exit(-1);
}
if (argc == 3) {
intensity = 0.5;
distance = 0;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&intensity);
distance = 0;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&intensity);
sscanf(argv[4],"%f",&distance);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// threshold
//
fab_threshold(&v,intensity);
//
// find edges
//
fab_edges(&v);
//
// find edge distances
//
fab_distances(&v);
//
// offset
//
count = fab_offset(&v,distance);
printf("png_offset: %d points remain\n",count);
//
// set edge directions
//
fab_directions(&v);
//
// shade states
//
fab_shade_states(&v);
//
// write PNG
//
fab_write_png_K(&v,argv[2]);
}

671
src/core/png_path.c 100644
Wyświetl plik

@ -0,0 +1,671 @@
//
// png_path.c
// slice, offset, and vectorize PNG to path
//
// Neil Gershenfeld 10/14/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
// todo:
#include "fab.h"
int main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
struct fab_vars vxz;
init_vars(&vxz);
struct fab_vars vyz;
init_vars(&vyz);
int offset_number,offset_count,
layer,layer_number,nz,xz,yz,xy,
ix,ixmin,ixmax,idx,
iy,iymin,iymax,idy,
iz,ithreshold,
*tool_dx,*tool_dy,*tool_iz,tool_pt,tool_n,tool_ir,tool_id,
*clearance_dx,*clearance_dy,*clearance_iz,clearance_pt,clearance_n,clearance_ir,clearance_id,
remaining_count,remaining_count_sum,tool_collision;
float error,offset_diameter,offset_overlap,clearance_length,clearance_diameter,
intensity_top,intensity_bottom,intensity_layer,
z_top,z_bottom,z_thickness,z_layer,*z_list,distance;
char tool_type;
//
// command line args
//
if ((argc < 3) || (argc > 18)) {
printf("command line: png_path in.png out.path [error [offset_diameter [offset_number [offset_overlap [intensity_top [intensity_bottom [z_top [z_bottom [z_thickness [xz [yz [xy [type [clearance_length clearance_diameter]]]]]]]]]]]]]]\n");
printf(" in.png = input PNG file\n");
printf(" out.path = output path file\n");
printf(" error = allowable vector fit deviation (optional, pixels, default 1.1)\n");
printf(" offset_diameter = diameter to offset (optional, mm, default 0)\n");
printf(" offset_number = number of contours to offset (optional, -1 to fill all, default 1)\n");
printf(" offset_overlap = tool offset overlap fraction (optional, 0 (no overlap) - 1 (complete overlap, default 0.5))\n");
printf(" intensity_top = top slice intensity (optional, 0-1, default 0.5)\n");
printf(" intensity_bottom = bottom slice intensity (optional, 0-1, default intensity_top)\n");
printf(" z_top = top slice z value (optional, mm, default 0)\n");
printf(" z_bottom = bottom slice z value (optional, mm, default z_top)\n");
printf(" z_thickness = slice z thickness (optional, mm, default z_top-z_bottom)\n");
printf(" xz = xz finish (optional, 1=yes, default 0\n");
printf(" yz = yz finish (optional, 1=yes, default 0\n");
printf(" xy = xy path (optional, 1=yes, default 1\n");
printf(" type = finish tool type (optional, f=flat end, b=ball end, default f\n");
printf(" clearance_length = finish tool clearance length (optional, mm, 0 = no limit, default 0\n");
printf(" clearance_diameter = finish tool clearance diameter (optional, mm, default offset_diameter\n");
exit(-1);
}
error = 1.1;
offset_diameter = 0;
offset_number = 1;
offset_overlap = 0.5;
intensity_top = 0.5;
intensity_bottom = intensity_top;
z_top = 0;
z_bottom = 0;
z_thickness = 0;
xz = 0;
yz = 0;
xy = 1;
tool_type = 'f';
if (argc >= 4) {
sscanf(argv[3],"%f",&error);
}
if (argc >= 5) {
sscanf(argv[4],"%f",&offset_diameter);
}
if (argc >= 6) {
sscanf(argv[5],"%d",&offset_number);
}
if (argc >= 7) {
sscanf(argv[6],"%f",&offset_overlap);
}
if (argc >= 8) {
sscanf(argv[7],"%f",&intensity_top);
intensity_bottom = intensity_top;
}
if (argc >= 9) {
sscanf(argv[8],"%f",&intensity_bottom);
}
if (argc >= 10) {
sscanf(argv[9],"%f",&z_top);
z_bottom = z_top;
}
if (argc >= 11) {
sscanf(argv[10],"%f",&z_bottom);
z_thickness = z_top - z_bottom;
}
if (argc >= 12) {
sscanf(argv[11],"%f",&z_thickness);
}
if (argc >= 13) {
sscanf(argv[12],"%d",&xz);
}
if (argc >= 14) {
sscanf(argv[13],"%d",&yz);
}
if (argc >= 15) {
sscanf(argv[14],"%d",&xy);
}
if (argc >= 16) {
sscanf(argv[15],"%c",&tool_type);
}
clearance_length = z_top - z_bottom;
clearance_diameter = offset_diameter;
if (argc >= 17) {
sscanf(argv[16],"%f",&clearance_length);
if (clearance_length == 0)
clearance_length = z_top - z_bottom;
}
if (argc >= 18) {
sscanf(argv[17],"%f",&clearance_diameter);
}
tool_collision = 0;
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// 2D path?
//
if (argc < 9) {
//
// start path
//
fab_path_start(&v,2);
printf("png_path: intensity %f\n",intensity_top);
//
// copy image to array
//
fab_png_array(&v);
//
// threshold array
//
printf(" threshold\n");
fab_threshold(&v,intensity_top);
//
// find edges
//
printf(" find edges\n");
remaining_count = fab_edges(&v);
if (remaining_count != 0) {
//
// find edge distances
//
printf(" find distances\n");
//test_fab_distances(&v);
fab_distances(&v);
//
// loop over contours
//
printf(" offset:\n");
offset_count = 0;
remaining_count_sum = 0;
do {
//
// offset
//
distance = offset_diameter/2.0 + offset_diameter*(1-offset_overlap)*offset_count;
remaining_count = fab_offset(&v,distance);
remaining_count_sum += remaining_count;
printf(" distance %f, %d exterior points remain\n",
distance,remaining_count);
if (remaining_count != 0) {
//
// set edge directions
//
fab_directions(&v);
//
// vectorize edge directions
//
fab_vectorize(&v,error,0);
}
++offset_count;
} while ((offset_count != offset_number) && (remaining_count != 0));
}
else {
printf("path.c: oops -- no layer edges\n");
exit(-1);
}
if (remaining_count_sum == 0) {
printf("png_path: no offset edges\n");
exit(1);
}
}
//
// 3D path
//
else {
//
// start path
//
fab_path_start(&v,3);
//
// set path z bounds
//
v.zmin = z_bottom;
v.dz = (z_top - z_bottom);
if (v.dz == 0)
v.nz = 1;
else
v.nz = v.dz * v.nx / v.dx;
//
// find z layer values
//
if (xy == 1) {
if (v.dz == 0)
nz = 1;
else {
nz = 2 + (z_top-z_bottom)/z_thickness;
z_list = (float*) malloc(nz*sizeof(float));
z_layer = z_top;
nz = 0;
while (1) {
z_list[nz] = z_layer;
nz += 1;
if (z_layer == z_bottom)
break;
z_layer -= z_thickness;
if (z_layer < z_bottom)
z_layer = z_bottom;
}
}
}
//
// copy image to array for finish cuts
//
fab_png_array(&v);
//
// create tool shape offset list
//
tool_ir = v.nx*offset_diameter/(2*v.dx);
tool_id = 2*tool_ir;
tool_dx = (int*) malloc(tool_id*tool_id*sizeof(int));
tool_dy = (int*) malloc(tool_id*tool_id*sizeof(int));
tool_iz = (int*) malloc(tool_id*tool_id*sizeof(int));
tool_pt = 0;
tool_n = 0;
for (ix = 0; ix < tool_id; ++ix)
for (iy = 0; iy < tool_id; ++iy)
if (sqrt((ix-tool_ir)*(ix-tool_ir)+(iy-tool_ir)*(iy-tool_ir)) < tool_ir) {
tool_dx[tool_pt] = ix-tool_ir;
tool_dy[tool_pt] = iy-tool_ir;
if (tool_type == 'f')
tool_iz[tool_pt] = 0;
else if (tool_type == 'b') {
tool_iz[tool_pt] = pow(2,v.bit_depth)*(tool_ir - sqrt(tool_ir*tool_ir
- ((ix-tool_ir)*(ix-tool_ir) + (iy-tool_ir)*(iy-tool_ir))))/v.nz;
}
else {
printf("path.c: oops -- unsupported tool type\n");
exit(-1);
}
tool_pt += 1;
tool_n = tool_pt;
}
//
// create tool clearance offset list
//
clearance_ir = v.nx*clearance_diameter/(2*v.dx);
clearance_id = 2*clearance_ir;
clearance_dx = (int*) malloc(clearance_id*clearance_id*sizeof(int));
clearance_dy = (int*) malloc(clearance_id*clearance_id*sizeof(int));
clearance_iz = (int*) malloc(clearance_id*clearance_id*sizeof(int));
clearance_pt = 0;
clearance_n = 0;
for (ix = 0; ix < clearance_id; ++ix)
for (iy = 0; iy < clearance_id; ++iy)
if (((sqrt((ix-clearance_ir)*(ix-clearance_ir)+(iy-clearance_ir)*(iy-clearance_ir))) >= tool_ir)
&& ((sqrt((ix-clearance_ir)*(ix-clearance_ir)+(iy-clearance_ir)*(iy-clearance_ir))) < clearance_ir)) {
clearance_dx[clearance_pt] = ix-clearance_ir;
clearance_dy[clearance_pt] = iy-clearance_ir;
clearance_iz[clearance_pt] = (pow(2,v.bit_depth)-1)*clearance_length/v.dz;
clearance_pt += 1;
clearance_n = clearance_pt;
}
//
// check for xz cut
//
if (xz == 1) {
//
// allocate xz finish cut array
//
vxz.nx = v.nx;
vxz.ny = v.nz;
vxz.nz = 1;
vxz.dx = v.dx;
vxz.dy = v.dz;
vxz.dz = 0;
vxz.xmin = v.xmin;
vxz.ymin = v.zmin;
vxz.zmin = 0;
vxz.array = malloc(v.nz*sizeof(uint32_t *));
for (iz = 0; iz < v.nz; ++iz)
vxz.array[iz] = malloc(v.nx*sizeof(uint32_t));
//
// start xz path
//
fab_path_start(&vxz,3);
//
// y loop
//
iymin = v.ny*clearance_diameter/(2.0*v.dy);
iymax = (v.ny-1) - v.ny*clearance_diameter/(2.0*v.dy);
idy = v.ny*offset_diameter*(1-offset_overlap)/v.dy;
printf(" xz finish:\n");
for (iy = iymin; iy <= iymax; (iy += idy)) {
printf(" y=%d/%d\n",iy,iymax);
//
// x loop
//
for (ix = 0; ix < vxz.nx; ++ix) {
//
// set z threshold
//
if ((ix <= clearance_ir) | (ix >= (vxz.nx-clearance_ir)))
//
// too close to edge, set max
//
ithreshold = pow(2,v.bit_depth);
else {
//
// offset for tool shape
//
ithreshold = 0;
for (tool_pt = 0; tool_pt < tool_n; ++tool_pt) {
if (v.array[iy+tool_dy[tool_pt]][ix+tool_dx[tool_pt]] > (ithreshold+tool_iz[tool_pt]))
ithreshold = v.array[iy+tool_dy[tool_pt]][ix+tool_dx[tool_pt]] - tool_iz[tool_pt];
}
//
// check clearance
//
for (clearance_pt = 0; clearance_pt < clearance_n; ++clearance_pt) {
if (v.array[iy+clearance_dy[clearance_pt]][ix+clearance_dx[clearance_pt]] > (ithreshold+clearance_iz[clearance_pt])) {
ithreshold = v.array[iy+clearance_dy[clearance_pt]][ix+clearance_dx[clearance_pt]] - clearance_iz[clearance_pt];
tool_collision = 1;
}
}
}
//
// convert from image to lattice units
//
ithreshold = 1+(v.nz-2.0)*ithreshold/(pow(2,v.bit_depth)-1.0); // +1 for bottom edge
//
// z (array y) loop
//
for (iz = 0; iz < vxz.ny; ++iz) {
if (iz <= ithreshold)
vxz.array[iz][ix] = v.interior;
else
vxz.array[iz][ix] = v.empty;
}
}
//
// set edge directions
//
fab_directions(&vxz);
//
// vectorize edge directions
//
fab_vectorize(&vxz,error,iy);
}
//
// copy xz path
//
vxz.path->segment = vxz.path->first;
while (1) {
//
// follow segment forward
//
vxz.path->segment->point = vxz.path->segment->first;
fab_path_segment(&v);
while (1) {
//
// follow points
//
fab_path_point(&v);
vxz.path->segment->point->axis = vxz.path->segment->point->first;
ix = vxz.path->segment->point->axis->value;
vxz.path->segment->point->axis = vxz.path->segment->point->axis->next;
iy = vxz.path->segment->point->axis->value;
vxz.path->segment->point->axis = vxz.path->segment->point->axis->next;
iz = vxz.path->segment->point->axis->value;
fab_path_axis(&v,ix);
fab_path_axis(&v,iz);
fab_path_axis(&v,iy);
if (vxz.path->segment->point->next == 0)
break;
vxz.path->segment->point = vxz.path->segment->point->next;
}
if (vxz.path->segment->next == 0)
break;
vxz.path->segment = vxz.path->segment->next;
//
// follow segment backwards
//
vxz.path->segment->point = vxz.path->segment->last;
fab_path_segment(&v);
while (1) {
//
// follow points
//
fab_path_point(&v);
vxz.path->segment->point->axis = vxz.path->segment->point->first;
ix = vxz.path->segment->point->axis->value;
vxz.path->segment->point->axis = vxz.path->segment->point->axis->next;
iy = vxz.path->segment->point->axis->value;
vxz.path->segment->point->axis = vxz.path->segment->point->axis->next;
iz = vxz.path->segment->point->axis->value;
fab_path_axis(&v,ix);
fab_path_axis(&v,iz);
fab_path_axis(&v,iy);
if (vxz.path->segment->point->previous == 0)
break;
vxz.path->segment->point = vxz.path->segment->point->previous;
}
if (vxz.path->segment->next == 0)
break;
vxz.path->segment = vxz.path->segment->next;
}
}
//
// check for yz cut
//
if (yz == 1) {
//
// allocate yz finish cut array
//
vyz.nx = v.ny;
vyz.ny = v.nz;
vyz.nz = 1;
vyz.dx = v.dy;
vyz.dy = v.dz;
vyz.dz = 0;
vyz.xmin = v.ymin;
vyz.ymin = v.zmin;
vyz.zmin = 0;
vyz.array = malloc(v.nz*sizeof(uint32_t *));
for (iz = 0; iz < v.nz; ++iz)
vyz.array[iz] = malloc(v.ny*sizeof(uint32_t));
//
// start yz path
//
fab_path_start(&vyz,3);
//
// x loop
//
ixmin = v.nx*clearance_diameter/(2.0*v.dx);
ixmax = (v.nx-1) - v.nx*clearance_diameter/(2.0*v.dx);
idx = v.nx*offset_diameter*(1-offset_overlap)/v.dx;
printf(" yz finish:\n");
for (ix = ixmax; ix >= ixmin; (ix -= idx)) {
printf(" x=%d/%d\n",ix,ixmax);
//
// y (array x) loop
//
for (iy = 0; iy < vyz.nx; ++iy) {
//
// set z threshold
//
if ((iy <= clearance_ir) | (iy >= (vyz.nx-clearance_ir)))
//
// too close to edge, set max
//
ithreshold = pow(2,v.bit_depth);
else {
//
// offset for tool shape
//
ithreshold = 0;
for (tool_pt = 0; tool_pt < tool_n; ++tool_pt) {
if (v.array[iy+tool_dy[tool_pt]][ix+tool_dx[tool_pt]] > (ithreshold+tool_iz[tool_pt]))
ithreshold = v.array[iy+tool_dy[tool_pt]][ix+tool_dx[tool_pt]] - tool_iz[tool_pt];
}
//
// check clearance
//
for (clearance_pt = 0; clearance_pt < clearance_n; ++clearance_pt) {
if (v.array[iy+clearance_dy[clearance_pt]][ix+clearance_dx[clearance_pt]] > (ithreshold+clearance_iz[clearance_pt])) {
ithreshold = v.array[iy+clearance_dy[clearance_pt]][ix+clearance_dx[clearance_pt]] - clearance_iz[clearance_pt];
tool_collision = 1;
}
}
}
//
// convert from image to lattice units
//
ithreshold = 1+(v.nz-2.0)*ithreshold/(pow(2,v.bit_depth)-1.0); // +1 for bottom edge
//
// z (array y) loop
//
for (iz = 0; iz < vyz.ny; ++iz) {
if (iz <= ithreshold)
vyz.array[iz][iy] = v.interior;
else
vyz.array[iz][iy] = v.empty;
}
}
//
// set edge directions
//
fab_directions(&vyz);
//
// vectorize edge directions
//
fab_vectorize(&vyz,error,ix);
}
//
// copy yz path
//
vyz.path->segment = vyz.path->first;
while (1) {
//
// follow segment forwards
//
vyz.path->segment->point = vyz.path->segment->first;
fab_path_segment(&v);
while (1) {
//
// follow points
//
fab_path_point(&v);
vyz.path->segment->point->axis = vyz.path->segment->point->first;
ix = vyz.path->segment->point->axis->value;
vyz.path->segment->point->axis = vyz.path->segment->point->axis->next;
iy = vyz.path->segment->point->axis->value;
vyz.path->segment->point->axis = vyz.path->segment->point->axis->next;
iz = vyz.path->segment->point->axis->value;
fab_path_axis(&v,iz);
fab_path_axis(&v,ix);
fab_path_axis(&v,iy);
if (vyz.path->segment->point->next == 0)
break;
vyz.path->segment->point = vyz.path->segment->point->next;
}
if (vyz.path->segment->next == 0)
break;
vyz.path->segment = vyz.path->segment->next;
//
// follow segment backwards
//
vyz.path->segment->point = vyz.path->segment->last;
fab_path_segment(&v);
while (1) {
//
// follow points
//
fab_path_point(&v);
vyz.path->segment->point->axis = vyz.path->segment->point->first;
ix = vyz.path->segment->point->axis->value;
vyz.path->segment->point->axis = vyz.path->segment->point->axis->next;
iy = vyz.path->segment->point->axis->value;
vyz.path->segment->point->axis = vyz.path->segment->point->axis->next;
iz = vyz.path->segment->point->axis->value;
fab_path_axis(&v,iz);
fab_path_axis(&v,ix);
fab_path_axis(&v,iy);
if (vyz.path->segment->point->previous == 0)
break;
vyz.path->segment->point = vyz.path->segment->point->previous;
}
if (vyz.path->segment->next == 0)
break;
vyz.path->segment = vyz.path->segment->next;
}
}
//
// check for xy cut
//
if (xy == 1) {
//
// z loop
//
for (layer = (nz-1); layer >= 0; --layer) {
if (v.dz == 0) {
z_layer = z_top;
intensity_layer = intensity_top;
layer_number = 0;
}
else {
z_layer = z_list[layer];
intensity_layer = intensity_bottom + (intensity_top-intensity_bottom)*(z_layer-z_bottom)/(z_top-z_bottom);
layer_number = v.nz*(z_layer-z_bottom)/(z_top-z_bottom);
}
printf("png_path: intensity %f, z %f\n",intensity_layer,z_layer);
//
// copy image to array
//
fab_png_array(&v);
//
// threshold array
//
printf(" threshold\n");
fab_threshold(&v,intensity_layer);
//
// find edges
//
printf(" find edges\n");
remaining_count = fab_edges(&v);
if (remaining_count == 0) {
printf(" no layer edges\n");
continue;
}
//
// find edge distances
//
printf(" find distances\n");
//test_fab_distances(&v);
fab_distances(&v);
//
// loop over contours
//
printf(" offset:\n");
offset_count = 0;
remaining_count_sum = 0;
do {
//
// offset
//
distance = offset_diameter/2.0 + offset_diameter*(1-offset_overlap)*offset_count;
remaining_count = fab_offset(&v,distance);
remaining_count_sum += remaining_count;
printf(" distance %f, %d exterior points remain\n",
distance,remaining_count);
if (remaining_count != 0) {
//
// set edge directions
//
fab_directions(&v);
//
// vectorize edge directions
//
fab_vectorize(&v,error,layer_number);
}
++offset_count;
} while ((offset_count != offset_number) && (remaining_count != 0));
}
if (remaining_count_sum == 0) {
printf("png_path: no offset edges\n");
exit(1);
}
}
}
if (tool_collision == 1)
printf(" tool collisions\n");
//
// write path
//
fab_write_path(&v,argv[2]);
//
// exit
//
exit(0);
}

Wyświetl plik

@ -0,0 +1,48 @@
//
// png_scale.c
// rescale PNG intensity
//
// Neil Gershenfeld
// CBA MIT 1/22/11
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float min,max;
//
// command line args
//
if (argc != 5) {
printf("command line: png_scale in.png out.png low high\n");
printf(" in.png = input PNG file\n");
printf(" out.png = output PNG file\n");
printf(" low = rescaled intensity minimum (0-1)\n");
printf(" high = rescaled intensity maximum (0-1)\n");
exit(-1);
}
//
// read PNG
//
fab_read_png(&v,argv[1]);
//
// rescale
//
sscanf(argv[3],"%f",&min);
sscanf(argv[4],"%f",&max);
fab_rescale(&v,min,max);
//
// write PNG
//
fab_write_png_K(&v,argv[2]);
}

Wyświetl plik

@ -0,0 +1,59 @@
//
// png_size.c
// display and edit PNG size
//
// Neil Gershenfeld
// CBA MIT 8/28/10
//
// (c) Massachusetts Institute of Technology 2010
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
// todo
// variable units
// pipe I/O
// variable bit depth
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float dx,dy;
//
// command line args
//
if (!((argc == 2) || (argc == 3) || (argc == 4))) {
printf("command line: png_size in.png [dx [dy]]\n");
printf(" in.png = input PNG file\n");
printf(" dx = set width (optional, mm)\n");
printf(" dy = set height (optional, mm)\n");
exit(-1);
}
//
// read image
//
fab_read_png(&v,argv[1]);
//
// rescale if size given
//
if (argc == 3) {
sscanf(argv[2],"%f",&dx);
dy = v.dy * dx / ((float) v.dx);
v.dx = dx;
v.dy = dy;
fab_write_png_K(&v,argv[1]);
}
else if (argc == 4) {
sscanf(argv[2],"%f",&dx);
sscanf(argv[3],"%f",&dy);
v.dx = dx;
v.dy = dy;
fab_write_png_K(&v,argv[1]);
}
}

Wyświetl plik

@ -0,0 +1,35 @@
//
// stl_info.c
// report .stl info
//
// Neil Gershenfeld
// CBA MIT 3/6/11
//
// (c) Massachusetts Institute of Technology 2011
// Permission granted for experimental and personal use;
// license for commercial sale available from MIT.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float units,resolution;
char axis;
//
// command line args
//
if (argc != 2) {
printf("command line: stl_info in.stl\n");
printf(" in.stl = input binary STL file\n");
exit(-1);
}
//
// read .stl
//
fab_read_stl(&v,argv[1]);
}

Wyświetl plik

@ -0,0 +1,64 @@
//
// stl_path.c
// convert .stl to .path
//
// Neil Gershenfeld 10/4/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include "fab.h"
int main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float units,resolution;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5))) {
printf("command line: stl_path in.stl out.path [units [resolution]]]\n");
printf(" in.stl = input binary STL file\n");
printf(" out.png = output PNG file\n");
printf(" units = file units (optional, mm/unit, default 1)\n");
printf(" resolution = image resolution (optional, pixels/mm, default 10)\n");
exit(-1);
}
if (argc == 3) {
units = 1;
resolution = 10;
}
else if (argc == 4) {
sscanf(argv[3],"%f",&units);
resolution = 10;
}
else if (argc == 5) {
sscanf(argv[3],"%f",&units);
sscanf(argv[4],"%f",&resolution);
}
//
// read .stl
//
fab_read_stl(&v,argv[1]);
//
// convert mesh to path
//
fab_mesh_path(&v,units,resolution);
//
// write .path
//
fab_write_path(&v,argv[2]);
//
// return
//
return(0);
}

76
src/core/stl_png.c 100644
Wyświetl plik

@ -0,0 +1,76 @@
//
// stl_png.c
// convert STL to PNG
//
// Neil Gershenfeld 10/4/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#include "fab.h"
main(int argc, char **argv) {
//
// local vars
//
struct fab_vars v;
init_vars(&v);
float units,resolution;
char axis;
//
// command line args
//
if (!((argc == 3) || (argc == 4) || (argc == 5) || (argc == 6))) {
printf("command line: stl_png in.stl out.png [units [resolution [axis]]]\n");
printf(" in.stl = input binary STL file\n");
printf(" out.png = output PNG file\n");
printf(" units = file units (optional, mm/unit, default 1)\n");
printf(" resolution = image resolution (optional, pixels/mm, default 10)\n");
printf(" axis = projection axis (optional, top or bottom, x|X|y|Y|z|Z, default z)\n");
exit(-1);
}
if (argc == 3) {
units = 1;
resolution = 10;
axis = 'z';
}
else if (argc == 4) {
sscanf(argv[3],"%f",&units);
resolution = 10;
axis = 'z';
}
else if (argc == 5) {
sscanf(argv[3],"%f",&units);
sscanf(argv[4],"%f",&resolution);
axis = 'z';
}
else if (argc == 6) {
sscanf(argv[3],"%f",&units);
sscanf(argv[4],"%f",&resolution);
sscanf(argv[5],"%c",&axis);
}
//
// read STL
//
fab_read_stl(&v,argv[1]);
//
// draw mesh into array
//
fab_shade_mesh(&v,units,resolution,axis);
//
// move origin to corner
//
v.xmin = 0;
v.ymin = 0;
v.zmin = 0;
//
// write PNG
//
fab_write_png_K(&v,argv[2]);
}

1255
src/core/svg_path.c 100644

Plik diff jest za duży Load Diff

18
src/core/test.c 100644

File diff suppressed because one or more lines are too long

265
src/core/vol_gif.c 100644
Wyświetl plik

@ -0,0 +1,265 @@
//
// vol_gif.c
// .vol to .gif
//
// Neil Gershenfeld 11/29/13
// (c) Massachusetts Institute of Technology 2013
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
/*
gcc -O3 vol_gif.c -o vol_gif -D_FILE_OFFSET_BITS=64 -Wall -lm -lgif
*/
#include "fab.h"
void read_voxel_f(FILE *input_file,float *f,int x,int y,int z,int *xi,int *yi,int *zi,int ix,int iy,int iz) {
int r,match=0;
while (1) {
if ((x == *xi) && (y == *yi) && (z == *zi)) {
match = 1;
}
r = fread(f,sizeof(*f),1,input_file);
if (r == 0) {
printf("vol_gif: oops -- not enough points in file\n");
exit(-1);
}
*xi += 1;
if (*xi == ix) {
*xi = 0;
*yi += 1;
if (*yi == iy) {
*yi = 0;
*zi += 1;
}
}
if (match == 1)
return;
}
}
void read_voxel_i(FILE *input_file,uint16_t *i,int x,int y,int z,int *xi,int *yi,int *zi,int ix,int iy,int iz) {
int r,match=0;
while (1) {
if ((x == *xi) && (y == *yi) && (z == *zi)) {
match = 1;
}
r = fread(i,sizeof(*i),1,input_file);
if (r == 0) {
printf("vol_gif: oops -- not enough points in file\n");
exit(-1);
}
*xi += 1;
if (*xi == ix) {
*xi = 0;
*yi += 1;
if (*yi == iy) {
*yi = 0;
*zi += 1;
}
}
if (match == 1)
return;
}
}
int main(int argc, char **argv) {
FILE *input_file;
float arg,size,rx,ry,rz;
float f,fmin=1e10,fmax=-1e10;
uint16_t i;
uint64_t count;
int xi,yi,zi,xo,yo,zo,nx,ny,nz,dx,dy,dz,x0,y0,z0,h;
int **image;
char format,type,comment[256];
GifFileType *GIFfile;
ColorMapObject *GIFcmap;
GifPixelType *GIFline;
//
// command line args
//
if (!((argc == 6) || (argc == 7) || (argc == 8) || (argc == 9) || (argc == 10) || (argc == 13) || (argc == 16) || (argc == 19))) {
printf("command line: vol_gif in.vol out.gif nx ny nz [format [type [arg [size [dx dy dz [x0 y0 z0 [rx ry rz]]]]]]]\n");
printf(" in.vol = input volume file\n");
printf(" out.gif = output GIF file\n");
printf(" nx,ny,nz = x,y,z input voxel number\n");
printf(" format = 'f' for float 32, 'i' for uint16_t (default 'f')\n");
printf(" type = 's' for section, 'h' for height (default 's')\n");
printf(" arg = gamma for 's', threshold for 'h' (default 1)\n");
printf(" size = mm per voxel (default 1)\n");
printf(" dx,dy,dz = x,y,z output voxel number (default all)\n");
printf(" x0,y0,z0 = x,y,z output voxel origin (default 0)\n");
printf(" to be implemented: rx,ry,rz = view rotation angles (degrees; default 0)\n");
exit(-1);
}
format = 'f';
type = 's';
arg = 1;
size = 1.0;
rx = ry = rz = 0;
sscanf(argv[3],"%d",&nx);
sscanf(argv[4],"%d",&ny);
sscanf(argv[5],"%d",&nz);
dx = nx; dy = ny; dz = nz;
x0 = y0 = z0 = 0;
if (argc >= 7) {
sscanf(argv[6],"%c",&format);
if (!((format == 'f') || (format == 'i'))) {
printf("vol_gif: oops -- format must be 'f' or 'i'\n");
exit(-1);
}
}
if (argc >= 8) {
sscanf(argv[7],"%c",&type);
if (!((type == 's') || (type == 'h'))) {
printf("vol_gif: oops -- type must be 's' or 'h'\n");
exit(-1);
}
}
if (argc >= 9) {
sscanf(argv[8],"%f",&arg);
}
if (argc >= 10) {
sscanf(argv[9],"%f",&size);
}
if (argc >= 13) {
sscanf(argv[10],"%d",&x0);
sscanf(argv[11],"%d",&y0);
sscanf(argv[12],"%d",&z0);
}
if (argc >= 16) {
sscanf(argv[13],"%d",&dx);
sscanf(argv[14],"%d",&dy);
sscanf(argv[15],"%d",&dz);
}
if (argc >= 19) {
sscanf(argv[16],"%f",&rx);
sscanf(argv[17],"%f",&ry);
sscanf(argv[18],"%f",&rz);
}
//
// check and find limits
//
input_file = fopen(argv[1],"rb");
if (input_file == NULL) {
printf("vol_gif: oops -- can not open %s\n",argv[1]);
exit(-1);
}
if (((x0 + dx) > nx) || ((y0 + dy) > ny) || ((z0 + dz) > nz)) {
printf("vol_gif: oops -- region too large\n");
exit(-1);
}
printf("read %s\n",argv[1]);
if (format == 'f') {
count = 0;
while (fread(&f,sizeof(f),1,input_file) != 0) {
if (f > fmax) fmax = f;
if (f < fmin) fmin = f;
count += 1;
}
}
else if (format == 'i') {
count = 0;
while (fread(&i,sizeof(i),1,input_file) != 0) {
if (i > fmax) fmax = i;
if (i < fmin) fmin = i;
count += 1;
}
}
printf(" %" PRIu64 " points, min %f, max %f\n",count,fmin,fmax);
printf(" nx ny nz: %d %d %d\n",nx,ny,nz);
rewind(input_file);
//
// set up color map
//
GIFcmap = MakeMapObject(256, NULL);
for (i = 0; i < 256; i++) {
GIFcmap->Colors[i].Red = i;
GIFcmap->Colors[i].Green = i;
GIFcmap->Colors[i].Blue = i;
}
//
// open GIF file
//
printf("write %s\n",argv[2]);
GIFfile = EGifOpenFileName(argv[2], 0);
EGifPutScreenDesc(GIFfile,dx,dy,8,0,GIFcmap);
unsigned char loop_count[] = {1,0,0};
EGifPutExtensionFirst(GIFfile, APPLICATION_EXT_FUNC_CODE, 11, "NETSCAPE2.0");
EGifPutExtensionLast(GIFfile, APPLICATION_EXT_FUNC_CODE, 3, loop_count);
unsigned char delay_count[5] = {
0, // no transparency
0, // delay time
0, // delay time
0 // transparent index not used
};
//
// allocate image
//
image = malloc(dy*sizeof(int *));
for (yo = 0; yo < dy; ++yo) {
image[yo] = malloc(dx*sizeof(int));
for (xo = 0; xo < dx; ++xo)
image[yo][xo] = 0;
}
GIFline = malloc(dx*sizeof(GifPixelType));
//
// scan file
//
xi = yi = zi = 0;
for (zo = 0; zo < dz; ++zo) {
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",zo);
EGifPutExtension(GIFfile,GRAPHICS_EXT_FUNC_CODE,4,delay_count);
EGifPutImageDesc(GIFfile,0,0,dx,dy,0,NULL);
//
// read layer
//
for (yo = 0; yo < dy; ++yo) {
for (xo = 0; xo < dx; ++xo) {
if (format == 'f') {
read_voxel_f(input_file,&f,xo+x0,yo+y0,zo+z0,&xi,&yi,&zi,nx,ny,nz);
if (type == 'h') {
h = 255*zo/(nz-1.0);
if ((h > image[yo][xo]) && (f > arg))
image[yo][xo] = h;
GIFline[xo] = image[yo][xo]*(nz-1.0)/zo;
}
else if (type == 's') {
GIFline[xo] = 255*pow((f-fmin)/(fmax-fmin),arg);
}
}
else if (format == 'i') {
read_voxel_i(input_file,&i,xo+x0,yo+y0,zo+z0,&xi,&yi,&zi,nx,ny,nz);
if (type == 'h') {
h = 255*zo/(nz-1.0);
if ((h > image[yo][xo]) && (i > arg))
image[yo][xo] = h;
GIFline[xo] = image[yo][xo]*(nz-1.0)/zo;
}
else if (type == 's') {
GIFline[xo] = 255*pow((i-fmin)/(fmax-fmin),arg);
}
}
}
EGifPutLine(GIFfile,GIFline,dx);
}
}
printf("\n");
//
// put mm per pixel in comment
//
sprintf(comment,"mm per pixel: %f;",size);
EGifPutComment(GIFfile,comment);
//
// exit
//
fclose(input_file);
EGifCloseFile(GIFfile);
exit(0);
}

667
src/core/vol_stl.c 100644
Wyświetl plik

@ -0,0 +1,667 @@
//
// vol_stl.c
// .vol to .stl
//
// Neil Gershenfeld 5/21/14
// (c) Massachusetts Institute of Technology 2014
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge the fab modules project. Copyright is
// retained and must be preserved. The work is provided
// as is; no warranty is provided, and users accept all
// liability.
//
#define MAX_LINE 10000
#include "fab.h"
/*
vertices:
---
6 7
4 5
---
2 3
0 1
---
edges:
---
k
l j
i
---
h g
e f
---
c
d b
a
---
*/
//
// rotate_x
// rotate rule around x and add
//
void rotate_x(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[4] << 0)
+(b[5] << 1)
+(b[0] << 2)
+(b[1] << 3)
+(b[6] << 4)
+(b[7] << 5)
+(b[2] << 6)
+(b[3] << 7);
for (i
= 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'c'; break;
case 'b': rules[*index][i] = 'g'; break;
case 'c': rules[*index][i] = 'k'; break;
case 'd': rules[*index][i] = 'h'; break;
case 'e': rules[*index][i] = 'd'; break;
case 'f': rules[*index][i] = 'b'; break;
case 'g': rules[*index][i] = 'j'; break;
case 'h': rules[*index][i] = 'l'; break;
case 'i': rules[*index][i] = 'a'; break;
case 'j': rules[*index][i] = 'f'; break;
case 'k': rules[*index][i] = 'i'; break;
case 'l': rules[*index][i] = 'e'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// rotate_y
// rotate rule around y and add
//
void rotate_y(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[1] << 0)
+(b[5] << 1)
+(b[3] << 2)
+(b[7] << 3)
+(b[0] << 4)
+(b[4] << 5)
+(b[2] << 6)
+(b[6] << 7);
for (i = 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'e'; break;
case 'b': rules[*index][i] = 'd'; break;
case 'c': rules[*index][i] = 'h'; break;
case 'd': rules[*index][i] = 'l'; break;
case 'e': rules[*index][i] = 'i'; break;
case 'f': rules[*index][i] = 'a'; break;
case 'g': rules[*index][i] = 'c'; break;
case 'h': rules[*index][i] = 'k'; break;
case 'i': rules[*index][i] = 'f'; break;
case 'j': rules[*index][i] = 'b'; break;
case 'k': rules[*index][i] = 'g'; break;
case 'l': rules[*index][i] = 'j'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// rotate_z
// rotate rule around z and add
//
void rotate_z(char rules[255][20], int *index) {
int i,b[8];
int old_index = *index;
for (i = 0; i < 8; ++i) b[i] = (*index & (1 << i)) >> i;
*index =
(b[2] << 0)
+(b[0] << 1)
+(b[3] << 2)
+(b[1] << 3)
+(b[6] << 4)
+(b[4] << 5)
+(b[7] << 6)
+(b[5] << 7);
for (i = 0; i < strlen(rules[old_index]); ++i) {
switch (rules[old_index][i]) {
case 'a': rules[*index][i] = 'b'; break;
case 'b': rules[*index][i] = 'c'; break;
case 'c': rules[*index][i] = 'd'; break;
case 'd': rules[*index][i] = 'a'; break;
case 'e': rules[*index][i] = 'f'; break;
case 'f': rules[*index][i] = 'g'; break;
case 'g': rules[*index][i] = 'h'; break;
case 'h': rules[*index][i] = 'e'; break;
case 'i': rules[*index][i] = 'j'; break;
case 'j': rules[*index][i] = 'k'; break;
case 'k': rules[*index][i] = 'l'; break;
case 'l': rules[*index][i] = 'i'; break;
case ' ': rules[*index][i] = ' '; break;
}
}
}
//
// print_rules
// print the rule table
//
void print_rules(char rules[255][20]) {
int i,b;
printf("76543210\n");
for (i = 0; i < 256; ++i) {
for (b = 7; b >= 0; --b) {
printf("%d",(i & (1 << b)) >> b);
}
printf(" %d %s\n",i,rules[i]);
}
}
// add_rules
// add a rule and its variants to the table
//
void add_rules(char rules[255][20], int index, char *edges) {
int i,j,k,l;
strcpy(rules[index],edges);
for (i=0; i<4; ++i) {
for (j=0; j<4; ++j) {
for (k=0; k<4; ++k) {
rotate_x(rules,&index);
}
rotate_y(rules,&index);
}
rotate_z(rules,&index);
}
}
//
// init_rules
// create the rule table
//
void init_rules(char rules[255][20]) {
int i,j;
for (i = 0; i < 256; ++i)
for (j = 0; j < 20; ++j)
rules[i][j] = 0;
add_rules(rules,0b00000000,""); // 0
add_rules(rules,0b11111111,""); // ~0
add_rules(rules,0b00000001,"eda"); // 1
add_rules(rules,0b11111110,"ade"); // ~1
add_rules(rules,0b00000011,"fed dbf"); // 2
add_rules(rules,0b11111100,"def fbd"); // ~2
add_rules(rules,0b00100001,"eda jif"); // 3
add_rules(rules,0b11011110,"ade fij"); // ~3
add_rules(rules,0b10000001,"eda gkj"); // 4
add_rules(rules,0b01111110,"ade jkg"); // ~4
add_rules(rules,0b00001110,"fhg fdh fad"); // 5
add_rules(rules,0b11110001,"ghf hdf daf"); // ~5
add_rules(rules,0b10000011,"fed fdb gkj"); // 6
add_rules(rules,0b01111100,"def bdf jkg"); // ~6
add_rules(rules,0b10010010,"bfa ile gkj"); // 7
add_rules(rules,0b01101101,"afb eli jkg"); // ~7
add_rules(rules,0b00001111,"ehg feg"); // 8
add_rules(rules,0b11110000,"ghe gef"); // ~8
add_rules(rules,0b01001101,"elk eka akg agb"); // 9
add_rules(rules,0b10110010,"kle ake gka bga"); // ~9
add_rules(rules,0b10011001,"ild ida ckj cjb"); // 10
add_rules(rules,0b01100110,"dli adi jkc bjc"); // ~10
add_rules(rules,0b10001101,"hkj hja hae ajb"); // 11
add_rules(rules,0b01110010,"jkh ajh eah bja"); // ~11
add_rules(rules,0b00011110,"ile hgf hfd dfa"); // 12
add_rules(rules,0b11100001,"eli fgh dfh afd"); // ~12
add_rules(rules,0b01101001,"eda bcg lkh jif"); // 13
add_rules(rules,0b10010110,"ade gcb hkl fij"); // ~13
add_rules(rules,0b01001110,"lkg lga lad agf"); // 14
add_rules(rules,0b10110001,"gkl agl dal fga"); // ~14
}
//
// vertex
// add a triangle vertex
//
void vertex(char c, int x, int y, int z, float voxel_size, float t, float *w, float *array) {
switch(c) {
case 'a':
array[0] = x+(w[0]-t)/(w[0]-w[1]);
array[1] = y;
array[2] = z;
break;
case 'b':
array[0] = x+1;
array[1] = y+(w[1]-t)/(w[1]-w[3]);
array[2] = z;
break;
case 'c':
array[0] = x+(w[2]-t)/(w[2]-w[3]);
array[1] = y+1;
array[2] = z;
break;
case 'd':
array[0] = x;
array[1] = y+(w[0]-t)/(w[0]-w[2]);
array[2] = z;
break;
case 'e':
array[0] = x;
array[1] = y;
array[2] = z+(w[0]-t)/(w[0]-w[4]);
break;
case 'f':
array[0] = x+1;
array[1] = y;
array[2] = z+(w[1]-t)/(w[1]-w[5]);
break;
case 'g':
array[0] = x+1;
array[1] = y+1;
array[2] = z+(w[3]-t)/(w[3]-w[7]);
break;
case 'h':
array[0] = x;
array[1] = y+1;
array[2] = z+(w[2]-t)/(w[2]-w[6]);
break;
case 'i':
array[0] = x+(w[4]-t)/(w[4]-w[5]);
array[1] = y;
array[2] = z+1;
break;
case 'j':
array[0] = x+1;
array[1] = y+(w[5]-t)/(w[5]-w[7]);
array[2] = z+1;
break;
case 'k':
array[0] = x+(w[6]-t)/(w[6]-w[7]);
array[1] = y+1;
array[2] = z+1;
break;
case 'l':
array[0] = x;
array[1] = y+(w[4]-t)/(w[4]-w[6]);
array[2] = z+1;
break;
}
array[0] = voxel_size*array[0];
array[1] = voxel_size*array[1];
array[2] = voxel_size*array[2];
}
//
// triangulate
// triangulate voxel at lattice site x,y,z with vertex weights w
//
void triangulate(int x, int y, int z, float voxel_size, float t, float *w, char rules[255][20], struct fab_vars *v) {
int i,index;
char c;
//
// set index code
//
index = ((w[0] < t) ? 0 : 1)
+ ((w[1] < t) ? 0 : 2)
+ ((w[2] < t) ? 0 : 4)
+ ((w[3] < t) ? 0 : 8)
+ ((w[4] < t) ? 0 : 16)
+ ((w[5] < t) ? 0 : 32)
+ ((w[6] < t) ? 0 : 64)
+ ((w[7] < t) ? 0 : 128);
//
// add triangles for rule
//
i = 0;
while (1) {
//
// loop over rule chars
//
c = rules[index][i];
if (c == 0)
//
// end of rule
//
break;
else if (c == ' ') {
//
// space between rules
//
i += 1;
continue;
}
else {
//
// create triangle for rule
//
v->mesh->last = malloc(sizeof(struct fab_mesh_triangle_type));
v->mesh->last->previous = v->mesh->triangle;
v->mesh->triangle->next = v->mesh->last;
v->mesh->triangle = v->mesh->last;
v->mesh->triangle->next = 0;
v->mesh->triangle->attribute = 0;
v->mesh->triangle->normal[0] = v->mesh->triangle->normal[1] = v->mesh->triangle->normal[2] = 0;
//
// add vertices for rule
//
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v0);
i += 1;
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v1);
i += 1;
c = rules[index][i];
vertex(c,x,y,z,voxel_size,t,w,v->mesh->triangle->v2);
i += 1;
}
}
}
void fab_write_stl(struct fab_vars *v, char *output_file_name) {
//
// write mesh as STL
//
FILE *output_file;
char buf[80];
uint32_t count;
//
// open output file
//
output_file = fopen(output_file_name, "wb");
if (output_file == 0) {
printf("fab.c: oops -- can't open %s\n",output_file_name);
exit(-1);
}
//
// write header
//
fwrite(buf,80,1,output_file);
//
// write count
//
count = 0;
v->mesh->triangle = v->mesh->first;
while (v->mesh->triangle->next != 0) {
v->mesh->triangle = v->mesh->triangle->next;
count += 1;
}
fwrite(&count,4,1,output_file);
//
// write triangles
//
v->mesh->triangle = v->mesh->first;
while (v->mesh->triangle->next != 0) {
v->mesh->triangle = v->mesh->triangle->next;
fwrite(v->mesh->triangle->normal,4,3,output_file);
fwrite(v->mesh->triangle->v0,4,3,output_file);
fwrite(v->mesh->triangle->v1,4,3,output_file);
fwrite(v->mesh->triangle->v2,4,3,output_file);
fwrite(&(v->mesh->triangle->attribute),2,1,output_file);
}
//
// return
//
printf("wrote %d triangles to %s\n",count,output_file_name);
fclose(output_file);
}
float interp(int x,int y,int i,int j,int k,float **lower_array,float **upper_array,int p) {
//
// trilinear interpolation within a voxel
//
return (lower_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ lower_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((p+1.0-k)/(p+1.0))
+ upper_array[y][x]*((p+1.0-i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y][x+1]*((i)/(p+1.0))*((p+1.0-j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x]*((p+1.0-i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0))
+ upper_array[y+1][x+1]*((i)/(p+1.0))*((j)/(p+1.0))*((k)/(p+1.0)));
}
int main(int argc, char **argv) {
//
// local vars
//
FILE *input_file;
uint64_t count;
uint16_t itype;
int x,y,z,i,j,k,n,p,imin,imax,nx,ny,nz;
int image_width,image_height,color_resolution,ret;
float w[8],**lower_array,**upper_array;
float threshold,voxel_size;
float ftype,fmin=1e10,fmax=-1e10;
char format,comment[256],rules[255][20];
struct fab_vars v;
init_vars(&v);
//
// command line args
//
if (!((argc == 6) || (argc == 7) || (argc == 8) || (argc == 9) || (argc == 10))) {
printf("command line: vol_stl in.vol out.stl nx ny nz [format [threshold [size [points [angle]]]]]\n");
printf(" in.vol = input VOL file\n");
printf(" out.stl = output STL file\n");
printf(" nx,ny,nz = x,y,z input voxel number\n");
printf(" format = 'f' for float 32, 'i' for uint16_t (default 'f')\n");
printf(" threshold: surface intensity threshold (0 = min, 1 = max, default 0.5))\n");
printf(" size = voxel size (mm, default from file))\n");
printf(" points = points to interpolate per point (default 0)\n");
printf(" to be implemented: angle = minimum relative face angle to decimate vertices (default 0)\n");
exit(-1);
}
format = 'f';
p = 0;
threshold = 0.5;
voxel_size = -1;
image_width = -1;
image_height = -1;
sscanf(argv[3],"%d",&nx);
sscanf(argv[4],"%d",&ny);
sscanf(argv[5],"%d",&nz);
if (argc >= 7) {
sscanf(argv[6],"%c",&format);
if (!((format == 'f') || (format == 'i'))) {
printf("vol_gif: oops -- format must be 'f' or 'i'\n");
exit(-1);
}
}
if (argc >= 8)
sscanf(argv[7],"%f",&threshold);
if (argc >= 9)
sscanf(argv[8],"%f",&voxel_size);
if (argc >= 10)
sscanf(argv[9],"%d",&p);
//
// initialize the rule table
//
init_rules(rules);
//
// check and find limits
//
input_file = fopen(argv[1],"rb");
if (input_file == NULL) {
printf("vol_stl: oops -- can not open %s\n",argv[1]);
exit(-1);
}
printf("read %s\n",argv[1]);
if (format == 'f') {
count = 0;
while (fread(&ftype,sizeof(ftype),1,input_file) != 0) {
if (ftype > fmax) fmax = ftype;
if (ftype < fmin) fmin = ftype;
count += 1;
}
}
else if (format == 'i') {
count = 0;
while (fread(&itype,sizeof(itype),1,input_file) != 0) {
if (itype > fmax) fmax = itype;
if (itype < fmin) fmin = itype;
count += 1;
}
}
if (nx*ny*nz != count) {
printf("vol_stl: oops -- file size doesn't match pixel number\n");
exit(-1);
}
printf(" %" PRIu64 " points, min %f, max %f\n",count,fmin,fmax);
printf(" nx ny nz: %d %d %d\n",nx,ny,nz);
rewind(input_file);
//
// scan the file
//
printf("read %s\n",argv[1]);
//
// set threshold
//
threshold = fmin + threshold*(fmax-fmin);
//
// add empty border
//
image_width = nx+2;
image_height = ny+2;
//
// allocate arrays
//
lower_array = malloc(image_height*sizeof(float *));
for (y = 0; y < image_height; ++y) {
lower_array[y] = malloc(image_width*sizeof(float));
for (x = 0; x < image_width; ++x)
lower_array[y][x] = 0;
}
upper_array = malloc(image_height*sizeof(float *));
for (y = 0; y < image_height; ++y) {
upper_array[y] = malloc(image_width*sizeof(float));
for (x = 0; x < image_width; ++x)
upper_array[y][x] = 0;
}
//
// read the file
//
z = 0;
v.mesh = malloc(sizeof(struct fab_mesh_type));
v.mesh->triangle = malloc(sizeof(struct fab_mesh_triangle_type));
v.mesh->first = v.mesh->triangle;
v.mesh->last = v.mesh->triangle;
v.mesh->triangle->previous = v.mesh->triangle->next = 0;
for (z = 0; z < nz; ++z) {
//
// read layer
//
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",z);
for (y = 0; y < ny; ++y) {
for (x = 0; x < nx; ++x) {
lower_array[y+1][x+1] = upper_array[y+1][x+1];
if (format == 'f') {
fread(&ftype,sizeof(ftype),1,input_file);
upper_array[y+1][x+1] = ftype;
}
else if (format == 'i') {
fread(&itype,sizeof(itype),1,input_file);
upper_array[y+1][x+1] = itype;
}
}
}
if (p == 0) {
//
// no interpolation, loop over layer voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
w[0] = lower_array[y][x];
w[1] = lower_array[y][x+1];
w[2] = lower_array[y+1][x];
w[3] = lower_array[y+1][x+1];
w[4] = upper_array[y][x];
w[5] = upper_array[y][x+1];
w[6] = upper_array[y+1][x];
w[7] = upper_array[y+1][x+1];
triangulate(x,y,z,voxel_size,threshold,w,rules,&v);
}
}
}
else {
//
// yes interpolation, loop over layer sub-voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
for (i = 0; i <= p; ++i) {
for (j = 0; j <= p; ++j) {
for (k = 0; k <= p; ++k) {
w[0] = interp(x,y,i,j,k,lower_array,upper_array,p);
w[1] = interp(x,y,i+1,j,k,lower_array,upper_array,p);
w[2] = interp(x,y,i,j+1,k,lower_array,upper_array,p);
w[3] = interp(x,y,i+1,j+1,k,lower_array,upper_array,p);
w[4] = interp(x,y,i,j,k+1,lower_array,upper_array,p);
w[5] = interp(x,y,i+1,j,k+1,lower_array,upper_array,p);
w[6] = interp(x,y,i,j+1,k+1,lower_array,upper_array,p);
w[7] = interp(x,y,i+1,j+1,k+1,lower_array,upper_array,p);
triangulate((1+p)*x+i,(1+p)*y+j,(1+p)*z+k,voxel_size,threshold,w,rules,&v);
}
}
}
}
}
}
}
//
// add empty top layer
//
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b layer = %d",z);
for (y = 0; y < (image_height-2); ++y) {
for (x = 0; x < (image_width-2); ++x) {
lower_array[y+1][x+1] = upper_array[y+1][x+1];
upper_array[y+1][x+1] = 0;
}
}
if (p == 0) {
//
// no interpolation, loop over layer voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
w[0] = lower_array[y][x];
w[1] = lower_array[y][x+1];
w[2] = lower_array[y+1][x];
w[3] = lower_array[y+1][x+1];
w[4] = upper_array[y][x];
w[5] = upper_array[y][x+1];
w[6] = upper_array[y+1][x];
w[7] = upper_array[y+1][x+1];
triangulate(x,y,z,voxel_size,threshold,w,rules,&v);
}
}
}
else {
//
// yes interpolation, loop over layer sub-voxels
//
for (x = 0; x < (image_width-1); ++x) {
for (y = 0; y < (image_height-1); ++y) {
for (i = 0; i <= p; ++i) {
for (j = 0; j <= p; ++j) {
for (k = 0; k <= p; ++k) {
w[0] = interp(x,y,i,j,k,lower_array,upper_array,p);
w[1] = interp(x,y,i+1,j,k,lower_array,upper_array,p);
w[2] = interp(x,y,i,j+1,k,lower_array,upper_array,p);
w[3] = interp(x,y,i+1,j+1,k,lower_array,upper_array,p);
w[4] = interp(x,y,i,j,k+1,lower_array,upper_array,p);
w[5] = interp(x,y,i+1,j,k+1,lower_array,upper_array,p);
w[6] = interp(x,y,i,j+1,k+1,lower_array,upper_array,p);
w[7] = interp(x,y,i+1,j+1,k+1,lower_array,upper_array,p);
triangulate((1+p)*x+i,(1+p)*y+j,(1+p)*z+k,voxel_size,threshold,w,rules,&v);
}
}
}
}
}
}
printf("\n");
//
// write STL
//
fab_write_stl(&v,argv[2]);
//
// exit
//
fclose(input_file);
exit(0);
}

Wyświetl plik

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 2.6)
set(GUIs fab fab.html fabserver
make_cad_png make_cad_eps make_cad_stl make_cad_camm make_cad_rml
make_cad_epi make_cad_uni make_cad_sbp make_cad_g make_cad_ord
make_cad_grb make_cad_drl
make_math_camm make_math_epi make_math_g make_math_ord make_math_eps
make_math_uni make_math_rml make_math_sbp make_math_grb
make_math_drl
make_png_png make_png_eps make_png_epi make_png_uni make_png_grb
make_png_epi_halftone make_png_uni_halftone make_png_rml make_png_sbp
make_png_ord make_png_camm make_png_plt make_png_g make_png_drl
make_png_oms
make_stl_png make_stl_rml make_stl_sbp make_stl_g
make_svg_camm make_svg_epi make_svg_uni make_svg_oms
make_svg_g make_svg_rml make_svg_sbp make_svg_ord make_png_snap
make_cad_snap make_stl_snap make_svg_snap make_png_eps_halftone
make_cad_dxf make_math_dxf make_math_stl make_png_dxf
make_gif_stl
cad_ui
rml_send_gui
CACHE STRING "GUI script list")
if( ${CMAKE_PROJECT_NAME} MATCHES fabmod )
install(PROGRAMS ${GUIs} DESTINATION ${PROJECT_SOURCE_DIR}/../bin)
endif( ${CMAKE_PROJECT_NAME} MATCHES fabmod )

1406
src/guis/cad_ui 100755

Plik diff jest za duży Load Diff

170
src/guis/fab 100755
Wyświetl plik

@ -0,0 +1,170 @@
#!/usr/bin/env python
#
# fab
# GUI wrapper wrapper
#
# Neil Gershenfeld
# CBA MIT
date = "10/4/13"
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx, sys, os, os.path
from fab_mods import set_workflows
#
# defaults
#
input_file = '""'
size = '400'
#
# command line
#
print "command line: fab [input_file [size]]"
print " input_file = input file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# set up frame
#
frame = wx.Frame(None, -1, 'fab')
frame_sizer = wx.GridBagSizer(10,10)
frame.SetSizer(frame_sizer)
bold_font = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
#
# quit routine
#
def quit(event):
sys.exit()
#
# labels
#
format_text = wx.StaticText(frame,label="from format:")
format_text.SetFont(bold_font)
frame_sizer.Add(format_text,(0,0),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
#
process_text = wx.StaticText(frame,label="to process:")
process_text.SetFont(bold_font)
frame_sizer.Add(process_text,(0,1),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
#
program_text = wx.StaticText(frame,label="with program:")
program_text.SetFont(bold_font)
frame_sizer.Add(program_text,(0,2),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
#
# menu event handler
#
def handler(event):
selected_format = frame.formats.GetValue()
selected_process = frame.processes.GetValue()
if ((selected_format == "format") | (selected_process == "process")):
return
key = selected_format + ' : ' + selected_process
if workflows.has_key(key):
frame.program = workflows[key]
frame.programs.SetLabel(frame.program)
frame.Layout()
frame.Fit()
else:
frame.program = ""
frame.programs.SetLabel("not defined")
frame.Layout()
frame.Fit()
#
# program call
#
frame.program = ""
def call_program(event):
if (frame.program != ""):
command = frame.program + ' ' + input_file + ' ' + size_control.GetValue() + '&'
print command
os.system(command)
#
# menus
#
frame.formats = wx.ComboBox(frame,value='format',style=wx.CB_READONLY)
frame.formats.Bind(wx.EVT_COMBOBOX,handler)
frame_sizer.Add(frame.formats,(1,0))
#
frame.processes = wx.ComboBox(frame,value='process',style=wx.CB_READONLY)
frame.processes.Bind(wx.EVT_COMBOBOX,handler)
frame_sizer.Add(frame.processes,(1,1))
#
frame.programs = wx.Button(frame,label='program')
frame.programs.Bind(wx.EVT_BUTTON,call_program)
frame_sizer.Add(frame.programs,(1,2),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
#
# set workflows
#
workflows = {}
formats = []
set_workflows(frame,formats,workflows)
#
# controls
#
control_panel = wx.Panel(frame)
control_sizer = wx.GridBagSizer(10,10)
control_panel.SetSizer(control_sizer)
#
control_sizer.Add(wx.StaticText(control_panel,label=' GUI size (pixels):'),(0,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
#
size_control = wx.TextCtrl(control_panel,-1,size)
control_sizer.Add(size_control,(0,1),flag=(wx.ALIGN_LEFT))
#
control_sizer.Add(wx.StaticText(control_panel,label="fab modules version: "+date),(0,2),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
#
d = 4
w = 1
l = 6*d+2*w
def logo_paint(event):
dc = wx.PaintDC(logo_panel)
dc.SetBrush(wx.Brush('white'))
dc.SetPen(wx.Pen('white', 0))
dc.DrawRectangleRect((0, 0, l, l))
dc.SetBrush(wx.Brush('red'))
dc.DrawCircle(d,d,d)
dc.DrawCircle(3*d+w,3*d+w,d)
dc.SetBrush(wx.Brush('blue'))
dc.DrawRectangleRect((2*d+w,0,2*d,2*d))
dc.DrawRectangleRect((4*d+2*w,0,2*d,2*d))
dc.DrawRectangleRect((0,2*d+w,2*d,2*d))
dc.DrawRectangleRect((4*d+2*w,2*d+w,2*d,2*d))
dc.DrawRectangleRect((0,4*d+2*w,2*d,2*d))
dc.DrawRectangleRect((2*d+w,4*d+2*w,2*d,2*d))
dc.DrawRectangleRect((4*d+2*w,4*d+2*w,2*d,2*d))
logo_panel = wx.Panel(control_panel,size=(l,l))
logo_panel.Bind(wx.EVT_PAINT,logo_paint)
control_sizer.Add(logo_panel,(0,3))
#
control_quit = wx.Button(control_panel,label='quit')
control_quit.Bind(wx.EVT_BUTTON,quit)
control_sizer.Add(control_quit,(0,4))
#
control_sizer.Add(wx.StaticText(control_panel,label=" "),(0,5),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
#
control_panel.Fit()
frame_sizer.Add(control_panel,(2,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# process command line
#
if (len(sys.argv) > 1):
input_file = sys.argv[1]
ext = os.path.splitext(input_file)[1]
if (formats.count(ext) != 0):
frame.formats.SetSelection(formats.index(ext))
if (len(sys.argv) > 2):
size = sys.argv[2]
#
# start mainloop
#
app.MainLoop()

6539
src/guis/fab.html 100644

Plik diff jest za duży Load Diff

369
src/guis/fabserver 100755
Wyświetl plik

@ -0,0 +1,369 @@
#!/usr/bin/env python
#
# fabserver.py
# command line syntax: python fabserver.py port
#
# Neil Gershenfeld
# CBA MIT 12/6/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
from socket import *
from string import *
from select import *
from math import *
import sys
import subprocess
import os
import glob
MAX_PACKET = 4096
MAX_RESPONSE = 10000000
PACKET_TIMEOUT = 0.01
SERVER_ADDRESS = "127.0.0.1"
def send_image(msg):
client_socket.sendall(
'HTTP/1.1 200 OK\n'
+'Content-Length: %d\n'%len(msg)
+'Content-Type: image/jpeg\n'
+'\n'
+msg
)
def send_text(text):
client_socket.sendall(
'HTTP/1.1 200 OK\n'
+'Content-Type: text/html\n'
+'\n'
+'\n'
+text
)
def parse():
global mode, units, dx, dy, dz, xmin, ymin, zmin, xrot, yrot, zrot, resolution, slices, expression
#
# parse math string
#
start = 0
start = 1+find(response,"{",start)
end = find(response,"}",start)
mode = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
units = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
dx = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
dy = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
dz = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
xmin = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
ymin = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
zmin = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
xrot = float(response[start:end])
start = 1+find(response,"{",end)
end = find(response,"}",start)
yrot = float(response[start:end])
start = 1+find(response,"{",end)
end = find(response,"}",start)
zrot = float(response[start:end])
start = 1+find(response,"{",end)
end = find(response,"}",start)
resolution = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
slices = response[start:end]
start = 1+find(response,"{",end)
end = find(response,"}",start)
expression = response[start:end]
def render():
#
# render math string, xy view
#
math_file = open("fab_render_xy.math","w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+dx+" "+dy+" "+dz+"\n")
math_file.write("xmin ymin zmin: "+xmin+" "+ymin+" "+zmin+"\n")
math_file.write("expression: "+expression+"\n")
math_file.close()
os.system("math_png fab_render_xy.math fab_render_xy.png "+resolution+" "+slices)
os.system("rm fab_render_xy.math")
if (float(dz) != 0):
#
# xz view
#
math_file = open("fab_render_xz.math","w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+dx+" "+dz+" "+dy+"\n")
math_file.write("xmin ymin zmin: "+xmin+" "+zmin+" "+ymin+"\n")
math_file.write("expression: "+expression+"\n")
new_expression = replace(expression,'Y','#')
new_expression = replace(new_expression,'Z','Y')
new_expression = replace(new_expression,'#','Z')
math_file.write("expression: "+new_expression+"\n")
math_file.close()
os.system("math_png fab_render_xz.math fab_render_xz.png "+resolution+" "+slices)
os.system("rm fab_render_xz.math")
#
# zy view
#
math_file = open("fab_render_zy.math","w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+dz+" "+dy+" "+dx+"\n")
math_file.write("xmin ymin zmin: "+zmin+" "+ymin+" "+xmin+"\n")
new_expression = replace(expression,'X','#')
new_expression = replace(new_expression,'Z','((%f)-X)'%(float(dz)+2*float(zmin)))
new_expression = replace(new_expression,'#','Z')
math_file.write("expression: "+new_expression+"\n")
math_file.close()
os.system("math_png fab_render_zy.math fab_render_zy.png "+resolution+" "+slices)
os.system("rm fab_render_zy.math")
#
# xyz view
#
math_file = open("fab_render_xyz.math","w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+"2"+" "+"2"+" "+"2"+"\n")
math_file.write("xmin ymin zmin: "+"-1"+" "+"-1"+" "+"-1"+"\n")
#
# view scaling
#
-1
1
new_expression = replace(expression,'X','(('+xmin+')+'+dx+'*(X+1)/2)')
new_expression = replace(new_expression,'Y','(('+ymin+')+'+dy+'*(Y+1)/2)')
new_expression = replace(new_expression,'Z','(('+zmin+')+'+dz+'*(Z+1)/2)')
#new_expression = replace(expression,'X','(X+('+xmin+')+1)')
#new_expression = replace(new_expression,'Y','(Y+('+ymin+')+1)')
#new_expression = replace(new_expression,'Z','(Z+('+zmin+')+1)')
#
# z rotation
#
new_expression = replace(new_expression,'X','(('+str(cos(zrot))+')*X+('+str(-sin(zrot))+')*ytemp)')
new_expression = replace(new_expression,'Y','(('+str(sin(zrot))+')*X+('+str(cos(zrot))+')*Y)')
new_expression = replace(new_expression,'ytemp','Y')
#
# y rotation (not used in GUI)
#
#
# x rotation
#
new_expression = replace(new_expression,'Y','(('+str(cos(xrot))+')*Y+('+str(sin(xrot))+')*ztemp)')
new_expression = replace(new_expression,'Z','(('+str(-sin(xrot))+')*Y+('+str(cos(xrot))+')*Z)')
new_expression = replace(new_expression,'ztemp','Z')
#
# write and evaluate
#
math_file.write("expression: "+new_expression+"\n")
math_file.close()
os.system("math_png fab_render_xyz.math fab_render_xyz.png "+resolution+" "+slices)
os.system("rm fab_render_xyz.math")
#send_text("render")
#
# get command line arguments
#
if (len(sys.argv) != 2):
print "command line syntax: python fabserver.py port"
sys.exit()
server_port = sys.argv[1]
#
# start listening on server port
#
try:
server_socket = socket(AF_INET, SOCK_STREAM)
server_socket.bind((SERVER_ADDRESS,int(server_port)))
server_socket.listen(5)
print "listening on port "+server_port
except:
print "error: couldn't open socket"
sys.exit()
#
# start main loop
#
while 1:
#
# blocking select call to wait for a connection
#
[read_ready, write_ready, error_ready] = select([server_socket],[],[])
if (read_ready != []):
#
# child process, non-blocking select call to receive packet
#
(client_socket, client_address) = server_socket.accept()
response = ""
while 1:
[read_ready, write_ready, error_ready] = select([client_socket],[],[],PACKET_TIMEOUT)
if (read_ready != []):
response += client_socket.recv(MAX_PACKET)
else:
break
#
# process response
#
#print response
if (find(response,"GET / ") == 0):
#
# root request, send fab.html
#
file = open(os.path.join(os.path.dirname(sys.argv[0]), 'fab.html'),
'rb')
msg = file.read()
file.close()
send_text(msg)
elif (find(response,"GET /fab_render_xy.png") == 0):
try:
file = open('fab_render_xy.png','rb')
os.system("rm fab_render_xy.png")
msg = file.read()
file.close()
send_image(msg)
except IOError:
print "oops"
elif (find(response,"GET /fab_render_xz.png") == 0):
try:
file = open('fab_render_xz.png','rb')
os.system("rm fab_render_xz.png")
msg = file.read()
file.close()
send_image(msg)
except IOError:
print "oops"
elif (find(response,"GET /fab_render_zy.png") == 0):
try:
file = open('fab_render_zy.png','rb')
os.system("rm fab_render_zy.png")
msg = file.read()
file.close()
send_image(msg)
except IOError:
print "oops"
elif (find(response,"GET /fab_render_xyz.png") == 0):
try:
file = open('fab_render_xyz.png','rb')
os.system("rm fab_render_xyz.png")
msg = file.read()
file.close()
send_image(msg)
except IOError:
print "oops"
elif (find(response,"GET /fab.html") == 0):
file = open('fab.html','rb')
msg = file.read()
file.close()
send_text(msg)
elif (find(response,"GET /quit") == 0):
break
elif (find(response,"POST /list_files") == 0):
files = glob.glob('*.fab')
file_names = ','.join(files)
cwd = os.getcwd()
dirs = filter(os.path.isdir, os.listdir('.'))
dirs_names = ','.join(dirs)
send_text(file_names+';'+cwd+';'+dirs_names)
elif (find(response,"POST /cd") == 0):
start = 1+find(response,"{")
end = find(response,"}",start)
dir_name = response[start:end]
os.chdir(dir_name)
files = glob.glob('*.fab')
file_names = ','.join(files)
cwd = os.getcwd()
dirs = filter(os.path.isdir, os.listdir('.'))
dirs_names = ','.join(dirs)
send_text(file_names+';'+cwd+';'+dirs_names)
elif (find(response,"POST /delete") == 0):
start = 1+find(response,"{")
end = find(response,"}",start)
file_name = response[start:end]
os.remove(file_name)
files = glob.glob('*.fab')
file_names = ','.join(files)
cwd = os.getcwd()
dirs = filter(os.path.isdir, os.listdir('.'))
dirs_names = ','.join(dirs)
send_text(file_names+';'+cwd+';'+dirs_names)
elif (find(response,"POST /open") == 0):
start = 1+find(response,"{")
end = find(response,"}",start)
file_name = response[start:end]
print "file"+file_name+"name"
try:
file = open(file_name,'rb')
msg = file.read()
file.close()
send_text(msg)
except IOError:
print "oops"
elif (find(response,"POST /render") == 0):
#
# render
#
parse()
render()
elif (find(response,"POST /fabricate") == 0):
#
# fabricate
#
parse()
math_file = open("fab_render_xy.math","w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+dx+" "+dy+" "+dz+"\n")
math_file.write("xmin ymin zmin: "+xmin+" "+ymin+" "+zmin+"\n")
math_file.write("expression: "+expression+"\n")
math_file.close()
os.system("fab fab_render_xy.math")
os.system("rm fab_render_xy.math")
elif (find(response,"POST /save_graph") == 0):
start = 17+find(response,"POST /save_graph")
end = find(response,"/",start)
file_name = response[start:end]
file = open(file_name,"w")
start = find(response,"graph start:")
file.writelines(response[start:])
file.close()
client_socket.send("saved "+file_name)
elif (find(response,"POST /save_math") == 0):
start = 16+find(response,"POST /save_math")
end = find(response,"/",start)
file_name = response[start:end]
parse()
math_file = open(file_name,"w")
math_file.write("format: "+mode+"\n")
math_file.write("mm per unit: "+units+"\n")
math_file.write("dx dy dz: "+dx+" "+dy+" "+dz+"\n")
math_file.write("xmin ymin zmin: "+xmin+" "+ymin+" "+zmin+"\n")
math_file.write("expression: "+expression+"\n")
math_file.close()
client_socket.send("saved "+file_name)
#
# close connection socket and exit
#
client_socket.close()
#
# close server socket and exit
#
server_socket.close()

Wyświetl plik

@ -0,0 +1,59 @@
#!/usr/bin/env python
#
# make_cad_camm
# .cad to .camm GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_camm import path_camm_panel
#
# command line
#
print "command line: make_cad_camm [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_camm",sys.argv)
frame.size = frame.size/1.25
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.camm_panel = path_camm_panel(frame)
frame.sizer.Add(frame.camm_panel,(1,3))
#
# defaults
#
frame.set_cad_camm()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_cad_drl
# .cad to .drl GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_drl import png_drl_panel
#
# command line
#
print "command line: make_cad_drl [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_drl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.drl_panel = png_drl_panel(frame)
frame.sizer.Add(frame.drl_panel,(1,2))
#
# defaults
#
#frame.set_cad_drl()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_dxf
# .cad to .dxf GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 8/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_dxf import path_dxf_panel
#
# command line
#
print "command line: make_cad_dxf [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_dxf",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.dxf_panel = path_dxf_panel(frame)
frame.sizer.Add(frame.dxf_panel,(1,3))
#
# defaults
#
#frame.set_cad_dxf()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_epi
# .cad to .epi GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_epi import path_epi_panel
#
# command line
#
print "command line: make_cad_epi [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_epi",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.epi_panel = path_epi_panel(frame)
frame.sizer.Add(frame.epi_panel,(1,3))
#
# defaults
#
frame.set_cad_epi()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,61 @@
#!/usr/bin/env python
#
# make_cad_eps
# .cad to .eps GUI wrapper
#
# Neil Gershenfeld 7/4/13
# (c) Massachusetts Institute of Technology 2013
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge the fab modules project. Copyright is
# retained and must be preserved. The work is provided
# as is; no warranty is provided, and users accept all
# liability.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_eps import path_eps_panel
#
# command line
#
print "command line: make_cad_eps [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_eps",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.eps_panel = path_eps_panel(frame)
frame.sizer.Add(frame.eps_panel,(1,3))
#
# defaults
#
frame.set_cad_eps()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_g
# .cad to .g GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_g import path_g_panel
#
# command line
#
print "command line: make_cad_g [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_g",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.g_panel = path_g_panel(frame)
frame.sizer.Add(frame.g_panel,(1,3))
#
# defaults
#
frame.set_cad_g()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_cad_grb
# .cad to .grb GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/24/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_grb import png_grb_panel
#
# command line
#
print "command line: make_cad_grb [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_grb",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.grb_panel = png_grb_panel(frame)
frame.sizer.Add(frame.grb_panel,(1,2))
#
# defaults
#
#frame.set_cad_grb()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_ord
# .cad to .ord GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_ord import path_ord_panel
#
# command line
#
print "command line: make_cad_ord [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_ord",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.ord_panel = path_ord_panel(frame)
frame.sizer.Add(frame.ord_panel,(1,3))
#
# defaults
#
frame.set_cad_ord()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,56 @@
#!/usr/bin/env python
#
# make_cad_png
# .cad to .png GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/18/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
#
# command line
#
print "command line: make_cad_png [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_png",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
#
# defaults
#
frame.defaults = {}
frame.control_panel.defaults.Append('preview')
frame.defaults["preview"] = "self.png_panel.resolution.SetValue('10')"
frame.control_panel.defaults.Append('render')
frame.defaults["render"] = "self.png_panel.resolution.SetValue('50')"
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_rml
# .cad to .rml GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_rml import path_rml_panel
#
# command line
#
print "command line: make_cad_rml [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_rml",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.rml_panel = path_rml_panel(frame)
frame.sizer.Add(frame.rml_panel,(1,3))
#
# defaults
#
frame.set_cad_rml()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_sbp
# .cad to .sbp GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_sbp import path_sbp_panel
#
# command line
#
print "command line: make_cad_sbp [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_sbp",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.cad_png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.cad_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.sbp_panel = path_sbp_panel(frame)
frame.sizer.Add(frame.sbp_panel,(1,3))
#
# defaults
#
frame.set_cad_sbp()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_snap
# .cad to MTP Snap GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/24/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_snap import path_snap_panel
#
# command line
#
print "command line: make_cad_snap [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_snap",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.snap_panel = path_snap_panel(frame)
frame.sizer.Add(frame.snap_panel,(1,3))
#
# defaults
#
#frame.set_cad_rml()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_cad_stl
# .cad to .stl GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/22/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_stl import cad_stl_panel
#
# command line
#
print "command line: make_cad_stl [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_stl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.stl_panel = cad_stl_panel(frame)
frame.sizer.Add(frame.stl_panel,(1,1))
#
# defaults
#
frame.defaults = {}
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_cad_uni
# .cad to .uni GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/6/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_cad import cad_panel
from panel_cad_png import cad_png_panel
from panel_png_path import png_path_panel
from panel_path_uni import path_uni_panel
#
# command line
#
print "command line: make_cad_uni [input_file [size]]"
print " input_file = input .cad file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_cad_uni",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.cad_panel = cad_panel(frame)
frame.sizer.Add(frame.cad_panel,(1,0))
frame.png_panel = cad_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.uni_panel = path_uni_panel(frame)
frame.sizer.Add(frame.uni_panel,(1,3))
#
# defaults
#
frame.set_cad_uni()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_gif_stl
# .gif to .stl GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/25/14
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_gif import gif_panel
from panel_gif_stl import gif_stl_panel
#
# command line
#
print "command line: make_gif_stl [input_file [size]]"
print " input_file = input .gif file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_gif_stl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.gif_panel = gif_panel(frame)
frame.sizer.Add(frame.gif_panel,(1,0))
frame.stl_panel = gif_stl_panel(frame)
frame.sizer.Add(frame.stl_panel,(1,1))
#
# defaults
#
frame.defaults = {}
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_camm
# .math to .camm GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_camm import path_camm_panel
#
# command line
#
print "command line: make_math_camm [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_camm",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.camm_panel = path_camm_panel(frame)
frame.sizer.Add(frame.camm_panel,(1,3))
#
# defaults
#
frame.set_math_camm()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_math_drl
# .math to .drl GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/24/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_drl import png_drl_panel
#
# command line
#
print "command line: make_math_drl [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_drl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.drl_panel = png_drl_panel(frame)
frame.sizer.Add(frame.drl_panel,(1,2))
#
# defaults
#
#frame.set_math_drl()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_dxf
# .math to .dxf GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 8/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_dxf import path_dxf_panel
#
# command line
#
print "command line: make_math_dxf [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_dxf",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.dxf_panel = path_dxf_panel(frame)
frame.sizer.Add(frame.dxf_panel,(1,3))
#
# defaults
#
#frame.set_math_dxf()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_epi
# .math to .epi GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_epi import path_epi_panel
#
# command line
#
print "command line: make_math_epi [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_epi",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.math_png_panel = math_png_panel(frame)
frame.sizer.Add(frame.math_png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.epi_panel = path_epi_panel(frame)
frame.sizer.Add(frame.epi_panel,(1,3))
#
# defaults
#
frame.set_math_epi()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,61 @@
#!/usr/bin/env python
#
# make_math_eps
# .math to .eps GUI wrapper
#
# Neil Gershenfeld 7/4/13
# (c) Massachusetts Institute of Technology 2013
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge the fab modules project. Copyright is
# retained and must be preserved. The work is provided
# as is; no warranty is provided, and users accept all
# liability.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_eps import path_eps_panel
#
# command line
#
print "command line: make_math_eps [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_eps",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.eps_panel = path_eps_panel(frame)
frame.sizer.Add(frame.eps_panel,(1,3))
#
# defaults
#
frame.set_math_eps()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_g
# .math to .g GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_g import path_g_panel
#
# command line
#
print "command line: make_math_g [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_g",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.math_png_panel = math_png_panel(frame)
frame.sizer.Add(frame.math_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.g_panel = path_g_panel(frame)
frame.sizer.Add(frame.g_panel,(1,3))
#
# defaults
#
frame.set_math_g()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_math_grb
# .math to .grb GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/24/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_grb import png_grb_panel
#
# command line
#
print "command line: make_math_grb [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_rml",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.grb_panel = png_grb_panel(frame)
frame.sizer.Add(frame.grb_panel,(1,2))
#
# defaults
#
#frame.set_math_grb()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_ord
# .math to .ord GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_ord import path_ord_panel
#
# command line
#
print "command line: make_math_ord [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_ord",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.ord_panel = path_ord_panel(frame)
frame.sizer.Add(frame.ord_panel,(1,3))
#
# defaults
#
frame.set_math_ord()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_rml
# .math to .rml GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_rml import path_rml_panel
#
# command line
#
print "command line: make_math_rml [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_rml",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.math_png_panel = math_png_panel(frame)
frame.sizer.Add(frame.math_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.rml_panel = path_rml_panel(frame)
frame.sizer.Add(frame.rml_panel,(1,3))
#
# defaults
#
frame.set_math_rml()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_sbp
# .math to .sbp GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_sbp import path_sbp_panel
#
# command line
#
print "command line: make_math_sbp [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_sbp",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.math_png_panel = math_png_panel(frame)
frame.sizer.Add(frame.math_png_panel,(1,1))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,2))
frame.sbp_panel = path_sbp_panel(frame)
frame.sizer.Add(frame.sbp_panel,(1,3))
#
# defaults
#
frame.set_math_sbp()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_math_stl
# .math to .stl GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 9/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_stl import math_stl_panel
#
# command line
#
print "command line: make_math_stl [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_stl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.stl_panel = math_stl_panel(frame)
frame.sizer.Add(frame.stl_panel,(1,1))
#
# defaults
#
frame.defaults = {}
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_math_uni
# .math to .uni GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 4/25/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_math import math_panel
from panel_math_png import math_png_panel
from panel_png_path import png_path_panel
from panel_path_uni import path_uni_panel
#
# command line
#
print "command line: make_math_uni [input_file [size]]"
print " input_file = input .math file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_math_uni",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.math_panel = math_panel(frame)
frame.sizer.Add(frame.math_panel,(1,0))
frame.png_panel = math_png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,1))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,2))
frame.uni_panel = path_uni_panel(frame)
frame.sizer.Add(frame.uni_panel,(1,3))
#
# defaults
#
frame.set_math_uni()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_camm
# .png to .camm GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_camm import path_camm_panel
#
# command line
#
print "command line: make_png_camm [input_file [size]]"
print " input_file = input .camm file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_camm",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.camm_panel = path_camm_panel(frame)
frame.sizer.Add(frame.camm_panel,(1,2))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_camm()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_png_grb
# .png to .grb GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/23/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_drl import png_drl_panel
#
# command line
#
print "command line: make_png_drl [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_drl",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.drl_panel = png_drl_panel(frame)
frame.sizer.Add(frame.drl_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# set defaults
#
#frame.set_png_drl()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_dxf
# .png to .dxf GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/12
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_dxf import path_dxf_panel
#
# command line
#
print "command line: make_png_dxf [input_file [size]]"
print " input_file = input .dxf file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_dxf",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.dxf_panel = path_dxf_panel(frame)
frame.sizer.Add(frame.dxf_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
#frame.set_png_dxf()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_epi
# .png to .epi GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 1/24/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_epi import path_epi_panel
#
# command line
#
print "command line: make_png_epi [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_epi",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.epi_panel = path_epi_panel(frame)
frame.sizer.Add(frame.epi_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# set defaults
#
frame.set_png_epi()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_epi_halftone
# .png to .epi halftone GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 3/12/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path_halftone import png_path_halftone_panel
from panel_path_epi import path_epi_panel
#
# command line
#
print "command line: make_png_epi_halftone [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_epi_halftone",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.epi_panel = path_epi_panel(frame)
frame.sizer.Add(frame.epi_panel,(1,2))
frame.path_panel = png_path_halftone_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_epi_halftone()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_png_eps
# .png to .eps GUI wrapper
#
# Neil Gershenfeld 7/4/13
# (c) Massachusetts Institute of Technology 2013
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge the fab modules project. Copyright is
# retained and must be preserved. The work is provided
# as is; no warranty is provided, and users accept all
# liability.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_eps import path_eps_panel
#
# command line
#
print "command line: make_png_eps [input_file [size]]"
print " input_file = input .eps file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_eps",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.eps_panel = path_eps_panel(frame)
frame.sizer.Add(frame.eps_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_eps()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,58 @@
#!/usr/bin/env python
#
# make_png_eps_halftone
# .png to .eps halftone GUI wrapper
#
# Neil Gershenfeld 7/4/13
# (c) Massachusetts Institute of Technology 2013
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge the fab modules project. Copyright is
# retained and must be preserved. The work is provided
# as is; no warranty is provided, and users accept all
# liability.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path_halftone import png_path_halftone_panel
from panel_path_eps import path_eps_panel
#
# command line
#
print "command line: make_png_eps_halftone [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_eps_halftone",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.eps_panel = path_eps_panel(frame)
frame.sizer.Add(frame.eps_panel,(1,2))
frame.path_panel = png_path_halftone_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
#frame.set_png_eps_halftone()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_g
# .png to .g GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_g import path_g_panel
#
# command line
#
print "command line: make_png_g [input_file [size]]"
print " input_file = input .g file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_g",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.g_panel = path_g_panel(frame)
frame.sizer.Add(frame.g_panel,(1,2))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_g()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_png_grb
# .png to .grb GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/23/12
#
# (c) Massachusetts Institute of Technology 2012
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_grb import png_grb_panel
#
# command line
#
print "command line: make_png_grb [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_grb",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.grb_panel = png_grb_panel(frame)
frame.sizer.Add(frame.grb_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# set defaults
#
#frame.set_png_grb()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_oms
# .png to .oms GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 5/25/13
#
# (c) Massachusetts Institute of Technology 2013
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_oms import path_oms_panel
#
# command line
#
print "command line: make_png_oms [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_oms",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.oms_panel = path_oms_panel(frame)
frame.sizer.Add(frame.oms_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# set defaults
#
frame.set_png_oms()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_ord
# .png to .ord GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_ord import path_ord_panel
#
# command line
#
print "command line: make_png_ord [input_file [size]]"
print " input_file = input .ord file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_ord",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.ord_panel = path_ord_panel(frame)
frame.sizer.Add(frame.ord_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_ord()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_plt
# .png to .plt GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_plt import path_plt_panel
#
# command line
#
print "command line: make_png_plt [input_file [size]]"
print " input_file = input .plt file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_plt",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.plt_panel = path_plt_panel(frame)
frame.sizer.Add(frame.plt_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_plt()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# make_png_png
# .png to .png GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_png import png_png_panel
#
# command line
#
print "command line: make_png_png [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_png",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.png_png_panel = png_png_panel(frame)
frame.sizer.Add(frame.png_png_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.defaults = {}
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_rml
# .png to .rml GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_rml import path_rml_panel
#
# command line
#
print "command line: make_png_rml [input_file [size]]"
print " input_file = input .rml file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_rml",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.rml_panel = path_rml_panel(frame)
frame.sizer.Add(frame.rml_panel,(1,2))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_rml()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_sbp
# .png to .sbp GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 2/19/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_sbp import path_sbp_panel
#
# command line
#
print "command line: make_png_sbp [input_file [size]]"
print " input_file = input .sbp file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_sbp",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.sbp_panel = path_sbp_panel(frame)
frame.sizer.Add(frame.sbp_panel,(1,2))
frame.png_path_panel = png_path_panel(frame)
frame.sizer.Add(frame.png_path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
frame.set_png_sbp()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Wyświetl plik

@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# make_png_snap
# .png to MTM Snap GUI wrapper
#
# Neil Gershenfeld
# CBA MIT 11/24/11
#
# (c) Massachusetts Institute of Technology 2011
# Permission granted for experimental and personal use;
# license for commercial sale available from MIT.
#
# imports
#
import wx,sys
from fab_set import fab_frame
from panel_control import control_panel
from panel_png import png_panel
from panel_png_path import png_path_panel
from panel_path_snap import path_snap_panel
#
# command line
#
print "command line: make_png_snap [input_file [size]]"
print " input_file = input .png file (optional)"
print " size = image panel size (optional)"
#
# start wx
#
app = wx.App()
#
# add panels to frame
#
frame = fab_frame("make_png_snap",sys.argv)
frame.control_panel = control_panel(frame)
frame.sizer.Add(frame.control_panel,(0,0),span=(1,3),flag=wx.ALIGN_CENTER_HORIZONTAL)
frame.snap_panel = path_snap_panel(frame)
frame.sizer.Add(frame.snap_panel,(1,2))
frame.path_panel = png_path_panel(frame)
frame.sizer.Add(frame.path_panel,(1,1))
frame.png_panel = png_panel(frame)
frame.sizer.Add(frame.png_panel,(1,0))
#
# defaults
#
#frame.set_png_snap()
#
# fit and show frame
#
frame.Fit()
frame.Show()
#
# start mainloop
#
app.MainLoop()

Some files were not shown because too many files have changed in this diff Show More