Giter Club home page Giter Club logo

stl-ruby's Introduction

STL

Build Status Gem Version

Read, write and manipulate both ASCII and binary STL files

Installation

Add this line to your application's Gemfile:

gem 'stl'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stl

Usage

require 'stl'

stl = STL.read('my_awesome.stl')
stl.faces			    # => [Face, ...]

To convert an ASCII STL file to a binary file:

STL.read('ascii.stl').write('binary.stl', :binary)

Writing binaries files is actually the default, so you can also leave off the last argument to write, if you want.

STL.read('ascii.stl').write('binary.stl')

You can also convert binary files to ASCII.

STL.read('binary.stl').write('ascii.stl', :ascii)

Converting between ASCII and binary

There's an easier way to do a format conversion, and it doesn't require that you know the original format. Simply use the convert method, and the format of the input will be toggled (ASCII to binary, or binary to ASCII). The converted filename will be the same as the original, but with '-ascii' or '-binary' appended, as appropriate.

STL.convert('ascii.stl')	# => ascii-binary.stl
STL.convert('binary.stl')	# => binary-ascii.stl

License

Copyright 2014 Brandon Fosdick [email protected] and released under the BSD license.

stl-ruby's People

Contributors

bfoz avatar fauno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lainventoria

stl-ruby's Issues

Add a write method

It should accept the output of read() and a write it to a file name. An optional argument should specify ASCII or binary (default to binary).

Add min and max attributes

This will require converting STL to a class

The min and max can be built during parsing to avoid additional traversing of the triangle list

Add a convert method

When given a filename, check if the file is ASCII or binary, then write it to a new file that's the opposite format.

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.