def process(self): if not any(socket.is_linked for socket in self.outputs): return center_s = self.inputs['Center'].sv_get(default=[Matrix()]) radius_s = self.inputs['Radius'].sv_get() t_min_s = self.inputs['TMin'].sv_get() t_max_s = self.inputs['TMax'].sv_get() radius_s = ensure_nesting_level(radius_s, 2) t_min_s = ensure_nesting_level(t_min_s, 2) t_max_s = ensure_nesting_level(t_max_s, 2) center_s = ensure_nesting_level(center_s, 2, data_types=(Matrix, )) curves_out = [] for centers, radiuses, t_mins, t_maxs in zip_long_repeat( center_s, radius_s, t_min_s, t_max_s): for center, radius, t_min, t_max in zip_long_repeat( centers, radiuses, t_mins, t_maxs): au = self.radians_conversion_factor() t_min, t_max = t_min * au, t_max * au curve = SvCircle(matrix=center, radius=radius) curve.u_bounds = (t_min, t_max) curves_out.append(curve) self.outputs['Curve'].sv_set(curves_out)
def process(self): if not any(s.is_linked for s in self.outputs): return params_in = [s.sv_get(deepcopy=False) for s in self.inputs[:4]] params_in.append(self.inputs['Fill / Stroke'].sv_get(deepcopy=False, default=[[None]])) get_curves = self.outputs['Curves'].is_linked shapes_out = [] curves_out = [] for params in zip(*mlr(params_in)): shapes = [] for loc, rad_x, rad_y, angle, atts in zip(*mlr(params)): shapes.append(SvgCircle(rad_x, rad_y, loc, angle, atts)) if get_curves: center = curve_matrix(loc, angle, rad_x, rad_y) curve = SvCircle(center, rad_x) curve.u_bounds = (0, 2 * pi) curves_out.append(curve) if self.ungroup: shapes_out.extend(shapes) else: shapes_out.append(SvgGroup(shapes)) self.outputs[0].sv_set(shapes_out) self.outputs[1].sv_set(curves_out)
def process(self): if not any(socket.is_linked for socket in self.outputs): return center_s = self.inputs['Center'].sv_get(default=[Matrix()]) radius_s = self.inputs['Radius'].sv_get() t_min_s = self.inputs['TMin'].sv_get() t_max_s = self.inputs['TMax'].sv_get() n_points_s = self.inputs['NPoints'].sv_get() radius_s = ensure_nesting_level(radius_s, 2) t_min_s = ensure_nesting_level(t_min_s, 2) t_max_s = ensure_nesting_level(t_max_s, 2) n_points_s = ensure_nesting_level(n_points_s, 2) center_s = ensure_nesting_level(center_s, 2, data_types=(Matrix, )) curves_out = [] for params in zip_long_repeat(center_s, radius_s, t_min_s, t_max_s, n_points_s): for center, radius, t_min, t_max, n_points in zip_long_repeat( *params): au = self.radians_conversion_factor() t_min, t_max = t_min * au, t_max * au curve = SvCircle(matrix=center, radius=radius) if self.curve_mode == 'GENERIC': curve.u_bounds = (t_min, t_max) else: curve = curve.to_nurbs_arc(n=n_points, t_min=t_min, t_max=t_max) curves_out.append(curve) self.outputs['Curve'].sv_set(curves_out)
def process(self): if not any(socket.is_linked for socket in self.outputs): return point1_s = self.inputs['Point1'].sv_get() point2_s = self.inputs['Point2'].sv_get() point3_s = self.inputs['Point3'].sv_get() point1_s = ensure_nesting_level(point1_s, 3) point2_s = ensure_nesting_level(point2_s, 3) point3_s = ensure_nesting_level(point3_s, 3) arcs_out = [] circles_out = [] centers_out = [] radius_out = [] angle_out = [] for point1s, point2s, point3s in zip_long_repeat( point1_s, point2_s, point3_s): arcs_new = [] circles_new = [] centers_new = [] radius_new = [] angle_new = [] for point1, point2, point3 in zip_long_repeat( point1s, point2s, point3s): circle_data = circle_by_three_points(point1, point2, point3) if circle_data is None: raise Exception( "Can't build a circle by these points: {}, {}, {}". format(point1, point2, point3)) matrix = circle_data.get_matrix() circle = SvCircle(matrix, circle_data.radius) arc = SvCircle(matrix, circle_data.radius) arc.u_bounds = (0.0, circle_data.arc_angle) arcs_new.append(arc) circles_new.append(circle) centers_new.append(matrix) radius_new.append(circle_data.radius) angle_new.append(circle_data.arc_angle) if self.join: arcs_out.extend(arcs_new) circles_out.extend(circles_new) centers_out.extend(centers_new) radius_out.extend(radius_new) angle_out.extend(angle_new) else: arcs_out.append(arcs_new) circles_out.append(circles_new) centers_out.append(centers_new) radius_out.append(radius_new) angle_out.append(angle_new) self.outputs['Arc'].sv_set(arcs_out) self.outputs['Circle'].sv_set(circles_out) self.outputs['Center'].sv_set(centers_out) self.outputs['Radius'].sv_set(radius_out) self.outputs['Angle'].sv_set(angle_out)
def get_curve(self): center = np.array(self.center) normal = np.array(self.normal) p1 = np.array(self.p1) circle = SvCircle(center=center, normal=-normal, vectorx=p1 - center) circle.u_bounds = (0.0, self.angle) #circle.u_bounds = (-self.angle, 0.0) return circle
def process(self): if not any(socket.is_linked for socket in self.outputs): return start_s = self.inputs['Start'].sv_get() end_s = self.inputs['End'].sv_get() tangent_s = self.inputs['Tangent'].sv_get() start_s = ensure_nesting_level(start_s, 3) end_s = ensure_nesting_level(end_s, 3) tangent_s = ensure_nesting_level(tangent_s, 3) arcs_out = [] circles_out = [] centers_out = [] radius_out = [] angle_out = [] for starts, ends, tangents in zip_long_repeat(start_s, end_s, tangent_s): arcs_new = [] circles_new = [] centers_new = [] radius_new = [] angle_new = [] for start, end, tangent in zip_long_repeat(starts, ends, tangents): circle_data = circle_by_start_end_tangent(start, end, tangent) if circle_data is None: raise Exception("Can't build a circle") matrix = circle_data.get_matrix() circle = SvCircle(matrix, circle_data.radius) arc = SvCircle(matrix, circle_data.radius) arc.u_bounds = (0.0, circle_data.arc_angle) arcs_new.append(arc) circles_new.append(circle) centers_new.append(matrix) radius_new.append(circle_data.radius) angle_new.append(circle_data.arc_angle) if self.join: arcs_out.extend(arcs_new) circles_out.extend(circles_new) centers_out.extend(centers_new) radius_out.extend(radius_new) angle_out.extend(angle_new) else: arcs_out.append(arcs_new) circles_out.append(circles_new) centers_out.append(centers_new) radius_out.append(radius_new) angle_out.append(angle_new) self.outputs['Arc'].sv_set(arcs_out) self.outputs['Circle'].sv_set(circles_out) self.outputs['Center'].sv_set(centers_out) self.outputs['Radius'].sv_set(radius_out) self.outputs['Angle'].sv_set(angle_out)
def get_curve(self): circle = SvCircle(self.matrix, self.radius) circle.u_bounds = (0.0, self.angle) #circle.u_bounds = (-self.angle, 0.0) return circle
def make_arc(center, radius, angle): matrix = Matrix.Translation(center) @ Matrix.Rotation( angle, 4, 'Z') circle = SvCircle(matrix, radius) circle.u_bounds = (0, pi / 2) return circle