コード例 #1
0
    def __init__(self, data, color=None, **kargs):
        from gui.drawable import saneColor

        Actor.__init__(self)
        self.object = data
        self.color = saneColor(color)
        self.samplingTolerance = 1.0
コード例 #2
0
    def __init__(self,control,knots=None,closed=False,order=0,color=black):
        Actor.__init__(self)
        self.closed = closed
        nctrl = len(control)
        
        if order <= 0:
            if knots is None:
                order = min(nctrl,3)
            else:
                order = len(knots) - nctrl
        if order <= 0:
            raise ValueError,"Length of knot vector (%s) must be larger than number of control points (%s)" % (len(knots),nctrl)

        if closed:
            if knots is None:
                nextra = order-1
            else:
                nextra = len(knots) - nctrl - order
                #print len(knots)
                #print nctrl
            print "extra %s" % nextra 
            control = Coords.concatenate([control[-nextra:],control])
            nctrl = len(control)
            #print nctrl

        if nctrl < order:
            raise ValueError,"Number of control points (%s) must not be smaller than order (%s)" % (nctrl,order)

        if knots is None:
            if closed:
                knots = unitRange(nctrl+order)
            else:
                knots = concatenate([[0.]*(order-1),unitRange(nctrl-order+2),[1.]*(order-1)])
        nknots = len(knots)                                                  
        if nknots != nctrl+order:
            
            raise ValueError,"Length of knot vector (%s) must be equal to number of control points (%s) plus order (%s)" % (nknots,nctrl,order)

        print "Nurbs curve of order %s with %s control points and %s knots" % (order,nctrl,nknots)

        self.control = control
        self.knots = knots
        self.order = order
        self.closed = closed
        self.samplingTolerance = 1.0
        self.color = color
        print self.control
        print self.knots