예제 #1
0
 def neighbors(self, n, mode='n'):
     """ Get the neighbors of node n. The final argument is either 'n' or 'e'. If it is 'n'
     the function returns all neighboring nodes, and if it is 'e' it returns incident edges."""
     nbors = IntVector()
     lib_py_gel.Graph_neighbors(self.obj, n, nbors.obj,
                                ct.c_char(mode.encode('ascii')))
     return nbors
예제 #2
0
파일: spatial.py 프로젝트: timfelle/GEL
 def in_sphere(self, p, r):
     """ Retrieve all points within a radius r of p.
     This function should only be called after build. """
     keys = Vec3dVector()
     vals = IntVector()
     n = lib_py_gel.I3DTree_in_sphere(self.obj, p[0], p[1], p[2], r,
                                      keys.obj, vals.obj)
     return (keys, vals)
예제 #3
0
def LS_skeleton(g, sampling=True):
    """ Skeletonize a graph using the local separators approach. The first argument,
        g, is the graph, and, sampling indicates whether we try to use all vertices
        (False) as starting points for finding separators or just a sampling (True).
        The function returns a new graph which is the skeleton of the input graph. """
    skel = Graph()
    mapping = IntVector()
    lib_py_gel.graph_LS_skeleton(g.obj, skel.obj, mapping.obj, sampling)
    return skel
예제 #4
0
 def circulate_vertex(self, vid, mode='v'):
     """ Circulate a vertex. Passed a vertex index, vid, and second argument,
     mode='f', this function will return an iterable with all faces incident
     on vid arranged in counter clockwise order. Similarly, if mode is 'h',
     incident halfedges (outgoing) are returned, and for mode = 'v', all
     neighboring vertices are returned. """
     nbrs = IntVector()
     n = lib_py_gel.Manifold_circulate_vertex(
         self.obj, vid, ct.c_char(mode.encode('ascii')), nbrs.obj)
     return nbrs
예제 #5
0
 def circulate_face(self, fid, mode='v'):
     """ Circulate a face. Passed a face index, fid, and second argument,
     mode='f', this function will return an iterable with all faces that
     share an edge with fid (in counter clockwise order). If the argument is
     mode='h', the halfedges themselves are returned. For mode='v', the
     incident vertices of the face are returned. """
     nbrs = IntVector()
     n = lib_py_gel.Manifold_circulate_face(self.obj, fid,
                                            ct.c_char(mode.encode('ascii')),
                                            nbrs.obj)
     return nbrs
예제 #6
0
def front_skeleton_and_map(g, colors):
    """ Skeletonize a graph using the front separators approach. The first argument,
        g, is the graph, and, colors is a 2D array where each row contains a sequence
        of floating point values - one for each node. We can have as many rows as needed
        for the front separator computation. We can think of this as a coloring
        of the nodes, hence the name. In practice, a coloring might just be the x-coordinate
        of the nodes or some other function that indicates something about the structure of the
        graph. The function returns a tuple containing a new graph which is the
        skeleton of the input graph and a map from the graph nodes to the skeletal nodes. """
    skel = Graph()
    mapping = IntVector()
    colors_flat = np.asarray(colors, dtype=np.float64)
    N_col = colors_flat.shape[0]
    lib_py_gel.graph_front_skeleton(
        g.obj, skel.obj, mapping.obj, N_col,
        colors_flat.ctypes.data_as(ct.POINTER(ct.c_double)))
    return skel, mapping
예제 #7
0
 def nodes(self):
     """ Get all nodes as an iterable range """
     nodes = IntVector()
     lib_py_gel.Graph_nodes(self.obj, nodes.obj)
     return nodes
예제 #8
0
 def faces(self):
     """ Returns an iterable containing all face indices"""
     faces = IntVector()
     n = lib_py_gel.Manifold_faces(self.obj, faces.obj)
     return faces
예제 #9
0
 def vertices(self):
     """ Returns an iterable containing all vertex indices"""
     verts = IntVector()
     n = lib_py_gel.Manifold_vertices(self.obj, verts.obj)
     return verts
예제 #10
0
 def halfedges(self):
     """ Returns an iterable containing all halfedge indices"""
     hedges = IntVector()
     n = lib_py_gel.Manifold_halfedges(self.obj, hedges.obj)
     return hedges