Ejemplo n.º 1
0
    def elevate_degree(self, delta=None, target=None):
        if delta is None and target is None:
            delta = 1
        if delta is not None and target is not None:
            raise Exception(
                "Of delta and target, only one parameter can be specified")
        degree = self.get_degree()
        if delta is None:
            delta = target - degree
            if delta < 0:
                raise Exception(
                    f"Curve already has degree {degree}, which is greater than target {target}"
                )
        if delta == 0:
            return self

        if self.is_bezier():
            control_points = self.get_homogenous_control_points()
            control_points = elevate_bezier_degree(degree, control_points,
                                                   delta)
            control_points, weights = from_homogenous(control_points)
            knotvector = self.get_knotvector()
            knotvector = sv_knotvector.elevate_degree(knotvector, delta)
            return SvNurbsCurve.build(self.get_nurbs_implementation(),
                                      degree + delta, knotvector,
                                      control_points, weights)
        else:
            raise UnsupportedCurveTypeException(
                "Degree elevation is not implemented for non-bezier curves yet"
            )
Ejemplo n.º 2
0
 def elevate_degree(self, delta=1):
     if self.is_bezier():
         control_points = self.get_homogenous_control_points()
         degree = self.get_degree()
         control_points = elevate_bezier_degree(degree, control_points, delta)
         control_points, weights = from_homogenous(control_points)
         knotvector = self.get_knotvector()
         knotvector = sv_knotvector.elevate_degree(knotvector, delta)
         return SvNurbsCurve.build(self.get_nurbs_implementation(),
                 degree+delta, knotvector, control_points, weights)
     else:
         raise Exception("Not implemented yet!")
Ejemplo n.º 3
0
    def elevate_degree(self, delta=None, target=None):
        orig_delta, orig_target = delta, target
        if delta is None and target is None:
            delta = 1
        if delta is not None and target is not None:
            raise Exception(
                "Of delta and target, only one parameter can be specified")
        degree = self.get_degree()
        if delta is None:
            delta = target - degree
            if delta < 0:
                raise Exception(
                    f"Curve already has degree {degree}, which is greater than target {target}"
                )
        if delta == 0:
            return self

        if self.is_bezier():
            control_points = self.get_homogenous_control_points()
            control_points = elevate_bezier_degree(degree, control_points,
                                                   delta)
            control_points, weights = from_homogenous(control_points)
            knotvector = self.get_knotvector()
            knotvector = sv_knotvector.elevate_degree(knotvector, delta)
            return SvNurbsCurve.build(self.get_nurbs_implementation(),
                                      degree + delta, knotvector,
                                      control_points, weights)
        else:
            src_t_min, src_t_max = self.get_u_bounds()
            segments = self.to_bezier_segments(to_bezier_class=False)
            segments = [
                segment.elevate_degree(orig_delta, orig_target)
                for segment in segments
            ]
            result = segments[0]
            for segment in segments[1:]:
                result = result.concatenate(segment)
            result = result.reparametrize(src_t_min, src_t_max)
            return result
Ejemplo n.º 4
0
 def test_elevate_knotvector(self):
     kv = np.array([0, 0, 0, 1, 1, 1], dtype=np.float64)
     result = sv_knotvector.elevate_degree(kv)
     expected = np.array([0, 0, 0, 0, 1, 1, 1, 1])
     self.assert_numpy_arrays_equal(result, expected, precision=8)