summaryrefslogtreecommitdiff
path: root/inc/cad/topology.h
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2025-11-20 22:31:53 +0100
committerJesper Jensen <jesper@jnsn.dev>2025-11-20 22:31:53 +0100
commitacfa01613f6e7fbeace88a15df61252156d39cf1 (patch)
tree9d81120f36c1cd74dfe5d2691ccf55c8707cd394 /inc/cad/topology.h
parent6e4df49832827e21c6d62f722767664e5cb9d575 (diff)
Separate everything out
Diffstat (limited to 'inc/cad/topology.h')
-rw-r--r--inc/cad/topology.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/inc/cad/topology.h b/inc/cad/topology.h
new file mode 100644
index 0000000..b3879b2
--- /dev/null
+++ b/inc/cad/topology.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <stddef.h>
+
+#define TOPO_MOVETO(c) \
+ { .cmd = {TOPO_MOVETO} }, \
+ { .arg = {c} } \
+
+#define TOPO_LINETO(c) \
+ { .cmd = {TOPO_LINETO} }, \
+ { .arg = {c} } \
+
+#define TOPO_ARCTO(center, end) \
+ { .cmd = {TOPO_ARCTO} }, \
+ { .arg = {center} }, \
+ { .arg = {end} } \
+
+#define TOPO_END() \
+ { .cmd = {TOPO_END} } \
+
+enum topology_op {
+ TOPO_MOVETO,
+ TOPO_LINETO,
+ TOPO_ARCTO,
+
+ TOPO_END,
+};
+
+struct topology_cmd {
+ enum topology_op op;
+};
+
+struct topology_arg {
+ struct component *c;
+};
+
+struct topology_elem {
+ union {
+ struct topology_cmd cmd;
+ struct topology_arg arg;
+ };
+};
+
+struct topology {
+ struct topology_elem *elements;
+ size_t length;
+ size_t capacity;
+};
+
+void add_fragment(struct topology *topo, struct topology_elem *new);