Skip to content

Rules and Vision Architecture

Source files: Architechture & Research/DFM Research/CNC Problem/DFM Single Problem Research.md Last synthesized: March 2026

Overview

The DFM analysis system combines two complementary approaches: rules-based geometry analysis and vision-based drawing interpretation. These are not competing techniques—they solve different problems. Geometry analysis is precise but blind to drawing annotations; vision analysis reads drawings like a human would but misses subtle geometric issues requiring measurement.

Four-Layer Architecture

Layer 1: Geometry Ingestion

Input: STEP/IGES/BREP files (universal CAD exchange formats) Process: - Parse with geometry kernel (OpenCASCADE via pythonOCC) - Extract face inventory: surface type, orientation, normal vectors, adjacency - Compute feature topology: edges, vertices, loops - Measure geometric properties: wall thicknesses, internal corner radii, surface curvature, hole depths, draft angles

Output: Structured geometry facts (faces with IDs, feature candidates, measurements)

Layer 2: Rules Engine

Input: Geometry facts + manufacturing configuration (process, material, industry) Process: - Apply deterministic rules against extracted geometry data - Logic: if minimum_internal_radius < tool_radius_threshold, flag as violation - Each rule is independent, evaluable, and citable to a standard/supplier guide

Output: Design-risk findings with severity, cost impact, and standards references

Strengths: - Deterministic and explainable (every finding traces to a measurement + threshold) - Fast (linear in part complexity) - Handles cases that vision cannot (internal geometry, aspect ratios, tool accessibility)

Limitations: - Requires accurate CAD geometry (garbage in, garbage out) - Cannot read drawing text, annotations, or process notes - Misses context-dependent decisions (is this hole structural or cosmetic?)

Layer 3: Vision Analysis

Input: Rendered 2D views (orthographic projections, section views) + optional 2D drawing PDF Process: - Render 3D model to standard views programmatically (using geometry kernel) - Pass images to vision model (trained on engineering drawing annotation) - Vision model identifies: GD&T callouts, surface finish symbols, material specs, title block info, process notes

Output: Annotation facts (what the drawing specifies)

Strengths: - Reads text, symbols, and human-authored context - Catches missing callouts (e.g., missing surface finish, missing material class) - Recognizes implicit requirements (notes like "break all sharp edges")

Limitations: - Requires good image quality and clear annotations - Can misread symbols or OCR text incorrectly - Cannot measure geometry precisely - Slower than pure geometry analysis

Layer 4: Synthesis

Input: Rules-based findings + vision-based annotation facts Process: - Merge findings by topic (e.g., corner radius warnings + vision callouts about surface finish) - Prioritize by severity, cost impact, manufacturing feasibility - Generate unified report with geometry-backed findings and annotation-backed context

Output: Prioritized DFM findings with cost estimates and standards traces


Open-Source Technology Stack

Geometry Extraction & Analysis

OpenCASCADE Technology (OCCT) - The foundation: free, BSD-licensed geometric modeling kernel - Powers FreeCAD, Salome, and many commercial CAD tools - Capabilities: - Load STEP, IGES, BREP files - Extract faces, edges, vertices, feature topology - Calculate wall thicknesses, corner radii, surface normals - Detect undercuts via ray casting (in tool axis direction) - Measure cavity depths and aspect ratios - Compute curvature and edge properties - Access: pythonOCC (Python wrapper); clean API for headless scripting - Usage: Backbone of geometry ingestion layer; runs deterministically without GUI

FreeCAD + Path Workbench - Built on OCCT; includes CAM module (Path workbench) - Has a DFM analysis workbench with checks for minimum thickness, draft angles, tool accessibility - Can run headlessly via Python (no GUI required) - Useful for: validating DFM checks against actual CAM toolpath generation, feature recognition hints - Limitation: Less polished than commercial tools; extraction logic needs integration work

Feature Recognition

PyMesh, Open3D, trimesh - Mesh-based libraries (complementary to solid modeling) - Useful for STL files when STEP is unavailable - trimesh: Lightweight; can compute wall thickness via ray casting, volume, surface area - Note: Less accurate than OCCT for exact B-rep geometry but simpler to deploy

CAM-Specific Analysis

OpenCAMLib (OCL) - C++ library with Python bindings - Specialized for drop-cutter and waterline algorithms (toolpath generation) - Key capability: Compute cutter accessibility—"Can a tool of diameter D reach this surface from direction Z?" - Usage: Setup analysis, undercut detection, tool-path feasibility - Status: Less actively maintained but algorithms are proven


Key Insight: Rules-Based vs. Vision as Complementary

Aspect Rules-Based Vision-Based
Input 3D geometry (STEP) 2D drawings or rendered views
Precision High (measurements are exact) Medium (depends on image quality)
Scope Geometry, features, tool access Annotations, callouts, process notes
Speed Fast (direct computation) Slower (ML inference)
Failure mode Garbage CAD → garbage findings Blurry drawing → missed annotations
Handles context? Limited (needs explicit rules) Yes (implicit in drawing)
Explainability Perfect (every result traces to rule) Good (attention maps, but not deterministic)

Example: Internal Corner Radius - Rules-based: OCCT measures every concave edge, finds minimum radius, compares to tool diameter thresholds. Perfect for "is this achievable with a 6mm end mill?" - Vision-based: Irrelevant. Radius is geometry, not a drawing annotation.

Example: Surface Finish Requirement - Rules-based: Cannot read "Ra 0.8 µm" from CAD alone. - Vision-based: Reads the surface finish callout from the drawing PDF, flags if missing or mismatched with geometry requirements.

Example: Material Specification - Rules-based: Cannot infer material from pure geometry. - Vision-based: Reads material spec from title block, supports downstream cost and process rules.


Practical Workflow

  1. User uploads STEP file (the CAD model)
  2. Geometry ingestion (Layer 1): OCCT extracts features, computes metrics
  3. Rules engine (Layer 2): Evaluates 145+ rules; generates findings (e.g., "corner radius too small for standard tooling")
  4. Optional vision (Layer 3): User provides drawing screenshot or PDF; vision model identifies callouts and notes
  5. Synthesis (Layer 4): Merge findings into final report with cost and standards references

Why This Architecture Wins

  • Decoupled: Geometry analysis works independently; vision is optional and complementary
  • Auditable: Every geometry finding is traceable to measurement + rule threshold
  • Scalable: Open-source tools mean no licensing dependencies; can run on-premise
  • Extensible: Add new rules without changing the geometry engine; retrain vision model independently
  • Realistic: Acknowledges that CAD geometry is usually reliable, but drawings are messy—use each tool where it's strongest

Next Steps

  • Short term: Integrate blamed geometry (trace findings back to specific faces for highlighting in 3D viewer)
  • Medium term: Improve feature recognition robustness (distinguish pocket from through-slot from boss geometrically)
  • Long term: Add physics awareness (stress concentration near sharp corners, vibration in slender features)