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.
- package/.claude/settings.local.json +16 -0
- package/CLAUDE.md +10 -0
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/biome.json +100 -0
- package/bunfig.toml +5 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +705 -0
- package/lib/index.ts +545 -0
- package/lib/mesh-generation.ts +333 -0
- package/package.json +29 -0
- package/test/basics/basics01/basics01.json +40 -0
- package/test/basics/basics01/basics01.test.ts +54 -0
- package/test/basics/basics02/basics02.json +19 -0
- package/test/basics/basics02/basics02.test.ts +38 -0
- package/test/basics/basics03/basics03.json +49 -0
- package/test/basics/basics03/basics03.test.ts +38 -0
- package/test/basics/basics04/basics04.json +52 -0
- package/test/basics/basics04/basics04.test.ts +49 -0
- package/test/repros/repro01/repro01.json +2917 -0
- package/test/repros/repro01/repro01.test.ts +48 -0
- package/test/utils/occt/importer.ts +119 -0
- package/tsconfig.json +30 -0
|
@@ -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)
|