CAD Fundamentals
Overview
This guide introduces the essential CAD (Computer-Aided Design) concepts needed to work with HOOPS AI. It is designed for machine learning engineers and data scientists who may not have a background in mechanical engineering or 3D modeling. We’ll explain everything from basic 3D geometry to advanced B-rep topology, and show how CAD data maps to machine learning structures.
What is CAD?
Computer-Aided Design (CAD) is the use of software to create, modify, analyze, and optimize 2D and 3D designs. CAD models represent physical objects digitally and are used across industries:
Mechanical Engineering: Machine parts, assemblies, vehicles
Architecture: Buildings, structural elements
Aerospace: Aircraft components, spacecraft
Consumer Products: Electronics, furniture, packaging
Manufacturing: Tooling, molds, fixtures
CAD files contain precise mathematical representations of geometry and topology, making them ideal for engineering analysis, simulation, and with HOOPS AI machine learning.
Types of CAD Representations
CAD systems use different methods to represent 3D objects. HOOPS AI primarily works with Boundary Representation (B-rep) but also supports mesh data.
Boundary Representation (B-rep)
B-rep models represent a solid object by defining its surfaces (boundaries). Instead of storing a solid volume, B-rep stores the shell that encloses the volume.
Key Concept: A B-rep model is a collection of connected surfaces (faces), curves (edges), and points (vertices) that together form a watertight boundary around a 3D solid.
Example: A simple cube
Faces: 6 rectangular surfaces (top, bottom, front, back, left, right)
Edges: 12 line segments where faces meet
Vertices: 8 corner points where edges meet
Cube B-rep: V7------E11-----V6 /| /| E8| E10| / E7 / E6 V4------E9------V5 | | | | | | V3------E3--|---V2 E4 / E5 / | E0 | E2 |/ |/ V0------E1------V1
Why B-rep for ML?
Precision: Mathematical surfaces (planes, cylinders, splines) not approximations
Topology: Explicit connectivity information (which faces are adjacent)
Semantics: Surface types (planar, cylindrical, conical) carry meaning
Compactness: Efficient representation compared to mesh for simple geometry
Industry Standard: Most CAD software (CATIA, SolidWorks, NX) uses B-rep
Mesh Representation
A mesh approximates surfaces using a collection of small flat triangles (or polygons).
Structure:
Vertices: 3D points in space
Faces (Triangles): Groups of 3 vertices forming a flat surface
Normals: Vectors indicating surface orientation at each vertex
Example: A cylinder represented as mesh
# Mesh data structure
vertices = [
[0.0, 0.0, 0.0], # Vertex 0
[1.0, 0.0, 0.0], # Vertex 1
[0.5, 0.87, 0.0], # Vertex 2
... # Hundreds or thousands of vertices
]
triangles = [
[0, 1, 2], # Triangle connecting vertices 0, 1, 2
[1, 3, 2], # Another triangle
...
]
normals = [
[0.0, 0.0, 1.0], # Normal at vertex 0
[0.0, 0.0, 1.0], # Normal at vertex 1
...
]
Mesh vs. B-rep:
Aspect |
B-rep |
Mesh |
|---|---|---|
Accuracy |
Exact mathematical surfaces |
Approximation (depends on triangle density) |
File Size |
Smaller for smooth geometry |
Can be very large (millions of triangles) |
Topology |
Explicit (face adjacency defined) |
Implicit (must compute from triangle connectivity) |
Surface Types |
Planes, cylinders, splines, etc. |
Only triangles |
ML Use Case |
GNNs, semantic features |
Point clouds, PointNet, CNNs |
B-rep Topology Hierarchy
B-rep models have a hierarchical structure with five main entity types.
The B-rep Hierarchy
Model (Part/Assembly) └── Bodies (Solids) └── Shells (Closed surface sets) └── Faces (Surfaces with boundaries) └── Loops (Boundary curves) └── Edges (Curve segments) └── Vertices (End points)
Let’s examine each level from bottom to top:
Vertices
Definition: A 0-dimensional point in 3D space.
Properties:
Position: (x, y, z) coordinates
Tolerance: Geometric precision threshold
Example:
vertex = { 'position': [10.5, 20.0, 5.3], 'tolerance': 1e-6 }In ML: Vertices are rarely used directly as features. They primarily serve to define edge endpoints.
Edges
Definition: A 1-dimensional curve segment connecting two vertices.
Types of Edges:
Line: Straight segment between two points
Circle/Arc: Portion of a circular curve
Ellipse/Elliptical Arc: Portion of an elliptical curve
Spline/Nurbs Curve: Freeform curve defined by control points
Properties:
Start Vertex: Where the edge begins
End Vertex: Where the edge ends
Curve Geometry: Mathematical definition (line equation, circle center/radius, spline parameters)
Length: Arc length of the curve
Convexity: Whether the edge represents a convex or concave feature
Example - Circular Edge:
edge = { 'id': 42, 'type': 'circle', 'start_vertex': vertex_10, 'end_vertex': vertex_11, 'center': [0.0, 0.0, 0.0], 'radius': 5.0, 'axis': [0.0, 0.0, 1.0], # Normal to circle plane 'length': 31.4159, # 2πr }In ML: Edge features are important for machining feature recognition:
Edge length distribution (short edges → complex geometry)
Curve type (lines vs. curves)
Convexity (sharp edges vs. blends)
Dihedral angle between adjacent faces
Faces
Definition: A 2-dimensional surface bounded by a closed loop of edges.
Types of Faces (Surface Geometry):
CAD systems classify faces by their underlying mathematical surface. This surface type classification has become a fundamental feature in modern deep learning approaches for CAD analysis. Research from BRepNet (Lambourne et al., 2021, Stanford paper) demonstrated that encoding surface type as a one-hot vector enables graph neural networks to learn machining features and part topology effectively. Similarly, JoinABLe (Willis et al., CVPR 2022, assembly learning paper) showed that surface type classification is critical for detecting mating surfaces in assembly joint prediction.
Plane: Flat surface (most common in machined parts). Zero curvature in all directions.
Cylinder: Curved surface at constant radius from an axis. One principal curvature is zero, the other is 1/radius.
Cone: Conical surface. Variable curvature along the axis direction.
Sphere: Spherical surface segment. Equal positive curvature in all directions.
Torus: Donut-shaped surface (fillets, rounds). Combination of major and minor radius curvatures.
Spline/Nurbs Surface: Freeform surface defined by control points. Variable curvature throughout.
Extrusion: Surface created by sweeping a curve along a path. Curvature depends on the sweep profile.
Revolution: Surface created by rotating a curve around an axis. Rotationally symmetric curvature.
Properties:
Surface Type: Plane, cylinder, cone, sphere, spline, etc.
Orientation: Normal vector direction (outward from solid)
Loops: Boundary loops (outer boundary + inner holes)
Area: Surface area
Bounding Box: Axis-aligned box containing the face
Curvature: Gaussian and mean curvature (measures how “curved” the surface is)
Color/Material: Visual/physical properties (optional)
Example - Planar Face:
face = { 'id': 7, 'type': 'plane', 'normal': [0.0, 0.0, 1.0], # Facing +Z direction 'origin': [0.0, 0.0, 10.0], # Point on the plane 'area': 25.0, # 5x5 square 'bounding_box': [[-2.5, -2.5, 10.0], [2.5, 2.5, 10.0]], 'loops': [ { # Outer boundary 'edges': [edge_1, edge_2, edge_3, edge_4] }, { # Hole 'edges': [edge_10, edge_11, edge_12, edge_13] } ] }In ML: Faces are the primary entities for most CAD ML tasks:
Face classification (identify machining features)
Face segmentation (group faces by function)
Face attributes drive GNN node features
Face Loops:
A face can have multiple loops:
Outer Loop: Defines the external boundary
Inner Loops: Define holes or cutouts in the face
+---------------------------+ | Outer Loop | | | | +-------+ | | | Hole | Inner Loop | | +-------+ | | | +---------------------------+
Shells
Definition: A connected set of faces that forms a closed or open surface.
Types:
Closed Shell: Watertight surface enclosing a volume (typical for solid bodies)
Open Shell: Incomplete surface (sheet metal, surface patches)
In ML: Shells are rarely used directly. Most analysis happens at the face or body level.
Bodies (Solids)
Definition: A 3D solid object, typically represented by one or more closed shells.
Properties:
Volume: Enclosed 3D space volume
Center of Mass: Geometric centroid
Bounding Box: Smallest box containing the entire body
Material: Physical properties (density, color, etc.)
In ML: Body-level features for whole-part classification:
Total volume
Surface area
Number of faces/edges/vertices (complexity measure)
Bounding box dimensions (length × width × height)
Model (Assembly)
Definition: A collection of bodies that may represent:
A single part (one body)
An assembly (multiple bodies with spatial relationships)
In ML: Assembly analysis is an advanced topic involving:
Part-to-part relationships (joints, contacts)
Spatial proximity (which parts are near each other)
Kinematic constraints (how parts move relative to each other)
B-rep Topology vs. Geometry
Understanding the distinction between topology and geometry is crucial for CAD ML.
Topology
Definition: The connectivity and relationships between entities, independent of their exact shape or position.
Topological Information:
Which faces are adjacent (share an edge)?
Which edges bound a face?
Which vertices terminate an edge?
How many holes does a face have?
Example: Topologically, a coffee mug and a donut (torus) are the same - both have one hole. Their geometry differs, but their topology is identical.
Why Topology Matters for ML:
Invariant to Deformation: Topological features don’t change if you stretch or bend (without tearing)
Structural Information: Adjacency reveals how features connect
Graph Neural Networks: Topology naturally maps to graph structure
Geometry
Definition: The precise mathematical shape and position of entities in 3D space.
Geometric Information:
Where is a vertex located? (x, y, z)
What curve does an edge follow? (line, arc, spline)
What surface defines a face? (plane equation, cylinder parameters)
How large is a face? (area, perimeter)
How curved is a surface? (curvature)
Example: Two cylinders with the same topology (cylindrical face, circular edges) but different geometry (radius 5mm vs. 50mm, height 10mm vs. 100mm).
Why Geometry Matters for ML:
Discriminative Features: Geometry distinguishes parts with similar topology
Physical Constraints: Manufacturing depends on exact dimensions
Numerical Features: ML models need numeric inputs (area, curvature, coordinates)
UV Grids: Sampling Face Geometry
UV grids are a way to sample points on a face’s surface in a structured 2D grid pattern.
What are UV Coordinates?
Most CAD surfaces have a natural parameterization: a mapping from 2D (u, v) space to 3D (x, y, z) space.
\[S(u, v) = (x(u, v), y(u, v), z(u, v))\]Where:
\(u, v \in [0, 1]\) are parameters in 2D space (normalized domain)
\(S(u, v)\) is the corresponding 3D point on the surface
Why UV Parameterization Matters:
UV parameterization converts continuous 3D surfaces into structured 2D grids, enabling:
CNN Processing: Treat surface as a 2D image with geometric channels (XYZ + normals)
Uniform Sampling: Sample points evenly in parameter space
Texture Mapping: Apply 2D patterns to 3D surfaces (visualization, material properties)
Surface Analysis: Compute derivatives, curvature, distortion
Visualization:
Face with 5×5 UV grid: v=1 +----+----+----+----+ | | | | | v=¾ +----+----+----+----+ | | | | | v=½ +----+----+----+----+ | | | | | v=¼ +----+----+----+----+ | | | | | v=0 +----+----+----+----+ u=0 u=¼ u=½ u=¾ u=1
UV Grids in Machine Learning
Use Cases:
Point Cloud Generation: UV grids provide uniform point sampling
CNN Input: Reshape UV grid to image-like tensor and use CNNs
Geometric Features: Compute local curvature, roughness from UV samples
Hybrid Models (UV-Net): CNN processes UV grid, GNN processes topology
Face Adjacency Graphs
The face adjacency graph is a fundamental structure for CAD machine learning.
What is a Face Adjacency Graph?
Definition: A graph where:
Nodes represent faces
Edges connect adjacent faces (faces that share at least one edge in the B-rep)
Simple Box (6 faces): Top | Left-Front-Right-Back | Bottom Adjacency relationships: - Front is adjacent to: Top, Bottom, Left, Right - Top is adjacent to: Front, Back, Left, Right - etc.Graph Representation:
# NetworkX graph import networkx as nx G = nx.Graph() G.add_nodes_from([0, 1, 2, 3, 4, 5]) # 6 faces # Front (0) adjacent to Top (1), Bottom (2), Left (3), Right (4) G.add_edges_from([ (0, 1), (0, 2), (0, 3), (0, 4), # Front adjacencies (5, 1), (5, 2), (5, 3), (5, 4), # Back adjacencies (1, 3), (1, 4), # Top adjacencies (2, 3), (2, 4), # Bottom adjacencies ])
Building Face Adjacency Graphs
HOOPS AI automatically builds and stores face adjacency graphs from the B-rep model using the BrepEncoder Interface. This graph represents the topology of the model where nodes are faces and edges connect adjacent faces.
What “Adjacent” Means:
Two faces are adjacent if they share at least one edge. The shared edge is called the common edge.
See also
For implementation details on building face adjacency graphs with the BrepEncoder interface, see the CAD Data Encoding guide. For a step-by-step walkthrough, follow the /tutorials/hoops_cadflow_tutorials_public/notebooks/2_encode_cad_file tutorial.
Graph Properties for ML
Topological Features (graph-level):
Number of nodes/edges: Model complexity
Average degree: How connected is the model?
Graph diameter: Maximum shortest path length
Connected components: Number of separate shells
Clustering coefficient: How “clustered” are faces?
Node Features (face-level):
for face_id in graph.nodes(): # Degree: how many adjacent faces? degree = graph.degree(face_id) # Geometric features surface_type, surface_description, face_area, face_centroid, loops_count = brep.get_face_attributes(face_id) # Store as node attributes graph.nodes[face_id].update({ 'degree': degree, 'area': area, 'surface_type': surface_type })Edge Features (adjacency-level):
for face_i, face_j in graph.edges(): # Access edge data from the adjacency graph edge_data = graph.get_edge_data(face_i, face_j) if 'edge' in edge_data: edge = edge_data['edge'] # Get edge attributes including dihedral angle edge_idx = edge_data['edge_index'] if edge_idx is not None: curve_type, curve_description, edge_length, dihedral_angle, convexity = brep.get_edge_attributes(edge_idx, {}) convexity_name = "convex" if convexity == 2 else "concave" if convexity == 1 else "smooth" # Store as edge attributes graph.edges[face_i, face_j].update({ 'dihedral_angle': dihedral_angle, 'edge_length': edge_length, 'convexity': convexity_name })
From CAD to Graph Neural Networks
Now we can see how CAD B-rep data maps naturally to GNN input.
Mapping B-rep to GNN
B-rep Concept
GNN Concept
Example
Face
Node
Node 0 = Top face
Face Adjacency
Edge (connection)
Edge (0,1) = Top and Front are adjacent
Face Geometry
Node Features
[area, curvature, surface_type, …]
Shared Edge Properties
Edge Features
[dihedral_angle, edge_length, …]
Entire Part
Graph
One graph per CAD file
Part Class
Graph Label
Label = “bracket”
Machining Feature
Node Label
Node 5 Label = “hole”
Advanced B-rep Concepts
Dihedral Angles
Definition: The angle between two adjacent faces measured at their shared edge.
Dihedral Angle: Face A \ \ θ (dihedral angle) \ +------- Shared Edge / / / Face BInterpretation:
θ = 180°: Faces are coplanar (smooth transition)
θ < 180°: Convex edge (outward corner)
θ > 180°: Concave edge (inward corner)
θ = 90°: Perpendicular faces (typical box corner)
In ML: Dihedral angles help identify:
Sharp edges (θ far from 180°)
Fillets and blends (θ close to 180°)
Feature boundaries (large angle changes)
# Get edge attributes for specific adjacent faces edge_data = graph.get_edge_data(face_i, face_j) if 'edge' in edge_data: edge = edge_data['edge'] edge_idx = edge_data['edge_index'] if edge_idx is not None: curve_type, curve_description, edge_length, dihedral_angle, convexity = brep.get_edge_attributes(edge_idx, {}) if abs(dihedral_angle - 180) < 5: # Within 5° of coplanar print("Smooth blend") elif dihedral_angle < 90: print("Sharp convex edge") elif dihedral_angle > 270: print("Sharp concave edge")
Surface Curvature
Definition: Measures how much a surface bends at each point.
Types:
Gaussian Curvature (\(K\)): Product of principal curvatures
\(K > 0\): Elliptic (bowl-like, sphere)
\(K = 0\): Flat or cylindrical
\(K < 0\): Hyperbolic (saddle-shaped)
Mean Curvature (\(H\)): Average of principal curvatures
Measures overall “bendiness”
Example:
# Sample curvature at face center centroid = brep.get_face_centroid(face_id) gaussian_curv = brep.get_gaussian_curvature(face_id, centroid) mean_curv = brep.get_mean_curvature(face_id, centroid) # Classify surface if abs(gaussian_curv) < 1e-6 and abs(mean_curv) < 1e-6: surface_class = "planar" elif abs(gaussian_curv) < 1e-6 and abs(mean_curv) > 1e-6: surface_class = "cylindrical" elif gaussian_curv > 0: surface_class = "spherical/elliptical" else: surface_class = "saddle/hyperbolic"In ML: Curvature features help distinguish:
Planar faces (machined flat surfaces)
Cylindrical faces (holes, shafts)
Freeform faces (complex shapes)
Machining Features
Definition: Geometric patterns that correspond to manufacturing operations.
Common Machining Features:
Hole: Cylindrical depression (drilled)
Pocket: Enclosed depression (milled)
Slot: Long, narrow depression (milled)
Boss: Cylindrical protrusion (turned)
Step: Change in height (milled)
Chamfer: Angled edge (chamfer tool)
Fillet/Round: Blended edge (radius tool)
CAD File Formats
HOOPS AI supports multiple CAD file formats through HOOPS Exchange:
For the complete list of supported formats, visit HOOPS Exchange Supported Formats
Coordinate Systems and Units
Right-Handed Coordinate System
CAD systems typically use a right-handed coordinate system:
Z (up) | | +------ X (right) / / Y (forward)
Right-hand Rule: Point your right thumb along +Z, fingers curl from +X toward +Y.
Units
CAD models store dimensions in specific units (mm, inches, meters). HOOPS AI preserves the original units.
Important: Normalize geometric features before ML:
# Areas might range from 0.001 mm² to 10000 mm² # Normalize to [0, 1] for better ML performance areas = np.array([brep.get_face_area(i) for i in face_indices]) # Min-max normalization area_min, area_max = areas.min(), areas.max() normalized_areas = (areas - area_min) / (area_max - area_min)
Best Practices for CAD ML
1. Understand Your Data
Inspect samples: Visualize a few CAD models to understand structure
Check statistics: Face count distribution, surface type distribution
Identify outliers: Very simple or very complex models
2. Normalize Features
Different geometric properties have vastly different scales:
# Before normalization (bad for ML) features = { 'area': 0.001, # mm² 'perimeter': 0.1, # mm 'curvature': 1000.0, # 1/mm 'num_edges': 4 # count } # After normalization (good for ML) normalized_features = { 'area': 0.35, # Scaled to [0, 1] 'perimeter': 0.42, # Scaled to [0, 1] 'curvature': 0.78, # Scaled to [0, 1] 'num_edges': 0.04 # Scaled relative to max (e.g., 100 edges) }Standardization (Z-score normalization):
\[x_{\text{norm}} = \frac{x - \mu}{\sigma}\]Where \(\mu\) is mean, \(\sigma\) is standard deviation.
3. Handle Variable Graph Sizes
CAD models have different numbers of faces (10 to 10,000+). GNNs handle this naturally through:
Message passing: Works on any graph size
Global pooling: Aggregates node features to fixed-size graph representation
4. Augmentation for CAD Data
Data augmentation increases dataset diversity:
Geometric Augmentations:
Rotation: Rotate the entire CAD model
Translation: Shift position (usually not useful, ML should be translation-invariant)
Scaling: Resize (changes dimensions but not topology)
Jittering: Add small noise to vertex positions
Topological Augmentations (advanced):
Edge dropout: Randomly remove some adjacency edges during training
Node dropout: Ignore some faces during training
Subgraph sampling: Train on parts of the graph
5. Feature Selection
Not all geometric properties are useful for every task:
Part Classification (whole model):
Total volume, surface area
Number of faces/edges/vertices
Bounding box dimensions
Complexity metrics
Feature Detection (face-level):
Face area, perimeter
Surface type (plane, cylinder, etc.)
Curvature
Adjacency degree
Dihedral angles with neighbors
Manufacturing Cost (regression):
Material volume
Surface area (machining time)
Number of operations (feature count)
Complexity (face/edge count)
Next Steps
Now that you understand CAD fundamentals:
Read CAD Data Access to learn HOOPS AI interfaces
Study CAD Data Encoding to see feature extraction
Review Storage to understand data management
Explore Tutorials for hands-on CAD ML workflows
Check API Reference for detailed class documentation