Sheet Metal Shapes#

Recognize sheet metal parts by identifying main faces and thickness faces.

Note

Prerequisites: Attributed Adjacency Graph (AAG)

Tip

Tutorial Data File: lances-sheet-metal.step

Sheet metal part used in this tutorial

Sheet Metal Recognition#

This module provides tools to recognize and analyze sheet metal parts from BRep (Boundary Representation) models. It uses the Attributed Adjacency Graph (AAG) to identify main faces (the two sides of the sheet) and thickness faces (the edges connecting them), enabling automatic feature extraction.

Reference: This implementation is based on the methodology described in Yang Yang et al. (2021) for automatic sheet metal feature recognition.


Overview#

Sheet metal parts are characterized by:

  • Two main face groups: The top and bottom surfaces of the sheet

  • Thickness faces: The thin faces connecting the two main surfaces

  • Features: Bends, corners, notches, reliefs, and other manufacturing features

The recognition process:

  1. Finds the largest face as a seed face

  2. Propagates through smooth angles to identify the first main face group

  3. Finds the largest remaining face as the opposite face

  4. Propagates to identify the second main face group

  5. Remaining faces are classified as thickness faces

  6. Validates the sheet metal structure


Quick Start#

from volmdlr.model import VolumeModel
from volmdlr_tools.shapes.recognizers import SheetMetalRecognizer
from volmdlr_tools.features.extractors import SheetMetalFeatureExtractor

# Load a STEP file
volume_model = VolumeModel.from_step("data/step/lances-sheet-metal.step")
shape = volume_model.primitives[0]

# Recognize sheet metal shape
recognizer = SheetMetalRecognizer(shape=shape)

if recognizer.perform():
    # Get the sheet metal abstraction
    sheet_metal = recognizer.result

    # Access properties
    print(f"Boundary thickness faces: {len(sheet_metal.boundary_chain)}")
    print(f"Internal features: {len(sheet_metal.internal_chains)}")

    # Get thickness shell for visualization
    boundary_shell = sheet_metal.get_boundary_thickness_shell()

Core Classes#

SheetMetalRecognizer#

The main entry point for sheet metal recognition. It analyzes a BRep shape to determine if it’s a sheet metal part and classifies its faces.

Constructor#
SheetMetalRecognizer(
    shape: Union[shapes.Shell, shapes.Solid],
    aag: Optional[AttributedAdjacencyGraph] = None,
    name: str = ""
)

Parameters:

  • shape: The BRep shape to analyze (Shell or Solid)

  • aag: (Optional) Pre-computed AttributedAdjacencyGraph

  • name: (Optional) Name for the recognizer instance

Properties#

Property

Type

Description

result

SheetMetalShape

The recognized sheet metal abstraction

main_faces

list[int]

Face IDs of main faces (both sides)

thickness_faces

list[int]

Face IDs of thickness faces

seed_face_id

int

The largest face used as starting point

opposite_face_id

int

The largest face on the opposite side

main_face_group_1

list[int]

First main face group (one side)

main_face_group_2

list[int]

Second main face group (other side)

refusal_reason

Optional[str]

Why the shape is not sheet metal, or None when it is

Methods#
  • perform() -> bool: Execute the recognition algorithm. Returns True if the shape is valid sheet metal.

Example#
from volmdlr_tools.shapes.recognizers import SheetMetalRecognizer

recognizer = SheetMetalRecognizer(shape=my_shape)

if recognizer.perform():
    print(f"Main faces: {len(recognizer.main_faces)}")
    print(f"Thickness faces: {len(recognizer.thickness_faces)}")

    # Access the shape abstraction
    sheet_metal = recognizer.result
else:
    print("Not a valid sheet metal part")

SheetMetalShape#

The shape abstraction representing a recognized sheet metal part. Provides access to geometric properties and feature extraction.

Properties#

Property

Type

Description

boundary_chain

ThicknessFaceChain

The perimeter thickness faces

internal_chains

list[ThicknessFaceChain]

Internal thickness face chains (holes, cutouts)

thickness

float

The sheet metal thickness

Key Methods#
  • get_boundary_thickness_shell() -> shapes.Shell: Returns the perimeter thickness faces as a shell for visualization

  • get_internal_thickness_shells() -> list[shapes.Shell]: Returns internal features as shells

  • get_fold_skins() -> dict[int, FoldSkin]: Returns the skin of every fold — bend, hem or curl — that a fan-shaped face ends, that is, the face on its outside and the face on its inside, keyed by each fan-shaped face that ends it. A fold counts when it splits the sheet into flanges, runs right across it or lies on a fold line, so the rounds of a deformation reaching the sheet edge are left out. A fold that reaches no edge of the sheet, such as a tray’s bend ending in corner reliefs or a bend drawn in one piece, shows no fan-shaped face and is not here: get_fold_lines() finds it

  • get_fold_lines() -> list[CoaxialBends]: Returns the fold lines of the sheet: the volmdlr_tools.shapes.plates_and_bends.CoaxialBends of get_plates_and_bends() (see Coaxial bends and fold lines below) that are folds, whether a fan-shaped face ends them or not

  • get_fold_faces(side=None) -> set[int]: Returns the skin faces of every fold, those of get_fold_skins() and those of get_fold_lines(), on both sides of the sheet, or on side 1 or 2 only, numbered in that side’s graph

  • get_gusset_skins() -> list[frozenset[int]]: Returns the faces of each gusset pressed across a fold, on both sides of the sheet (see the Gusset in Sheet Metal Features); get_gusset_faces(side=None) gives them all as one set, like get_fold_faces

  • get_plates_and_bends() -> PlatesAndBends: Returns the sheet’s thickness, its flat plates and every bend it turns round, with the plates each bend joins (see Plates, Bends and Folded Sheets below)

  • get_fold_flanges() -> list[FoldFlanges]: Returns every fold, side by side, with the flanges it borders; each flange lists every fold it borders, so whether the sheet goes on past a fold, and whether it folds again, is read from there. The pieces of one fold line are one fold, and whatever bridges the gaps between them, a gusset most often, is a border between its two flanges like the fold, in neither flange, even when it is not read as a gusset

Example#
# After recognition
sheet_metal = recognizer.result

# Get the boundary (perimeter) as a shell
boundary_shell = sheet_metal.get_boundary_thickness_shell()
boundary_shell.color = (1.0, 0.0, 0.0)  # Red

# Get internal features
internal_shells = sheet_metal.get_internal_thickness_shells()
for shell in internal_shells:
    shell.color = (0.0, 1.0, 0.0)  # Green

# Visualize
from volmdlr.model import VolumeModel
VolumeModel([my_shape, boundary_shell, *internal_shells]).babylonjs()

ThicknessFaceChain#

Represents a connected chain of thickness faces. According to Yang Yang et al., thickness face chains are the fundamental building blocks for sheet metal feature recognition.

Constructor#
ThicknessFaceChain(
    face_ids: list[int],
    aag: AttributedAdjacencyGraph,
    is_closed: bool = True,
    is_internal_chain: bool = False,
    cut_into_edge: bool = False,
    fold_directions: int = 0,
    mouth: Optional[tuple[Point3D, Point3D]] = None,
    name: Optional[str] = None
)
Properties#

Property

Type

Description

face_ids

list[int]

Ordered list of face IDs in the chain

is_closed

bool

Whether the chain forms a closed loop

is_internal_chain

bool

Whether this is an internal chain

cut_into_edge

bool

Whether the chain is a cut into the outer edge of the sheet

fold_directions

int

For a cut into the edge, how many bends it sits at the end of

mouth

tuple[Point3D, Point3D] or None

For a cut into the edge, a point at each end of its mouth on the line of the edge

adjacency_map

dict[int, list[int]]

Face adjacency relationships

thickness

float

Calculated thickness value

thickness_shell

shapes.Shell

Shell representation of the chain

Key Methods#
  • get_fan_shaped_faces() -> list[FanShapedFace]: Identify fan-shaped faces (used for bend detection)

  • get_fan_shaped_pairs(max_angle: float) -> list[tuple]: Get paired fan-shaped faces

  • get_concave_subchains() -> list[ThicknessFaceChain]: Extract concave angle subchains

  • get_convex_subchains() -> list[ThicknessFaceChain]: Extract convex angle subchains

  • extract_fsf_subchains() -> list[ThicknessFaceChain]: Extract fan-shaped-face bounded subchains

Example#
# Work with the boundary chain
boundary = sheet_metal.boundary_chain

print(f"Chain length: {len(boundary)} faces")
print(f"Is closed: {boundary.is_closed}")

# Find fan-shaped faces (bends)
fan_faces = boundary.get_fan_shaped_faces()
print(f"Found {len(fan_faces)} fan-shaped faces")

# Get face adjacency
for face_id, neighbors in boundary.adjacency_map.items():
    print(f"Face {face_id} neighbors: {neighbors}")

FanShapedFace#

Represents a fan-shaped thickness face used in bend detection. A fan-shaped face is planar with two concentric circular edges and two straight thickness edges.

Attributes#

Attribute

Type

Description

face_id

int

The face ID in the AAG

inner_circular_edge

Arc3D

The inner circular edge

outer_circular_edge

Arc3D

The outer circular edge

thickness_edges

list

The two straight edges

arc_center

Point3D

Center point of the concentric arcs

angle

float

Arc angle in radians

partner_face

FanShapedFace

Paired face for bend detection

Methods#
  • can_pair_with(other, aag) -> bool: Check if two fan-shaped faces can form a bend pair


TFCGroup#

Groups related thickness face chains for feature classification.

Key Methods#
  • extract_cut_feature_properties() -> dict: Extract properties for cut feature classification

  • extract_composite_feature_properties() -> dict: Extract properties for composite feature classification (bends, jogs)


Plates, Bends and Folded Sheets#

A recognized sheet can also be read as the flat plates it is made of and the bends that turn it. There are two readings, one built on the other:

  • SheetMetalShape.get_plates_and_bends() works on any sheet the recognizer accepts, with its dimples, louvres, curls and flanged cut-outs. It reports what is there and judges nothing.

  • recognise_folded_sheet(shape), or assess_folded_sheet(sheet_metal) for a sheet already recognized, accepts only a part that is nothing but flat plates of one thickness, joined two to a bend, and says why when it refuses one. recognise_folded_sheet also takes the part’s face adjacency graph as aag, when you already have it, so that the sheet’s face ids are that graph’s.

Plates and bends of any sheet#

get_plates_and_bends() returns the sheet’s thickness, its plates and its bends. The two sides of the sheet are main_face_group_1 (side 1) and main_face_group_2 (side 2). The thickness is None when no face of one side has a partner on the other, and face_ids lists every face of a plate or of a bend, on either side; a face of a side that is in neither, such as the floor of a dimple or a free-form panel, is not in it.

Item

What it holds

SheetPlate

face_pairs: each flat face of side 1 with the face one thickness behind it on side 2; normal, pointing out of side 1; faces(side), origin(side) and outward_normal(side)

SheetBend

side_1_faces and side_2_faces, the two cylinders the sheet turns round; axis_origin, axis_direction, inner_radius, angle (radians), length along the axis; inside_side, the side whose cylinder is nearer the axis; plates, the plates it joins, as positions in plates

A cylinder written as several faces is one bend. A bend usually joins two plates: one when the sheet ends on it, as at a curl, and none when no flat face meets it, as inside some formed features.

Coaxial bends and fold lines#

Something formed across a fold, such as a gusset, cuts its cylinders into pieces that touch nowhere, and each piece reads as a SheetBend of its own. sheet_metal.get_plates_and_bends().coaxial_bends() groups the bends that join two plates into CoaxialBends (from volmdlr_tools.shapes.plates_and_bends): the bends on one cylinder, with the same inside, joining the same two plates. Its bends are the pieces, in face order rather than along the axis, and its faces(side=None) are their faces on one side or on both. A group is a candidate: the rounds of an emboss join plates too. A fold line is a group the sheet keeps as one of its folds, sheet_metal.get_fold_lines(), when on both sides of the sheet one of its pieces is a fold already, fan-shaped faces end its pieces twice between them, or taking it away parts that side into flanges. Neither is the BendLine of a flat pattern (volmdlr_tools.features.unfold.flat_pattern.BendLine), the line on the blank along which the press folds it.

A bend that gussets cut into pieces and that no fan-shaped face ends, such as a tray’s bend ending in corner reliefs with a gusset across it, is not yet a fold line: the gusset joins its two plates, so taking the pieces away parts nothing. Its pieces and its gusset are then read as no fold.

import math

from volmdlr.model import VolumeModel
from volmdlr_tools.shapes.recognizers import SheetMetalRecognizer

shape = VolumeModel.from_step("data/step/feature_extractors/bend_rules_bracket.step").primitives[0]
recognizer = SheetMetalRecognizer(shape=shape)
if not recognizer.perform():
    print(recognizer.refusal_reason)
sheet_metal = recognizer.result

reading = sheet_metal.get_plates_and_bends()
print(f"thickness {reading.thickness * 1000:.1f} mm, {len(reading.plates)} plates, {len(reading.bends)} bends")
for bend in reading.bends:
    print(
        f"R{bend.inner_radius * 1000:.1f} mm, {math.degrees(bend.angle):.0f} degrees, "
        f"side {bend.inside_side} inside, joins plates {bend.plates}"
    )
# thickness 2.0 mm, 3 plates, 2 bends
# R4.0 mm, 90 degrees, side 2 inside, joins plates (0, 1)
# R1.0 mm, 90 degrees, side 2 inside, joins plates (0, 2)

Below, the bracket’s base, plate 0, is sand; its tall flange, plate 1, green; its short lip, plate 2, violet; and the two bends that join them blue.

The bracket read as plates and bends: plate 0, the base (sand), plate 1, the tall flange (green), plate 2, the short lip (violet), and the two bends joining them (blue)

When the recognizer turns a part down, refusal_reason says why: there is no second side, a wall between the two sides is pierced as a machined face is, or the sides do not form one sheet.

Folded sheets#

A FoldedSheet is a sheet that unfolds onto a plane: every face of either side belongs to a plate or to a bend, every other face is a wall between the two sides, and every bend joins two plates. A hem folded back flat over its plate is a bend of half a turn, and a flat plate is a folded sheet with no bend. Anything else is a NotFoldedSheet whose reason names what stands in the way: a slab too thick for its size, a tube, a curl, a curved panel, a fold that ends in free material, or a face that is neither flat nor bent. A part that is not sheet metal at all gives the reason not sheet metal: followed by the recognizer’s refusal_reason.

A FoldedSheet has the reading above (thickness, plates, bends, bend_radius, the radius most bends share) and answers what unfolding needs:

  • fold_tree(base): the FoldSteps that reach every plate from the plate base, nearest first. Each step names the plate it starts from (parent), the plate it reaches (child) and its bends: one, or several when a cut across the fold splits it into pieces. A sheet whose folds close a loop, like the walls of a box, or whose plates are not all reached from base, raises FoldedSheetError.

  • plate_face(plate, side): the plate’s faces on one side as one face. It raises FoldedSheetError when they do not make a single face.

  • tangent_line(bend, plate, side): the line where a bend meets a plate, on one side. It raises FoldedSheetError when the bend does not meet the plate along exactly one edge, or that edge is not straight.

from volmdlr_tools.shapes.folded_sheet import FoldedSheet, assess_folded_sheet

folded = assess_folded_sheet(sheet_metal)
if isinstance(folded, FoldedSheet):
    for step in folded.fold_tree(base=0):
        print(f"plate {step.parent} -> bends {step.bends} -> plate {step.child}")
else:
    print(folded.reason)
# plate 0 -> bends (0,) -> plate 1
# plate 0 -> bends (1,) -> plate 2

Bends of the sheet and fold features#

The feature catalogue has its own Bend, Hem and Curl, all kinds of Fold (see Sheet Metal Features). Both describe the sheet turning round a cylinder, and where both see the same fold they agree on its radius and angle. They answer different questions:

SheetBend

Fold feature (Bend, Hem, Curl)

What it is

A fact about the sheet’s shape: the sheet turns here

A feature of the design: a fold made on purpose, listed with the part’s other features

Which folds

Every one, wherever the sheet turns round a cylinder, including the rim of a flanged cut-out, the collar of an extrusion hole, the walls of a louvre or an emboss, and a curl

Only a fold that divides the sheet into flanges or runs right across it; the turns inside a formed or pressed feature belong to that feature

Its faces

The two cylinders, one per side

The fold zone: both cylinders and the walls that close it at the sheet’s edge; a hem also holds its leg

Its neighbours

plates, the plates it joins, and inside_side

None: the flat sheet either side is not the fold’s, and a flange’s length is a measurement

Bend, hem or curl

Not told: a hem is a bend of half a turn

Told by its type, so a check written for bends never reaches a hem

Used for

Unfolding, fold order, the plate a bend belongs to

Design rules, feature counts, colouring the part

On the tutorial part lances-sheet-metal.step the sheet turns round 32 bends. Two are Bend features (blue below). The other 30 (magenta) belong to FlangedCutout features: the rims of its lanced cut-outs, and its two end tabs, each with the stiffening rib that crosses its fold.

The 32 bends of the tutorial part: the two that are Bend features (blue) and the 30 that belong to flanged cut-outs (magenta)


Utility Functions#

are_faces_parallel(face1, face2, tolerance=1e-6) -> bool#

Check if two faces are geometrically parallel.

from volmdlr_tools.shapes.sheet_metal import are_faces_parallel

if are_faces_parallel(face1, face2):
    print("Faces are parallel")

get_face_normal(face) -> Vector3D#

Extract the normal vector from a planar face.

from volmdlr_tools.shapes.sheet_metal import get_face_normal

normal = get_face_normal(my_face)
print(f"Normal: {normal}")

order_nodes_by_graph(nodes, subgraph) -> list[int]#

Order nodes according to their connectivity in a graph.

from volmdlr_tools.shapes.sheet_metal import order_nodes_by_graph

ordered = order_nodes_by_graph(face_ids, subgraph)

See Also#

See Also#