Shape Kind#
Say which kind of process a part reads as made by: machined, turned, sheet, cast, moulded or free-form.
Note
Prerequisites: Attributed Adjacency Graph (AAG)
Tip
Tutorial Data Files: ANC101.brep,
lances-sheet-metal.step
Shape Kind Recognition#
A part keeps on its faces the way it was made. A machined part is cut along a few square directions: its walls stand straight along them, its holes are drilled at any angle, and its edges are broken by blends here and there. A cast or moulded part leans its walls a few degrees from the direction it leaves the mould by, and rounds its inside corners at several radii. A free-form part is mostly surfaces that turn about no axis at all.
ShapeKindRecognizer reads those traces and says which kind of process the part reads as made by. Use it before
choosing how to read a part further: a part that reads as machined can be read back as a stock with cuts taken from
it, while a cast or a free-form part cannot.
Quick Start#
from volmdlr.model import VolumeModel
from volmdlr.shapes import Solid
from volmdlr_tools.shapes.recognizers import ShapeKindRecognizer
block = Solid.from_brep("data/brep/ANC101.brep")
kind = ShapeKindRecognizer(block).result
print(kind.verdict, kind.is_machined)
# machined True
print(kind.describe())
# it reads as machined (machined 1.00, turned 0.00, sheet 0.00, cast 0.00, moulded 0.00, free_form 0.00)
sheet = VolumeModel.from_step("data/step/lances-sheet-metal.step").primitives[0]
print(ShapeKindRecognizer(sheet).result.describe())
# it reads as mixed (machined 0.38, turned 0.00, sheet 0.00, cast 0.78, moulded 0.00, free_form 0.00)
print(ShapeKindRecognizer(sheet, sheet=True).result.describe())
# it reads as sheet (machined 0.38, turned 0.00, sheet 1.00, cast 0.78, moulded 0.00, free_form 0.00)
The block reads as machined and as nothing else. The sheet part, read without a hint, scores high as cast because its bends round its inside corners at many radii, but its straight walls keep it too high as machined for cast to dominate, so it reads as mixed. Told that it is a sheet, it reads as one.

ANC101 reads as machined: its walls and caps are square to three directions and its holes are drilled.

The lances sheet part reads as mixed on its own faces, and as sheet once sheet=True says so.
The Kinds#
Kind |
What the part looks like |
|---|---|
|
Walls and caps square to a few directions, drilled holes at any angle, edges broken by blends |
|
Turned about one axis; taken from the |
|
One bent sheet; taken from the |
|
Walls drafted a few degrees from one pull direction, or inside corners rounded at several radii |
|
Cast-like or free-form, with walls of constant thickness that enclose a void (needs |
|
Mostly surfaces that turn about no axis |
Reading the Result#
ShapeKindRecognizer(shape).result is a ShapeKind:
Attribute |
Meaning |
|---|---|
|
For each kind above, how strongly the part reads as made that way, from 0 to 1 |
|
The shares and ratios the scores are combined from (see below) |
|
The kind that dominates, or |
|
The part’s three square directions, its strongest first, as three |
|
The direction its drafted walls lean from, or |
|
Whether the part reads as machined and as nothing else |
|
One line saying what the part reads as, with every score |
ShapeKindRecognizer.is_machined gives the same answer as result.is_machined.
The signals are shares of the part’s surface or counts, among them:
prismatic_share: the share of the surface a machine makes along the part’s square directions;undirected_share: the share that turns about no axis;near_miss_share: the share of walls leaning a few degrees from one direction, as a draft does;filleted_concave_ratio: how much of the length of the inside corners is rounded;n_distinct_radii: how many different blend radii the part has;wall_shareandn_enclosing_walls, only when walls are read (see below).
How the verdict is chosen#
A part given as a sheet (
sheet=True) is a sheet, and a part given as turned (turned=True) is turned.Otherwise the part is machined when it scores at least 0.8 as machined and no more than 0.3 as cast, moulded or free-form. The machined score is full when nearly all of the surface is made along the part’s square directions, and it drops as walls lean in draft, as free-form surface grows, and as inside corners are rounded at several radii.
Otherwise the strongest of cast, moulded and free-form is named when it reaches 0.7 while the part scores no more than 0.3 as machined.
Otherwise no kind dominates and
verdictisNone.
Options#
ShapeKindRecognizer(shape, aag=None, *, turned=None, sheet=None, with_walls=False)
aag: the part’s face adjacency graph, when you have already built it. It is read and not changed: what the reading records goes on a copy.turned,sheet: what you already know of the part. These two kinds are not read from the faces;Truenames the kind, andNone(not known) is read as not.with_walls: also look for walls of constant thickness, which tell a moulded shell from a solid casting. It addswall_share(the share of the surface on such walls) andn_enclosing_walls(how many of them enclose a void) to the signals, and it is what lets a part score as moulded. It costs far more than the rest of the reading, which on its own costs about as much as building the part’s face adjacency graph.
The reading raises ValueError when the part has no surface to read.
See Also#
Sheet Metal Shapes - Sheet metal recognition
Swept Shapes - Swept shape recognition
Feature-Driven Pipeline - Reading a part back to its stock and its cuts