originally this was a script to convert images to height maps as polyhedrons suitable for use in openscad...now it has become a tool for making height map textured ring shapes
add control for fading edges of image
modifications based on prototype from i.materialise
Ring .stl internal diameter seemed to be 6 or 16.5mm, but size is entered correctly as 6.5 or 16.9mm which is correct
GENERATING A NON-TEXTURED RING GIVES CORRECT DIMENSIONS however adding an embossed texture to the inside adds material
in... if texture:
print "texture inside not outside"
#changes made here to fix texture size issue
NOW vertex_list.append([row*height_scaling,column,texture_depth - (pix[row,column]*depth_scaling) ])
WAS vertex_list.append([row*height_scaling,column, - (pix[row,column] *depth_scaling) ])
sizes/etc changed for 2nd prototype/production version
texture_depth=0.2 #to match prototype which turned out well, default was 0.5
ring_width=4.4 #to match engagement ring, default was 4
inputImage = 'slightlycleanedbetter_text.png' to include engraving text
texture_height_ring_circum_ratio=1#changed from 0.6 to take account of longer texture image featuring text
doming looks good now with adjusted shape
add control for how much of ring is covered in pattern
added texture_scale ability
possibly this introduces shadows at the edges... perhaps have option to trim 1 pixel from
each edge before using for texture to prevent this?
identified possible bug with texture direction when only using partial coverage
identified possible bug where back vertical edges have gaps...possibly due to ctrl+h replacing of
width and height previously...blergh!
reduced the number of holes and bad edges but still not perfect... this requires further
attention as at the moment it generates bad .STLs!!!
Now can directly make the entire ring!
ability to invert/flip/rotate image
add control over emboss/engrave
fix jumbled up width and height
removed openscad output options to functions
removed make_square section to function
add control for placing image on inner/outer surface
control the shapes of inner/outer surface so can directly create final ring
curvature direction and amount on inner and outer surface
add 2 separate ellispe radii for each surface implementing simple control over curving in
fixed some bugs where curved surfaces shape and change in height was miscalculated
Only tested on combinations of flat and convex...possibly bugs in concave surfaces???
implement curving in second direction
Moved items to main
fixed calculation of ring width
added ability to connect ends together so you can get a complete ring
add option for direct output in ascii .stl format (from https://en.wikipedia.org/wiki/STL_
An STL file describes a raw unstructured triangulated surface by the unit normal and vertices
(ordered by the right-hand rule) of the triangles using a three-dimensional Cartesian coordinate
system. STL coordinates must be positive numbers, there is no scale information, and the units are
An ASCII STL file begins with the line:
where name is an optional string (though if name is omitted there must still be a space after solid). The file continues with any number of triangles, each represented as follows:
Line 2 to n-1
facet normal ni nj nk
In both ASCII and binary versions of STL, the facet normal should be a unit vector
pointing outwards from the solid object. In most software this may be set to (0,0,0) and the software will automatically calculate a normal based on the order of the triangle vertices using
the 'right-hand rule'
vertex v1x v1y v1z
vertex v2x v2y v2z
vertex v3x v3y v3z
where each n or v is a floating point number in sign-mantissa 'e'-sign-exponent format, e.g.,
"-2.648000e-002". The file concludes with:
3d graph of vertex points with ID numbers
simple hack around failure with non-square images by adding blank pixels to edges to make it square! This works but leaves flat parts at the edges uses the maxima from im.extrema() to scale the texture heights uses user input to select width of output polygon via x position of vertex points
began attempt to join ends together
vertex array is now curved in 1 dimension
all data is saved to arrays rather than written immediately to file this will allow for easier editing
moved all polygon and triangle surface generation (textured top, flat bottom & sides) into single block
swapped order of side 4 in attempt to fix winding order
This can now generate a valid 3d polyhedron... but openscad has trouble with non-square input textures (not sure why)
Now able to generate all surfaces...still need to integrate this all into one method (removing special values) so they can form one object!
Cleaned up section that generates upper surface so it is more like that used to generate subsequent surfaces (easier to read and integrate)
converted to use load() (for better speed) based on http://stackoverflow.com/questions/11064786/get-pixels-rgb-using-pil
Add option to output simple cube (set op_format=1) or ployhedron (triangles) based maps (set op_format=0)
added ability to direct output to file (greatly speeds up operation)
Fixed output of base polygon so it appears at the end!
Having difficulties generatign the edges and sides
simple script to open a simple diagonal greysale_10x10_diagonal image in multiple formats and extract pixel data for manipulation
code initially taken from here http://stackoverflow.com/questions/14111705/python-displaying-a-grayscale-image
It will calculate the "elevation" for each pixel using the average RGB value as a height, kinda like a height/bump-map
an attempt to create an openscad compatible ployhedron object containing a list of vertices and triangles
Current output can be viewed in Openscad but cannot be rendered and output unless input is square!!!