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 in sand: a machined block with drilled and bored holes

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

The lances sheet part in sand: a bent sheet with lances and a flange

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

"machined"

Walls and caps square to a few directions, drilled holes at any angle, edges broken by blends

"turned"

Turned about one axis; taken from the turned hint, not read from the faces

"sheet"

One bent sheet; taken from the sheet hint, not read from the faces

"cast"

Walls drafted a few degrees from one pull direction, or inside corners rounded at several radii

"moulded"

Cast-like or free-form, with walls of constant thickness that enclose a void (needs with_walls)

"free_form"

Mostly surfaces that turn about no axis


Reading the Result#

ShapeKindRecognizer(shape).result is a ShapeKind:

Attribute

Meaning

scores

For each kind above, how strongly the part reads as made that way, from 0 to 1

signals

The shares and ratios the scores are combined from (see below)

verdict

The kind that dominates, or None when none does: the part is mixed

frame

The part’s three square directions, its strongest first, as three Vector3D

pull_axis

The direction its drafted walls lean from, or None when it has no drafted walls

is_machined

Whether the part reads as machined and as nothing else

describe()

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_share and n_enclosing_walls, only when walls are read (see below).

How the verdict is chosen#

  1. A part given as a sheet (sheet=True) is a sheet, and a part given as turned (turned=True) is turned.

  2. 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.

  3. 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.

  4. Otherwise no kind dominates and verdict is None.


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; True names the kind, and None (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 adds wall_share (the share of the surface on such walls) and n_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#