cyclecad 3.6.0 → 3.8.0

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,2728 @@
1
+ # cycleCAD Killer Features Guide
2
+
3
+ Complete technical reference and user guide for cycleCAD's 6 next-generation features that redefine browser-based CAD.
4
+
5
+ **Version:** 3.5.0
6
+ **Last Updated:** 2026-03-31
7
+ **Status:** Production Ready
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ 1. [Overview](#overview)
14
+ 2. [Text-to-CAD](#text-to-cad-ai-powered-geometry-generation)
15
+ 3. [Photo-to-CAD](#photo-to-cad-image-based-reverse-engineering)
16
+ 4. [Manufacturability](#manufacturability-dfm-analysis-and-costing)
17
+ 5. [Generative Design](#generative-design-topology-optimization)
18
+ 6. [Multi-Physics](#multi-physics-simulation)
19
+ 7. [Smart Parts Library](#smart-parts-library)
20
+ 8. [Integration Guide](#integration-guide)
21
+ 9. [Troubleshooting](#troubleshooting-common-issues)
22
+
23
+ ---
24
+
25
+ ## Overview
26
+
27
+ ### What Makes cycleCAD Unique
28
+
29
+ cycleCAD is the first browser-native parametric CAD platform that combines all six of these killer features in a single, cohesive ecosystem:
30
+
31
+ - **AI-Native Design** (Text-to-CAD) — Never type CAD commands again
32
+ - **Vision-to-3D** (Photo-to-CAD) — Turn photos into parametric models
33
+ - **Real-time Manufacturing Insight** (Manufacturability) — Know cost, feasibility, and lead time as you design
34
+ - **Topology Optimization** (Generative Design) — Automatically reduce weight 30-50%
35
+ - **Instant Physics Validation** (Multi-Physics) — Drop test, thermal analysis, vibration—all in real-time
36
+ - **Smart Sourcing** (Smart Parts Library) — Auto-populate BOMs from 200+ standard parts
37
+
38
+ ### Competitive Landscape
39
+
40
+ #### Feature Comparison Matrix
41
+
42
+ | Feature | cycleCAD | OnShape | Fusion 360 | SolidWorks | FreeCAD | Aurorin |
43
+ |---------|----------|---------|-----------|-----------|---------|---------|
44
+ | **Text-to-CAD** | ✅ Full | ✗ | ✗ | ✗ | ✗ | Partial |
45
+ | **Photo-to-CAD** | ✅ Full | ✗ | ✗ | ✗ | ✗ | ✗ |
46
+ | **Manufacturability** | ✅ 9 processes | Partial | Partial | ✅ | ✗ | Partial |
47
+ | **Generative Design** | ✅ Real-time | ✅ | ✅ | ✅ | ✗ | ✗ |
48
+ | **FEA/Thermal** | ✅ Multi-physics | ✗ | ✅ | ✅ | ✅ | ✗ |
49
+ | **Drop Test** | ✅ Real-time | ✗ | ✗ | ✗ | ✗ | ✗ |
50
+ | **Smart Parts** | ✅ 200+ | Partial | ✅ | ✅ | ✗ | ✗ |
51
+ | **Browser-Native** | ✅ | ✅ | ✗ | ✗ | ✗ | ✓ |
52
+ | **Free** | ✅ | ✗ | ✗ | ✗ | ✅ | ✗ |
53
+ | **Open Source** | ✅ | ✗ | ✗ | ✗ | ✅ | ✗ |
54
+
55
+ ### Architecture Overview
56
+
57
+ ```
58
+ ┌─────────────────────────────────────────────────────────────┐
59
+ │ cycleCAD v3.5.0 │
60
+ ├─────────────────────────────────────────────────────────────┤
61
+ │ │
62
+ │ ┌─────────────────┐ ┌────────────────┐ ┌─────────────┐ │
63
+ │ │ Text-to-CAD │ │ Photo-to-CAD │ │Manufacturability
64
+ │ │ (AI) │ │ (Vision) │ │ (DFM) │ │
65
+ │ └────────┬────────┘ └────────┬───────┘ └──────┬──────┘ │
66
+ │ │ │ │ │
67
+ │ └────────────────────┼─────────────────┘ │
68
+ │ │ │
69
+ │ ┌───────────────────────────────────────────────────────┐ │
70
+ │ │ Unified 3D Geometry Engine (Three.js) │ │
71
+ │ │ (All features read/write geometry via shared API) │ │
72
+ │ └───────────────────┬─────────────────────────────────┘ │
73
+ │ │ │
74
+ │ ┌────────────────┐ │ ┌──────────────┐ ┌────────────┐ │
75
+ │ │ Generative │ │ │Multi-Physics │ │Smart Parts │ │
76
+ │ │ Design (SIMP) │──┴──│ (FEA/Thermal)│ │Library │ │
77
+ │ │ (Topology Opt) │ │ (GPU Accel) │ │(200+ parts)│ │
78
+ │ └────────────────┘ └──────────────┘ └────────────┘ │
79
+ │ │
80
+ │ ┌─────────────────────────────────────────────────────┐ │
81
+ │ │ Shared Services Layer │ │
82
+ │ │ - Material Database (20+ materials) │ │
83
+ │ │ - Dimension & Unit Conversion │ │
84
+ │ │ - Feature History & Undo/Redo │ │
85
+ │ │ - STEP/STL Import-Export │ │
86
+ │ │ - BOM Management │ │
87
+ │ └─────────────────────────────────────────────────────┘ │
88
+ │ │
89
+ └─────────────────────────────────────────────────────────────┘
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Text-to-CAD: AI-Powered Geometry Generation
95
+
96
+ Convert natural language descriptions directly into 3D parametric geometry. Powered by GPT-4/Claude NLP with fallback local transformer model for offline use.
97
+
98
+ ### How It Works
99
+
100
+ **Pipeline:** User Input → NLP Tokenization → Intent Detection → Shape Matching → Dimension Extraction → Geometry Generation → Live Preview
101
+
102
+ #### 1. NLP Processing
103
+ - **Tokenization**: Split description into semantic tokens
104
+ - **Intent Detection**: Classify as CREATE, MODIFY, ANALYZE, EXPORT
105
+ - **Entity Extraction**: Identify shape names, materials, dimensions, tolerances
106
+ - **Ambiguity Resolution**: Ask clarifying questions when needed
107
+
108
+ #### 2. Shape Recognition
109
+
110
+ The system recognizes 18+ geometric primitives and parametric forms:
111
+
112
+ | Shape | Aliases | Extracted Parameters | Example |
113
+ |-------|---------|---------------------|---------|
114
+ | **Cylinder** | "cyl", "rod", "pin", "shaft" | radius, height, axis | `create cylinder 25mm diameter 50mm tall` |
115
+ | **Sphere** | "ball", "sphere", "orb" | radius | `create sphere 30mm` |
116
+ | **Box** | "block", "cube", "rectangular prism" | width, depth, height | `create box 100 x 50 x 25mm` |
117
+ | **Cone** | "taper", "cone" | base radius, height, apex | `create cone 40mm base 30mm height` |
118
+ | **Disk** | "plate", "washer", "ring" | outer radius, inner radius (opt), thickness | `create disk 50mm outer 25mm inner 5mm thick` |
119
+ | **Tube** | "pipe", "hollow cylinder" | outer radius, inner radius, length | `create tube 30mm outer 20mm inner 80mm long` |
120
+ | **Torus** | "donut", "ring" | major radius, minor radius | `create torus 40mm major 10mm minor` |
121
+ | **Hexagon** | "hex", "bolt head" | width across flats, height | `create hex 13mm 8mm tall` |
122
+ | **Gear** | "gear", "sprocket", "cog" | num teeth, module, bore | `create gear 20 teeth 2mm module 8mm bore` |
123
+ | **Bracket** | "L-bracket", "corner" | arm width, arm depth, thickness, radius | `create bracket 50x50x10mm 5mm radius` |
124
+ | **Flange** | "flange", "hub" | hub diameter, flange outer, bolt circle | `create flange hub 20mm flange 80mm 4 bolt holes` |
125
+ | **Washer** | "washer", "shim" | outer diameter, inner diameter, thickness | `create washer 25mm outer 10mm inner 2mm thick` |
126
+ | **Ring** | "ring", "collar" | outer diameter, inner diameter, width | `create ring 40mm outer 25mm inner 10mm wide` |
127
+ | **Spring** | "spring", "coil" | diameter, pitch, turns, wire gauge | `create spring 30mm diameter 5mm pitch 10 turns` |
128
+ | **Thread** | "screw", "bolt", "thread" | diameter, pitch, length, handedness | `create thread M10 x 1.5mm 30mm long` |
129
+ | **Polygon** | "pentagon", "octagon" | num sides, circumscribed radius | `create polygon 8 sides 25mm radius` |
130
+ | **Lofted Form** | "teardrop", "boat hull" | profile count, tapering | `create lofted hull 5 profiles tapering 0.8` |
131
+ | **Polyhedron** | "pyramid", "tetrahedron" | base, num sides, height | `create pyramid square 50mm base 75mm tall` |
132
+
133
+ ### Supported Features & Operations
134
+
135
+ After creating a base shape, layer parametric features:
136
+
137
+ ```
138
+ Text Command Generated CAD Feature
139
+ ────────────────────────────────────────────────────────────────
140
+ "add hole 10mm diameter center" Hole (diameter, depth, location)
141
+ "add 5mm fillet on all edges" Fillet (radius, selection mode)
142
+ "chamfer the top 2mm" Chamfer (distance, face selection)
143
+ "create rectangular array 3x4 spacing 15mm" Linear Pattern (count, spacing, direction)
144
+ "add M8 thread 20mm deep" Thread (size, depth, direction)
145
+ "mirror across the front plane" Mirror (plane selection)
146
+ "scale to 80% of original" Scale (factor, center point)
147
+ "subtract the hole from main body" Boolean Cut (tool body, keep face)
148
+ "combine with fastener part" Boolean Union (multiple bodies)
149
+ ```
150
+
151
+ ### Unit Support & Conversion
152
+
153
+ cycleCAD automatically detects and converts units:
154
+
155
+ ```javascript
156
+ // Supported unit declarations
157
+ "100mm" → 100 millimeters
158
+ "4 inches" → 101.6mm
159
+ "3.5 cm" → 35mm
160
+ "0.5m" → 500mm
161
+ "2'" → 609.6mm (feet)
162
+ "5 thou" → 0.127mm (thousandths of inch)
163
+ "2.5 in" → 63.5mm
164
+
165
+ // Default: millimeters if unspecified
166
+ "cylinder 50 tall" → 50mm height
167
+ ```
168
+
169
+ ### Multi-Step Workflow Examples
170
+
171
+ cycleCAD supports iterative, stateful design:
172
+
173
+ #### Example 1: Create a Simple Shaft with Shoulders
174
+
175
+ ```
176
+ Step 1: "create cylinder 25mm diameter 100mm tall"
177
+ → Main body created, preview shows
178
+
179
+ Step 2: "add shoulder 35mm diameter 10mm long at top"
180
+ → Additional feature added, cumulatively displayed
181
+
182
+ Step 3: "add 10mm diameter hole through center"
183
+ → Hole subtracted, history tracked
184
+
185
+ Step 4: "fillet all edges 2mm"
186
+ → Final operation applied
187
+
188
+ Result: Complete shaft in 4 simple sentences
189
+ ```
190
+
191
+ #### Example 2: Create a Bearing Flange with Bolt Holes
192
+
193
+ ```
194
+ Step 1: "create disk 80mm outer 30mm inner 8mm thick"
195
+ → Base disk created
196
+
197
+ Step 2: "add 4 holes 10mm diameter bolt circle 60mm"
198
+ → Holes distributed in circular pattern
199
+
200
+ Step 3: "chamfer the bolt holes 2mm"
201
+ → All holes chamfered
202
+
203
+ Step 4: "export as stl"
204
+ → Ready for 3D printing
205
+ ```
206
+
207
+ ### Confidence Scoring
208
+
209
+ The NLP engine reports confidence for each extracted parameter:
210
+
211
+ ```
212
+ Extracted Parameters:
213
+ ─────────────────────────────────────────────────────
214
+ Shape: Cylinder Confidence: 98%
215
+ Diameter: 25mm Confidence: 95%
216
+ Height: 50mm Confidence: 92%
217
+
218
+ Ambiguities Detected:
219
+ - "tall" could mean HEIGHT or TOTAL LENGTH (asked user)
220
+ - "large hole" inferred as "diameter > 50% of shaft" (70% confidence)
221
+
222
+ Recommendation: Preview before confirming
223
+ ```
224
+
225
+ If confidence < 80%, the system prompts for clarification:
226
+ - "Did you mean 50mm diameter or 50mm radius?"
227
+ - "Should the hole go through the entire part or 10mm deep?"
228
+ - "Apply the 5mm fillet to all edges or just the top?"
229
+
230
+ ### Live Preview System
231
+
232
+ As you type, cycleCAD renders a semi-transparent "ghost" geometry preview:
233
+
234
+ ```
235
+ User Types: Preview Updates:
236
+ ────────────────────────────────────────────
237
+ "create cyl" Cylinder outline appears (1x1x1 default)
238
+ "25mm diameter" Diameter dimension updates in real-time
239
+ "50mm tall" Height extends to 50mm
240
+ "add hole" Hole preview appears
241
+ "10mm" Hole diameter set to 10mm
242
+ (press Enter) Live preview becomes solid geometry
243
+ ```
244
+
245
+ ### Keyboard Shortcuts & UI
246
+
247
+ | Shortcut | Action |
248
+ |----------|--------|
249
+ | `Ctrl+T` | Open Text-to-CAD input box |
250
+ | `Enter` | Execute current command |
251
+ | `Escape` | Cancel preview, revert to last solid |
252
+ | `Tab` | Show parameter suggestions (dropdown) |
253
+ | `Ctrl+↓` | Next command from history |
254
+ | `Ctrl+↑` | Previous command from history |
255
+ | `F1` | Show NLP help and example prompts |
256
+
257
+ ### API Reference
258
+
259
+ #### Execute a Text Command
260
+
261
+ ```javascript
262
+ // Basic usage
263
+ const result = await window.cycleCAD.textToCad.execute(
264
+ "create cylinder 25mm diameter 50mm tall"
265
+ );
266
+
267
+ // Returns
268
+ {
269
+ success: true,
270
+ geometry: THREE.BufferGeometry,
271
+ parameters: {
272
+ shape: "cylinder",
273
+ diameter: 25,
274
+ height: 50,
275
+ unit: "mm"
276
+ },
277
+ confidence: 0.95,
278
+ timestamp: 1711900800000
279
+ }
280
+ ```
281
+
282
+ #### Get Shape Suggestions (for Autocomplete)
283
+
284
+ ```javascript
285
+ const suggestions = window.cycleCAD.textToCad.getSuggestions("create cyl");
286
+ // Returns: ["cylinder", "cylindrical", "cylindric form", ...]
287
+ ```
288
+
289
+ #### Parse Dimensions with Unit Conversion
290
+
291
+ ```javascript
292
+ const parsed = window.cycleCAD.textToCad.parseDimension("3.5 inches");
293
+ // Returns: { value: 88.9, unit: "mm", original: "3.5 inches" }
294
+ ```
295
+
296
+ #### Build Multi-Step History
297
+
298
+ ```javascript
299
+ const history = window.cycleCAD.textToCad.getHistory();
300
+ // Returns array of all executed commands with timestamps and geometries
301
+ ```
302
+
303
+ #### Clear Preview (Manual Control)
304
+
305
+ ```javascript
306
+ window.cycleCAD.textToCad.clearPreview(); // Remove ghost geometry
307
+ window.cycleCAD.textToCad.confirm(); // Confirm current preview as solid
308
+ ```
309
+
310
+ ### Limitations & Workarounds
311
+
312
+ | Limitation | Workaround |
313
+ |-----------|-----------|
314
+ | Complex shapes (aerodynamic curves) | Use Photo-to-CAD from reference image |
315
+ | Under-constrained dimensions | System asks clarifying questions |
316
+ | Ambiguous directions (top/bottom on sphere) | Specify with "upper hemisphere" or exact angle |
317
+ | Compound boolean ops (A-(B+C)) | Execute step-by-step: create A, subtract B, subtract C |
318
+ | Non-parametric freeform | Use Generative Design to auto-shape from constraints |
319
+
320
+ ### 10 Example Prompts
321
+
322
+ **Beginner Level:**
323
+
324
+ 1. `create cylinder 30mm diameter 80mm tall`
325
+ 2. `create box 100 x 50 x 25mm`
326
+ 3. `add hole 10mm diameter through center`
327
+
328
+ **Intermediate Level:**
329
+
330
+ 4. `create gear 20 teeth 2mm module 8mm bore then add M8 thread 20mm`
331
+ 5. `create disk 80mm outer 25mm inner 5mm thick then add 4 holes bolt circle 60mm`
332
+ 6. `create bracket 50x50 arms 10mm thick then fillet all edges 2mm`
333
+
334
+ **Advanced Level:**
335
+
336
+ 7. `create cylindrical shell 40mm outer 30mm inner 100mm long then add reinforcing ribs 5mm thick 4 spines`
337
+ 8. `create lofted hull with 5 profiles tapering from 100mm top to 50mm bottom over 150mm length then add keel slot 20mm deep`
338
+ 9. `create springboard shape with parabolic curve stiffness 80%, length 500mm width 100mm, then add mounting holes at ends`
339
+ 10. `create hollow rotor blade with leading edge 15mm sharp trailing edge rounded 10mm, chord 80mm, span 200mm, twisted 25 degrees, then simulate for stress`
340
+
341
+ ---
342
+
343
+ ## Photo-to-CAD: Image-Based Reverse Engineering
344
+
345
+ Convert 2D photographs into parametric 3D models using computer vision and AI-assisted shape recognition.
346
+
347
+ ### How It Works
348
+
349
+ **Pipeline:** Image Input → Preprocessing → Edge Detection → Contour Extraction → Shape Matching → 3D Reconstruction → Parameterization
350
+
351
+ #### 1. Image Input Methods
352
+
353
+ Users can provide reference images in three ways:
354
+
355
+ ```
356
+ Method 1: Drag-and-Drop
357
+ ───────────────────────
358
+ Drag image file into 3D viewport
359
+ → System auto-detects and prompts for reference dimension
360
+
361
+ Method 2: Camera Capture
362
+ ───────────────────────
363
+ Click camera icon, aim at physical object
364
+ → Photo captured, auto-analyzed, scale dialog appears
365
+
366
+ Method 3: Clipboard Paste
367
+ ───────────────────────
368
+ Copy image, press Ctrl+V in viewport
369
+ → System extracts from clipboard, processes immediately
370
+ ```
371
+
372
+ #### 2. Edge Detection Pipeline
373
+
374
+ Multi-stage computer vision processing:
375
+
376
+ ```
377
+ Original Image
378
+
379
+ [Grayscale Conversion]
380
+
381
+ [Gaussian Blur (5x5 kernel)] → Noise reduction
382
+
383
+ [Sobel Edge Detection] → Edge magnitude & direction
384
+
385
+ [Non-Maximum Suppression] → Thin edges to 1px
386
+
387
+ [Hysteresis Thresholding] → Strong / weak edges
388
+
389
+ [Contour Tracing] → Extract boundary polygons
390
+
391
+ [Simplification (Douglas-Peucker)] → Reduce point count
392
+
393
+ Contour Points Ready for Shape Matching
394
+ ```
395
+
396
+ #### 3. Shape Detection & Matching
397
+
398
+ The system recognizes these geometric forms from contours:
399
+
400
+ | Detected Shape | Matching Algorithm | Parameters Extracted |
401
+ |---|---|---|
402
+ | **Circles** | Least-squares circle fit | Center (x,y), radius, eccentricity |
403
+ | **Ellipses** | Covariance matrix diagonalization | Center, major/minor axes, angle |
404
+ | **Rectangles** | Corner detection + corner angle refinement | Width, height, corner radii |
405
+ | **Polygons** | n-gon vertex clustering | Num sides, regularity score, rotation |
406
+ | **Arcs** | Arc fitting to point sequence | Start angle, end angle, radius |
407
+ | **Lines** | Hough transform or least-squares fit | Start point, end point, angle |
408
+ | **Curves** | Spline fitting (B-spline or Bezier) | Control points, degree, tension |
409
+ | **Composite** | Recursive decomposition | Sub-shape list with connectivity |
410
+
411
+ ### Reference Dimension System
412
+
413
+ cycleCAD uses a visual reference object to establish scale:
414
+
415
+ ```
416
+ User Action:
417
+ ─────────────────────────────────────────────
418
+ 1. Image uploaded showing part + ruler
419
+ 2. System asks: "Select the reference dimension"
420
+ 3. User clicks & drags along ruler edge
421
+ 4. User enters value: "50mm"
422
+ 5. System: "Established scale: 1 pixel = 0.5mm"
423
+ 6. All extracted dimensions auto-scaled
424
+
425
+ Alternative: Manual scale entry
426
+ ─────────────────────────────────────────────
427
+ 1. Image uploaded (no ruler visible)
428
+ 2. User clicks "Reference" button
429
+ 3. Enters: "This part is 100mm tall"
430
+ 4. Selects the tall edge in preview
431
+ 5. System scales entire contour to match
432
+ ```
433
+
434
+ ### AI Enhancement (Optional)
435
+
436
+ When enabled, Gemini Vision API analyzes the image semantically:
437
+
438
+ ```
439
+ Gemini Analysis:
440
+ ────────────────────────────────────────────
441
+ Image Description:
442
+ "Aluminum bracket with bent flanges, two
443
+ mounting holes, likely CNC machined"
444
+
445
+ Material Detection: Aluminum (inferred from finish)
446
+ Process Hint: CNC milling (suggests sharp corners,
447
+ not injection molded)
448
+ Feature Suggestions:
449
+ - Add 2mm chamfers (standard for CNC)
450
+ - Suggest sheet metal origin (if <2mm thick)
451
+ - Check for undercuts (not manufacturable)
452
+
453
+ Confidence: 87%
454
+ ```
455
+
456
+ ### Interactive Refinement Workflow
457
+
458
+ User has full control to refine the AI-generated 3D model:
459
+
460
+ ```
461
+ Step 1: Image Analysis
462
+ ↓ Shows contour preview on original image
463
+
464
+ Step 2: Contour Acceptance
465
+ ↓ User approves or manually adjusts edge points
466
+
467
+ Step 3: Shape Matching
468
+ ↓ User confirms shape type (cylinder, box, loft, etc.)
469
+
470
+ Step 4: Scale & Dimension
471
+ ↓ User sets reference scale and dimension labels
472
+
473
+ Step 5: 3D Reconstruction
474
+ ↓ System auto-generates 3D geometry
475
+
476
+ Step 6: Review & Confirm
477
+ ↓ User checks preview, suggests revisions
478
+ → Can iterate: adjust scale, change shape type, etc.
479
+
480
+ Step 7: Parametrization (Optional)
481
+ ↓ User can:
482
+ • Name parameters
483
+ • Set relationships (width = 2x height)
484
+ • Lock certain dimensions as "reference"
485
+ ```
486
+
487
+ ### Shape Detection Examples
488
+
489
+ #### Example 1: Bracket from Photo
490
+
491
+ ```
492
+ Input: Smartphone photo of aluminum L-bracket on workbench
493
+
494
+ Edge Detection Output:
495
+ ├─ Outer profile: L-shaped polygon (12 vertices)
496
+ ├─ Hole 1: Circle, center (x=42, y=28), r=4mm
497
+ └─ Hole 2: Circle, center (x=42, y=58), r=4mm
498
+
499
+ Shape Recognition:
500
+ Primary Shape: Right-angle bracket
501
+ └─ Arm 1: Rectangle 50mm x 10mm (horizontal)
502
+ └─ Arm 2: Rectangle 10mm x 60mm (vertical)
503
+ └─ Corner Radius: 3mm (detected from rounded corner pixels)
504
+
505
+ Features:
506
+ └─ Hole 1: 8mm diameter countersink
507
+ └─ Hole 2: 8mm diameter countersink
508
+
509
+ Generated CAD:
510
+ 1. Create box 50 x 10 x 10mm
511
+ 2. Create box 10 x 60 x 10mm (positioned)
512
+ 3. Boolean union
513
+ 4. Fillet corners 3mm
514
+ 5. Add counterbore holes at (42, 28) and (42, 58)
515
+ ```
516
+
517
+ #### Example 2: Circular Flanged Part
518
+
519
+ ```
520
+ Input: Top-down photo of circular part with 4 bolt holes
521
+
522
+ Contour Detection:
523
+ ├─ Outer circle: diameter 80mm ✓
524
+ ├─ Center hole: diameter 25mm ✓
525
+ └─ 4 bolt holes: 8mm, arranged in bolt circle
526
+ └─ Bolt circle diameter: 60mm (calculated from positions)
527
+
528
+ Shape Recognition:
529
+ Primary: Disk/flange
530
+ ├─ Outer diameter: 80mm
531
+ ├─ Center bore: 25mm
532
+ └─ Thickness: ~5mm (estimated from lighting/shadows)
533
+
534
+ Generated CAD:
535
+ 1. Create disk 80mm outer 25mm inner 5mm thick
536
+ 2. Add 4 holes 8mm diameter bolt circle 60mm
537
+ 3. Chamfer bolt holes 2mm
538
+ ```
539
+
540
+ ### API Reference
541
+
542
+ #### Upload & Process Image
543
+
544
+ ```javascript
545
+ // File input
546
+ const file = document.querySelector('#imageUpload').files[0];
547
+ const result = await window.cycleCAD.photoToCad.processImage(file);
548
+
549
+ // Returns
550
+ {
551
+ success: true,
552
+ edges: ImageData, // Canvas ImageData of edge map
553
+ contours: [[{x,y}, ...], ...], // Array of contour point lists
554
+ shapes: [
555
+ { type: "circle", center: {x,y}, radius: 42, confidence: 0.94 },
556
+ { type: "circle", center: {x,y}, radius: 8, confidence: 0.88 },
557
+ // ...
558
+ ],
559
+ scalePixelsPerMM: 0.5, // Requires reference dimension
560
+ preprocessedImage: ImageData // After blur/normalization
561
+ }
562
+ ```
563
+
564
+ #### Set Reference Dimension
565
+
566
+ ```javascript
567
+ // Define scale by selecting two points and entering dimension
568
+ window.cycleCAD.photoToCad.setReferenceDimension(
569
+ {x: 100, y: 200}, // Point 1 on image
570
+ {x: 350, y: 200}, // Point 2 on image
571
+ 250, // Distance in millimeters
572
+ "mm" // Unit
573
+ );
574
+ // Internally calculates: 1 pixel = 250 / |p1-p2| mm
575
+ ```
576
+
577
+ #### Detect Edges (Manual)
578
+
579
+ ```javascript
580
+ const edges = await window.cycleCAD.photoToCad.detectEdges(
581
+ canvasContext, // 2D canvas context with image data
582
+ {
583
+ blurRadius: 5,
584
+ sobelThreshold: 50,
585
+ lowThreshold: 100,
586
+ highThreshold: 200
587
+ }
588
+ );
589
+ // Returns ImageData with edge pixels
590
+ ```
591
+
592
+ #### Reconstruct 3D Geometry
593
+
594
+ ```javascript
595
+ const geometry3D = await window.cycleCAD.photoToCad.reconstruct3D(
596
+ shapes, // Shape array from processImage()
597
+ {
598
+ primaryShape: "disk", // Override auto-detection
599
+ thickness: 5, // Extrusion depth in mm
600
+ smoothing: true, // Apply Catmull-Rom smoothing
601
+ tolerance: 0.5 // Deviation tolerance
602
+ }
603
+ );
604
+ // Returns THREE.BufferGeometry
605
+ ```
606
+
607
+ #### Apply AI Enhancement
608
+
609
+ ```javascript
610
+ const enhanced = await window.cycleCAD.photoToCad.enhanceWithAI(
611
+ {
612
+ originalImage: File,
613
+ detectedShapes: shapes,
614
+ scale: { pixelsPerMM: 0.5 }
615
+ }
616
+ );
617
+
618
+ // Returns
619
+ {
620
+ materialGuess: "aluminum",
621
+ processHints: ["CNC milling", "sheet metal"],
622
+ suggestedFeatures: [
623
+ { type: "chamfer", radius: 2 },
624
+ { type: "check", issue: "sharp internal corner not manufacturable" }
625
+ ],
626
+ confidence: 0.87
627
+ }
628
+ ```
629
+
630
+ ### Limitations & Best Practices
631
+
632
+ | Issue | Solution |
633
+ |-------|----------|
634
+ | **Shadows obscure edges** | Use even lighting, capture perpendicular to surface |
635
+ | **Reflective surfaces** | Matte reference object nearby for scale |
636
+ | **Complex curves (NURBS)** | Use Text-to-CAD with "lofted" description instead |
637
+ | **Very small features** | Include macro photography (close-up) for accurate edge detect |
638
+ | **Multiple overlapping parts** | Photograph each part separately, assemble after import |
639
+ | **Transparent materials** | Place matte background behind part |
640
+
641
+ ### Tips for Best Results
642
+
643
+ 1. **Lighting:** Bright, even illumination with minimal shadows
644
+ 2. **Background:** Plain, contrasting color (white for dark parts, gray for reflective)
645
+ 3. **Angle:** Perpendicular to largest feature (top-down for flanges, side view for shafts)
646
+ 4. **Resolution:** >= 1024x1024 pixels (smartphone photos are adequate)
647
+ 5. **Reference:** Always include scale reference (ruler, coin, or known-size object)
648
+ 6. **Zoom:** Frame the part to fill 60-80% of the image
649
+ 7. **Orientation:** Position part so edges are mostly horizontal/vertical
650
+
651
+ ---
652
+
653
+ ## Manufacturability: DFM Analysis and Costing
654
+
655
+ Real-time Design for Manufacturability (DFM) analysis and instant cost estimation across 9 manufacturing processes and 20+ materials.
656
+
657
+ ### How It Works
658
+
659
+ **Pipeline:** Geometry Analysis → Process-Specific Rule Checking → Cost Calculation → Visualization → Report Generation
660
+
661
+ The system continuously monitors the current design and flags manufacturability issues in real-time:
662
+
663
+ ```
664
+ As User Designs:
665
+ ─────────────────────────────────────
666
+ Add feature → Analyze for all 9 processes
667
+
668
+ Check material compatibility
669
+
670
+ Calculate cost delta
671
+
672
+ Update heatmap overlay
673
+
674
+ Alert if rule violations
675
+ ```
676
+
677
+ ### Supported Processes
678
+
679
+ #### 1. CNC Milling (3-Axis)
680
+
681
+ **Rules Checked:**
682
+
683
+ ```
684
+ Rule Limit Alert Level
685
+ ─────────────────────────────────────────────────────────
686
+ Minimum corner radius 1mm RED if < 1mm
687
+ Minimum feature size 2mm YELLOW if < 3mm
688
+ Maximum depth-to-width 4:1 RED if > 5:1
689
+ Tool reach (spindle height) 150mm RED if exceeds
690
+ Hole minimum diameter 2mm RED if < 2mm
691
+ Hole minimum depth 1.5 x Ø YELLOW if < 2 x Ø
692
+ Wall thickness (internal) 2mm RED if < 2mm
693
+ ```
694
+
695
+ **Cost Factors:**
696
+
697
+ ```
698
+ Base: $ 5.00 per setup
699
+
700
+ Variable:
701
+ ├─ Tool changes: $2.00 each
702
+ ├─ Complex tool paths: $0.50 per pocket
703
+ ├─ Material cost: $/gram (see Material Database)
704
+ ├─ Machine time: $0.25/min
705
+ └─ Quantity discount: -10% @ 10+, -25% @ 100+
706
+ ```
707
+
708
+ **Example:**
709
+ ```
710
+ Part: 50x50x25mm aluminum bracket with 3 pockets, 4 holes
711
+ Setup cost: $5.00
712
+ Tool changes (3 tools): $6.00
713
+ Pocket cost: $1.50
714
+ Machine time (15 min @ $0.25): $3.75
715
+ Material (aluminum, 47g @ $0.002/g): $0.09
716
+ ────────────────────────────────────────
717
+ Unit cost: $16.34
718
+ Qty 10: $14.71 each
719
+ ```
720
+
721
+ #### 2. CNC Milling (5-Axis)
722
+
723
+ **Additional Rules:**
724
+
725
+ ```
726
+ Rule Limit
727
+ ─────────────────────────────────────────────────
728
+ 5-axis simultaneous machining 2-axis rotary heads available
729
+ Undercut allowance 0 (no geometry interference)
730
+ Minimum feature angle 5° from vertical
731
+ Dynamic stability max 2mm deviation
732
+ ```
733
+
734
+ **Cost Adjustment:**
735
+ - Machine hourly rate: +100% vs 3-axis
736
+ - Tool changes: same
737
+ - Setup time: +50%
738
+
739
+ #### 3. 3D Printing (FDM — Fused Deposition Modeling)
740
+
741
+ **Rules Checked:**
742
+
743
+ ```
744
+ Rule Limit Alert Level
745
+ ─────────────────────────────────────────────────────────
746
+ Wall thickness (minimum) 0.8mm RED if < 0.8mm
747
+ Wall thickness (maximum) 50mm YELLOW if > 80mm
748
+ Overhangs (unsupported) 45° RED if steeper
749
+ Support generation auto Manual if > 20% volume
750
+ Bridging distance 10mm RED if > 15mm
751
+ Minimum feature size 1mm RED if < 1mm
752
+ Layer height 0.2mm (user config)
753
+ Infill percentage 15-100% Affects strength
754
+ ```
755
+
756
+ **Cost Factors:**
757
+
758
+ ```
759
+ Base: $1.50 per print
760
+
761
+ Variable:
762
+ ├─ Resin/filament: $/gram (material dependent)
763
+ ├─ Print time: $0.01/hour (utility)
764
+ ├─ Support material: +15% volume cost
765
+ ├─ Post-processing: $2.00 (washing for SLA)
766
+ └─ Quantity: bulk print discount (multiple parts)
767
+ ```
768
+
769
+ **Example:**
770
+ ```
771
+ Part: Hollow bracket, 50g PLA, 4 hours print time
772
+ Material cost (PLA $15/kg): 50g × $0.015 = $0.75
773
+ Print time (4hrs @ $0.01/hr): $0.04
774
+ Base: $1.50
775
+ Support removal: $0.50
776
+ ────────────────────────────────────────
777
+ Unit cost: $2.79
778
+ Qty 1: $2.79
779
+ Qty 50: $0.89 each (bulk print)
780
+ ```
781
+
782
+ #### 4. 3D Printing (SLA — Stereolithography)
783
+
784
+ **Rules Checked:**
785
+
786
+ ```
787
+ Rule Limit
788
+ ─────────────────────────────────────────────────
789
+ Part tilt angle (support) 30-60°
790
+ Minimum wall thickness 0.6mm (thin walls)
791
+ Minimum feature 0.25mm (high detail)
792
+ Trapped resin in voids Alert if detected
793
+ Build platform Z-offset min 2mm
794
+ ```
795
+
796
+ **Cost Factors:**
797
+ - Resin cost: $/gram (premium: 2-5x FDM)
798
+ - Post-cure time: +$1.00
799
+ - Cleaning: +$0.50
800
+ - Fine details charge: +$0.25/complex feature
801
+
802
+ #### 5. Injection Molding
803
+
804
+ **Rules Checked:**
805
+
806
+ ```
807
+ Rule Limit Alert Level
808
+ ─────────────────────────────────────────────────────────
809
+ Draft angle (unmold-able) 0.5° min RED if < 0.5°
810
+ Wall thickness uniformity ± 0.5mm YELLOW if > ±1mm
811
+ Rib thickness 50% of wall RED if > 60% wall
812
+ Rib height 2-3x thick YELLOW if > 4x
813
+ Minimum feature 0.5mm RED if < 0.5mm
814
+ Undercut allowance 0mm (strict) RED if undercut
815
+ Gate location thick area YELLOW if on thin wall
816
+ Cooling time 3-20 sec (material dependent)
817
+ ```
818
+
819
+ **Cost Factors:**
820
+
821
+ ```
822
+ Tooling (one-time):
823
+ ├─ Simple 2-cavity mold: $5,000-15,000
824
+ ├─ Complex 4-cavity mold: $15,000-40,000
825
+ └─ Ultra-complex (5+ features): $40,000+
826
+
827
+ Per-unit variable:
828
+ ├─ Resin cost: $0.50-2.00/part (material)
829
+ ├─ Machine time: $0.10/part
830
+ ├─ Cycle time: 30-120 sec
831
+ └─ Finishing: $0.25/part (gates, flash removal)
832
+ ```
833
+
834
+ **Cost Calculation:**
835
+
836
+ ```
837
+ 1-shot tooling:
838
+ ├─ Mold cost: $12,000
839
+ ├─ Unit cost (qty 1000): $12,000/1000 + $1.50 = $13.50
840
+ ├─ Unit cost (qty 10000): $12,000/10000 + $1.50 = $2.70
841
+ └─ Unit cost (qty 100000): $12,000/100000 + $1.50 = $1.62
842
+ ```
843
+
844
+ #### 6. Sheet Metal Forming
845
+
846
+ **Rules Checked:**
847
+
848
+ ```
849
+ Rule Limit Alert Level
850
+ ─────────────────────────────────────────────────────────
851
+ Material thickness 0.5-3mm RED if outside
852
+ Bend radius (minimum) 1-2x thick RED if < 1x
853
+ Bend angle (formable) 0-180° RED if < 0°
854
+ Hole distance from bend 3x thick YELLOW if < 2x
855
+ Sharp corners post-bend radius 0.5mm RED if too sharp
856
+ Flange length (minimum) 2.5x thick RED if < 2x thick
857
+ Notch size (accurate) user input YELLOW if undefined
858
+ ```
859
+
860
+ **Cost Factors:**
861
+
862
+ ```
863
+ Base: $3.00 per bend/form
864
+
865
+ Variable:
866
+ ├─ Stock material: $/kg (steel, aluminum, brass)
867
+ ├─ Laser cutting: $0.50/meter of edge
868
+ ├─ Bending: $2.00 per 90° bend
869
+ ├─ Holes (punched): $0.15 each
870
+ ├─ Assembly (rivets/welds): $1.00-5.00
871
+ └─ Finishing: $0.50-2.00 (paint, powder coat, anodize)
872
+ ```
873
+
874
+ **Example:**
875
+ ```
876
+ Part: Aluminum bracket, 1.5mm thick, 4 bends, 4 holes, powder coat
877
+ Material (0.2kg aluminum @ $3/kg): $0.60
878
+ Cutting: $1.00
879
+ Bending (4x @$2): $8.00
880
+ Holes (4x @ $0.15): $0.60
881
+ Powder coat: $1.50
882
+ ────────────────────────────────────────
883
+ Unit cost: $11.70
884
+ Qty 50: $10.80 each
885
+ Qty 500: $8.50 each
886
+ ```
887
+
888
+ #### 7. Casting (Sand Casting)
889
+
890
+ **Rules Checked:**
891
+
892
+ ```
893
+ Rule Limit Alert Level
894
+ ─────────────────────────────────────────────────────────
895
+ Minimum thickness 4-5mm RED if < 4mm
896
+ Draft angle (mold release) 1.0° min RED if < 1.0°
897
+ Fillet radius (sharp corners) 3-5mm RED if < 2mm
898
+ Undercut allowance none RED if undercut
899
+ Cooling allowance +0.5-2mm Allow for shrinkage
900
+ Internal cores restricted YELLOW if complex
901
+ Gate/riser location hot spots Alert if suboptimal
902
+ ```
903
+
904
+ **Cost Factors:**
905
+
906
+ ```
907
+ Tooling (sand mold):
908
+ ├─ Wood/aluminum pattern: $500-2000 (one-time)
909
+ ├─ Core boxes: $200-500 each
910
+
911
+ Per-unit variable:
912
+ ├─ Molding labor: $5-15 per part
913
+ ├─ Casting material: $/kg (iron, aluminum, bronze)
914
+ ├─ Pouring/cooling: $2-10 per part
915
+ ├─ Finishing (cleanup, drilling): $3-8
916
+ └─ Machining (post-cast): $0-20 depending on precision
917
+ ```
918
+
919
+ #### 8. Casting (Investment Casting)
920
+
921
+ **Rules Checked:**
922
+
923
+ ```
924
+ Rule Limit Alert Level
925
+ ─────────────────────────────────────────────────────────
926
+ Wall thickness 2-5mm RED if < 2mm
927
+ Detail definition high ✓ for fine features
928
+ Undercut restriction limited Alert if complex
929
+ Surface finish (as-cast) Ra 6.3µm baseline
930
+ ```
931
+
932
+ **Cost Factors:**
933
+ - Pattern cost: $2,000-10,000 (one-time)
934
+ - Per-part: $3-15 (material + labor)
935
+ - Finishing (polishing, HIP, shot-peen): +$2-10
936
+
937
+ #### 9. Waterjet Cutting
938
+
939
+ **Rules Checked:**
940
+
941
+ ```
942
+ Rule Limit
943
+ ─────────────────────────────────────────────────
944
+ Material thickness 2-100mm
945
+ Minimum corner radius 0.3mm
946
+ Acute corner angle > 15°
947
+ Cutting head diameter 0.015"
948
+ Taper allowance <1° on thickness
949
+ Piercing location > 6mm from edge
950
+ ```
951
+
952
+ **Cost Factors:**
953
+ - Setup: $10-30
954
+ - Cutting: $0.05-0.30 per inch of cut
955
+ - Material cost: as input
956
+ - Post-processing: minimal
957
+
958
+ ### Material Database
959
+
960
+ cycleCAD includes 20+ materials with complete property tables:
961
+
962
+ ```
963
+ Material Density Yield E Cost Notes
964
+ g/cm³ Strength MPa $/kg
965
+ ────────────────────────────────────────────────────────────
966
+ Steel (AISI 7.85 250 200 0.50 General purpose
967
+ 1018)
968
+
969
+ Aluminum 2.70 90 69 3.00 Lightweight,
970
+ (6061-T6) machinable
971
+
972
+ Titanium 4.51 880 103 15.00 High strength,
973
+ (Ti-6Al-4V) expensive
974
+
975
+ Brass 8.47 300 97 8.50 Corrosion resistant
976
+ (C360)
977
+
978
+ Nylon 6 1.14 70 3.0 4.00 Low friction,
979
+ tough
980
+
981
+ ABS 1.05 40 2.3 2.50 Impact resistant,
982
+ printable
983
+
984
+ PLA 1.24 50 2.7 1.50 Biodegradable,
985
+ easy print
986
+
987
+ Copper 8.96 200 117 5.00 Electrical conductor
988
+
989
+ Magnesium 1.81 160 45 8.00 Very light
990
+ ```
991
+
992
+ Each material includes:
993
+ - Tensile strength, yield strength, elongation
994
+ - Young's modulus, Poisson ratio
995
+ - Thermal conductivity, expansion coefficient
996
+ - Machinability rating, weldability
997
+ - Cost per kg (market rates)
998
+ - Recommended processes
999
+ - Environmental/hazard notes
1000
+
1001
+ ### Cost Estimation Model
1002
+
1003
+ #### Formula
1004
+
1005
+ ```
1006
+ Total Cost = Setup Cost + Material Cost + Process Cost + Labor Cost + Markup
1007
+
1008
+ Where:
1009
+ ──────────────────────────────────────────────────────────────
1010
+
1011
+ Setup Cost = Process base fee
1012
+ (e.g., CNC: $5, 3D print: $1.50)
1013
+
1014
+ Material Cost = Volume (cm³) × Density (g/cm³) × $/kg ÷ 1000
1015
+
1016
+ Process Cost = Feature count × Feature cost
1017
+ + Machine time (minutes) × Hourly rate ÷ 60
1018
+ + Tool changes × Tool change cost
1019
+
1020
+ Labor Cost = Finishing time (min) × Labor rate ($/min)
1021
+ + Assembly time × Assembly rate
1022
+
1023
+ Markup = (Setup + Material + Process + Labor) × Margin%
1024
+ (Typical: 30-50% for job shops)
1025
+
1026
+ Quantity Discount = -5% @ 5 units, -15% @ 50, -30% @ 500+
1027
+ ```
1028
+
1029
+ #### Real-Time Cost Heatmap
1030
+
1031
+ As the user designs, cycleCAD overlays cost data on the geometry:
1032
+
1033
+ ```
1034
+ Colors: Meaning:
1035
+ ─────────────────────────────────────────────
1036
+ 🟢 Green < $1/unit (low cost)
1037
+ 🟡 Yellow $1-5/unit (moderate)
1038
+ 🟠 Orange $5-20/unit (expensive)
1039
+ 🔴 Red > $20/unit (very expensive)
1040
+ or unmanufacturable
1041
+ ```
1042
+
1043
+ Features like sharp corners or thin walls turn red to warn the user.
1044
+
1045
+ ### Report Generation
1046
+
1047
+ The Manufacturability panel generates a detailed report:
1048
+
1049
+ ```markdown
1050
+ # Design for Manufacturability Report
1051
+ Part: Bracket Assembly
1052
+ Generated: 2026-03-31 10:45 UTC
1053
+
1054
+ ## Summary
1055
+ │ Optimal for: CNC Milling, Sheet Metal
1056
+ │ Acceptable: 3D Printing (FDM)
1057
+ │ Not Recommended: Injection Molding (sharp corner)
1058
+ │ Issues Found: 3 warnings, 1 critical
1059
+
1060
+ ## Cost Estimation (Quantity: 100)
1061
+
1062
+ Process Unit Cost Total Cost Lead Time
1063
+ ────────────────────────────────────────────────────────
1064
+ CNC 3-axis $18.50 $1,850 2-3 weeks
1065
+ Sheet Metal $12.20 $1,220 1-2 weeks
1066
+ 3D Print (SLS) $8.75 $875 3-5 days
1067
+ Injection Mold $2.10* $210* 4-6 weeks
1068
+ (*tooling $8K)
1069
+
1070
+ Recommended: Sheet Metal ($1,220, 1-2 weeks)
1071
+
1072
+ ## Manufacturability Findings
1073
+
1074
+ ✓ Passing Rules:
1075
+ ├─ All hole sizes >= 3mm
1076
+ ├─ Wall thickness 2-4mm (optimal)
1077
+ └─ No trapped undercuts
1078
+
1079
+ ⚠ Warnings:
1080
+ ├─ Corner radius 0.5mm (minimum is 1mm)
1081
+ │ → Suggest 1mm fillet, adds $0.10/part
1082
+ ├─ Bolt hole locations within 2mm of edge
1083
+ │ → Stress concentration possible
1084
+ └─ Sheet metal edge length 340mm (tooling: 350mm max)
1085
+ → Fits within standard tool size
1086
+
1087
+ ✗ Critical Issues:
1088
+ └─ Sharp internal corner (0 radius) at mounting post
1089
+ → NOT machinable with CNC ER32 collet
1090
+ → FIX: Add 1mm fillet
1091
+ → Impact: Adds 30 sec machine time ($0.13)
1092
+
1093
+ ## Material Selection Analysis
1094
+
1095
+ Selected: Aluminum 6061-T6
1096
+
1097
+ Alternatives:
1098
+ ├─ Steel (AISI 1020): +10% cost, +15% weight, +strength
1099
+ ├─ Brass (C360): +250% cost, corrosion-resistant, no coating needed
1100
+ └─ Nylon 6: -20% cost, electrical insulation, creep under load
1101
+
1102
+ Verdict: Aluminum 6061-T6 is optimal for this application
1103
+
1104
+ ## Manufacturing Notes
1105
+
1106
+ CNC Milling Sequence:
1107
+ 1. Stock: 60x60x10mm aluminum plate
1108
+ 2. Face mill top and bottom: 0.2mm pass
1109
+ 3. Drill 4 mounting holes: 3mm dia.
1110
+ 4. Counterbore mounting holes: 5mm dia. x 2mm deep
1111
+ 5. Mill pockets (3 designs): 0.5mm step-down
1112
+ 6. Fillet all edges: 1mm radius (2mm endmill, slow feed)
1113
+ 7. Remove sharp corners with deburr tool
1114
+ 8. Degreasing wash + compressed air dry
1115
+
1116
+ Total Setup & Machine Time: 22 minutes
1117
+ Est. Cost @ 3-axis shop rate ($30/hr): $11
1118
+
1119
+ ## DFM Recommendations
1120
+
1121
+ Priority 1 (Must fix):
1122
+ 1. Add 1mm fillet to sharp internal corner (post #5)
1123
+ 2. Increase bolt hole edge distance to 3mm minimum
1124
+
1125
+ Priority 2 (Should fix):
1126
+ 1. Consider 1.5mm corner radius (better aesthetics, no cost)
1127
+ 2. Specify anodize finish after machining (+$0.80, corrosion resist)
1128
+
1129
+ Priority 3 (Nice to have):
1130
+ 1. Add serialization engraving ($1.50)
1131
+ 2. Silk-screen logo ($2.00 setup, $0.05/part)
1132
+
1133
+ ## Conclusion
1134
+
1135
+ Design is APPROVED for manufacturing with 2 minor DFM improvements.
1136
+ Recommended vendor: Local CNC job shop (fast turnaround).
1137
+ Estimated budget: $1,850 @ qty 100 (3-week delivery).
1138
+ ```
1139
+
1140
+ ### API Reference
1141
+
1142
+ #### Analyze Geometry for All Processes
1143
+
1144
+ ```javascript
1145
+ const report = await window.cycleCAD.manufacturability.analyze(
1146
+ THREE.BufferGeometry, // Current part geometry
1147
+ {
1148
+ material: "aluminum-6061",
1149
+ processes: ["cnc-3axis", "cnc-5axis", "fdm", "injection"],
1150
+ quantity: 100,
1151
+ currency: "USD"
1152
+ }
1153
+ );
1154
+
1155
+ // Returns
1156
+ {
1157
+ suitable_processes: ["cnc-3axis", "fdm"],
1158
+ unsuitable_processes: ["injection"],
1159
+ violations: [
1160
+ { severity: "warning", process: "cnc-3axis", rule: "corner_radius",
1161
+ value: "0.5mm", limit: "1mm", fix: "Add 1mm fillet" }
1162
+ ],
1163
+ costs: {
1164
+ "cnc-3axis": { unit: 18.50, total: 1850, leadtime_days: 14 },
1165
+ "fdm": { unit: 8.75, total: 875, leadtime_days: 3 }
1166
+ },
1167
+ recommended: "cnc-3axis"
1168
+ }
1169
+ ```
1170
+
1171
+ #### Get Cost Estimate
1172
+
1173
+ ```javascript
1174
+ const estimate = await window.cycleCAD.manufacturability.estimateCost(
1175
+ geometry,
1176
+ "cnc-3axis",
1177
+ { material: "steel-1018", quantity: 50 }
1178
+ );
1179
+
1180
+ // Returns
1181
+ {
1182
+ setup: 5.00,
1183
+ material: 12.50,
1184
+ machining: 8.75,
1185
+ labor: 2.00,
1186
+ subtotal: 28.25,
1187
+ margin_30pct: 8.48,
1188
+ unit_cost: 36.73,
1189
+ total_qty_50: 1836.50,
1190
+ leadtime: "2-3 weeks",
1191
+ breakdown: { ... }
1192
+ }
1193
+ ```
1194
+
1195
+ #### Generate Heatmap Overlay
1196
+
1197
+ ```javascript
1198
+ window.cycleCAD.manufacturability.showCostHeatmap(
1199
+ geometry,
1200
+ {
1201
+ process: "injection",
1202
+ colorScheme: "cost", // "cost", "difficulty", "speed"
1203
+ scale: "log" // "linear" or "log"
1204
+ }
1205
+ );
1206
+ // Renders color overlay on 3D geometry in viewport
1207
+ ```
1208
+
1209
+ #### Create Manufacturing Notes
1210
+
1211
+ ```javascript
1212
+ const notes = window.cycleCAD.manufacturability.generateNotes(
1213
+ geometry,
1214
+ {
1215
+ process: "cnc-3axis",
1216
+ includeToolpath: false, // Skip CAM integration
1217
+ language: "en"
1218
+ }
1219
+ );
1220
+ // Returns markdown text with operation sequence
1221
+ ```
1222
+
1223
+ ---
1224
+
1225
+ ## Generative Design: Topology Optimization
1226
+
1227
+ Automatically optimize part geometry for minimum weight, maximum stiffness, or lowest cost using SIMP (Solid Isotropic Material with Penalization) topology optimization algorithm.
1228
+
1229
+ ### How It Works
1230
+
1231
+ **Pipeline:** Design Space Definition → Load & Constraint Setup → Voxel Discretization → Density Optimization → Sensitivity Filtering → Marching Cubes → Smoothing
1232
+
1233
+ #### 1. Design Space Definition
1234
+
1235
+ User specifies:
1236
+
1237
+ ```javascript
1238
+ // Method 1: Draw keep/avoid regions
1239
+ const designSpace = {
1240
+ keepRegions: [
1241
+ // Regions that must stay solid (e.g., mounting points)
1242
+ { shape: "sphere", center: {x:0, y:0, z:10}, radius: 15 }
1243
+ ],
1244
+ avoidRegions: [
1245
+ // Regions to exclude (e.g., for clearance)
1246
+ { shape: "box", min: {x:-30, y:-30, z:20}, max: {x:30, y:30, z:40} }
1247
+ ],
1248
+ optimizationZone: {
1249
+ // Overall bounding volume to optimize
1250
+ min: {x:-50, y:-50, z:0},
1251
+ max: {x:50, y:50, z:60}
1252
+ }
1253
+ };
1254
+
1255
+ // Method 2: Use existing geometry
1256
+ const designSpace = window.cycleCAD.generativeDesign.createFromGeometry(
1257
+ baseGeometry,
1258
+ { expansion: 10 } // Expand by 10mm in all directions
1259
+ );
1260
+ ```
1261
+
1262
+ #### 2. Loads & Constraints
1263
+
1264
+ Define physical conditions:
1265
+
1266
+ ```javascript
1267
+ const loadCase = {
1268
+ loads: [
1269
+ {
1270
+ type: "force",
1271
+ location: {x: 0, y: 0, z: 60}, // Top center
1272
+ direction: {x: 0, y: 0, z: -1}, // Downward
1273
+ magnitude: 1000 // 1000 N
1274
+ },
1275
+ {
1276
+ type: "moment",
1277
+ location: {x: 0, y: 0, z: 0},
1278
+ axis: {x: 1, y: 0, z: 0}, // Around X-axis
1279
+ magnitude: 50 // 50 Nm
1280
+ }
1281
+ ],
1282
+ constraints: [
1283
+ {
1284
+ type: "fixed", // Fixed support
1285
+ region: { shape: "sphere", center: {x:0, y:0, z:-5}, radius: 10 }
1286
+ }
1287
+ ],
1288
+ material: {
1289
+ name: "aluminum-6061",
1290
+ density: 2700, // kg/m³
1291
+ youngs_modulus: 69, // GPa
1292
+ yield_strength: 90 // MPa
1293
+ }
1294
+ };
1295
+ ```
1296
+
1297
+ #### 3. Voxel Discretization
1298
+
1299
+ The optimization zone is converted to a 3D grid of voxels:
1300
+
1301
+ ```
1302
+ Example: 80x80x60 mm design space
1303
+ Voxel size: 2mm per voxel
1304
+ Grid dimensions: 40 x 40 x 30 voxels
1305
+ Total voxels: 48,000 (solvable in <10 seconds)
1306
+
1307
+ Initial state:
1308
+ └─ All voxels: density = 1.0 (100% solid)
1309
+ ```
1310
+
1311
+ #### 4. Density Optimization (SIMP Method)
1312
+
1313
+ The algorithm iteratively adjusts voxel densities to minimize compliance (C) while respecting volume constraint:
1314
+
1315
+ ```
1316
+ SIMP Formulation:
1317
+ ─────────────────────────────────────────────────────────
1318
+ Minimize: C = U^T K U (compliance = deformation energy)
1319
+ Subject to: ∑ρ ≤ V_target (volume constraint)
1320
+ 0 ≤ ρ ≤ 1 (density bounds)
1321
+ K U = F (FEA equation)
1322
+
1323
+ Density-to-Stiffness Relation:
1324
+ ─────────────────────────────────────────────────────────
1325
+ E(ρ) = E0 × ρ^p
1326
+
1327
+ where:
1328
+ E(ρ) = effective Young's modulus
1329
+ E0 = base material modulus
1330
+ ρ = voxel relative density (0-1)
1331
+ p = penalization exponent (typically 3)
1332
+
1333
+ Effect:
1334
+ ρ = 0.5 → E = 0.125 × E0 (very weak, encouraged to remove)
1335
+ ρ = 0.1 → E = 0.001 × E0 (nearly void)
1336
+ ρ = 1.0 → E = E0 (full material)
1337
+
1338
+ Sensitivity:
1339
+ ───────────────────────────────────────────────────────────
1340
+ dC/dρ = -p × ρ^(p-1) × (stress_energy / avg_density)
1341
+
1342
+ Rule: Remove voxels with low sensitivity (won't affect stiffness much)
1343
+ ```
1344
+
1345
+ #### 5. Optimization Loop
1346
+
1347
+ ```
1348
+ Iteration 1:
1349
+ ├─ Solve FEA: Calculate stress in each voxel
1350
+ ├─ Compute sensitivity: dC/dρ for each voxel
1351
+ ├─ Update densities:
1352
+ │ ├─ High sensitivity (must-keep): ρ → 1.0
1353
+ │ ├─ Medium: ρ → 0.5
1354
+ │ └─ Low (can remove): ρ → 0.0
1355
+ ├─ Apply filter (see below)
1356
+ └─ Convergence check: |ΔC| < tolerance?
1357
+ ├─ YES → Done! Go to step 6
1358
+ └─ NO → Iteration 2 (repeat)
1359
+
1360
+ Typical convergence: 10-50 iterations
1361
+ Time per iteration: 100-500ms (depending on grid size)
1362
+ Total optimization time: 2-30 seconds
1363
+ ```
1364
+
1365
+ #### 6. Sensitivity Filtering
1366
+
1367
+ After each iteration, a spatial filter prevents checkerboard patterns:
1368
+
1369
+ ```javascript
1370
+ // Checkerboard Prevention (Helmholtz filter)
1371
+ // For each voxel ρ_i, replace with weighted average of neighbors:
1372
+
1373
+ ρ_new[i] = (
1374
+ ∑(w[j] × ρ_old[j]) / ∑w[j]
1375
+ )
1376
+
1377
+ where:
1378
+ w[j] = max(0, R_filter - distance(i, j))
1379
+ R_filter = filter radius (typical: 1.5 voxel sizes)
1380
+
1381
+ Example:
1382
+ Before filter: █░███░█░░ (checkerboard)
1383
+ After filter: ███░░░█░░ (smooth transition)
1384
+ ```
1385
+
1386
+ #### 7. Marching Cubes Isosurface Extraction
1387
+
1388
+ Convert voxel density field to triangulated mesh:
1389
+
1390
+ ```
1391
+ Algorithm:
1392
+ ──────────────────────────────────────────────────────────
1393
+ Input: 3D density grid (each voxel: 0 ≤ ρ ≤ 1)
1394
+ Threshold: ρ_iso = 0.5 (extract surface where density = 0.5)
1395
+
1396
+ For each cube of 8 voxels:
1397
+ ├─ Classify: which voxels are above/below threshold?
1398
+ ├─ Determine cube type: 256 possible cases (2^8)
1399
+ │ └─ Pre-computed triangle list for each case
1400
+ ├─ Interpolate vertex positions on edges
1401
+ │ └─ Linear interpolation to find exact crossing point
1402
+ └─ Add triangles to output mesh
1403
+
1404
+ Output: THREE.BufferGeometry with ~50,000-200,000 triangles
1405
+ (density-dependent, further reducible)
1406
+ ```
1407
+
1408
+ #### 8. Smoothing & Mesh Post-Processing
1409
+
1410
+ Raw marching cubes output is faceted; apply Laplacian smoothing:
1411
+
1412
+ ```javascript
1413
+ // Laplacian Smoothing (Catmull-Clark-inspired)
1414
+ for (5 iterations) {
1415
+ for (each vertex v) {
1416
+ neighbors = adjacentVertices(v);
1417
+ v_new = (v + avg(neighbors)) / 2;
1418
+ }
1419
+ }
1420
+
1421
+ Result: Smooth, manufacturable geometry
1422
+ ```
1423
+
1424
+ ### Example Optimization: Cantilever Bracket
1425
+
1426
+ ```
1427
+ Input:
1428
+ Design space: 100x50x80mm box
1429
+ Load: 500N downward at top-right corner
1430
+ Constraint: Fixed base at bottom-left corner
1431
+ Material: Steel
1432
+ Target volume: 50% of original
1433
+
1434
+ Iteration 1 (Initial):
1435
+ └─ All solid, stress concentrated at corners
1436
+
1437
+ Iteration 5:
1438
+ └─ Material migrating to main load path
1439
+ │ Side walls reducing, internal ribs forming
1440
+
1441
+ Iteration 15:
1442
+ └─ Clear load-path visible
1443
+ │ Internal topology resembles bone structure
1444
+
1445
+ Iteration 25 (Converged):
1446
+ ├─ Final weight: 47% of original ✓
1447
+ ├─ Compliance: 52% increase (acceptable: you saved 53% weight)
1448
+ ├─ Max stress: 180 MPa (safe, yield = 250 MPa)
1449
+ ├─ Symmetry: Natural (load path is one-sided)
1450
+ └─ Manufacturability: CNC machinable, no internal voids
1451
+
1452
+ Output Geometry:
1453
+ ├─ Main wall: 3mm solid (load-bearing)
1454
+ ├─ Support ribs: 2mm thickness
1455
+ ├─ Far corner: Reduced to shell with ribs
1456
+ └─ Total material removed: Main body walls thinned, side void
1457
+ ```
1458
+
1459
+ ### Multi-Objective Optimization
1460
+
1461
+ cycleCAD supports simultaneous optimization for multiple goals:
1462
+
1463
+ ```javascript
1464
+ const result = await window.cycleCAD.generativeDesign.optimize({
1465
+ objectives: [
1466
+ {
1467
+ name: "weight",
1468
+ priority: 1.0, // Highest priority
1469
+ target: "minimize"
1470
+ },
1471
+ {
1472
+ name: "cost",
1473
+ priority: 0.5, // Lower priority
1474
+ target: "minimize"
1475
+ },
1476
+ {
1477
+ name: "manufacturability",
1478
+ priority: 0.3,
1479
+ target: "maximize" // Easier to manufacture
1480
+ }
1481
+ ],
1482
+ constraints: {
1483
+ maxDeformation: 2.0, // mm max
1484
+ maxStress: 150, // MPa
1485
+ volumeTarget: 0.45 // 45% of original
1486
+ }
1487
+ });
1488
+
1489
+ // Returns
1490
+ {
1491
+ geometry: THREE.BufferGeometry,
1492
+ metrics: {
1493
+ weight: 0.47, // 47% of original
1494
+ cost: 0.52, // 52% of original cost
1495
+ manufacturability: 8.2, // Score 1-10
1496
+ maxStress: 148, // MPa
1497
+ deformation: 1.8, // mm
1498
+ },
1499
+ iterations: 28,
1500
+ convergenceTime: 18500, // ms
1501
+ recommendedProcess: "CNC milling"
1502
+ }
1503
+ ```
1504
+
1505
+ ### API Reference
1506
+
1507
+ #### Run Topology Optimization
1508
+
1509
+ ```javascript
1510
+ const result = await window.cycleCAD.generativeDesign.optimize(config);
1511
+
1512
+ // config:
1513
+ {
1514
+ designSpace: {
1515
+ // as defined above
1516
+ },
1517
+ loadCase: {
1518
+ // as defined above
1519
+ },
1520
+ optimization: {
1521
+ volumeFraction: 0.5, // Target 50% material
1522
+ penalizationPower: 3, // SIMP exponent
1523
+ filterRadius: 1.5, // Sensitivity filter radius (voxels)
1524
+ threshold: 0.5, // Isosurface threshold
1525
+ maxIterations: 50,
1526
+ convergenceTolerance: 0.001, // Stop when Δ C < 0.001
1527
+ verbose: true // Console progress updates
1528
+ }
1529
+ }
1530
+
1531
+ // Returns
1532
+ {
1533
+ geometry: THREE.BufferGeometry,
1534
+ densityField: Float32Array, // 3D grid (for visualization)
1535
+ metrics: { weight, cost, stress, deformation, iterations },
1536
+ convergenceHistory: [ ... ], // Compliance vs iteration
1537
+ metadata: {
1538
+ voxelSize: 2.0, // mm per voxel
1539
+ gridDimensions: [40, 40, 60],
1540
+ totalVoxels: 96000,
1541
+ activeVoxels: 45000
1542
+ }
1543
+ }
1544
+ ```
1545
+
1546
+ #### Visualize Density Field (Debugging)
1547
+
1548
+ ```javascript
1549
+ // Show semi-transparent density distribution during optimization
1550
+ window.cycleCAD.generativeDesign.visualizeDensityField(
1551
+ densityField,
1552
+ {
1553
+ colorScheme: "density", // density, stress, sensitivity
1554
+ opacity: 0.3,
1555
+ showIsosurface: true
1556
+ }
1557
+ );
1558
+ ```
1559
+
1560
+ #### Create Manufacturing Notes
1561
+
1562
+ ```javascript
1563
+ const notes = window.cycleCAD.generativeDesign.getManufacturingNotes(
1564
+ geometry,
1565
+ {
1566
+ process: "cnc-3axis",
1567
+ tolerances: {
1568
+ general: 0.1,
1569
+ critical: 0.05
1570
+ }
1571
+ }
1572
+ );
1573
+
1574
+ // Returns markdown with suggested approach for machining
1575
+ ```
1576
+
1577
+ ---
1578
+
1579
+ ## Multi-Physics: Simulation
1580
+
1581
+ Real-time physics simulation combining FEA (Finite Element Analysis), thermal analysis, modal analysis, and drop testing—all in the browser with GPU acceleration.
1582
+
1583
+ ### How It Works
1584
+
1585
+ **Pipeline:** Mesh Discretization → Matrix Assembly → Solver (CG/GMRES) → Post-Processing → Visualization
1586
+
1587
+ #### 1. Supported Analysis Types
1588
+
1589
+ | Analysis Type | What It Solves | Output | Typical Use |
1590
+ |---|---|---|---|
1591
+ | **Static Structural** | Stress & deformation under loads | Von Mises stress, displacement, safety factor | Check part won't break |
1592
+ | **Thermal** | Heat flow, temperature distribution | Temperature field, thermal stress | Check thermal stability |
1593
+ | **Modal (Vibration)** | Natural frequencies & mode shapes | Freq (Hz), mode shape (deformation pattern) | Avoid resonance frequencies |
1594
+ | **Harmonic (Swept Freq)** | Response to oscillating loads | Amplitude vs frequency | Vibration isolation tuning |
1595
+ | **Drop Test (Transient)** | Impact dynamics, peak acceleration | Acceleration peak, energy absorption | Package protection validation |
1596
+ | **Buckling** | Critical load to cause collapse | Buckling load factor, mode shapes | Column/beam stability |
1597
+
1598
+ #### 2. Static Structural Analysis
1599
+
1600
+ **FEA Formulation:**
1601
+
1602
+ ```
1603
+ Global Stiffness Equation:
1604
+ ─────────────────────────────────────────────────────────
1605
+ [K] {u} = {F}
1606
+
1607
+ where:
1608
+ [K] = global stiffness matrix (size: n_DOF × n_DOF)
1609
+ {u} = displacement vector
1610
+ {F} = load vector
1611
+
1612
+ Assembly Process:
1613
+ ─────────────────────────────────────────────────────────
1614
+ For each tetrahedral element:
1615
+ 1. Compute local element stiffness [k_e]
1616
+ (depends on element shape, Young's modulus, Poisson ratio)
1617
+ 2. Compute local load vector {f_e}
1618
+ 3. Add to global system: [K] += [k_e], {F} += {f_e}
1619
+
1620
+ Boundary Conditions:
1621
+ ─────────────────────────────────────────────────────────
1622
+ Fixed support: u_x = u_y = u_z = 0 at selected nodes
1623
+ Roller support: u_z = 0 (constrained in one direction only)
1624
+ Load: F_x, F_y, or F_z applied at node
1625
+
1626
+ Solution:
1627
+ ─────────────────────────────────────────────────────────
1628
+ Solve [K] {u} = {F} using Conjugate Gradient (CG) solver
1629
+ Sparse matrix format: CSR (Compressed Sparse Row)
1630
+ Iterative solver: <100 iterations for well-conditioned problems
1631
+ Tolerance: ||r|| < 1e-6 × ||F||
1632
+
1633
+ Post-Process:
1634
+ ─────────────────────────────────────────────────────────
1635
+ For each element:
1636
+ 1. Recover strain: {ε} = [B] {u_e}
1637
+ where [B] = strain-displacement matrix
1638
+ 2. Recover stress: {σ} = [E] {ε}
1639
+ where [E] = material stiffness matrix (Hooke's law)
1640
+ 3. Von Mises stress: σ_vm = √(σ_x² + σ_y² + σ_z² - σ_x*σ_y - σ_y*σ_z - σ_z*σ_x)
1641
+ 4. Safety factor: SF = σ_yield / σ_vm (for each element)
1642
+ ```
1643
+
1644
+ **Example: Load on Bracket**
1645
+
1646
+ ```
1647
+ Load case:
1648
+ ├─ 500 N downward at top-right
1649
+ ├─ Fixed support at base
1650
+ └─ Material: Aluminum (E = 69 GPa, σ_yield = 90 MPa)
1651
+
1652
+ Mesh:
1653
+ ├─ Tetrahedra: 5,000 elements
1654
+ ├─ Nodes: 1,200 nodes
1655
+ └─ DOF: 3,600 (3 per node)
1656
+
1657
+ Solution:
1658
+ ├─ Max displacement: 2.1 mm (at load point)
1659
+ ├─ Max stress: 67 MPa (at fixed end)
1660
+ ├─ Safety factor: 90 / 67 = 1.34 ✓ (safe)
1661
+ └─ Solve time: 245 ms
1662
+
1663
+ Visualization:
1664
+ ├─ Deformation: 10x scale for visibility
1665
+ ├─ Stress heatmap: Red (high stress) → Green (low)
1666
+ └─ Displacement vector field: Arrows show direction
1667
+ ```
1668
+
1669
+ #### 3. Thermal Analysis
1670
+
1671
+ **Heat Transfer Equation:**
1672
+
1673
+ ```
1674
+ Transient Heat Conduction:
1675
+ ─────────────────────────────────────────────────────────
1676
+ ρ C_p ∂T/∂t = ∇·(k ∇T) + Q
1677
+
1678
+ where:
1679
+ ρ = density (kg/m³)
1680
+ C_p = specific heat (J/kg·K)
1681
+ T = temperature (K)
1682
+ k = thermal conductivity (W/m·K)
1683
+ Q = heat source (W/m³)
1684
+
1685
+ Boundary Conditions:
1686
+ ─────────────────────────────────────────────────────────
1687
+ - Fixed temperature: T = T_boundary (convection chamber)
1688
+ - Heat flux: -k ∇T·n = q (applied heat)
1689
+ - Convection: -k ∇T·n = h (T - T_ambient)
1690
+ where h = convection coefficient (W/m²·K)
1691
+
1692
+ Material Properties (Temperature-Dependent):
1693
+ ─────────────────────────────────────────────────────────
1694
+ Aluminum (example):
1695
+ k(T) = 237 - 0.05×(T - 300) W/m·K (decreases with temperature)
1696
+ C_p ≈ 900 J/kg·K (varies slightly)
1697
+
1698
+ Assembly & Solution:
1699
+ ─────────────────────────────────────────────────────────
1700
+ [C]{Ṫ} + [K]{T} = {Q}
1701
+
1702
+ Solve using:
1703
+ 1. Spatial discretization: Galerkin FEM
1704
+ 2. Time stepping: Implicit Euler or Crank-Nicolson
1705
+ 3. Sparse solver: GMRES with preconditioning
1706
+ ```
1707
+
1708
+ **Example: Motor Housing Thermal Profile**
1709
+
1710
+ ```
1711
+ Load case:
1712
+ ├─ Heat source: 150 W (internal motor loss)
1713
+ ├─ Ambient temp: 25°C
1714
+ ├─ Cooling: Natural convection (h = 10 W/m²·K)
1715
+ └─ Material: Aluminum
1716
+
1717
+ Transient Analysis (first 600 seconds):
1718
+ ├─ t = 0: T = 25°C everywhere
1719
+ ├─ t = 60s: Peak interior 85°C (temperature rising)
1720
+ ├─ t = 300s: Steady-state approached
1721
+ │ ├─ Interior: 82°C
1722
+ │ ├─ Outer surface: 65°C
1723
+ │ └─ Edges: 55°C (better cooling)
1724
+ └─ t = 600s: Fully steady
1725
+
1726
+ Peak temperature: 82°C (safe, aluminum OK to ~150°C)
1727
+ Thermal gradient: 82 - 25 = 57°C (may cause thermal stress)
1728
+ ```
1729
+
1730
+ #### 4. Modal Analysis (Vibration Frequencies)
1731
+
1732
+ **Eigenvalue Problem:**
1733
+
1734
+ ```
1735
+ Undamped Free Vibration:
1736
+ ─────────────────────────────────────────────────────────
1737
+ [K]{φ} = ω² [M]{φ}
1738
+
1739
+ Rearranged (standard eigenvalue form):
1740
+ ([K] - ω² [M]){φ} = 0
1741
+
1742
+ where:
1743
+ [K] = stiffness matrix
1744
+ [M] = mass matrix
1745
+ ω = natural frequency (rad/s)
1746
+ {φ} = mode shape (eigenvector)
1747
+
1748
+ Solution Method:
1749
+ ─────────────────────────────────────────────────────────
1750
+ Use Lanczos iteration or Subspace method to find:
1751
+ - Lowest N natural frequencies (typically N = 5-20)
1752
+ - Corresponding mode shapes
1753
+
1754
+ Conversion:
1755
+ f (Hz) = ω (rad/s) / (2π)
1756
+ Period T (ms) = 1000 / f
1757
+ ```
1758
+
1759
+ **Example: Cantilever Beam Vibration**
1760
+
1761
+ ```
1762
+ Part: Aluminum beam, 200mm long, fixed at one end
1763
+ Mesh: 2,000 tetrahedral elements
1764
+
1765
+ First 5 Natural Frequencies:
1766
+ ┌─────┬──────────┬──────────┬───────────────────────────┐
1767
+ │ Mode│ Freq (Hz)│ Period │ Mode Shape Description │
1768
+ ├─────┼──────────┼──────────┼───────────────────────────┤
1769
+ │ 1 │ 48.2 Hz │ 20.7 ms │ Primary bending (1st half)│
1770
+ │ 2 │ 302 Hz │ 3.3 ms │ Primary bending (full len)│
1771
+ │ 3 │ 845 Hz │ 1.2 ms │ Complex 3D bending │
1772
+ │ 4 │ 1650 Hz │ 0.61 ms │ Torsional twist │
1773
+ │ 5 │ 2310 Hz │ 0.43 ms │ Higher-order torsion │
1774
+ └─────┴──────────┴──────────┴───────────────────────────┘
1775
+
1776
+ Design Implication:
1777
+ If operating at 50 Hz → AVOID (near mode 1 = resonance!)
1778
+ If operating at 100 Hz → OK (away from all modes)
1779
+ If operating at 1000 Hz → RISKY (approaching mode 3)
1780
+ ```
1781
+
1782
+ #### 5. Drop Test Analysis
1783
+
1784
+ **Transient Impact Dynamics:**
1785
+
1786
+ ```
1787
+ Simplified Model:
1788
+ ─────────────────────────────────────────────────────────
1789
+ Part drops from height H
1790
+ v_impact = √(2 g H) (velocity at contact)
1791
+
1792
+ Contact with floor (1ms contact duration):
1793
+ ├─ Deceleration impulse: F = m (v_impact / Δt)
1794
+ ├─ Acceleration: a = F / m
1795
+ └─ Peak deceleration: a_peak = v_impact / Δt
1796
+
1797
+ FEA During Impact:
1798
+ ─────────────────────────────────────────────────────────
1799
+ [M]{ü} + [C]{u̇} + [K]{u} = {F(t)}
1800
+
1801
+ where:
1802
+ [M] = mass matrix (inertia resists acceleration)
1803
+ [C] = damping matrix (energy dissipation)
1804
+ {F(t)} = time-varying contact force
1805
+
1806
+ Contact Detection:
1807
+ ─────────────────────────────────────────────────────────
1808
+ 1. Find lowest point of part
1809
+ 2. When z < 0 (floor level): activate contact
1810
+ 3. Contact force: F = k_contact × penetration
1811
+ (spring-like floor: very stiff, k ~ 1e8 N/m)
1812
+ 4. Damping: c_contact = 0.2-0.5 × critical damping
1813
+ ```
1814
+
1815
+ **Example: Smartphone Drop Test**
1816
+
1817
+ ```
1818
+ Scenario:
1819
+ ├─ Phone mass: 200g
1820
+ ├─ Drop height: 1.5 meters (home shoulder height)
1821
+ ├─ Impact surface: Concrete (hard, high damping)
1822
+ └─ Case: TPU rubber (shock-absorbing)
1823
+
1824
+ Impact Analysis:
1825
+ ├─ Impact velocity: √(2 × 9.81 × 1.5) = 5.4 m/s
1826
+ ├─ Contact duration: ~3 ms (estimated from material properties)
1827
+ ├─ Peak deceleration: 5.4 / 0.003 = 1,800 g (!!)
1828
+ │ (1,800 times gravity — very harsh)
1829
+ └─ Peak deceleration (with damping): 450 g (still severe)
1830
+
1831
+ Stress During Impact:
1832
+ ├─ Display glass: 650 MPa (breaks at 1000 MPa) → SAFE
1833
+ ├─ PCB: 450 MPa (breaks at 800 MPa) → SAFE
1834
+ ├─ Solder joints: 280 MPa (breaks at 350 MPa) → MARGINAL ⚠
1835
+ └─ Camera corner: 920 MPa (expected point of failure) ✗
1836
+
1837
+ Pass/Fail:
1838
+ └─ FAIL: Camera assembly will break at concrete impact
1839
+ (but TPU case reduces effective deceleration)
1840
+
1841
+ Recommendations:
1842
+ ├─ Add padding around camera
1843
+ ├─ Increase TPU thickness from 2mm to 3mm
1844
+ └─ Redesign solder joint reinforcement
1845
+ ```
1846
+
1847
+ ### Material Properties Database
1848
+
1849
+ Multi-physics module includes complete property tables for all materials:
1850
+
1851
+ ```
1852
+ Material ρ(kg/m³) E(GPa) σ_y(MPa) k(W/m·K) α(µm/m·K) Notes
1853
+ ────────────────────────────────────────────────────────────────────────
1854
+ Steel (1018) 7850 200 250 52 11.0 Magnetic
1855
+ Aluminum 6061 2700 69 90 167 23.6 Light
1856
+ Titanium 6-4 4510 103 880 7.4 8.6 Expensive
1857
+ Brass C360 8470 97 300 109 20.0 High damping
1858
+ Nylon 6 1140 3.0 70 0.26 80.0 Low k
1859
+ ABS plastic 1050 2.3 40 0.2 100 Low k, tough
1860
+ Copper 8960 110 210 401 16.5 High k
1861
+ Cast Iron 7750 150 340 46 10.5 Brittle
1862
+ Glass (SiO2) 2200 70 50 1.2 0.5 Brittle
1863
+ Carbon composite 1550 130 1100 5 -1.0 Anisotropic
1864
+ ```
1865
+
1866
+ Each material includes also:
1867
+ - Temperature-dependent properties (k, E vary with T)
1868
+ - Damping ratio (ζ) for vibration analysis
1869
+ - Thermal expansion coefficient (α) for thermal stress
1870
+ - Yield and ultimate tensile strength
1871
+ - Shear modulus (G) and Poisson ratio (ν)
1872
+
1873
+ ### API Reference
1874
+
1875
+ #### Run Static Analysis
1876
+
1877
+ ```javascript
1878
+ const result = await window.cycleCAD.multiPhysics.runAnalysis(
1879
+ geometry,
1880
+ {
1881
+ analysisType: "static",
1882
+ material: "aluminum-6061",
1883
+ loads: [
1884
+ {
1885
+ type: "force",
1886
+ location: {x: 0, y: 0, z: 100},
1887
+ direction: {x: 0, y: 0, z: -1},
1888
+ magnitude: 500 // 500 N
1889
+ }
1890
+ ],
1891
+ constraints: [
1892
+ {
1893
+ type: "fixed",
1894
+ region: { shape: "sphere", center: {x:0, y:0, z:-10}, radius: 15 }
1895
+ }
1896
+ ],
1897
+ meshDensity: "medium", // "coarse", "medium", "fine"
1898
+ solver: "cg" // Conjugate Gradient
1899
+ }
1900
+ );
1901
+
1902
+ // Returns
1903
+ {
1904
+ success: true,
1905
+ maxStress: 67.5, // MPa
1906
+ maxDisplacement: 2.1, // mm
1907
+ safetyFactor: 1.33, // σ_yield / σ_max
1908
+ strainEnergy: 1.245, // Joules
1909
+ deformationGeometry: THREE.BufferGeometry,
1910
+ stressField: Float32Array, // Stress at each element
1911
+ displacementField: Float32Array,
1912
+ solveTime: 245, // milliseconds
1913
+ iterations: 87
1914
+ }
1915
+ ```
1916
+
1917
+ #### Run Thermal Analysis
1918
+
1919
+ ```javascript
1920
+ const result = await window.cycleCAD.multiPhysics.runAnalysis(
1921
+ geometry,
1922
+ {
1923
+ analysisType: "thermal",
1924
+ material: "aluminum-6061",
1925
+ heatSources: [
1926
+ { location: {x:0, y:0, z:0}, power: 150 } // 150 W at center
1927
+ ],
1928
+ boundaryConditions: [
1929
+ {
1930
+ type: "convection",
1931
+ region: { shape: "surface" },
1932
+ ambientTemp: 25, // °C
1933
+ convectionCoeff: 10 // W/m²·K
1934
+ }
1935
+ ],
1936
+ transientTime: 600, // seconds to simulate
1937
+ timeStep: 5, // seconds per step
1938
+ initialTemp: 25 // °C everywhere
1939
+ }
1940
+ );
1941
+
1942
+ // Returns
1943
+ {
1944
+ temperature: Float32Array, // T at each node over time
1945
+ timeSteps: [0, 5, 10, ..., 600],
1946
+ peakTemperature: 82, // °C
1947
+ temperatureGradient: 57, // max T - min T
1948
+ steadyStateReached: true,
1949
+ convergenceTime: 320, // seconds to steady
1950
+ heatFlux: Float32Array, // W/m² at boundary
1951
+ thermalStress: Float32Array // Stress from thermal expansion
1952
+ }
1953
+ ```
1954
+
1955
+ #### Run Modal Analysis
1956
+
1957
+ ```javascript
1958
+ const result = await window.cycleCAD.multiPhysics.runAnalysis(
1959
+ geometry,
1960
+ {
1961
+ analysisType: "modal",
1962
+ material: "aluminum-6061",
1963
+ constraints: [
1964
+ { type: "fixed", region: { shape: "sphere", ... } }
1965
+ ],
1966
+ numModes: 10, // Extract first 10 modes
1967
+ solver: "lanczos"
1968
+ }
1969
+ );
1970
+
1971
+ // Returns
1972
+ {
1973
+ frequencies: [48.2, 302, 845, 1650, 2310, ...], // Hz
1974
+ periods: [20.7, 3.3, 1.2, 0.61, 0.43, ...], // ms
1975
+ modeShapes: [
1976
+ THREE.BufferGeometry, // Mode 1 shape
1977
+ THREE.BufferGeometry, // Mode 2 shape
1978
+ // ...
1979
+ ],
1980
+ dampingRatios: [0.02, 0.02, 0.03, ...], // ζ values
1981
+ modalMasses: [150, 145, 140, ...], // kg
1982
+ participationFactors: [0.85, 0.12, 0.02, ...] // contribution to motion
1983
+ }
1984
+ ```
1985
+
1986
+ #### Run Drop Test
1987
+
1988
+ ```javascript
1989
+ const result = await window.cycleCAD.multiPhysics.runAnalysis(
1990
+ geometry,
1991
+ {
1992
+ analysisType: "drop",
1993
+ material: "aluminum-6061",
1994
+ dropHeight: 1500, // mm
1995
+ impactSurface: "concrete", // concrete, wood, foam
1996
+ contactStiffness: 1e8, // N/m (very stiff surface)
1997
+ damping: 0.3, // critical damping ratio
1998
+ simulationTime: 0.05, // seconds
1999
+ timeStep: 0.0001 // seconds (auto-refined near impact)
2000
+ }
2001
+ );
2002
+
2003
+ // Returns
2004
+ {
2005
+ peakAcceleration: 1200, // g (gravitational units)
2006
+ peakVelocity: 5.4, // m/s (impact velocity)
2007
+ peakStress: 850, // MPa
2008
+ peakDisplacement: 3.2, // mm (max penetration)
2009
+ impactDuration: 0.003, // seconds (contact time)
2010
+ energyAbsorbed: 2.9, // Joules
2011
+ passFailRegions: {
2012
+ camera: "FAIL", // Stress > ultimate
2013
+ solder: "MARGINAL", // Stress near limit
2014
+ display: "PASS" // Stress < safe
2015
+ },
2016
+ deformationTimeSeries: [...], // Geometry evolution during impact
2017
+ accelerationTimeSeries: [...] // a(t) during impact
2018
+ }
2019
+ ```
2020
+
2021
+ #### Visualize Results
2022
+
2023
+ ```javascript
2024
+ // Show stress heatmap on deformed geometry
2025
+ window.cycleCAD.multiPhysics.visualizeResults(
2026
+ result,
2027
+ {
2028
+ field: "stress", // stress, displacement, temp, frequency
2029
+ deformationScale: 10, // 10x exaggeration
2030
+ colorScheme: "diverging", // diverging, sequential, categorical
2031
+ showLegend: true,
2032
+ showDeformation: true,
2033
+ contourLines: true // Draw iso-contours
2034
+ }
2035
+ );
2036
+
2037
+ // Export results
2038
+ const dataURL = window.cycleCAD.multiPhysics.exportResults(
2039
+ result,
2040
+ {
2041
+ format: "vtk", // VTK format for Paraview
2042
+ includeField: ["stress", "displacement"]
2043
+ }
2044
+ );
2045
+ // Download as VTK file
2046
+ ```
2047
+
2048
+ ---
2049
+
2050
+ ## Smart Parts Library
2051
+
2052
+ Access 200+ standard parts including fasteners, bearings, linear motion components, structural elements, and electronics. Intelligent search, auto-insertion, BOM management, and supplier cross-reference.
2053
+
2054
+ ### Catalog Overview
2055
+
2056
+ | Category | Part Count | Examples |
2057
+ |----------|-----------|----------|
2058
+ | **Fasteners** | 85 | ISO 4762 socket head caps, DIN 912 hex bolts, M3-M20, stainless steel variants |
2059
+ | **Bearings** | 32 | Deep groove ball (6000, 6200 series), angular contact, pillow block units |
2060
+ | **Linear Motion** | 28 | THK rails, Hiwin blocks, ball screws ISO 4014, lead screws, bushings |
2061
+ | **Structural** | 24 | Aluminum extrusions (45x45 T-slot, 40x80), angle iron, hollow tubes |
2062
+ | **Electronics** | 18 | DC motors (12V, 24V), stepper motors (NEMA 17, 23), limit switches, relays |
2063
+ | **Pneumatics** | 13 | Cylinders (compact, rod), solenoid valves, regulators, fittings ISO 6149 |
2064
+ | **Total** | **200+** | Complete standard catalog |
2065
+
2066
+ ### Fastener Category Details
2067
+
2068
+ ```
2069
+ ISO 4762 Socket Head Cap Screw
2070
+ ├─ Sizes: M3, M4, M5, M6, M8, M10, M12, M16, M20
2071
+ ├─ Lengths: 6-100mm (standard increments)
2072
+ ├─ Materials:
2073
+ │ ├─ Stainless Steel A2-70 (corrosion resist)
2074
+ │ ├─ Stainless Steel A4-80 (marine grade)
2075
+ │ ├─ Carbon Steel 8.8 (standard, cheaper)
2076
+ │ └─ Titanium Grade 5 (lightweight)
2077
+ ├─ Properties (example M8):
2078
+ │ ├─ Head height: 8mm
2079
+ │ ├─ Socket: 6mm hex
2080
+ │ ├─ Proof load: 48 kN
2081
+ │ ├─ Yield: 640 MPa
2082
+ │ ├─ Cost: $0.08-0.50 depending on material/length
2083
+ │ └─ Weight: 4.0g per piece
2084
+ └─ Models: 3D CAD model (STEP/STL) for each variant
2085
+
2086
+ DIN 912 Hex Bolt (alternative to ISO 4762)
2087
+ ├─ Similar specs but with hex head instead of socket
2088
+ ├─ Cost: 20% cheaper
2089
+ ├─ Easier to install with common wrench
2090
+ └─ Models available for M5-M24
2091
+
2092
+ ...similar details for 83 other fastener types
2093
+ ```
2094
+
2095
+ ### AI Search Capabilities
2096
+
2097
+ #### Natural Language Queries
2098
+
2099
+ ```
2100
+ User Types: System Interprets:
2101
+ ──────────────────────────────────────────────────────────
2102
+ "10mm bolt stainless" ISO 4762 M10, stainless A2
2103
+ "bearing for 20mm shaft" Deep groove ball bearing 6004
2104
+ "50mm aluminum extrusion" 45x45 or 40x80 T-slot, aluminum
2105
+ "motor 24 volt" DC motor 24VDC, ~5-50W range
2106
+ "limit switch NO contact" Electronic limit switch, N.O. type
2107
+ ```
2108
+
2109
+ #### Fuzzy Matching
2110
+
2111
+ ```
2112
+ Query typos handled:
2113
+ "ISO 4672" → "ISO 4762" ✓
2114
+ "M8x1.25 bolt" → "M8 screw" ✓
2115
+ "bearing 6002 series" → "bearing 6002" ✓
2116
+ ```
2117
+
2118
+ #### Semantic Search
2119
+
2120
+ ```
2121
+ "I need something to hold a shaft on the motor"
2122
+ → Suggests: shaft collar, key, set screw, bearing
2123
+
2124
+ "Low friction linear motion"
2125
+ → Suggests: linear rail (ball or roller), low-friction bushing
2126
+ ```
2127
+
2128
+ #### Supplier Integration
2129
+
2130
+ Each part includes cross-references:
2131
+
2132
+ ```
2133
+ Part: ISO 4762 M8 x 20 Socket Head Cap Screw (Stainless A2)
2134
+
2135
+ Suppliers:
2136
+ ├─ McMaster: 91292A162, $0.32/each
2137
+ ├─ Misumi: SCBS-M8-20, $0.25/each
2138
+ ├─ DigiKey: H765-ND, $0.28/each
2139
+ ├─ RS Components: 503-648, $0.30/each
2140
+ └─ eBay (bulk 100/box): $0.12/each if qty >= 1000
2141
+
2142
+ Recommended: Misumi (lowest cost, quick ship Japan)
2143
+ ```
2144
+
2145
+ ### Part Insertion Workflow
2146
+
2147
+ #### Step 1: Search & Select
2148
+
2149
+ ```
2150
+ User Action System Response
2151
+ ────────────────────────────────────────────────────
2152
+ Type "M8 bolt" Show 5 part suggestions
2153
+ Click "ISO 4762 M8x20" Preview 3D model in mini viewport
2154
+ Select variant: stainless A2 Confirm choice, add to insert queue
2155
+ ```
2156
+
2157
+ #### Step 2: Positioning
2158
+
2159
+ ```
2160
+ Insert Mode Activated:
2161
+ └─ Part follows mouse cursor (3D preview)
2162
+
2163
+ User Actions:
2164
+ ├─ Move mouse → Preview moves
2165
+ ├─ Click on geometry → Part placed at click location
2166
+ │ (auto-snaps to nearest hole or surface if applicable)
2167
+ ├─ Right-click → Rotate preview 45° increments
2168
+ ├─ Scroll → Scale preview (if part is adjustable)
2169
+ └─ Enter → Confirm placement
2170
+ ```
2171
+
2172
+ #### Step 3: Auto-Assembly (Optional)
2173
+
2174
+ If inserting fastener into existing hole:
2175
+
2176
+ ```
2177
+ Detection:
2178
+ ├─ System finds nearest hole in geometry
2179
+ ├─ Matches M8 bolt to M8 hole
2180
+ └─ Auto-aligns bolt axis with hole axis
2181
+
2182
+ User Confirmation:
2183
+ "Auto-snap M8 bolt to hole at (x, y, z)?"
2184
+ └─ Yes/No dialog
2185
+ ```
2186
+
2187
+ #### Step 4: BOM Generation
2188
+
2189
+ ```
2190
+ BOM Table Auto-Updated:
2191
+ ┌──────────────────────────────────┬───┬──────────────┐
2192
+ │ Part │ Qty│ Supplier │
2193
+ ├──────────────────────────────────┼───┼──────────────┤
2194
+ │ ISO 4762 M8x20 Stainless A2-70 │ 4 │ Misumi │
2195
+ │ Deep Groove Bearing 6004 │ 2 │ SKF/NSK │
2196
+ │ THK Linear Rail HRW15CA 300mm │ 1 │ McMaster │
2197
+ │ NEMA 17 Stepper Motor │ 1 │ Amazon │
2198
+ └──────────────────────────────────┴───┴──────────────┘
2199
+
2200
+ Total Cost: $47.50
2201
+ Weight: 450g
2202
+ Lead Time: 5-7 days (Misumi + Amazon)
2203
+ ```
2204
+
2205
+ ### API Reference
2206
+
2207
+ #### Search Catalog
2208
+
2209
+ ```javascript
2210
+ const results = await window.cycleCAD.smartParts.search(
2211
+ "M8 bolt stainless",
2212
+ {
2213
+ limit: 10,
2214
+ fuzzyMatch: true,
2215
+ includeProperties: ["cost", "supplier", "weight"],
2216
+ sortBy: "relevance" // relevance, cost, weight, lead_time
2217
+ }
2218
+ );
2219
+
2220
+ // Returns
2221
+ [
2222
+ {
2223
+ id: "iso-4762-m8-20-ss-a2",
2224
+ name: "ISO 4762 Socket Head Cap Screw M8 x 20 Stainless A2-70",
2225
+ category: "fasteners",
2226
+ properties: {
2227
+ diameter: 8,
2228
+ length: 20,
2229
+ pitch: 1.25,
2230
+ material: "stainless steel A2-70",
2231
+ headHeight: 8,
2232
+ socketSize: 6
2233
+ },
2234
+ cost: { min: 0.12, avg: 0.28, max: 0.50 },
2235
+ suppliers: [
2236
+ { name: "Misumi", partNo: "SCBS-M8-20", cost: 0.25, leadDays: 3 },
2237
+ { name: "McMaster", partNo: "91292A162", cost: 0.32, leadDays: 1 }
2238
+ ],
2239
+ weight: 0.63, // grams
2240
+ geometryUrl: "models/iso-4762-m8-20.step",
2241
+ confidence: 0.95
2242
+ },
2243
+ // ... more results
2244
+ ]
2245
+ ```
2246
+
2247
+ #### Get Part Details
2248
+
2249
+ ```javascript
2250
+ const partDetail = await window.cycleCAD.smartParts.getPart("iso-4762-m8-20-ss-a2");
2251
+
2252
+ // Returns
2253
+ {
2254
+ id, name, category, ...,
2255
+ technical: {
2256
+ proofLoad: 48000, // N
2257
+ yieldStrength: 640, // MPa
2258
+ tensionArea: 36.6, // mm²
2259
+ threadPitch: 1.25, // mm
2260
+ shearStrength: 480, // MPa
2261
+ hardness: 300, // HV
2262
+ },
2263
+ 3dModels: {
2264
+ step: "models/iso-4762-m8-20.step",
2265
+ stl: "models/iso-4762-m8-20.stl",
2266
+ threaded: true,
2267
+ parametric: false
2268
+ },
2269
+ documentatio: {
2270
+ spec: "ISO 4762:2004 (socket head cap screw)",
2271
+ drawing: "pdf/..."
2272
+ }
2273
+ }
2274
+ ```
2275
+
2276
+ #### Insert Part into Assembly
2277
+
2278
+ ```javascript
2279
+ const inserted = await window.cycleCAD.smartParts.insertPart(
2280
+ "iso-4762-m8-20-ss-a2",
2281
+ {
2282
+ position: {x: 0, y: 0, z: 50},
2283
+ rotation: {x: 0, y: 0, z: 0},
2284
+ quantity: 4,
2285
+ autoSnap: true, // Auto-align to nearest hole
2286
+ addToBOM: true
2287
+ }
2288
+ );
2289
+
2290
+ // Returns
2291
+ {
2292
+ geometry: THREE.BufferGeometry,
2293
+ instanceCount: 4,
2294
+ positions: [[0,0,50], [20,0,50], [0,20,50], [20,20,50]],
2295
+ snappedToHoles: [hole1, hole2, hole3, hole4],
2296
+ bomEntry: { partId, quantity, supplier, cost },
2297
+ addedToScene: true
2298
+ }
2299
+ ```
2300
+
2301
+ #### Generate Bill of Materials (BOM)
2302
+
2303
+ ```javascript
2304
+ const bom = window.cycleCAD.smartParts.generateBOM(
2305
+ {
2306
+ format: "csv", // csv, json, xlsx, html
2307
+ includeSuppliers: true,
2308
+ includeCosts: true,
2309
+ groupBySupplier: true
2310
+ }
2311
+ );
2312
+
2313
+ // Returns CSV:
2314
+ // Part,Description,Qty,Unit Cost,Total Cost,Supplier,Lead Days
2315
+ // iso-4762-m8-20-ss-a2,"Socket Head Cap M8x20",4,$0.25,$1.00,Misumi,3
2316
+ // 6004-2z-ss,"Deep Groove Bearing",2,$5.50,$11.00,SKF,1
2317
+ // ...
2318
+ ```
2319
+
2320
+ #### Export BOM to CSV/Excel
2321
+
2322
+ ```javascript
2323
+ const csvData = window.cycleCAD.smartParts.exportBOM("csv");
2324
+ const file = new File([csvData], "assembly-bom.csv", {type: "text/csv"});
2325
+ // User downloads file
2326
+ ```
2327
+
2328
+ ---
2329
+
2330
+ ## Integration Guide
2331
+
2332
+ ### Wiring All 6 Modules into cycleCAD
2333
+
2334
+ #### Step 1: Import in index.html
2335
+
2336
+ Add to the module import section:
2337
+
2338
+ ```html
2339
+ <!-- In app/index.html, within <script> tags -->
2340
+ <script type="module">
2341
+ // Import all 6 killer modules
2342
+ import TextToCad from './js/text-to-cad.js';
2343
+ import PhotoToCad from './js/photo-to-cad.js';
2344
+ import Manufacturability from './js/manufacturability.js';
2345
+ import GenerativeDesign from './js/generative-design.js';
2346
+ import MultiPhysics from './js/multi-physics.js';
2347
+ import SmartParts from './js/smart-parts.js';
2348
+
2349
+ // Initialize on app load
2350
+ window.addEventListener('DOMContentLoaded', () => {
2351
+ const app = window.cycleCAD;
2352
+
2353
+ // Register modules
2354
+ app.textToCad = new TextToCad(app);
2355
+ app.photoToCad = new PhotoToCad(app);
2356
+ app.manufacturability = new Manufacturability(app);
2357
+ app.generativeDesign = new GenerativeDesign(app);
2358
+ app.multiPhysics = new MultiPhysics(app);
2359
+ app.smartParts = new SmartParts(app);
2360
+
2361
+ // Initialize each module
2362
+ app.textToCad.init();
2363
+ app.photoToCad.init();
2364
+ app.manufacturability.init();
2365
+ app.generativeDesign.init();
2366
+ app.multiPhysics.init();
2367
+ app.smartParts.init();
2368
+
2369
+ console.log('✓ All 6 killer modules loaded');
2370
+ });
2371
+ </script>
2372
+ ```
2373
+
2374
+ #### Step 2: Add UI Buttons to Toolbar
2375
+
2376
+ ```html
2377
+ <!-- In the toolbar section of index.html -->
2378
+ <div id="toolbar">
2379
+ <!-- ... existing buttons ... -->
2380
+
2381
+ <!-- Killer Features Section -->
2382
+ <div class="toolbar-group" title="AI & Optimization">
2383
+ <button id="btn-text-to-cad" title="Text-to-CAD (Ctrl+T)">
2384
+ <span class="icon">📝</span> T2C
2385
+ </button>
2386
+ <button id="btn-photo-to-cad" title="Photo-to-CAD (Ctrl+P)">
2387
+ <span class="icon">📷</span> P2C
2388
+ </button>
2389
+ <button id="btn-manufacturability" title="DFM Analysis (Ctrl+M)">
2390
+ <span class="icon">🏭</span> DFM
2391
+ </button>
2392
+ <button id="btn-generative" title="Topology Optimization (Ctrl+G)">
2393
+ <span class="icon">🧬</span> Gen
2394
+ </button>
2395
+ <button id="btn-physics" title="Multi-Physics (Ctrl+Shift+P)">
2396
+ <span class="icon">⚙️</span> FEA
2397
+ </button>
2398
+ <button id="btn-parts" title="Smart Parts Library (Ctrl+L)">
2399
+ <span class="icon">📦</span> Parts
2400
+ </button>
2401
+ </div>
2402
+ </div>
2403
+ ```
2404
+
2405
+ #### Step 3: Wire Button Handlers
2406
+
2407
+ ```javascript
2408
+ // In app.js initialization section
2409
+ document.getElementById('btn-text-to-cad').addEventListener('click', () => {
2410
+ window.cycleCAD.textToCad.show();
2411
+ });
2412
+
2413
+ document.getElementById('btn-photo-to-cad').addEventListener('click', () => {
2414
+ window.cycleCAD.photoToCad.show();
2415
+ });
2416
+
2417
+ document.getElementById('btn-manufacturability').addEventListener('click', () => {
2418
+ window.cycleCAD.manufacturability.show();
2419
+ });
2420
+
2421
+ document.getElementById('btn-generative').addEventListener('click', () => {
2422
+ window.cycleCAD.generativeDesign.show();
2423
+ });
2424
+
2425
+ document.getElementById('btn-physics').addEventListener('click', () => {
2426
+ window.cycleCAD.multiPhysics.show();
2427
+ });
2428
+
2429
+ document.getElementById('btn-parts').addEventListener('click', () => {
2430
+ window.cycleCAD.smartParts.show();
2431
+ });
2432
+ ```
2433
+
2434
+ ### Chaining Modules for Powerful Workflows
2435
+
2436
+ #### Workflow 1: Design → Optimize → Check DFM → Order Parts
2437
+
2438
+ ```javascript
2439
+ // User-facing workflow (high-level)
2440
+
2441
+ async function designOptimizeAndProcure() {
2442
+ // Step 1: Create initial design with Text-to-CAD
2443
+ const geometry1 = await window.cycleCAD.textToCad.execute(
2444
+ "create bracket 50x50x10mm with 4 mounting holes"
2445
+ );
2446
+ addToScene(geometry1);
2447
+
2448
+ // Step 2: Check manufacturability
2449
+ const dfmReport = await window.cycleCAD.manufacturability.analyze(
2450
+ geometry1,
2451
+ { material: "aluminum-6061", processes: ["cnc-3axis"] }
2452
+ );
2453
+
2454
+ if (dfmReport.issues.length > 0) {
2455
+ console.log("DFM issues found, optimizing...");
2456
+
2457
+ // Step 3: Use Generative Design to fix issues while reducing weight
2458
+ const geometry2 = await window.cycleCAD.generativeDesign.optimize({
2459
+ designSpace: geometry1,
2460
+ constraints: { maxStress: 100, maxDeformation: 2.0 },
2461
+ volumeFraction: 0.7
2462
+ });
2463
+
2464
+ // Check DFM again
2465
+ const dfmReport2 = await window.cycleCAD.manufacturability.analyze(geometry2);
2466
+ if (dfmReport2.suitable_processes.includes("cnc-3axis")) {
2467
+ addToScene(geometry2);
2468
+ geometry = geometry2;
2469
+ }
2470
+ }
2471
+
2472
+ // Step 4: Insert fasteners from Smart Parts
2473
+ await window.cycleCAD.smartParts.insertPart(
2474
+ "iso-4762-m8-20-ss-a2",
2475
+ { quantity: 4, autoSnap: true }
2476
+ );
2477
+
2478
+ // Step 5: Generate BOM
2479
+ const bom = window.cycleCAD.smartParts.generateBOM({
2480
+ format: "csv",
2481
+ groupBySupplier: true
2482
+ });
2483
+
2484
+ return { geometry, dfmReport: dfmReport2, bom };
2485
+ }
2486
+ ```
2487
+
2488
+ #### Workflow 2: Photo Reference → 3D Model → Simulation → Validation
2489
+
2490
+ ```javascript
2491
+ async function reverseEngineerAndValidate() {
2492
+ // Step 1: Photo-to-CAD from image
2493
+ const image = await selectImageFile();
2494
+ const geometry = await window.cycleCAD.photoToCad.processImage(image);
2495
+
2496
+ // Step 2: Refine scale
2497
+ window.cycleCAD.photoToCad.setReferenceDimension(
2498
+ {x: 100, y: 200},
2499
+ {x: 350, y: 200},
2500
+ 250, // 250mm dimension
2501
+ "mm"
2502
+ );
2503
+
2504
+ // Step 3: Run FEA to validate under typical loads
2505
+ const fea = await window.cycleCAD.multiPhysics.runAnalysis(
2506
+ geometry,
2507
+ {
2508
+ analysisType: "static",
2509
+ material: "aluminum-6061",
2510
+ loads: [{
2511
+ type: "force",
2512
+ location: geometry.getCenter(),
2513
+ direction: {x: 0, y: 0, z: -1},
2514
+ magnitude: 500 // 500N downward
2515
+ }],
2516
+ constraints: [{ type: "fixed", region: { ... } }]
2517
+ }
2518
+ );
2519
+
2520
+ // Step 4: Check if it passes
2521
+ if (fea.safetyFactor > 1.5) {
2522
+ console.log("✓ Design passes validation");
2523
+ return { geometry, fea };
2524
+ } else {
2525
+ console.log("✗ Design needs refinement");
2526
+ // Suggest Generative Design or manual editing
2527
+ }
2528
+ }
2529
+ ```
2530
+
2531
+ ### WebSocket Integration (for Real-Time Collaboration)
2532
+
2533
+ When using the REST API server, broadcast module actions to other clients:
2534
+
2535
+ ```javascript
2536
+ // In each module's execute() method, after completion:
2537
+
2538
+ async function broadcastAction(action) {
2539
+ return fetch('http://localhost:8080/api/design/action', {
2540
+ method: 'POST',
2541
+ body: JSON.stringify({
2542
+ module: action.module, // 'text-to-cad', 'generative-design', etc.
2543
+ command: action.command,
2544
+ parameters: action.parameters,
2545
+ result: action.result,
2546
+ timestamp: Date.now(),
2547
+ userId: currentUserId
2548
+ })
2549
+ });
2550
+ }
2551
+
2552
+ // Usage (inside TextToCad.execute()):
2553
+ await broadcastAction({
2554
+ module: 'text-to-cad',
2555
+ command: 'create_cylinder',
2556
+ parameters: { diameter: 25, height: 50 },
2557
+ result: { geometry, confidence: 0.95 }
2558
+ });
2559
+ ```
2560
+
2561
+ ### MCP Server Integration
2562
+
2563
+ Expose all modules via Model Context Protocol for AI agents:
2564
+
2565
+ ```javascript
2566
+ // In server/mcp-server.js, add tool definitions:
2567
+
2568
+ const tools = [
2569
+ {
2570
+ name: "text_to_cad_execute",
2571
+ description: "Execute Text-to-CAD NLP command",
2572
+ inputSchema: {
2573
+ type: "object",
2574
+ properties: {
2575
+ description: { type: "string", description: "Natural language description" },
2576
+ unit: { type: "string", enum: ["mm", "cm", "in", "m"] }
2577
+ }
2578
+ }
2579
+ },
2580
+ {
2581
+ name: "photo_to_cad_process",
2582
+ description: "Process image for reverse engineering",
2583
+ inputSchema: {
2584
+ type: "object",
2585
+ properties: {
2586
+ imageUrl: { type: "string" },
2587
+ referenceScale: { type: "number" },
2588
+ referenceDimension: { type: "number" }
2589
+ }
2590
+ }
2591
+ },
2592
+ // ... similar for other 4 modules
2593
+ ];
2594
+ ```
2595
+
2596
+ ---
2597
+
2598
+ ## Troubleshooting: Common Issues
2599
+
2600
+ ### Text-to-CAD Issues
2601
+
2602
+ | Problem | Cause | Solution |
2603
+ |---------|-------|----------|
2604
+ | **"Unrecognized shape"** | Shape name not in vocabulary | Use alias (e.g., "cyl" for cylinder) or describe shape (e.g., "round rod") |
2605
+ | **Dimensions not extracted** | Missing unit or ambiguous value | Always include units: "25mm" not "25" |
2606
+ | **Confidence too low** | Ambiguous phrasing | Rephrase: "add 10mm hole through the center" instead of "add hole" |
2607
+ | **Preview not appearing** | GPU memory exceeded | Reduce scene complexity or clear undo history (Ctrl+Shift+H) |
2608
+
2609
+ ### Photo-to-CAD Issues
2610
+
2611
+ | Problem | Cause | Solution |
2612
+ |---------|-------|----------|
2613
+ | **Edge detection poor** | Shadows or low contrast | Retake photo with better lighting, increase blur kernel size |
2614
+ | **Wrong scale detected** | Reference object not visible | Click reference button, manually select dimension line |
2615
+ | **Contour has gaps** | Edge line is broken | Increase `highThreshold` in edge detection settings or manually trace missing edges |
2616
+ | **Too many/few vertices** | Contour simplification threshold off | Adjust Douglas-Peucker `epsilon` parameter (default 1px) |
2617
+
2618
+ ### Manufacturability Issues
2619
+
2620
+ | Problem | Cause | Solution |
2621
+ |---------|-------|----------|
2622
+ | **Cost unreasonably high** | Wrong process selected | Switch to different process or change material |
2623
+ | **"Unmachinable corner"** | Sharp internal corner < 1mm radius | Add fillet: "fillet internal corners 1mm" in Text-to-CAD |
2624
+ | **Injection mold cost huge** | No tooling for low quantities | Use CNC or 3D printing for qty < 500 |
2625
+ | **Sheet metal can't bend** | Bend radius too tight | Increase radius to ≥ 2x material thickness |
2626
+
2627
+ ### Generative Design Issues
2628
+
2629
+ | Problem | Cause | Solution |
2630
+ |---------|-------|----------|
2631
+ | **Optimization slow** | Too many voxels (fine mesh) | Reduce `meshDensity` or increase `voxelSize` |
2632
+ | **Result has unrealistic features** | Volume fraction too low | Increase from 0.3 to 0.5+ to keep more material |
2633
+ | **Checkerboard pattern in result** | Sensitivity filter not applied | Ensure `filterRadius > 1.0` |
2634
+ | **Not converging** | Constraints too tight | Relax constraints: increase `maxDeformation` or lower stress limit slightly |
2635
+
2636
+ ### Multi-Physics Issues
2637
+
2638
+ | Problem | Cause | Solution |
2639
+ |---------|-------|----------|
2640
+ | **FEA solver fails** | Matrix singular (unconstrained part) | Add fixed constraint at base or support points |
2641
+ | **Stress unreasonably high** | Load applied to single point node | Distribute load over area using "pressure" type instead |
2642
+ | **Natural frequency wrong** | Mesh too coarse | Use "fine" mesh density (`meshDensity: "fine"`) |
2643
+ | **Drop test peaks unrealistic** | Contact duration too short | Increase `contactStiffness` damping ratio to 0.5 |
2644
+ | **Memory exhausted mid-analysis** | Large geometry + fine mesh | Reduce geometry complexity or use coarser mesh |
2645
+
2646
+ ### Smart Parts Issues
2647
+
2648
+ | Problem | Cause | Solution |
2649
+ |---------|-------|----------|
2650
+ | **Part not found** | Typo or part not in catalog | Try fuzzy search or browse category |
2651
+ | **Supplier lead time shows "N/A"** | Real-time supplier API down | Check supplier website manually or use last cached value |
2652
+ | **3D model missing** | Vendor didn't provide geometry | Use simplified placeholder model or import from supplier CAD file |
2653
+ | **BOM export corrupted** | Special characters in part names | Use UTF-8 encoding or remove special characters |
2654
+
2655
+ ### General Browser Issues
2656
+
2657
+ | Problem | Solution |
2658
+ |---------|----------|
2659
+ | **WebGL not supported** | Use Chrome/Firefox (Safari: enable WebGL in advanced settings) |
2660
+ | **Memory leak after long session** | Reload page or clear browser cache (DevTools: Cmd+Shift+Delete) |
2661
+ | **Slow performance** | Close other tabs, reduce window size, disable hardware acceleration if FPS drops |
2662
+ | **File upload hangs** | Reduce image size (< 10MB) or use different format |
2663
+
2664
+ ### Performance Tips
2665
+
2666
+ 1. **For Text-to-CAD:** Batch multiple commands (create, fillet, add hole) rather than one-at-a-time
2667
+ 2. **For Photo-to-CAD:** Use 1024x1024 images or smaller (smaller = faster edge detection)
2668
+ 3. **For Generative Design:** Start with coarse mesh, then refine if needed; typical: 10-30 voxels per dimension
2669
+ 4. **For FEA:** Use "medium" mesh density initially; upgrade to "fine" only if stress concentrations matter
2670
+ 5. **For Smart Parts:** Search with category filters first ("fasteners") before free-text search
2671
+
2672
+ ---
2673
+
2674
+ ## API Quick Reference
2675
+
2676
+ ### Core Namespaces
2677
+
2678
+ ```javascript
2679
+ // All modules accessible via window.cycleCAD.*
2680
+
2681
+ window.cycleCAD.textToCad.execute(description)
2682
+ window.cycleCAD.photoToCad.processImage(file)
2683
+ window.cycleCAD.manufacturability.analyze(geometry, config)
2684
+ window.cycleCAD.generativeDesign.optimize(config)
2685
+ window.cycleCAD.multiPhysics.runAnalysis(geometry, config)
2686
+ window.cycleCAD.smartParts.search(query)
2687
+ ```
2688
+
2689
+ ### Common Parameters
2690
+
2691
+ ```javascript
2692
+ // Material selection (all modules)
2693
+ { material: "aluminum-6061" } // Use ID from material database
2694
+
2695
+ // Geometry input (all modules)
2696
+ geometry // THREE.BufferGeometry object
2697
+
2698
+ // Load/constraint definition (FEA, generative)
2699
+ loads: [{ type: "force", location: {x,y,z}, direction: {x,y,z}, magnitude: N }]
2700
+ constraints: [{ type: "fixed", region: { shape, ... } }]
2701
+
2702
+ // Visualization options
2703
+ { colorScheme: "viridis", showDeformation: true, scale: 10 }
2704
+ ```
2705
+
2706
+ ---
2707
+
2708
+ ## Summary
2709
+
2710
+ These 6 killer features represent a paradigm shift in browser-based CAD:
2711
+
2712
+ 1. **Text-to-CAD** — NL interface for non-specialists
2713
+ 2. **Photo-to-CAD** — Vision-based reverse engineering
2714
+ 3. **Manufacturability** — Real-time DFM + costing
2715
+ 4. **Generative Design** — Automatic topology optimization
2716
+ 5. **Multi-Physics** — FEA, thermal, modal, drop test
2717
+ 6. **Smart Parts** — 200+ standard parts + sourcing
2718
+
2719
+ **Together, they make cycleCAD the first platform where humans and AI agents can collaborate seamlessly on physical design.**
2720
+
2721
+ ---
2722
+
2723
+ **For support or detailed feature documentation, see:**
2724
+ - `docs/QUICK-REFERENCE.md` — Keyboard shortcuts & workflows
2725
+ - `docs/FUSION-FEATURES-GUIDE.md` — Complete feature list
2726
+ - `docs/API-REFERENCE.md` — Full API documentation
2727
+ - `app/js/text-to-cad.js` — Implementation source code
2728
+