jay3sh / cadmium Goto Github PK
View Code? Open in Web Editor NEWPython library for Solid Modelling
Home Page: http://jay3sh.github.com/cadmium
License: Other
Python library for Solid Modelling
Home Page: http://jay3sh.github.com/cadmium
License: Other
please look at this:
import sys
sys.path.append('./src')
from cadmium import *
u = Box(62,62,100, center=True) + Sphere(19).translate(-31,-31,-31)```
when run with current HEAD, I get:
```Traceback (most recent call last):
File "examples/fail.py", line 5, in <module>
u = Box(62,62,100, center=True) + Sphere(19).translate(-31,-31,-31)
File "./src/cadmium/solid.py", line 50, in __add__
union = BRepAlgoAPI_Fuse(self.shape, other.shape).Shape()
File "/usr/lib/pymodules/python2.7/OCC/BRepAlgoAPI.py", line 222, in __init__
_BRepAlgoAPI.BRepAlgoAPI_Fuse_swiginit(self,_BRepAlgoAPI.new_BRepAlgoAPI_Fuse(*args))
RuntimeError: Standard_ConstructionError```
Hallo,
i dont know if it is possible to import an stl and use it a primive.
I tried to do it but keep getting a runtime exception in line "
test = sol + s0":
"Message File Name Line Position
Traceback
C:\Documents and Settings\Tarjan\My Documents\Downloads\jayesh3-cadmium-ff4e994\jayesh3-cadmium-ff4e994\examples\example-001b.py 21
add c:\Python26\Lib\site-packages\cadmium\solid.py 42
RuntimeError: StdFail_NotDone
BRep_API: command not done "
My Code is:
import sys
import math
sys.path.append('./src')
from cadmium import *
stlfname = "example.stl"#sys.argv[1]
s0 = Sphere(r=4)
from OCC.Utils.DataExchange import STL
reader = STL.STLImporter(r'basebrick.stl')
reader.read_file()
sol = Solid(reader.get_shape())
test = sol + s0
test.toSTL(stlfname)
If somebody tells me how, ican upload the stl file. It seems that the OpenCASCADE lib throws the exception. But i cant step into it...
Tarjan
Union consumes about 500 Kb per sphere, though not producing new vertices.
Following program was run on a machine with 512Mb memory limit, crashed after making union of 800 identical spheres.
import sys
import math
from cadmium import *
def memory_usage():
"""Memory usage of the current process in MB."""
status = None
result = {'peak': 0, 'rss': 0}
try:
status = open('/proc/self/status')
for line in status:
parts = line.split()
key = parts[0][2:-1].lower()
if key in result:
result[key] = int(parts[1]) / 1024
finally:
if status is not None:
status.close()
return result
s = Sphere(r = 5, center = True)
a = s
n = int(sys.argv[1])
for i in xrange(0, n):
s = s + a
if (i % 100) == 0:
print "i =", i, "mem usage", memory_usage()
s.toSTL("1.stl")
Output was:
deltaflight@natty32:~$ time python loop.py 900
i = 0 mem usage {'peak': 148, 'rss': 79}
i = 100 mem usage {'peak': 197, 'rss': 127}
i = 200 mem usage {'peak': 247, 'rss': 176}
i = 300 mem usage {'peak': 297, 'rss': 225}
i = 400 mem usage {'peak': 350, 'rss': 277}
i = 500 mem usage {'peak': 400, 'rss': 325}
i = 600 mem usage {'peak': 450, 'rss': 374}
i = 700 mem usage {'peak': 499, 'rss': 422}
i = 800 mem usage {'peak': 554, 'rss': 462}
Killed
real 2m6.949s
user 0m25.714s
sys 1m10.208s
deltaflight@natty32:~$ dmesg |tail -2
[ 3123.445580] Out of memory: Kill process 1101 (python) score 934 or sacrifice child
[ 3123.445833] Killed process 1101 (python) total-vm:607704kB, anon-rss:474520kB, file-rss:24kB
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.