Coder Social home page Coder Social logo

Comments (5)

hroncok avatar hroncok commented on September 25, 2024

Both features are something that I wanted to have but decided not to implement it yet due to higher complexity. I would gladly accept contributions containing those features.

Problem 1: read from stream

This will be hard. Currently, loading from file is done by directly calling underlying admesh code and passing the path down to C. In C, the stl_open function calls stuff that will eventually open the file in different modes.

Possible approaches:

  • create a separate loading mechanism in Cython, that works with Python streams (cons: when a bug is found in the C code, it has to be fixed on multiple places)
  • change the C code so that it can accept something else than path (cons: I have no idea how to pass a Python stream to C library, I think it is not possible or very hard)

Problem 2: add facets manually

This should be much easier. All that has to be done:

  1. change the __cinit__ so that it initializes and empty inmemory STL struct when no filename is given
  2. remove the open() method and the _opened attribute
  3. add a method that would add a facet to the struct, get inspired by stl_open_merge

Loading facets one by one would be very inefficient. A method that can load facets in bulk would be much better. I suggest it would be able to get list of dicts and/or a NumPy-like array (or even numpy-stl object).

Let me know if ypou decide to implement 2, if so I will do a quick release deprecating the open() method.

from python-admesh.

sumpfralle avatar sumpfralle commented on September 25, 2024

Thank you for your detailed thoughts!

Sadly I have to admit, that my cython knowledge is fairly non-existing. Nevertheless I tried my luck and prepared a trivial merge request (#11). It should partly solve problem (2) - except for being highly inefficient.
I assume, that my changes are not suitable (at least not the "add_facets" function). Feel free to ignore/change them at your will.

from python-admesh.

hroncok avatar hroncok commented on September 25, 2024

Would you like to digg deeper?

from python-admesh.

sumpfralle avatar sumpfralle commented on September 25, 2024

I am sorry: no, I do not want to acquire more knowledge about cython.
Please feel free to use or discard my changeset - whatever feels appropriate for you.

from python-admesh.

hroncok avatar hroncok commented on September 25, 2024

Closing this, since reading from stream will probably not get implemented. Manually adding facets added in #12

from python-admesh.

Related Issues (12)

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.