示例#1
0
    def refineknotvector(self, XI, knotvec_choice):
        """Insert the knots contained in XI into U or V"""
        XI = np.asarray(XI, np.float).reshape(-1, )
        if knotvec_choice == 'U':
            if np.min(XI) <= np.min(self.U):
                raise "Knots cannot be inserted: some elements too small"
            if np.max(XI) >= np.max(self.U):
                raise "Knots cannot be inserted: some elements too large"
            if np.any([
                    np.equal(xi, self.U).sum() + np.equal(xi, XI).sum() >
                    self.p for xi in np.unique(XI)
            ]):
                raise "Knots cannot be inserted: some multiplicities too large"
            self.U, self.V, self.Pw = NURBSinC.RefineKnotVectSurface(
                self.n, self.p, self.U, self.m, self.q, self.V, self.Pw, XI, 0)
            self.r = self.U.shape[0] - 1
            self.n = self.r - self.p - 1
            self.pspans = np.unique(self.U)

        if knotvec_choice == 'V':
            if np.min(XI) <= np.min(self.V):
                raise "Knots cannot be inserted: some elements too small"
            if np.max(XI) >= np.max(self.V):
                raise "Knots cannot be inserted: some elements too large"
            if np.any([
                    np.equal(xi, self.V).sum() + np.equal(xi, XI).sum() >
                    self.q for xi in np.unique(XI)
            ]):
                raise "Knots cannot be inserted: some multiplicities too large"
            self.V, self.U, self.Pw = NURBSinC.RefineKnotVectSurface(
                self.m, self.q, self.V, self.n, self.p, self.U,
                np.transpose(self.Pw, (1, 0, 2)), XI, 0)
            self.Pw = np.transpose(self.Pw, (1, 0, 2))

            self.s = self.V.shape[0] - 1
            self.m = self.s - self.q - 1
            self.qspans = np.unique(self.V)

        self.P = (self.Pw[:, :, :3].T / self.Pw[:, :, 3].T).T
        self.w = self.Pw[:, :, 3]