Code Monkey home page Code Monkey logo

Comments (4)

mlivesu avatar mlivesu commented on May 27, 2024

hi, there is a function called write_STL that does exactly this. You can find it in cinolib/io/write_STL.h

from cinolib.

Another-Anonymous-User avatar Another-Anonymous-User commented on May 27, 2024

But currently I am using trimesh.save() to create the stl which as far as I can tell from the source code uses the write_STL function you mention. However, the normals seem to have been randomly oriented and not consistently outwards.

from cinolib.

mlivesu avatar mlivesu commented on May 27, 2024

A tiny clarification: if you load a method with inconsistent normals and then you save it as an STL... you'll just propagate the same inconsistent normals in the new file! There's no magic in the save method.

Perhaps what you need is an algorithm to re-orient a badly oriented discrete surface? I do not have it in cinolib, but it should be fairly easy for you to code one. You just have to start from a trusted triangle (e.g. the first triangle you intersect from a ray coming from the outside), fix that normal, and then propagate the same orientation to the adjacent elements via flooding. If the surface is orientable, the algorithm converges to a consistent mesh orientation. If it is not, you will try to assign an opposite normal to a triangle you already visited, and by then you would know that your surface is non-orientable (e.g. a Mobius strip)

from cinolib.

Another-Anonymous-User avatar Another-Anonymous-User commented on May 27, 2024

Thanks for the clarification, I was asking mostly hoping it would not be necessary to implement it or use some other library for it, but alas, there is no other option.

from cinolib.

Related Issues (20)

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.