def solid_stl_demo(**kwargs): from stl import mesh from ifigure.interactive import solid, figure, threed import ifigure, os from os.path import dirname path = dirname(dirname(dirname(ifigure.__file__))) mymesh = mesh.Mesh.from_file(os.path.join(path, 'example', 'D_antenna.stl')) v = figure() threed('on') solid(mymesh.vectors, alpha = 0.5, **kwargs)
def solid_stl_demo(**kwargs): from stl import mesh from ifigure.interactive import solid, figure, threed import ifigure, os from os.path import dirname path = dirname(dirname(dirname(ifigure.__file__))) mymesh = mesh.Mesh.from_file(os.path.join(path, 'example', 'D_antenna.stl')) v = figure() threed('on') solid(mymesh.vectors, alpha=0.5, **kwargs)
def plot_tet(self, idx, **kwargs): from ifigure.interactive import solid grids = self.dataset['GRIDS'] tet = self.dataset['ELEMS']['TETRA'] i = tet[idx] pts = [ grids[[i[0], i[1], i[2]]], grids[[i[1], i[2], i[3]]], grids[[i[2], i[3], i[0]]], grids[[i[3], i[0], i[1]]] ] pts = np.rollaxis(np.dstack(pts), 2, 0) solid(pts, **kwargs)
def solid_demo(**kwargs): ''' solid_demo2(cz = True, linewidths = 1.0, edgecolor='red') solid_demo2(facecolor='b', linewidths = 1.0, edgecolor='red') ''' from ifigure.interactive import solid, figure, threed, isec, nsec, lighting import ifigure, os # preparing the data, the same as mplot3d demo theta = np.linspace(0, 2.0 * np.pi, endpoint=True, num=50) r = np.linspace(0.01, 4.0, endpoint=True, num=50) # This is the Mobius mapping, taking a u, v pair and returning an x, y, z # triple THETA, R = np.meshgrid(theta, r) X = R * np.cos(THETA) Y = R * np.sin(THETA) Z = np.exp(-R * R) import matplotlib.tri as mtri tri = mtri.Triangulation(X.flatten(), Y.flatten()) # Triangulate parameter space to determine the triangles if 'cz' in kwargs and kwargs['cz']: v = np.dstack(( tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles], )) v = np.vstack((tri.x, tri.y, Z.flatten())) kwargs['cdata'] = 5 * Z.flatten()[tri.triangles] kwargs['cdata'] = 5 * Z.flatten() kwargs['cz'] = True # or # v = np.dstack(( tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles], 5 * Z.flatten()[tri.triangles], )) v = np.vstack((tri.x, tri.y, Z.flatten(), 5 * Z.flatten())) elif 'twod' in kwargs and kwargs['twod']: v = np.dstack((tri.x[tri.triangles], tri.y[tri.triangles]), ) v = np.vstack(( tri.x, tri.y, )) kwargs.pop('twod') kwargs['zvalue'] = 1.0 else: v = np.dstack(( tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles], )) v = np.vstack((tri.x, tri.y, Z.flatten())) idxset = tri.triangles v = v.transpose() print v.shape, idxset.shape viewer = figure() nsec(3) isec(0) threed('on') solid(v, idxset, edgecolor='k', facecolor='b') lighting(light=0.5, ambient=0.5) isec(1) threed('on') solid(v, idxset, cz=True) lighting(light=0.5, ambient=0.5) isec(2) threed('on') solid(v, idxset, cz=True, cdata=v[..., 0], shade='linear') lighting(light=0.5, ambient=0.5)
def solid_demo(**kwargs): ''' solid_demo2(cz = True, linewidths = 1.0, edgecolor='red') solid_demo2(facecolor='b', linewidths = 1.0, edgecolor='red') ''' from ifigure.interactive import solid, figure, threed, isec, nsec, lighting import ifigure, os # preparing the data, the same as mplot3d demo theta = np.linspace(0, 2.0 * np.pi, endpoint=True, num=50) r = np.linspace(0.01, 4.0, endpoint=True, num=50) # This is the Mobius mapping, taking a u, v pair and returning an x, y, z # triple THETA, R = np.meshgrid(theta, r) X = R*np.cos(THETA) Y = R*np.sin(THETA) Z = np.exp(- R*R) import matplotlib.tri as mtri tri = mtri.Triangulation(X.flatten(), Y.flatten()) # Triangulate parameter space to determine the triangles if 'cz' in kwargs and kwargs['cz']: v = np.dstack((tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles],)) v = np.vstack((tri.x, tri.y, Z.flatten())) kwargs['cdata'] = 5*Z.flatten()[tri.triangles] kwargs['cdata'] = 5*Z.flatten() kwargs['cz'] = True # or # v = np.dstack((tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles], 5 * Z.flatten()[tri.triangles],)) v = np.vstack((tri.x, tri.y, Z.flatten(), 5*Z.flatten())) elif 'twod' in kwargs and kwargs['twod']: v = np.dstack((tri.x[tri.triangles], tri.y[tri.triangles]),) v = np.vstack((tri.x, tri.y, )) kwargs.pop('twod') kwargs['zvalue'] = 1.0 else: v = np.dstack((tri.x[tri.triangles], tri.y[tri.triangles], Z.flatten()[tri.triangles],)) v = np.vstack((tri.x, tri.y, Z.flatten())) idxset=tri.triangles v = v.transpose() print v.shape, idxset.shape viewer = figure() nsec(3) isec(0) threed('on') solid(v, idxset, edgecolor = 'k', facecolor = 'b') lighting(light = 0.5, ambient = 0.5) isec(1) threed('on') solid(v, idxset, cz = True) lighting(light = 0.5, ambient = 0.5) isec(2) threed('on') solid(v, idxset, cz = True, cdata = v[...,0], shade='linear') lighting(light = 0.5, ambient = 0.5)