Skip to content

Commit 2eeff28

Browse files
committed
refactor(viewer): rename control_vertices to cp_vertices
1 parent e86ab60 commit 2eeff28

3 files changed

Lines changed: 41 additions & 23 deletions

File tree

bot/view/scene.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ def apply_patch(self, payload: ScenePayload) -> None:
278278
curve.apply_geometry_bytes(
279279
geometry["curve_vertices"], delta["vertex_count"]
280280
)
281-
control_vertices = geometry.get("control_vertices")
282-
if control_vertices is not None and delta.get("cp_count"):
283-
curve.apply_control_vertices_bytes(control_vertices, delta["cp_count"])
281+
cp_vertices = geometry.get("cp_vertices")
282+
if cp_vertices is not None and delta.get("cp_count"):
283+
curve.apply_control_vertices_bytes(cp_vertices, delta["cp_count"])
284284

285285
def remove_curves(self, tags: list[str]) -> None:
286286
"""Remove curves identified by namespaced tags."""

bot/viewer/contracts.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,51 @@ class ViewEventType(IntEnum):
8080
class CurveGeometry(TypedDict):
8181
"""Binary geometry channels for a single curve."""
8282

83-
curve_vertices: bytes
84-
control_vertices: NotRequired[bytes]
83+
curve_vertices: bytes # Flat float32 byte array of xyz coordinates for the evaluated curve points.
84+
cp_vertices: NotRequired[
85+
bytes
86+
] # Flat float32 byte array of xyz coordinates for the control points.
8587

8688

8789
class CurveDelta(TypedDict):
8890
"""Per-curve render delta sent over the IPC pipe."""
8991

90-
type: Literal["linear", BEZIER_TYP, NURBS_TYP]
91-
geometry: CurveGeometry
92-
vertex_count: int
93-
edges: list[tuple[int, int]] | None
92+
type: Literal["linear", BEZIER_TYP, NURBS_TYP] # Mathematical type of the curve.
93+
geometry: (
94+
CurveGeometry # The binary vertex data for the curve and its control points.
95+
)
96+
vertex_count: int # Number of 3D vertices encoded in `geometry["curve_vertices"]`.
97+
edges: (
98+
list[tuple[int, int]] | None
99+
) # Point connectivity indices (idx_a, idx_b) to form line segments.
94100

95-
degree: NotRequired[int]
96-
cp_count: NotRequired[int]
101+
degree: NotRequired[
102+
int
103+
] # Mathematical degree of the spline (e.g., 3 for cubic Bézier/NURBS).
104+
cp_count: NotRequired[
105+
int
106+
] # Number of 3D control points encoded in `geometry["cp_vertices"]`.
97107

98108

99109
class ScenePayload(TypedDict):
100110
"""Universal exchange format for incremental scene updates."""
101111

102-
op: SceneUpdateOp
103-
changed_curves: dict[str, CurveDelta]
104-
deleted_curves: NotRequired[list[str]]
105-
bounds: NotRequired[dict[str, Any]]
106-
points: NotRequired[bytes]
107-
edges: NotRequired[list[tuple[int, int, str]]]
112+
op: SceneUpdateOp # The type of operation (ADD, UPDATE, or DELETE).
113+
changed_curves: dict[
114+
str, CurveDelta
115+
] # Mapping of namespaced curve tags (e.g., "cad:1") to their update delta.
116+
deleted_curves: NotRequired[
117+
list[str]
118+
] # List of namespaced tags for curves that should be removed.
119+
bounds: NotRequired[
120+
dict[str, Any]
121+
] # Global scene bounding box dimensions (min, max, center, size).
122+
points: NotRequired[
123+
bytes
124+
] # Flat float32 byte array of xyz coordinates for all CAD nodes (load-only).
125+
edges: NotRequired[
126+
list[tuple[int, int, str]]
127+
] # Flat list of all scene edges (idx_a, idx_b, tag) (load-only).
108128

109129

110130
class EventHover(TypedDict):

bot/viewer/serialize.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def pack_curve_geometry(
3838
"""Build a CurveGeometry dict with float32 byte channels."""
3939
geometry: CurveGeometry = {"curve_vertices": floats_to_bytes(curve_points)}
4040
if control_points is not None and len(control_points) > 0:
41-
geometry["control_vertices"] = floats_to_bytes(control_points)
41+
geometry["cp_vertices"] = floats_to_bytes(control_points)
4242
return geometry
4343

4444

@@ -120,11 +120,9 @@ def curve_delta_to_curve_info(tag: str, delta: CurveDelta) -> dict[str, Any]:
120120
"edges": edges,
121121
"type": delta["type"],
122122
}
123-
control_vertices = delta["geometry"].get("control_vertices")
124-
if control_vertices is not None and delta.get("cp_count"):
125-
info["control_points"] = bytes_to_point_list(
126-
control_vertices, delta["cp_count"]
127-
)
123+
cp_vertices = delta["geometry"].get("cp_vertices")
124+
if cp_vertices is not None and delta.get("cp_count"):
125+
info["control_points"] = bytes_to_point_list(cp_vertices, delta["cp_count"])
128126
if "degree" in delta:
129127
info["degree"] = delta["degree"]
130128
return info

0 commit comments

Comments
 (0)