Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hmc dev #7

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Python stuff
*.pyc
__pycache__

# swap file
*~
.swp

*.ppm

*.png
!images/*.png
*.bak
*.mp4
*.mp3
*.mpg

.idea
*.pfd

*.nsi

*.stl

__pycache__
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ The easiest way to setup PythonOCC and OpenCASCADE is to do it in Ubuntu server

To install OpenCASCADE just do `apt-get install libopencascade-dev`. You can get PythonOCC from [here](http://www.pythonocc.org/download/). If you choose to build it from source [these instructions](http://code.google.com/p/pythonocc/source/browse/trunk/INSTALL) are helpful.

Under Windwos it is advised to use the Anaconda Python installation. PythonOCC and the utils can be installed using

conda install -c https://conda.anaconda.org/dlr-sc pythonocc-core

pip install git+https://github.com/tpaviot/pythonocc-utils.git#egg=pythonocc-utils

Note that cadmium can also be directly installed using pip as

pip install git+https://github.com/eelcovv/cadmium#egg=cadmium

Running example code
---------------------

Expand Down
14 changes: 9 additions & 5 deletions examples/example-001.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

import sys
import math
sys.path.append('./src')

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext

stlfname = splitext(basename(__file__))[0] + ".stl"

c0 = Cylinder(radius=1, height=8, center=True)
c1 = Cylinder(radius=1, height=8, center=True).rotate(X_axis, 45)
c2 = Cylinder(radius=1, height=8, center=True).rotate(X_axis, -45)
c3 = Cylinder(radius=1, height=8, center=True).rotate(X_axis, 90)
b = Box(x=8,y=1,z=1,center=True)
s0 = Sphere(r=1).translate(1.5,0,0)
s1 = Sphere(r=1).translate(-1.5,0,0)
b = Box(x=8, y=1, z=1, center=True)
s0 = Sphere(r=1).translate(1.5, 0, 0)
s1 = Sphere(r=1).translate(-1.5, 0, 0)

u = ((c0 + c1 + c2 + c3) - b) - (s0 + s1)

Expand Down
6 changes: 5 additions & 1 deletion examples/example-002.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

b0 = Box(x=4, y=4, z=4, center=True)
b1 = Box(x=4, y=4, z=4, center=True).rotate(X_axis, 45)
Expand Down
6 changes: 5 additions & 1 deletion examples/example-003.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

b0 = Box(x=4,y=4,z=4, center=True)
s0 = Sphere(radius=2.5)
Expand Down
6 changes: 5 additions & 1 deletion examples/example-004.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

ring = (
Cylinder(radius=6, height=2, center=True) - \
Expand Down
7 changes: 6 additions & 1 deletion examples/example-005.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@

final = star_wheel - x

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

final.toSTL(stlfname)
7 changes: 6 additions & 1 deletion examples/example-006.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ def generate_verbose(height, radius, hole_r, border, recess, num_support):

bushing = generate_compact(16, 75.0/2, 4.5, 1.56,5,3)

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

bushing.toSTL(stlfname)
6 changes: 5 additions & 1 deletion examples/example-007.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

u = Cylinder(radius=1, height=8, center=True).translate(x=4) + \
Cylinder(radius=1, height=8, center=True).translate(x=-4)\
Expand Down
10 changes: 8 additions & 2 deletions examples/example-008.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

def dragon(k,s):
print("k = {} ".format(k))
if k < 1:
return Cylinder(r=2*s, h=1).scale(0.1).translate(x=s) + \
Box(x=s, y=2*s/5.0, z=1).translate(y=-s/5.0) + \
Expand All @@ -19,6 +24,7 @@ def dragon(k,s):
dragon(k-1,s).rotate(Z_axis, 90).translate(x=c.real,y=c.imag)

print 'This is going to take a while...'
u = dragon(8,1)
u = dragon(2,1)

print('Writing result to {}'.format(stlfname)
u.toSTL(stlfname)
7 changes: 6 additions & 1 deletion examples/example-009.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
sys.path.append('./src')

from cadmium import *
stlfname = sys.argv[1]

try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

LIMIT = 9

Expand Down
8 changes: 6 additions & 2 deletions examples/example-010.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
import sys
import math
sys.path.append('./src')

from cadmium import *
stlfname = sys.argv[1]

try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

class Spoke(Solid):
def __init__(self, maxr, smallr, bigr, height, ratio, center=True):
Expand Down
10 changes: 8 additions & 2 deletions examples/example-011.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/python
# this example does not work

import os
import sys
import math
sys.path.append('./src')

from cadmium import *
jsonfname = sys.argv[1]

try:
jsonfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
jsonfname = splitext(basename(__file__))[0] + ".json"

t = Torus(r1=10,r2=2)

Expand All @@ -20,7 +26,7 @@

precision += 0.01
t = Torus(r1=10,r2=2)
t.toJSON(jsonfname, precision=precision)
t.toJSON(jsonfname)

size = os.stat(jsonfname).st_size
print size,precision
Expand Down
8 changes: 5 additions & 3 deletions examples/example-012.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import sys
import math
sys.path.append('./src')

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

s = Sphere(r=3)
s.scale(scaleY=2, scaleZ=2)
Expand Down
8 changes: 7 additions & 1 deletion examples/example-013.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from cadmium import Revolution
from cadmium import CadmiumException

try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

s = Revolution(
knotVector=[0,0,0,0,1,5,6,8,8,8,8],
controlPoints=[
Expand All @@ -18,7 +24,7 @@
degree=3,
axis=1)

s.toSTL(sys.argv[1])
s.toSTL(stlfname)

try:
s = Revolution(
Expand Down
8 changes: 7 additions & 1 deletion examples/example-014.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from cadmium import Extrusion
from cadmium import CadmiumException

try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

s = Extrusion(
knotVector=[0,0,0,0,1,5,6,8,8,8,8],
controlPoints=[
Expand All @@ -17,7 +23,7 @@
],
degree=3)

s.toSTL(sys.argv[1])
s.toSTL(stlfname)

try:
s = Extrusion(
Expand Down
6 changes: 5 additions & 1 deletion examples/text-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

from cadmium import *

stlfname = sys.argv[1]
try:
stlfname = sys.argv[1]
except IndexError:
from os.path import basename, splitext
stlfname = splitext(basename(__file__))[0] + ".stl"

s = Text('Cadmium',
fontpath='DejaVuSerif.ttf', # Give full path on your system
Expand Down
Loading