Example #1
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        surface_s = self.inputs['Surface'].sv_get()
        value_s = self.inputs['Value'].sv_get()

        if isinstance(surface_s[0], SvSurface):
            surface_s = [surface_s]
        value_s = ensure_nesting_level(value_s, 2)

        u_curves_out = []
        v_curves_out = []
        for surfaces, values in zip_long_repeat(surface_s, value_s):
            new_u_curves = []
            new_v_curves = []
            for surface, value in zip_long_repeat(surfaces, values):
                u_curve = SvIsoUvCurve.take(surface, 'V', value)
                v_curve = SvIsoUvCurve.take(surface, 'U', value)
                new_u_curves.append(u_curve)
                new_v_curves.append(v_curve)

            if self.join:
                u_curves_out.extend(new_u_curves)
                v_curves_out.extend(new_v_curves)
            else:
                u_curves_out.append(new_u_curves)
                v_curves_out.append(new_v_curves)

        self.outputs['UCurve'].sv_set(u_curves_out)
        self.outputs['VCurve'].sv_set(v_curves_out)
Example #2
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        surface_s = self.inputs['Surface'].sv_get()
        if isinstance(surface_s[0], SvSurface):
            surface_s = [surface_s]

        curves_out = []
        for surfaces in surface_s:
            for surface in surfaces:
                u_min, u_max = surface.get_u_min(), surface.get_u_max()
                v_min, v_max = surface.get_v_min(), surface.get_v_max()
                if self.cyclic_mode == 'NO':
                    curve1 = SvIsoUvCurve.take(surface, 'V', v_min, flip=False)
                    curve2 = SvIsoUvCurve.take(surface, 'U', u_max, flip=False)
                    curve3 = SvIsoUvCurve.take(surface, 'V', v_max, flip=True)
                    curve4 = SvIsoUvCurve.take(surface, 'U', u_min, flip=True)
                    if self.concatenate:
                        sorted_curves = sort_curves_for_concat([curve1, curve2, curve3, curve4], allow_flip=True).curves
                        new_curves = [concatenate_curves(sorted_curves)]
                    else:
                        new_curves = [curve1, curve2, curve3, curve4]
                elif self.cyclic_mode == 'U':
                    curve1 = SvIsoUvCurve.take(surface, 'V', v_max, flip=False)
                    curve2 = SvIsoUvCurve.take(surface, 'V', v_min, flip=False)
                    new_curves = [curve1, curve2]
                elif self.cyclic_mode == 'V':
                    curve1 = SvIsoUvCurve.take(surface, 'U', u_max, flip=False)
                    curve2 = SvIsoUvCurve.take(surface, 'U', u_min, flip=False)
                    new_curves = [curve1, curve2]
                else:
                    raise Exception("Unsupported mode")
                curves_out.append(new_curves)

        self.outputs['Boundary'].sv_set(curves_out)