Coder Social home page Coder Social logo

scadtrace's Introduction

SCADTrace

This is a toolset to convert a black-and-white bitmap into an openscad object suitable for using to emboss a cylindrical object.

from something like this (image by Biofarben GmbH):

Source Image

to this:

Geometry

It uses potrace to generate an SVG representation of the figure from a bitmap. potrace rocks.
It then uses a python script to parse the SVG, extract the path geometry and generate openscad geometry.

Generating the inner and outer faces of the geometry presents a somewhat complicated problem because the faces need to be expressed as triangles. I've used Triangle to generate tesselations, and it works well. There are still some issues remaining and the code is far from clean.

Using

The steps for converting a JPG to an openscad model are in the Makefile.

  1. convert the source image into a BMP file using convert from imagemagick
  2. convert the BMP into an SVG outline using potrace
  3. convert the SVG into an openscad model using svgtoscad.py, which invokes triangle to tessellate the faces. svgtoscad.py takes the location of the triangle binary as a command line argument.

Dependencies

  1. potrace 1.11 to generate an SVG representation of the figure from a bitmap.
  2. triangle to tesselate the SVG shapes into triangles.
  3. imagemagick to convert source image to BMP

Tesselations

Here's a close-up that shows the effect of the triangulation. Pretty, hey? Quality Tesselation

The "quality" option introduces internal nodes which allow the geometry to be deformed into a cylinder without nasty distortion of the faces.

Quality Tesselation Projected

Here's the artwork used as a negative geometry to emboss the inside of a translucent diffuser.

Translucent Embossed Diffuser

Installation of potrace

Under OSX Mavericks, the steps are:

  1. mkdir potrace; cd potrace
  2. wget http://potrace.sourceforge.net/download/potrace-1.11.tar.gz
  3. tar -zxf potrace-1.11.tar.gz
  4. cd potrace-1.11
  5. ./configure
  6. make

Installation of Triangle

Under OSX Mavericks the steps are:

  1. mkdir triangle; cd triangle
  2. wget http://www.netlib.org/voronoi/triangle.zip
  3. unzip triangle.zip
  4. vi makefile
  5. Delete '-DLINUX' from the makefile
  6. make triangle

Installation of ImageMagick

Note: you probably don't want to install like this. Install a precompiled package for your operating system.

  1. wget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.9.0-10.tar.bz2
  2. tar -zxf ImageMagick-6.9.0-10.tar.bz2
  3. ./configure
  4. make
  5. sudo make install

scadtrace's People

Contributors

guyc avatar

Stargazers

Josep Ma. avatar Klemens Wittig avatar  avatar  avatar Sean Stevens avatar  avatar Chris Hart avatar  avatar Jan Horvath avatar Alice Atlas avatar Shawn Grimes avatar  avatar Suz Hinton avatar  avatar Giles Hall avatar

Watchers

 avatar James Cloos avatar

scadtrace's Issues

make error

make
convert artwork.jpg artwork.bmp
potrace --svg artwork.bmp
./svgtoscad.py artwork.svg
Traceback (most recent call last):
File "./svgtoscad.py", line 115, in
svg = Svg(filename)
File "/home/eduardo/src/scadtrace/svg.py", line 153, in init
self.width = int(svgNode.attributes["width"].value.rstrip("pt"))
ValueError: invalid literal for int() with base 10: '400.000000'
make: *** [all] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.