Пример #1
0
def dodecahedron(side=1.0):
    verts = icosahedronVerts()
    cubes = [
        rot(cadmium.Box(x=1.5 * side, y=1.5 * side, z=1.5 * side, center=True),
            *tuple(v)).translate(*tuple(v * side)) for v in verts
    ]
    dodeca = (cadmium.Sphere(r=side, center=True) - sum(cubes))
    return dodeca
Пример #2
0
 def test(self):
   box = cadmium.Box(x=4,y=4,z=4, center=True)
   box.toSTL('box.stl')
   self.assertTrue(are_same('box.stl','data/box.stl'))
   os.remove('box.stl')
   box.toJSON('box.json.gz', compress=True)
   self.assertTrue(are_same('box.json.gz','data/box.json.gz'))
   os.remove('box.json.gz')
Пример #3
0
def octahedron(side=1.0):
    verts = cubeVerts()
    cubes = [
        rot(cadmium.Box(x=1.5 * side, y=1.5 * side, z=1.5 * side, center=True),
            *tuple(v)).translate(*tuple(side * v)) for v in verts
    ]
    octa = (cadmium.Sphere(r=0.7 * side, center=True) - sum(cubes))
    octa.toSTL("octa.stl")
    return octa
Пример #4
0
def tetrahedron(side=1.0):
    verts = tetrahedronVerts()
    norms = closestNorm3(verts)

    cubes = [
        rot(cadmium.Box(x=2.0 * side, y=2.0 * side, z=2.0 * side, center=True),
            *tuple(n)).translate(*tuple(n * (mag(n) + side) / mag(n)))
        for n in norms
    ]
    tetra = (cadmium.Sphere(r=side, center=True) - sum(cubes))
    tetra.toSTL("tetra.stl")
    return tetra
Пример #5
0
def icosahedron(side=1.0):
    verts = icosahedronVerts()
    norms = closestNorm3(verts)

    cubes = [
        rot(cadmium.Box(x=side, y=side, z=side, center=True),
            *tuple(n)).translate(*tuple(n * side)) for n in norms
    ]
    sphere = cadmium.Sphere(r=side / 2.0, center=True)
    icosa = (sphere - sum(cubes))
    # icosa.toSTL("icosa.stl")
    return icosa
Пример #6
0
def generate_data():
  cyl = cadmium.Cylinder(r=5, h=10, center=True)
  cyl.toSTL('data/cylinder.stl')
  cyl.toJSON('data/cylinder.json.gz',compress=True)

  box = cadmium.Box(x=4,y=4,z=4, center=True)
  box.toSTL('data/box.stl')
  box.toJSON('data/box.json.gz', compress=True)

  cone = cadmium.Cone(r=5,h=10, center=True)
  cone.toSTL('data/cone.stl')
  cone.toJSON('data/cone.json.gz', compress=True)

  wedge = cadmium.Wedge(dx=5,dy=5,dz=5, center=True)
  wedge.toSTL('data/wedge.stl')
  wedge.toJSON('data/wedge.json.gz', compress=True)

  torus = cadmium.Torus(r1=1, r2=.2, center=True)
  torus.toSTL('data/torus.stl')
  torus.toJSON('data/torus.json.gz', compress=True)

  sph = cadmium.Sphere(r=1, center=True)
  sph.toSTL('data/sphere.stl')
  sph.toJSON('data/sphere.json.gz', compress=True)
Пример #7
0
def cube(side=1.0):
    cube = cadmium.Box(x=side, y=side, z=side, center=True)
    cube.toSTL("cube.stl")
    return cube