Code Monkey home page Code Monkey logo

stlsort's Introduction

stlsort

image

image

Some tools such as OpenSCAD produce randomly ordered STL files so source control like git can't tell if they have changed or not. This tool orders each triangle to start with the lowest vertex first (comparing x, then y, then z). It then sorts the triangles to start with the one with the lowest vertices first (comparing first vertex, second, then third). This has no effect on the model but makes the STL consistent. I.e. it makes a canonical form.

Sort your STL files before committing changes! Add a pre-commit hook like this:

#!/bin/sh
# This was not tested with filenames containing spaces
files=`git diff --cached --name-only --diff-filter=ACM | grep .stl$ | tr '\n' ' '`
if [[ x"$files" != x ]]; then
  stlsort $files
  git add $files
fi

This was created by nop head as a part of Mendel90 repository. Works only for ASCII STLs (convert your STLs from binary to ASCII in pre-commit hook if needed).

stlsort's People

Contributors

hroncok avatar

Watchers

Chris avatar James Cloos avatar  avatar  avatar

stlsort's Issues

Stlsort does not correct "negative zeros" (-0)

Hi,
it would be very useful if STLSORT could correct the "negative zeros". Some STL renders can produce in facet normals value "-0". I think STLSORT should correct the values of -0 to 0

This can be seen in the following diff (These files passed through stlsort)
obrazek

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.