コード例 #1
0
ファイル: curve3_test.py プロジェクト: mirmik/zencad
    def test_api(self):
        a = zencad.interpolate([(0, 0, 0), (0, 0, 1)], [(0, 0, 1), (0, 0, 1)],
                               closed=False)
        b = zencad.interpolate([(0, 0, 0), (0, 0, 1)], closed=False)

        self.assertEqual(a.value(0), zencad.point3(0, 0, 0))
        self.assertEqual(a.value(1), zencad.point3(0, 0, 1))
        self.assertEqual(a.value(0.5), zencad.point3(0, 0, 0.5))
コード例 #2
0
 def test_interpolate_probe(self):
     pnts = [(0, 0, 0), (10, 20, 30), (10, 21, 35), (10, 22, 40)]
     tang = [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 0, 0)]
     zencad.interpolate(pnts, closed=False)
     zencad.interpolate(pnts, closed=True)
     zencad.interpolate(pnts, tang, closed=False)
     zencad.interpolate(pnts, tang, closed=True)
コード例 #3
0
ファイル: ops3d_test.py プロジェクト: lyndametref/zencad
 def test_pipe_shell(self):
     proto0 = zencad.circle(20, wire=True)
     proto1 = zencad.circle(30, wire=True).up(10)
     proto2 = zencad.circle(30, wire=True).up(20)
     path = zencad.interpolate([(0, 0, 0), (0, 0, 10), (0, 10, 20)])
     zencad.pipe_shell([proto0, proto1, proto2], path)
     zencad.pipe_shell(profiles=[proto0, proto1, proto2], spine=path)
コード例 #4
0
 def test_interpolate(self):
     zencad.interpolate([(0, 0, 0), (1, 1, 0), (1, 1, 1)])
     zencad.interpolate(pnts=[(0, 0, 0), (1, 1, 0), (1, 1, 1)], closed=True)
     zencad.interpolate([(0, 0, 0), (1, 1, 0), (1, 1, 1)], [(0, 0, 0),
                                                            (1, 1, 0),
                                                            (1, 1, 1)])
     zencad.interpolate(
         pnts=[(0, 0, 0), (1, 1, 0), (1, 1, 1)],
         tangs=[(0, 0, 0), (1, 0, 0), (0, 0, 1)],
         closed=True,
     )
コード例 #5
0
ファイル: ops3d_test.py プロジェクト: lyndametref/zencad
 def test_pipe(self):
     proto = zencad.circle(20)
     path = zencad.interpolate([(0, 0, 0), (0, 0, 10), (0, 10, 20)])
     zencad.pipe(proto, path)
     zencad.pipe(profile=proto, spine=path)
コード例 #6
0
def build():
    r = io.imread("image.png", as_gray=True)

    # Find contours at a constant value of 0.8
    contours = measure.find_contours(r, 0.8)

    zcountours = [
        zencad.interpolate([zencad.point3(t[0], t[1]) for t in contour])
        for contour in contours
    ]

    gons = [z.fill() for z in zcountours if z.is_closed()]
    ncls = [z for z in zcountours if not z.is_closed()]

    ints = []
    for i in range(0, len(gons)):
        for j in range(0, len(gons)):
            if i == j:
                continue
            ints.append(gons[i] ^ gons[j])

    ints = zencad.union(ints)
    gons = [g - ints for g in gons]

    gons = zencad.union(gons)

    pnts = chain(*[n.endpoints().unlazy() for n in ncls])
    pnts = list(pnts)

    rpnts = []
    for i in range(0, len(pnts)):
        for j in range(0, len(pnts)):
            if i == j or j > i:
                continue
            if (
                math.sqrt(
                    (pnts[i].x - pnts[j].x) ** 2
                    + (pnts[i].y - pnts[j].y) ** 2
                    + (pnts[i].z - pnts[j].z) ** 2
                )
                < 150
            ):
                rpnts.append((i, j))

    wires = ncls + [zencad.segment(pnts[a], pnts[b]) for a, b in rpnts]

    wires = [
        wires[0],
        wires[4],
        wires[1],
        wires[7],
        wires[3],
        wires[6],
        wires[2],
        wires[5],
    ]

    gons = gons.left(760 / 2).back(768 / 2)
    w0 = zencad.sew(wires).left(760 / 2).back(768 / 2)
    w1 = w0.scale(1.2, zencad.point3(0, 0, 0))

    f = w1.fill() - w0.fill()

    mechanicus = gons + f
    mechanicus = mechanicus.extrude(20).up(20)

    base = zencad.circle(r=500).extrude(20)

    return mechanicus, base, zcountours
コード例 #7
0
#!/usr/bin/env python3
# coding: utf-8

import zencad

pnts = zencad.points([(0, 0), (1, 0), (2, 0), (4, 1), (5, 2), (6, 3)])

tang = zencad.vectors([(1, 0), (0, 0), (1, 0), (1, 1), (1, 1), (1, 1)])

zencad.display(zencad.interpolate(pnts=pnts))
for p in pnts:
    zencad.display(p)
zencad.show()
コード例 #8
0
ファイル: ops3d_test.py プロジェクト: ont/zencad
 def test_sweep(self):
     proto = zencad.circle(20, wire=True)
     path = zencad.interpolate([(0, 0, 0), (0, 0, 10), (0, 10, 20)])
     zencad.sweep(proto, path)
     zencad.sweep(proto=proto, path=path)
コード例 #9
0
ファイル: ops3d_test.py プロジェクト: ont/zencad
 def test_pipe_shell(self):
     proto = zencad.circle(20, wire=True)
     path = zencad.interpolate([(0, 0, 0), (0, 0, 10), (0, 10, 20)])
     zencad.pipe_shell(proto, path)
     zencad.pipe_shell(proto=proto, path=path)