diff --git a/core/nodeslicer/nodes/base.sync-conflict-20261015-141227-M62EUDG.py b/core/nodeslicer/nodes/base.sync-conflict-20261015-141227-M62EUDG.py deleted file mode 100644 index f80b6e0..0000000 --- a/core/nodeslicer/nodes/base.sync-conflict-20261015-141227-M62EUDG.py +++ /dev/null @@ -1,238 +0,0 @@ -from __future__ import annotations -from typing import Any, TypeAlias -import bpy -import numpy as np - -from ..bpy_ns_types import NfEnumProperty, notify_tree_changed - -from ...slice import Pather, slice_at_range, SlicePaths -from ....infra.blender.blender_mesh_capture import SlicingCollection, SlicingObject, capture_mesh_edges, SlicingGroup -from ....infra.blender.blender_bridge import get_all_children -from ....infra.blender.blender_slice_nodes_generic import SliceNode, resolve_input - -class SliceIntrinsics: - bed_x: float - bed_y: float - feedrate: float - travel_feedrate: float - extrusion_rate: float - retraction: float - lift: float - retraction_feedrate: float - - def __init__(self, bed_x: float = 250.0, bed_y: float = 250.0, feedrate: float = 1200.0, travel_feedrate: float = 2400.0, extrusion_rate: float = 0.017, retraction: float = 0.0, lift: float = 0.0, retraction_feedrate: float = 0.0): - self.bed_x = bed_x - self.bed_y = bed_y - self.feedrate = feedrate - self.travel_feedrate = travel_feedrate - self.extrusion_rate = extrusion_rate - self.retraction = retraction - self.lift = lift - self.retraction_feedrate = retraction_feedrate - -class InputNode(SliceNode): - implicit_multivalue: bool = False - input_type: str = "" - socket_type: str = "" - - def __init_subclass__(cls, **kwargs): - super().__init_subclass__(**kwargs) - if "bl_label" not in cls.__dict__: cls.bl_label = cls.input_type - - def init(self, context) -> None: - stype = self.socket_type or (f"NodeSocket{self.bl_label}" if not self.bl_label.startswith("NodeSocket") else self.bl_label) - self.add_output(stype) - - def draw_buttons(self, context, layout): - assert layout - if self.outputs: - sock = self.outputs[0] - if hasattr(sock, "default_value"): - layout.prop(sock, "default_value", text="") - elif hasattr(sock, "value"): - layout.prop(sock, "value", text="") - - def evaluate_output(self, socket_name: str, **_kwargs): - out = self.outputs.get(socket_name) or (self.outputs[0] if self.outputs else None) - if out is None: return None - return getattr(out, "value", getattr(out, "default_value", None)) - -_MATH_OPS: dict[str, Any] = { - 'ADD': lambda a, b, t: a + b, - 'SUBTRACT': lambda a, b, t: a - b, - 'MULTIPLY': lambda a, b, t: a * b, - 'DIVIDE': lambda a, b, t: a / b if b != 0 else 0, - 'ABS': lambda a, b, t: abs(a), - 'NEGATE': lambda a, b, t: -a, - 'POWER': lambda a, b, t: t(a ** b) if not (a == 0 and b < 0) else 0, - 'MIN': lambda a, b, t: min(a, b), - 'MAX': lambda a, b, t: max(a, b), - 'SIGN': lambda a, b, t: (a > 0) - (a < 0), - 'DIVIDE_ROUND': lambda a, b, t: t(round(a / b)) if b != 0 else 0, - 'DIVIDE_FLOOR': lambda a, b, t: a // b if b != 0 else 0, - 'DIVIDE_TRUNCATE': lambda a, b, t: t(a / b) if b != 0 else 0, - 'MODULO_FLOORED': lambda a, b, t: a % b if b != 0 else 0, - 'MODULO_TRUNCATED': lambda a, b, t: a - (b * t(a / b)) if b != 0 else 0, -} - -class MathNode(SliceNode): - bl_label = "Float Math" - - operation: str = NfEnumProperty( - name="Operation", - items=[ - ('ADD', "Add", "Add the two values"), - ('SUBTRACT', "Subtract", "Subtract the second value from the first"), - ('MULTIPLY', "Multiply", "Multiply the two values"), - ('DIVIDE', "Divide", "Division"), - ('ABS', "Absolute", "Absolute value of the first value"), - ('NEGATE', "Negate", "Negate the first value"), - ('POWER', "Power", "First value raised to the power of the second"), - ('MIN', "Minimum", "The smaller of the two values"), - ('MAX', "Maximum", "The larger of the two values"), - ('SIGN', "Sign", "The sign of the first value (-1, 0, or 1)"), - ('DIVIDE_ROUND', "Divide Round", "Division rounded to the nearest integer"), - ('DIVIDE_FLOOR', "Divide Floor", "Division rounded down"), - ('DIVIDE_TRUNCATE', "Divide Truncate", "Division rounded towards zero"), - ('MODULO_FLOORED', "Floored Modulo", "Modulo using floor division"), - ('MODULO_TRUNCATED', "Truncated Modulo", "Modulo using truncated division"), - ], - default='ADD' - ) - - math_type: TypeAlias = float - socket_label: str = "Float" - socket_type: str = "NodeSocketFloat" - - def init(self, context): - self.add_output(self.socket_type, "Value") - - self.add_input(self.socket_type, "Value") - self.add_input(self.socket_type, "Value") - - def draw_buttons(self, context, layout): - assert layout - layout.prop(self, "operation", text="") - - def update(self) -> None: - super().update() - from ....infra.blender.list_utils import is_socket_linked_to_list, set_socket_shape - if self.inputs: - a_list = is_socket_linked_to_list(self.inputs[0]) - b_list = is_socket_linked_to_list(self.inputs[1]) if len(self.inputs) > 1 else False - set_socket_shape(self.inputs[0], "LIST" if a_list else "CIRCLE") - if len(self.inputs) > 1: - set_socket_shape(self.inputs[1], "LIST" if b_list else "CIRCLE") - if self.outputs: - set_socket_shape(self.outputs[0], "LIST" if (a_list or b_list) else "CIRCLE") - - def evaluate_output(self, socket_name: str, **_kwargs) -> Any: - t = self.math_type - inputs = getattr(self, "inputs", []) - a_raw = self.resolve(inputs[0] if len(inputs) > 0 else 0) - b_raw = self.resolve(inputs[1] if len(inputs) > 1 else 1) - - op_fn = _MATH_OPS.get(self.operation) - if not op_fn: - return 0 - - try: - a_num = t(a_raw if a_raw is not None else 0) - b_num = t(b_raw if b_raw is not None else 0) - return op_fn(a_num, b_num, t) - except Exception: - return 0 - -class SliceNodeJoiner(SliceNode): - implicit_multivalue: bool = False - socket_type: str = "" - output_socket_type: str = "" - socket_label: str = "" - - def init(self, context): - self.add_output(self.output_socket_type or self.socket_type, name=self.socket_label) - self.add_multi_socket_group(self.socket_type, name=self.socket_label) - - def update(self) -> None: - super().update() - from ....infra.blender.list_utils import is_socket_linked_to_list, set_socket_shape - for inp in self.inputs: - if getattr(inp, "name", "") == self.socket_label or getattr(inp, "identifier", "").startswith(f"{self.socket_label}_ms_in_"): - is_list = is_socket_linked_to_list(inp) - set_socket_shape(inp, "LIST" if is_list else "CIRCLE") - -class SliceNodeListJoiner(SliceNode): - implicit_multivalue: bool = False - socket_type: str = "" - output_socket_type: str = "" - socket_label: str = "" - output_socket_name: str = "" - is_list_output: bool = True - - def init(self, context): - self.add_output(self.output_socket_type or self.socket_type, name=self.output_socket_name or self.socket_label, display_shape='LIST') - self.add_multi_socket_group(self.socket_type, name=self.socket_label) - - def update(self) -> None: - super().update() - from ....infra.blender.list_utils import is_socket_linked_to_list, set_socket_shape - for inp in self.inputs: - if getattr(inp, "name", "") == self.socket_label or getattr(inp, "identifier", "").startswith(f"{self.socket_label}_ms_in_"): - is_list = is_socket_linked_to_list(inp) - set_socket_shape(inp, "LIST" if is_list else "CIRCLE") - - def evaluate_output(self, socket_name: str, **kwargs) -> list[Any]: - from ....infra.blender.list_utils import flatten_list, is_list_data - items: list[Any] = [] - - def _append_val(v: Any) -> None: - if v is not None: - if is_list_data(v): - items.extend(flatten_list(v)) - else: - items.append(v) - - target_inputs = [ - i for i in getattr(self, "inputs", []) - if getattr(i, "name", "") == self.socket_label or getattr(i, "identifier", "").startswith(f"{self.socket_label}_ms_in_") - ] - - if "resolve_multi_input" in self.__dict__ or not target_inputs: - for val in self.resolve_multi_input(self.socket_label): - _append_val(val) - return items - - cache = getattr(self, "_current_cache", None) - visited = getattr(self, "_current_visited", None) - from ....infra.blender.blender_slice_nodes_generic import resolve_input - - for inp in target_inputs: - if not getattr(inp, "is_linked", False): - val = getattr(inp, "value", None) - if val is None or val == "": - val = getattr(inp, "default_value", None) - if val is None or val == "": - continue - if type(val).__name__ == "SlicePaths" and len(val) == 0: - continue - else: - val = resolve_input(inp, cache=cache, visited=visited, fieldname=self.socket_label, node=self) - - _append_val(val) - - return items - -class ExecSliceNode(SliceNode): - button_label: str = 'Execute' - - def _init_exec(self): - self.add_output("SLICESOCK_ExecutionLink") - - def draw_buttons(self, context, layout): - assert layout - layout.operator("slicenode.execute", text=self.button_label).node_name = self.name - - def evaluate_output(self, socket_name: str, **_kwargs) -> Any: - if socket_name == "Execution Link": - return self - return None