Exemple #1
0
def add_or_remove_new_edge(self, idx):
    '''
        - only add idx if not edge_prime
        - and not currently present in selected_edges
    '''
    p_idx = self.edge_prime_idx

    if idx == p_idx:
        print(idx, 'is edge prime, not adding')
        return

    if (idx in self.selected_edges):
        self.selected_edges.remove(idx)
        del self.xvectors[idx]
    else:
        edge_prime = cm.coords_tuple_from_edge_idx(self.bm, p_idx)
        edge2 = cm.coords_tuple_from_edge_idx(self.bm, idx)
        p = cm.get_intersection(edge_prime, edge2)

        if not cm.point_on_edge(p, edge_prime):
            return

        vert_idx_closest = cm.closest_idx(p, self.bm.edges[idx])
        self.xvectors[idx] = [p, vert_idx_closest]
        self.selected_edges.append(idx)
Exemple #2
0
def doVTX(self):
    '''
    At this point we know that there is an intersection, and if it
    is V, T or X.
    - If both are None, then both edges are projected towards point. (V)
    - If only one is None, then it's a projection onto a real edge (T)
    - Else, then the intersection lies on both edges (X)
    '''
    print('point:', self.point)
    print('edges selected:', self.idx1, self.idx2)
    print('edges to use:', self.edges)

    self.bm.verts.new((self.point))

    earmarked = self.edges
    pt = self.point

    # V (projection of both edges)
    if [] == earmarked:
        cl_vert1 = cm.closest_idx(pt, self.bm.edges[self.idx1])
        cl_vert2 = cm.closest_idx(pt, self.bm.edges[self.idx2])
        add_edges(self, [cl_vert1, cl_vert2])

    # X (weld intersection)
    elif len(earmarked) == 2:
        vector_indices = cm.vertex_indices_from_edges_tuple(self.bm, earmarked)
        add_edges(self, vector_indices)

    # T (extend towards)
    else:
        to_edge_idx = self.edges[0]
        from_edge_idx = self.idx1 if to_edge_idx == self.idx2 else self.idx2

        # make 3 new edges: 2 on the towards, 1 as extender
        cl_vert = cm.closest_idx(pt, self.bm.edges[from_edge_idx])
        to_vert1, to_vert2 = cm.vert_idxs_from_edge_idx(self.bm, to_edge_idx)
        roto_indices = [cl_vert, to_vert1, to_vert2]
        add_edges(self, roto_indices)

    # final refresh before returning to user.
    if earmarked:
        remove_earmarked_edges(self, earmarked)
    bmesh.update_edit_mesh(self.me, True)
Exemple #3
0
def doVTX(self):
    '''
    At this point we know that there is an intersection, and if it
    is V, T or X.
    - If both are None, then both edges are projected towards point. (V)
    - If only one is None, then it's a projection onto a real edge (T)
    - Else, then the intersection lies on both edges (X)
    '''
    print('point:', self.point)
    print('edges selected:', self.idx1, self.idx2)
    print('edges to use:', self.edges)

    self.bm.verts.new((self.point))

    earmarked = self.edges
    pt = self.point

    # V (projection of both edges)
    if [] == earmarked:
        cl_vert1 = cm.closest_idx(pt, self.bm.edges[self.idx1])
        cl_vert2 = cm.closest_idx(pt, self.bm.edges[self.idx2])
        add_edges(self, [cl_vert1, cl_vert2])

    # X (weld intersection)
    elif len(earmarked) == 2:
        vector_indices = cm.vertex_indices_from_edges_tuple(self.bm, earmarked)
        add_edges(self, vector_indices)

    # T (extend towards)
    else:
        to_edge_idx = self.edges[0]
        from_edge_idx = self.idx1 if to_edge_idx == self.idx2 else self.idx2

        # make 3 new edges: 2 on the towards, 1 as extender
        cl_vert = cm.closest_idx(pt, self.bm.edges[from_edge_idx])
        to_vert1, to_vert2 = cm.vert_idxs_from_edge_idx(self.bm, to_edge_idx)
        roto_indices = [cl_vert, to_vert1, to_vert2]
        add_edges(self, roto_indices)

    # final refresh before returning to user.
    if earmarked:
        remove_earmarked_edges(self, earmarked)
    bmesh.update_edit_mesh(self.me, True)