def surface2d_test(): cnf = Canvas3DFrame(None) x, y = np.ogrid[-2:2:20j, -2:2:20j] z = x * np.exp(-x**2 - y**2) vts, fs, ns, cs = surfutil.build_surf2d(z, ds=1, k=20, sigma=2) cs[:] = surfutil.auto_lookup(vts[:, 2], surfutil.linear_color('jet')) / 255 dem = Surface(vts, fs, ns, cs) cnf.add_surf('dem', dem) cnf.Show()
def run(self, para=None): vts = np.array([(0, 0, 0), (1, 1, 0), (2, 1, 0), (1, 0, 0)], dtype=np.float32) fs = np.array([(0, 1, 2), (1, 2, 3)], dtype=np.uint32) ns = np.ones((4, 3), dtype=np.float32) n_mer, n_long = 6, 11 pi = np.pi dphi = pi / 1000.0 phi = np.arange(0.0, 2 * pi + 0.5 * dphi, dphi) mu = phi * n_mer x = np.cos(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5) y = np.sin(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5) z = np.sin(n_long * mu / n_mer) * 0.5 vts, fs, ns, cs = surfutil.build_line(x, y, z, (1, 0, 0)) cs[:] = surfutil.auto_lookup(vts[:, 2], surfutil.linear_color('jet')) / 255 self.app.show_mesh(Surface(vts, fs, ns, cs, mode='grid'), 'line')
def run(self, para=None): dphi, dtheta = np.pi / 20.0, np.pi / 20.0 [phi, theta] = np.mgrid[0:np.pi + dphi * 1.5:dphi, 0:2 * np.pi + dtheta * 1.5:dtheta] m0 = 4 m1 = 3 m2 = 2 m3 = 3 m4 = 6 m5 = 2 m6 = 6 m7 = 4 r = np.sin(m0 * phi)**m1 + np.cos(m2 * phi)**m3 + np.sin( m4 * theta)**m5 + np.cos(m6 * theta)**m7 x = r * np.sin(phi) * np.cos(theta) y = r * np.cos(phi) z = r * np.sin(phi) * np.sin(theta) vts, fs, ns, cs = surfutil.build_mesh(x, y, z) cs[:] = surfutil.auto_lookup(vts[:, 2], surfutil.linear_color('jet')) / 255 self.app.show_mesh(Surface(vts, fs, ns, cs), 'decoration')