def new_cap(drawing, cap_name): from chimerax.core.models import Model, Surface if isinstance(drawing, Model): # Make cap a model when capping a model so color can be set by command. c = Surface(cap_name, drawing.session) c.display_style = drawing.display_style c.SESSION_SAVE = False drawing.add([c]) else: # Cap is on a Drawing that is not a Model c = drawing.new_drawing(cap_name) c.is_clip_cap = True return c
def show_hk_lattice(session, h, k, radius, orientation='222', color=(255, 255, 255, 255), sphere_factor=0, edge_radius=None, mesh=False, replace=True): varray, tarray, hex_edges = hk_icosahedron_lattice(h, k, radius, orientation) interpolate_with_sphere(varray, radius, sphere_factor) name = 'Icosahedron h = %d, k = %d' % (h, k) if mesh: model = sm = _cage_surface(session, name, replace) sm.set_geometry(varray, None, tarray) sm.color = color sm.display_style = sm.Mesh sm.edge_mask = hex_edges # Hide spokes of hexagons. if sm.id is None: session.models.add([sm]) else: # Make cage from markers. from chimerax.core.models import Surface sm = Surface(name, session) sm.set_geometry(varray, None, tarray) sm.color = color sm.display_style = sm.Mesh sm.edge_mask = hex_edges # Hide spokes of hexagons. if edge_radius is None: edge_radius = .01 * radius mset = _cage_markers(session, name) if replace else None from chimerax.markers.cmd import markers_from_mesh model = markers_from_mesh(session, [sm], color=color, edge_radius=edge_radius, markers=mset) model.name = name if mset: mset._prev_markers.delete() model.hkcage = True return model
def ellipsoid_mesh(session, name, center, radii, rotation, divisions, color, opacity): vertices, edges = lattitude_longtitude_circles(divisions) # Stretch, rotate and center vertices *= radii rotation.transform_points(vertices, in_place=True) vertices += center # Create ellipsoid model from chimerax.core.models import Surface s = Surface(name, session) normals = None s.set_geometry(vertices, normals, edges) s.color = [int(255 * r) for r in color + [opacity]] s.display_style = s.Mesh session.models.add([s])