circuit-json-to-step 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ import { writeFileSync } from "node:fs"
2
+ import { test, expect } from "bun:test"
3
+ import { circuitJsonToStep } from "../../../lib/index"
4
+ import { importStepWithOcct } from "../../utils/occt/importer"
5
+ import circuitJson from "./basics04.json"
6
+
7
+ test("basics04: convert circuit json with components to STEP", async () => {
8
+ const stepText = await circuitJsonToStep(circuitJson as any, {
9
+ includeComponents: true,
10
+ includeExternalMeshes: true,
11
+ productName: "TestPCB_with_components",
12
+ })
13
+
14
+ // Verify STEP format
15
+ expect(stepText).toContain("ISO-10303-21")
16
+ expect(stepText).toContain("END-ISO-10303-21")
17
+
18
+ // Verify product structure
19
+ expect(stepText).toContain("TestPCB_with_components")
20
+ expect(stepText).toContain("MANIFOLD_SOLID_BREP")
21
+
22
+ // Verify holes are created
23
+ expect(stepText).toContain("CIRCLE")
24
+ expect(stepText).toContain("CYLINDRICAL_SURFACE")
25
+
26
+ // Verify we have multiple solids (board + components)
27
+ const solidCount = (stepText.match(/MANIFOLD_SOLID_BREP/g) || []).length
28
+ expect(solidCount).toBeGreaterThanOrEqual(1)
29
+
30
+ // Write STEP file to debug-output
31
+ const outputPath = "debug-output/basics04.step"
32
+ writeFileSync(outputPath, stepText)
33
+
34
+ console.log("✓ STEP file with components generated successfully")
35
+ console.log(` - Solids created: ${solidCount}`)
36
+ console.log(` - STEP text length: ${stepText.length} bytes`)
37
+ console.log(` - Output: ${outputPath}`)
38
+
39
+ // Validate STEP file can be imported with occt-import-js
40
+ const occtResult = await importStepWithOcct(stepText)
41
+ expect(occtResult.success).toBe(true)
42
+ expect(occtResult.meshes.length).toBeGreaterThan(0)
43
+
44
+ const [firstMesh] = occtResult.meshes
45
+ expect(firstMesh.attributes.position.array.length).toBeGreaterThan(0)
46
+ expect(firstMesh.index.array.length).toBeGreaterThan(0)
47
+
48
+ console.log("✓ STEP file successfully validated with occt-import-js")
49
+ }, 30000)