Exemple #1
0
class Edge(object):
    """
    connects any two points
    """

    #tuple of points, and the instance index to which the edge is rooted
    points     = (None, None)
    transforms = ((0,0), (0,0))  #transform relative to root domain, which define the root edge

    curve      = None           #subdivision curve; this should really be here. controlpoints are part of datamodel. cmputation and caching should be handled by the editor
    color      = (0,0,0)        #for giggles
    boundary   = True
    driving    = True           #driving edges enforce their radius on the relief
    width      = 0.01           #smoothing width to apply to get stencil

    def __init__(self, points, transforms = ((0,0), (0,0))):
        self.points     = points
        self.transforms = transforms
        self.curve      = Curve(self)

    def basis(self):
        """return start, end and orientation vectors for each edge"""
        L, R = [p.instantiate_offset(self.group.permute_forward(p.transform, t))
                    for p,t in zip(self.points, self.transforms)]

        o = np.array([+1,-1])[:len(L)]
        S = np.cross(L, R) * o[:, None, None]
        return L, R, S

    def instantiate(self):
        """"returns actual curve data by subdivision?"""
        #this is a hack... find better way to propagate point radii
        self.curve.radius[0] = self.points[1].radius
        self.curve.radius[-1] = self.points[0].radius
        return self.curve.curve()
    def instantiate_cp(self):
        """"returns actual curve data by subdivision?"""
        #this is a hack...
        self.curve.radius[0] = self.points[1].radius
        self.curve.radius[-1] = self.points[0].radius
        return self.curve.controlpoints()

    @property
    def group(self):
        return self.points[0].group
    @property
    def datamodel(self):
        return self.points[0].datamodel
Exemple #2
0
 def __init__(self, points, transforms = ((0,0), (0,0))):
     self.points     = points
     self.transforms = transforms
     self.curve      = Curve(self)