Example #1
0
def teapot():
    """  Generate the Utah teapot as 32 cubic bezier patches. This teapot has a
    rim, but no bottom. It is also self-intersecting making it unsuitable for
    perfect-match multipatch modeling.

    The data is picked from http://www.holmes3d.net/graphics/teapot/

    :return: The utah teapot
    :rtype: List of Surface
    """
    path = join(dirname(realpath(__file__)), 'templates', 'teapot.bpt')
    with open(path) as f:
        results = []
        numb_patches = int(f.readline())
        for i in range(numb_patches):
            p = np.fromstring(f.readline(), dtype=np.uint8, count=2, sep=' ')
            basis1 = BSplineBasis(p[0] + 1)
            basis2 = BSplineBasis(p[1] + 1)

            ncp = basis1.num_functions() * basis2.num_functions()
            cp = [
                np.fromstring(f.readline(), dtype=np.float, count=3, sep=' ')
                for j in range(ncp)
            ]
            results.append(Surface(basis1, basis2, cp))

    return results
Example #2
0
 def test_num_functions(self):
     b = BSplineBasis(4, [0, 0, 0, 0, 1, 2, 3, 3, 3, 3])
     self.assertEqual(b.num_functions(), 6)
     b = BSplineBasis(4, [-2, -1, 0, 0, 1, 2, 3, 3, 4, 5], periodic=1)
     self.assertEqual(b.num_functions(), 4)
Example #3
0
 def test_num_functions(self):
     b = BSplineBasis(4, [0, 0, 0, 0, 1, 2, 3, 3, 3, 3])
     self.assertEqual(b.num_functions(), 6)
     b = BSplineBasis(4, [-2, -1, 0, 0, 1, 2, 3, 3, 4, 5], periodic=1)
     self.assertEqual(b.num_functions(), 4)