Return a copy of mesh with line vertices and edges added.

        mesh: A Mesh
        lines: A list of Polyline or Lines objects.
16070
def create_from_mesh_and_lines(cls, mesh, lines):
        '''
        

        '''
        mesh_with_lines = mesh.copy()
        mesh_with_lines.add_lines(lines)
        return mesh_with_lines
16721
def edges
      edge_ary = Array.new(4)
      edge_ary[0] = FiniteLine.new( base_point, base_point+u_vector)
      edge_ary[1] = FiniteLine.new( base_point+u_vector, base_point+u_vector+v_vector)
      edge_ary[2] = FiniteLine.new( base_point+u_vector+v_vector, base_point+v_vector)
      edge_ary[3] = FiniteLine.new( base_point+v_vector, base_point)
      return edge_ary
    end
1236581
def mesh(self,xyzs):
        
        return sum(c*p.mesh(xyzs) for c,p in self)
169525
def bounds(self):
        
        # return bounds including ONLY referenced vertices
        in_mesh = self.vertices[self.referenced_vertices]
        # get mesh bounds with min and max
        mesh_bounds = np.array([in_mesh.min(axis=0),
                                in_mesh.max(axis=0)])
        # should not be mutable
        mesh_bounds.flags.writeable = False
        return mesh_bounds
721854
def _get_edge_set(self, tol=0.1):
        
        edges = []
        for surface in self.surfaces:
            if isinstance(surface, GriddedSurface):
                return edges.append(surface.mesh)
            elif isinstance(surface, PlanarSurface):
                # Top edge determined from two end points
                edge = []
                for pnt in [surface.top_left, surface.top_right]:
                    edge.append([pnt.longitude, pnt.latitude, pnt.depth])
                edges.append(numpy.array(edge))
            elif isinstance(surface,
                            (ComplexFaultSurface, SimpleFaultSurface)):
                # Rectangular meshes are downsampled to reduce their
                # overall size
                edges.append(downsample_trace(surface.mesh, tol))
            else:
                raise ValueError("Surface %s not recognised" % str(surface))
        return edges
725528
def identify_vertex_triangles(self, vertices):
        

        triangles = []

        for vertex in np.array(vertices).reshape(-1):
            triangles.append(np.where(self.simplices == vertex)[0])

        return np.unique(np.concatenate(triangles))
16895
def export_dict(mesh, encoding=None):
    

    def encode(item, dtype=None):
        if encoding is None:
            return item.tolist()
        else:
            if dtype is None:
                dtype = item.dtype
            return util.array_to_encoded(item, dtype=dtype, encoding=encoding)

    # metadata keys we explicitly want to preserve
    # sometimes there are giant datastructures we don't
    # care about in metadata which causes exports to be
    # extremely slow, so skip all but known good keys
    meta_keys = ['units', 'file_name', 'file_path']
    metadata = {k: v for k, v in mesh.metadata.items() if k in meta_keys}

    export = {
        'metadata': metadata,
        'faces': encode(mesh.faces),
        'face_normals': encode(mesh.face_normals),
        'vertices': encode(mesh.vertices)
    }
    if mesh.visual.kind == 'face':
        export['face_colors'] = encode(mesh.visual.face_colors)
    elif mesh.visual.kind == 'vertex':
        export['vertex_colors'] = encode(mesh.visual.vertex_colors)

    return export
705199
def _explode_lines(shape):
    

    if shape.geom_type == 'LineString':
        return [shape]

    elif shape.geom_type == 'MultiLineString':
        return shape.geoms

    elif shape.geom_type == 'GeometryCollection':
        lines = []
        for geom in shape.geoms:
            lines.extend(_explode_lines(geom))
        return lines

    return []
133411
public static IndexedTriangleMesh toIndexed(TriangleMesh mesh) {
		if (mesh instanceof IndexedTriangleMesh) return (IndexedTriangleMesh)mesh;
		if (mesh instanceof PointList) return new TriangleSetImpl((PointList)mesh);
		TriangleListIterator iterator = mesh.iterateTriangles();
		List<Vector3> vertices=new ArrayList<Vector3>();
		while (iterator.hasNext()) {
			iterator.next();
			vertices.add(iterator.getV1());
			vertices.add(iterator.getV2());
			vertices.add(iterator.getV3());
		}
		return new TriangleSetImpl(vertices);
	}
188181
def triangles(self):
        
        triangles = collections.deque()
        triangles_node = collections.deque()

        for node_name in self.graph.nodes_geometry:
            # which geometry does this node refer to
            transform, geometry_name = self.graph[node_name]

            # get the actual potential mesh instance
            geometry = self.geometry[geometry_name]
            if not hasattr(geometry, 'triangles'):
                continue
            # append the (n, 3, 3) triangles to a sequence
            triangles.append(
                transformations.transform_points(
                    geometry.triangles.copy().reshape((-1, 3)),
                    matrix=transform))
            # save the node names for each triangle
            triangles_node.append(
                np.tile(node_name,
                        len(geometry.triangles)))
        # save the resulting nodes to the cache
        self._cache['triangles_node'] = np.hstack(triangles_node)
        triangles = np.vstack(triangles).reshape((-1, 3, 3))
        return triangles
899867
def add_edge(edges, edge_points, coords, i, j):
    
    if (i, j) in edges or (j, i) in edges:
        # already added
        return( edges.add((i, j)), edge_points.append(coords[[i, j]]))
327722
def add_lines(self, lines):
        '''
        

        '''
        import numpy as np
        if not lines:
            return

        v_lines = np.vstack([l.v for l in lines])
        v_index_offset = np.cumsum([0] + [len(l.v) for l in lines])
        e_lines = np.vstack([l.e + v_index_offset[i] for i, l in enumerate(lines)])
        num_body_verts = self.v.shape[0]
        self.v = np.vstack([self.v, v_lines])
        self.e = e_lines + num_body_verts
1194773
def get_edge_list(self):
        
        edge_objs = list()

        for obj_dict_list in self.obj_dict['edges'].values():
            edge_objs.extend([
                Edge(obj_dict=obj_d)
                for obj_d
                in obj_dict_list])

        return edge_objs
1214826
def new_vertex(self):
    
    vertex = Vertex(len(self.vertices))
    self.vertices.append(vertex)
    return vertex
1224472
def keep_vertices(self, indices_to_keep, ret_kept_edges=False):
        '''
        

        '''

        if self.v is None:
            return

        initial_num_verts = self.v.shape[0]
        if self.e is not None:
            initial_num_edges = self.e.shape[0]
            e_indices_to_keep = self.all_edges_with_verts(indices_to_keep, as_boolean=True)

        self.v = self.v[indices_to_keep]
        if self.e is not None:
            v_old_to_new = np.zeros(initial_num_verts, dtype=int)
            e_old_to_new = np.zeros(initial_num_edges, dtype=int)

            v_old_to_new[indices_to_keep] = np.arange(len(indices_to_keep), dtype=int)
            self.e = v_old_to_new[self.e[e_indices_to_keep]]
            e_old_to_new[e_indices_to_keep] = np.arange(self.e.shape[0], dtype=int)
        else:
            e_indices_to_keep = []

        return np.nonzero(e_indices_to_keep)[0] if ret_kept_edges else self
111299
def mesh(self):
        """"""
        triangles = np.empty((self.f.shape[0], 4))
        triangles[:, -3:] = self.f
        triangles[:, 0] = 3
        return vtki.PolyData(self.v, triangles, deep=False)
954056
def build_edges(self):
        
        self.edges = [
            edge if isinstance(edge, Edge) else Edge(*edge)
            for node in self.nodes.values()
            for edge in getattr(node, "edges", [])
            if edge[0] in self.nodes and edge[1] in self.nodes
        ]
        return self