Comments (5)
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:
- change the
__cinit__
so that it initializes and emptyinmemory
STL struct when no filename is given - remove the
open()
method and the_opened
attribute - 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.
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.
Would you like to digg deeper?
from python-admesh.
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.
Closing this, since reading from stream will probably not get implemented. Manually adding facets added in #12
from python-admesh.
Related Issues (12)
- Python3 admesh issue HOT 2
- Fails to compile with new Cython
- test/utils.py not in sdist
- Mac - problem with installation HOT 10
- Member variables of stl_file (stats, facet_start, etc.) are not exposed HOT 2
- get_size() and calculate_volume() methods return None HOT 8
- Make ADMeshException HOT 1
- 0.98.4 fails to compile HOT 10
- Does not compile with Cython 0.23 HOT 2
- Missing surface_area in stats HOT 8
- Deepcopy doesn't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-admesh.