Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add M20 two-body boolean workflow UI and diagnostics

Yuechen Li91c72a931279
diff --git a/aetheris.client/src/App.css b/aetheris.client/src/App.css
index 8e27331b..8bc5293b 100644
--- a/aetheris.client/src/App.css
+++ b/aetheris.client/src/App.css
@@ -85,6 +85,22 @@ input {
background: #020617;
}
+select {
+ border-radius: 4px;
+ border: 1px solid #334155;
+ padding: 0.3rem 0.4rem;
+ color: #e2e8f0;
+ background: #020617;
+}
+
+.boolean-grid {
+ grid-template-columns: 1fr;
+}
+
+.boolean-actions {
+ margin-bottom: 0.5rem;
+}
+
button {
border-radius: 6px;
border: 1px solid #334155;
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index a1aead0f..66eeb24d 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -4,10 +4,12 @@ import {
ApiError,
createBox,
createDocument,
+ executeBoolean,
getDocumentSummary,
pickBody,
tessellateBody,
translateBody,
+ type BooleanOperation,
type DiagnosticDto,
type PickHitDto,
type TessellationResponseDto,
@@ -16,6 +18,13 @@ import { ViewerViewport } from './viewer/ViewerViewport';
import { mapTessellationToRenderData } from './viewer/tessellationMapper';
type RequestStatus = 'idle' | 'loading' | 'success' | 'error';
+type BooleanOperationUi = 'Union' | 'Subtract' | 'Intersect';
+
+const BOOLEAN_OP_TO_API: Record<BooleanOperationUi, BooleanOperation> = {
+ Union: 'union',
+ Subtract: 'subtract',
+ Intersect: 'intersect',
+};
function App() {
const [documentId, setDocumentId] = useState<string | null>(null);
@@ -35,6 +44,9 @@ function App() {
const [tx, setTx] = useState('0');
const [ty, setTy] = useState('0');
const [tz, setTz] = useState('0');
+ const [booleanTargetBodyId, setBooleanTargetBodyId] = useState<string>('');
+ const [booleanToolBodyId, setBooleanToolBodyId] = useState<string>('');
+ const [booleanOperation, setBooleanOperation] = useState<BooleanOperationUi>('Union');
const runAction = useCallback(async (actionName: string, action: () => Promise<void>) => {
setStatus('loading');
@@ -85,6 +97,9 @@ function App() {
setPickMessage('Click in the viewport to run nearest-hit pick.');
setPickDiagnostics([]);
setPickHits([]);
+ setBooleanTargetBodyId('');
+ setBooleanToolBodyId('');
+ setBooleanOperation('Union');
});
}, [runAction]);
@@ -165,6 +180,54 @@ function App() {
});
}, [activeBodyId, documentId, runAction]);
+ const handleUseActiveBodyAsTarget = useCallback(() => {
+ if (activeBodyId) {
+ setBooleanTargetBodyId(activeBodyId);
+ }
+ }, [activeBodyId]);
+
+ const handleUseActiveBodyAsTool = useCallback(() => {
+ if (activeBodyId) {
+ setBooleanToolBodyId(activeBodyId);
+ }
+ }, [activeBodyId]);
+
+ const handleExecuteBoolean = useCallback(async () => {
+ if (!documentId) {
+ return;
+ }
+
+ if (!booleanTargetBodyId || !booleanToolBodyId) {
+ setStatus('error');
+ setStatusMessage('Boolean operation requires both target and tool bodies.');
+ setDiagnostics([]);
+ return;
+ }
+
+ if (booleanTargetBodyId === booleanToolBodyId) {
+ setStatus('error');
+ setStatusMessage('Boolean target and tool must be different bodies.');
+ setDiagnostics([]);
+ return;
+ }
+
+ await runAction(`Boolean ${booleanOperation}`, async () => {
+ const result = await executeBoolean(documentId, {
+ leftBodyId: booleanTargetBodyId,
+ rightBodyId: booleanToolBodyId,
+ operation: BOOLEAN_OP_TO_API[booleanOperation],
+ });
+
+ await refreshSummaryAndActiveTessellation(result.bodyId);
+ setBooleanTargetBodyId(result.bodyId);
+ setPickStatus('idle');
+ setPickMessage(`Boolean ${booleanOperation} succeeded. Result body ${result.bodyId} is now active.`);
+ setPickDiagnostics([]);
+ setPickHits([]);
+ setStatusMessage(`Boolean ${booleanOperation} succeeded: target ${booleanTargetBodyId}, tool ${booleanToolBodyId}, result ${result.bodyId}.`);
+ });
+ }, [booleanOperation, booleanTargetBodyId, booleanToolBodyId, documentId, refreshSummaryAndActiveTessellation, runAction]);
+
const handlePickRay = useCallback(async (origin: { x: number; y: number; z: number }, direction: { x: number; y: number; z: number }) => {
if (!documentId || !activeBodyId) {
setPickStatus('error');
@@ -208,11 +271,18 @@ function App() {
const nearestHit = pickHits[0] ?? null;
const highlightedFaceId = nearestHit?.entityKind === 'Face' ? nearestHit.faceId : null;
const highlightedEdgeId = nearestHit?.entityKind === 'Edge' ? nearestHit.edgeId : null;
+ const canExecuteBoolean = Boolean(
+ documentId
+ && bodyIds.length >= 2
+ && booleanTargetBodyId
+ && booleanToolBodyId
+ && booleanTargetBodyId !== booleanToolBodyId
+ && status !== 'loading');
return (
<div className="app-shell">
<header className="toolbar">
- <h1>Aetheris Basic Modeling UI (M19)</h1>
+ <h1>Aetheris Modeling UI (M20)</h1>
<div className="toolbar-actions">
<button type="button" onClick={() => void handleCreateDocument()} disabled={status === 'loading'}>
Create Document
@@ -271,6 +341,43 @@ function App() {
<button type="button" onClick={() => void handleApplyTranslation()} disabled={!activeBodyId || status === 'loading'}>Apply Translation</button>
</section>
+ <section>
+ <h3>Boolean (Two-Body)</h3>
+ <div className="form-grid boolean-grid">
+ <label>
+ Target Body
+ <select value={booleanTargetBodyId} onChange={(event) => setBooleanTargetBodyId(event.target.value)}>
+ <option value="">Select target body</option>
+ {bodyIds.map((bodyId) => <option key={`target-${bodyId}`} value={bodyId}>{bodyId}</option>)}
+ </select>
+ </label>
+ <label>
+ Tool Body
+ <select value={booleanToolBodyId} onChange={(event) => setBooleanToolBodyId(event.target.value)}>
+ <option value="">Select tool body</option>
+ {bodyIds.map((bodyId) => <option key={`tool-${bodyId}`} value={bodyId}>{bodyId}</option>)}
+ </select>
+ </label>
+ <label>
+ Operation
+ <select value={booleanOperation} onChange={(event) => setBooleanOperation(event.target.value as BooleanOperationUi)}>
+ <option value="Union">Union</option>
+ <option value="Subtract">Subtract</option>
+ <option value="Intersect">Intersect</option>
+ </select>
+ </label>
+ </div>
+ <div className="toolbar-actions boolean-actions">
+ <button type="button" onClick={handleUseActiveBodyAsTarget} disabled={!activeBodyId || status === 'loading'}>Use Active as Target</button>
+ <button type="button" onClick={handleUseActiveBodyAsTool} disabled={!activeBodyId || status === 'loading'}>Use Active as Tool</button>
+ </div>
+ <button type="button" onClick={() => void handleExecuteBoolean()} disabled={!canExecuteBoolean}>Execute Boolean</button>
+ {bodyIds.length < 2 ? <p>Need at least 2 bodies to run a boolean.</p> : null}
+ {booleanTargetBodyId && booleanToolBodyId && booleanTargetBodyId === booleanToolBodyId ? (
+ <p>Target and tool must be different body IDs.</p>
+ ) : null}
+ </section>
+
<h2>Debug / Status</h2>
<p><strong>Request status:</strong> {status}</p>
<p><strong>Message:</strong> {statusMessage}</p>
diff --git a/aetheris.client/src/__tests__/aetherisApi.test.ts b/aetheris.client/src/__tests__/aetherisApi.test.ts
index f2eb82bb..43ff55bc 100644
--- a/aetheris.client/src/__tests__/aetherisApi.test.ts
+++ b/aetheris.client/src/__tests__/aetherisApi.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { ApiError, parseEnvelope, pickBody, translateBody } from '../api/aetherisApi';
+import { ApiError, executeBoolean, parseEnvelope, pickBody, translateBody } from '../api/aetherisApi';
describe('parseEnvelope', () => {
it('returns data when envelope success is true', async () => {
@@ -96,3 +96,58 @@ describe('translateBody', () => {
expect(response.appliedTranslation.z).toBe(3);
});
});
+
+describe('executeBoolean', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it('posts boolean payload with v1 envelope handling', async () => {
+ const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({
+ success: true,
+ data: {
+ documentId: 'doc-1',
+ bodyId: 'result-body-1',
+ faceCount: 6,
+ edgeCount: 12,
+ vertexCount: 8,
+ },
+ diagnostics: [],
+ }), { status: 200 }));
+ vi.stubGlobal('fetch', fetchMock);
+
+ const response = await executeBoolean('doc-1', {
+ leftBodyId: 'body-a',
+ rightBodyId: 'body-b',
+ operation: 'union',
+ });
+
+ expect(fetchMock).toHaveBeenCalledWith('/api/v1/documents/doc-1/operations/boolean', expect.objectContaining({ method: 'POST' }));
+ expect(response.bodyId).toBe('result-body-1');
+ });
+
+ it('surfaces unsupported diagnostics from envelope failures', async () => {
+ const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({
+ success: false,
+ data: null,
+ diagnostics: [{
+ code: 'NotImplemented',
+ severity: 'Error',
+ message: 'Boolean operation not yet implemented for non-box input.',
+ source: 'operations.boolean',
+ }],
+ }), { status: 501 }));
+ vi.stubGlobal('fetch', fetchMock);
+
+ await expect(executeBoolean('doc-1', {
+ leftBodyId: 'body-a',
+ rightBodyId: 'body-b',
+ operation: 'intersect',
+ })).rejects.toEqual(new ApiError('Boolean operation not yet implemented for non-box input.', [{
+ code: 'NotImplemented',
+ severity: 'Error',
+ message: 'Boolean operation not yet implemented for non-box input.',
+ source: 'operations.boolean',
+ }]));
+ });
+});
diff --git a/aetheris.client/src/api/aetherisApi.ts b/aetheris.client/src/api/aetherisApi.ts
index 599550f6..db6139e4 100644
--- a/aetheris.client/src/api/aetherisApi.ts
+++ b/aetheris.client/src/api/aetherisApi.ts
@@ -38,6 +38,14 @@ export interface BodyTransformedResponseDto {
appliedTranslation: Vector3Dto;
}
+export type BooleanOperation = 'union' | 'subtract' | 'intersect';
+
+export interface BooleanRequestDto {
+ leftBodyId: string;
+ rightBodyId: string;
+ operation: BooleanOperation;
+}
+
export interface Point3Dto {
x: number;
y: number;
@@ -180,4 +188,11 @@ export async function translateBody(documentId: string, bodyId: string, translat
});
}
+export async function executeBoolean(documentId: string, requestDto: BooleanRequestDto): Promise<BodyCreatedResponseDto> {
+ return request<BodyCreatedResponseDto>(`/api/v1/documents/${documentId}/operations/boolean`, {
+ method: 'POST',
+ body: JSON.stringify(requestDto),
+ });
+}
+
export { parseEnvelope };
diff --git a/docs/milestones.md b/docs/milestones.md
index 73da9e19..4c0febdc 100644
--- a/docs/milestones.md
+++ b/docs/milestones.md
@@ -179,3 +179,13 @@
- [x] Add minimal backend transform route (`POST /api/v1/documents/{documentId}/bodies/{bodyId}/transform`) with typed DTOs and M17 envelope semantics.
- [x] Apply document-level body transforms to tessellation and picking responses so viewport updates and hit data stay in world space after translation.
- [x] Preserve M18/M18.5 debug visibility (active body, body count, pick status/hits/diagnostics, tessellation counts) while deferring booleans UI, gizmos, undo/redo, feature tree, and persistence to later milestones.
+
+
+## M20 — Boolean UI Workflow v1 (Two-Body Union/Subtract/Intersect)
+
+- [x] Add explicit React boolean controls for target body, tool body, operation (`Union`, `Subtract`, `Intersect`), and execute action in the modeling panel.
+- [x] Integrate `/api/v1/documents/{documentId}/operations/boolean` through typed client contracts and M17 envelope parsing (`parseEnvelope<T>` with deterministic `ApiError` diagnostics).
+- [x] Keep backend as source of truth for support limits: M13 narrow axis-aligned box/box subset is unchanged, and unsupported cases surface structured diagnostics (including `NotImplemented`) directly in the UI.
+- [x] Adopt deterministic success semantics aligned with current backend behavior: keep original bodies and add a new boolean result body, refresh document summary, auto-select/tessellate the returned result body, and intentionally clear pick highlight/hits after success.
+- [x] Preserve failure stability: on unsupported/error responses the previous viewport/tessellation state is preserved while status/diagnostics update for observability.
+- [x] Defer boolean previews, feature history, undo/redo, gizmo-based selection, advanced naming/metadata workflows, and generalized boolean support beyond M13.