Add ocs_doc_api: object-oriented CAD entity API (v2)

New crate crates/ocs_doc_api: object-centric facade (DocApi -> Document ->
collections -> typed handles), transport-agnostic wire layer (DocApiEnvelope =
single op | read-only query batch), per-op autocommit (no write transactions),
bulk ops with upfront-validation all-or-nothing, structured ApiError, and
build-time codegen (spec/entities.toml -> ops/query enums, api_reference.md,
binding_schema.json).

ocs_plugin_api: append-only PluginRequest::DocApiRequest / PluginResponse::
DocApiResponse (serde_bytes payload) + defaulted HostApi::doc_api_dispatch.

Host: DocApiBackend impl for HostSession (src/app/doc_api.rs) mapping to scene
primitives (solid_models lift-on-miss, register_prepared_solid_model, meshes
metrics), entity conversions (doc_api_convert.rs), HostSession accessors +
doc_api_dispatch override.

Tests: 592 host lib (incl. 7 DocApi integration tests: create/boolean/query,
unknown-id, transform-many all-or-nothing, query-batch cap, 2D/geometric/DWG
roundtrips), 8 crate unit tests. Examples + README/ARCHITECTURE/IMPLEMENTATION docs.
This commit is contained in:
Sebastian committed 2026-09-06 00:15:27 +02:00
1 parent 9129c85f97
commit e41086b058
44 files changed
+4837 -12

No files matched your search

@@ -0,0 +1,210 @@
{
"envelope_version": 1,
"families": [
{
"acadrust_variant": "Solid3D",
"collection": "solids",
"handle": "Solid",
"methods": [
{
"args": [
{
"name": "other",
"ty": "Solid"
}
],
"bulk": false,
"fixed": {
"erase_sources": true,
"op": "Intersection"
},
"kind": "op",
"name": "intersect",
"op": "SolidBoolean",
"query": null,
"read_only": false,
"returns": "Solid"
},
{
"args": [
{
"name": "other",
"ty": "Solid"
}
],
"bulk": false,
"fixed": {
"erase_sources": true,
"op": "Union"
},
"kind": "op",
"name": "union",
"op": "SolidBoolean",
"query": null,
"read_only": false,
"returns": "Solid"
},
{
"args": [
{
"name": "other",
"ty": "Solid"
}
],
"bulk": false,
"fixed": {
"erase_sources": true,
"op": "Difference"
},
"kind": "op",
"name": "subtract",
"op": "SolidBoolean",
"query": null,
"read_only": false,
"returns": "Solid"
},
{
"args": [],
"bulk": false,
"fixed": null,
"kind": "query",
"name": "volume",
"op": null,
"query": "GetVolume",
"read_only": true,
"returns": "f64"
},
{
"args": [],
"bulk": false,
"fixed": null,
"kind": "query",
"name": "centroid",
"op": null,
"query": "GetCentroid",
"read_only": true,
"returns": "[f64; 3]"
},
{
"args": [
{
"name": "other",
"ty": "Solid"
}
],
"bulk": false,
"fixed": null,
"kind": "query",
"name": "intersects",
"op": null,
"query": "GetIntersects",
"read_only": true,
"returns": "bool"
}
],
"name": "Solid"
},
{
"acadrust_variant": "Line",
"collection": "curves",
"handle": "Line",
"methods": [],
"name": "Line"
},
{
"acadrust_variant": "Circle",
"collection": "curves",
"handle": "Circle",
"methods": [],
"name": "Circle"
},
{
"acadrust_variant": "LwPolyline",
"collection": "curves",
"handle": "Polyline",
"methods": [
{
"args": [
{
"name": "at",
"ty": "usize"
},
{
"name": "point",
"ty": "[f64; 3]"
}
],
"bulk": false,
"fixed": null,
"kind": "op",
"name": "add_vertex",
"op": "AddVertex",
"query": null,
"read_only": false,
"returns": "()"
}
],
"name": "Polyline"
},
{
"acadrust_variant": "Point",
"collection": "curves",
"handle": "Point",
"methods": [],
"name": "Point"
}
],
"layouts": {
"ObjectId": {
"struct": [
{
"name": "0",
"type": "u64"
}
]
},
"Operation": {
"enum": [
"CreateSolid(SolidPrimitive)",
"CreateCurve(Curve2Spec)",
"Extrude { profile: ObjectId, direction: [f64; 3] }",
"Revolve { profile: ObjectId, axis: ([f64; 3], [f64; 3]), angle: f64 }",
"Transform { id: ObjectId, placement: PlacementSpec }",
"SolidBoolean { op: BoolOp, a: ObjectId, b: ObjectId, erase_sources: bool }",
"AddVertex { id: ObjectId, at: usize, point: [f64; 3] }",
"Delete { id: ObjectId }",
"CreateMany(Vec<EntitySpec>)",
"TransformMany { ids: Vec<ObjectId>, placement: PlacementSpec }",
"DeleteMany(Vec<ObjectId>)"
]
},
"Query": {
"enum": [
"GetEntity { id: ObjectId }",
"GetBounds { id: ObjectId }",
"GetCentroid { id: ObjectId }",
"GetVolume { id: ObjectId }",
"GetIntersects { a: ObjectId, b: ObjectId }",
"GetGeometryRevision"
]
}
},
"object_model": {
"collections": [
"solids",
"curves",
"entities"
],
"document": "Document",
"handles": [
"Entity",
"Solid",
"Line",
"Circle",
"Polyline",
"Point"
],
"root": "DocApi"
},
"schema": "ocs_doc_api/binding_schema"
}