Bosses and Local Features#

Read the small features that stand on or sink into a part’s body: cylindrical bosses with their blends, holes and bosses turned about an axis of their own, and pads and pockets drawn as sketches on a surface.

Bosses and Local Features#

A part is seldom made by one technique alone. A plate carries a boss to screw into, a drilled hole, a counterbore, a raised plaque with a marking on it, a shallow pocket. Each of these is small next to the body, stands on it or is sunk into it, and is made by a technique of its own. Once the body is read, these local features are the faces left over.

Three techniques read them. Each takes the part’s PartReading, the one reading of the part every technique shares, and face ids numbered as the part’s adjacency graph numbers them:

Function

Module

Reads

recognise_bosses

...techniques.bosses

Cylinders standing on the body, with their end blends and the blend round their foot

recognise_local_features

...techniques.local_features

Bosses, holes and pockets turned about an axis of their own

recognise_local_pads

...techniques.local_pads

Pads raised off a flat or round surface, and pockets sunk into it, read as sketches

The modules live in volmdlr_tools.reverse_engineering.techniques.


Quick Start#

A plate 60 by 40 and 10 thick, its top at Z = 0, with a boss of radius 6 standing 8 high on it and a hole of radius 3 through it (download plate_with_boss_and_hole.step, in millimetres):

from volmdlr.model import VolumeModel

from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.reverse_engineering.techniques.local_features import recognise_local_features

solid = VolumeModel.from_step("plate_with_boss_and_hole.step", reading_unit="MM").primitives[0]

for feature in recognise_local_features(PartReading(solid)):
    print(feature.mode, feature.end_kind, round(feature.height, 6), round(feature.radius, 6))
# add flat 8.0 6.0
# remove open 10.0 3.0

The boss adds material and ends on a flat top; the hole removes material and runs right through.


Cylindrical bosses#

A moulded tab is a short cylinder standing on the body. Its top circle is often rounded, and its foot blended into the body, which leaves a ring of small rounded faces around it. recognise_bosses(reading, face_ids) reads such faces: the largest group of cylinders sharing an axis and a radius is the boss, the rounded faces at its ends give the fillet of its ends, and the small rounded faces reaching it through one another are its junction blend.

It works on the faces a first reading of the part leaves over, not on the whole part. Here the plain plate explains every face but the boss’s: claim_faces(part, plain), in volmdlr_tools.reverse_engineering.techniques.claims, tells which faces of the part the plain plate reproduces, and the rest are passed on. The boss, of radius 6, stands 8 high on a plate 40 by 30 and 10 thick centred on the origin, 5 along X from its centre. Its top is rounded to radius 1 and its foot blended to radius 1.5 (download blended_boss.step and the plain plate, download plain_plate.step, in millimetres):

from volmdlr_tools.reverse_engineering.techniques.bosses import recognise_bosses
from volmdlr_tools.reverse_engineering.techniques.claims import claim_faces

solid = VolumeModel.from_step("blended_boss.step", reading_unit="MM").primitives[0]
plate = VolumeModel.from_step("plain_plate.step", reading_unit="MM").primitives[0]

residual = claim_faces(solid, plate).unclaimed
(boss,), unexplained = recognise_bosses(PartReading(solid), residual)
print(boss.radius, round(boss.height, 6), boss.base_center, boss.direction)
# 6.0 8.0 (5.0, 0.0, 5.0) (0.0, 0.0, 1.0)
print(boss.end_blend_radius, boss.junction_blend_radius)
# 1.0 1.5
print(sorted(boss.face_ids), sorted(boss.junction_face_ids), unexplained)
# [0, 1, 2, 4] [1] frozenset()

The boss is drawn from the plate’s top, where its foot stands, to its top, as the cylinder was sketched before it was rounded. It returns the bosses and the faces none of them explains.

Member of CylindricalBoss

Description

face_ids

Every face of the boss: its wall, its end blends, its caps and its junction blend

base_center

The centre of its foot, on its axis; it may lie inside the body

direction

The unit axis, from the foot to the top

radius / height

The radius of the cylinder and its length from foot to top

end_blend_radius

The fillet on its end circles, None when they are sharp

junction_blend_radius

The blend joining it to the body, None when the foot is sharp

junction_face_ids

The faces of that junction blend

A boss needs at least one closed end: a flat cap square to its axis, or a rounded end whose fillet meets the wall. An open end stands on a flat face of the body square to the axis, or is buried in a round bar whose axis crosses the boss’s, and the boss is then drawn from that axis. When both ends are closed, they must agree: both sharp, or both rounded to the same radius. A rib fused to the boss is not part of its junction blend, and neither is a bore through its cap: those faces come back unexplained. Bosses of several groups of faces that share an axis, a radius and end planes are one boss, as when a tab straddles a wall and shows on both sides of it.

Rounded corners are not bosses#

A cylinder that runs on smoothly into a flat face along every straight edge it has rounds a corner of a prism: the rounded upright corners of a plate, or the round ends of an obround boss. Such a cylinder is part of the prism’s profile, not a boss standing on the part, so it is left unexplained, even when every face of the part is given. The straight prisms read it with the rest of the outline.

Here a plate 40 by 30 and 6 thick has its four upright corners rounded to radius 3 (download rounded_plate.step), and an obround 20 by 8 stands 6 high on a plain plate of the same size (download obround_boss.step, both in millimetres):

for name in ("rounded_plate.step", "obround_boss.step"):
    reading = PartReading(VolumeModel.from_step(name, reading_unit="MM").primitives[0])
    bosses, unexplained = recognise_bosses(reading, range(reading.face_count))
    print(bosses, len(unexplained) == reading.face_count)
# () True
# () True

A boss with its end blend and junction blend, beside a rounded plate and an obround boss that are not bosses

Left, the boss: its wall, rounded top and cap in blue, its junction blend in amber. Middle, a plate whose upright corners are rounded, and right, an obround standing on a plate: their rounds, in teal, run on smoothly into flat faces and are left unexplained.


Features of revolution#

Many small features are a profile turned about a line of their own: a drafted boss with a rounded top, a drilled hole with a pointed end, a counterbore. Their faces share one axis: cylinders, cones and tori turn about it, spheres are centred on it, and flat faces square to it close the ends or form the shoulders. recognise_local_features(reading, face_ids=None) groups such faces and cuts them by a half plane through the axis. The cut is the feature’s meridian: its radius against its position along the axis, a chain of lines and arcs in which a draft, an end blend or a root blend shows as a slanted line or an arc, as in a revolved sketch.

Which side of its faces the material lies on tells whether the feature adds material or removes it, so a boss with a bore is read as two features on one axis. By default it reads every face of the part.

Here the plate is 80 by 50 and 20 thick, its top at Z = 0. A drafted boss 12 high, of radius 8 at its foot and 6 at its top, has its top rounded to radius 2 and its foot blended to radius 1.5. A hole of radius 4 runs through the plate, counterbored to radius 7 and 5 deep (download drafted_boss_and_counterbore.step, in millimetres):

import math

solid = VolumeModel.from_step("drafted_boss_and_counterbore.step", reading_unit="MM").primitives[0]

boss, hole = recognise_local_features(PartReading(solid))
print(boss.mode, boss.end_kind, boss.height, round(boss.radius, 2), round(math.degrees(boss.draft_angle), 3))
# add flat 12.0 7.79 9.462
print(boss.end_blend_radius, boss.root_blend_radius, [piece.kind for piece in boss.profile])
# 2.0 1.5 ['arc', 'line', 'arc', 'line']
print(hole.mode, hole.end_kind, hole.depth, hole.radius, [piece.kind for piece in hole.profile])
# remove open 20.0 4.0 ['line', 'line', 'line']

The boss’s meridian runs from its root to its tip: the root blend, the drafted wall, the rounded top and the flat top. Its radius is read where the wall starts, just above the root blend, which is why it is a little under 8. The hole is open, so its root is its wider end: the counterbore wall, the shoulder, then the hole’s own wall, the longest, which gives its radius.

A drafted boss and a counterbored hole read as features of revolution, beside a hole cut through the plate's edge

Left, the plate: the faces of the drafted boss, which adds material, in blue; the faces of the counterbored hole, which removes it, in magenta. Right, the plain plate with a hole cut through its edge, which turns only half way round its axis.

Member of LocalRevolvedFeature

Description

mode

"add" for a boss, "remove" for a hole or pocket

axis_origin / axis_direction

The point of the axis at the feature’s root, where it meets the body, and the unit axis from root to tip

profile

The meridian, from root to tip, in the axes (position along the axis, distance from it)

height / depth

The distance along the axis from root to tip; depth is the same length, for a hole

end_kind

The tip: "flat", "conical", "spherical" (a ball end), "rounded", or "open" when the feature runs through

radius / draft_angle

The radius of the longest wall at its root end, and the angle in radians between that wall and the axis, positive when the feature narrows towards its tip; None for a feature with no wall, such as a shallow cone

end_blend_radius / root_blend_radius

The arcs at the tip and at the root, None when sharp

face_ids

The faces the meridian explains

root_face_ids

Further faces of a given piece that blend its root into a curved body

turn_share

The share of a whole turn about the axis that the faces cover

area / deviation

The area of face_ids, and the largest distance from them to the meridian turned about the axis

closed_profile() closes the meridian along the axis into the region the feature sweeps, and profile_edge_tuples() gives the meridian as sketch edges.

Features that do not turn a whole turn#

A feature is reported only when its faces turn far enough about the axis. By default that is a whole turn, so a groove cut through a wall or a pad with rounded corners is not one. A hole that other geometry interrupts is read when a lower share is accepted with min_turn. Here the plain plate above, 80 by 50 and 20 thick, has a hole of radius 5 cut through it, its axis on the plate’s end face, so that only half of it is left (download notched_plate.step, in millimetres):

notched = VolumeModel.from_step("notched_plate.step", reading_unit="MM").primitives[0]
reading = PartReading(notched)
print(recognise_local_features(reading))
# ()
(notch,) = recognise_local_features(reading, min_turn=0.4)
print(notch.mode, notch.end_kind, notch.radius, round(notch.turn_share, 6))
# remove open 5.0 0.5

Keep min_turn above 0.25 to leave a fillet along a straight edge, a quarter turn, out. Nothing is reported for a body of revolution whose both ends reach the axis, nor for a set of faces that adds as much material as it removes.

To read one piece of the part on its own, a boss or pocket cut off along a closed loop of edges with its end and root blends, pass its faces to recognise_local_feature(reading, face_ids): it returns the largest feature they make, or None when the piece is not of revolution. The faces of a piece that blend its root into a curved body, and are not themselves turned about the axis, come back in root_face_ids.


Pads and pockets#

Lettering, plaques, spot faces and shallow pockets share one shape: a set of faces hangs from the rest of the part along a single closed loop of edges, and from nowhere else. The loop is concave, sharp or blended, round the foot of a pad, and convex round the rim of a pocket. recognise_local_pads(reading, face_ids=None) cuts the part along every such loop, and reads each piece as a sketch extruded off its base when:

  • the faces across its loop lie on one plane or one cylinder, its base;

  • its top, or the floor of a pocket, lies at one height above the base;

  • its side walls lean by less than 30 degrees.

The outline is the section of the walls midway up, carried back to the base along their draft, so it is the sketch as it was drawn on the base. On a cylinder it is drawn on the unrolled surface.

A plate 60 by 40 and 5 thick, its top at Z = 0, carries a plaque 24 by 14 with corners of radius 2, raised 1 with walls drafted by 4 degrees. Two bars 3 by 8 and 0.4 high stand on the plaque, and a pocket 12 by 8 is sunk 1.5 into the plate (download plaque_bars_and_pocket.step, in millimetres):

from volmdlr_tools.reverse_engineering.techniques.local_pads import group_local_pads, recognise_local_pads

part = VolumeModel.from_step("plaque_bars_and_pocket.step", reading_unit="MM").primitives[0]

pads = recognise_local_pads(PartReading(part))
for pad in pads:
    print(pad.mode, pad.parent, round(pad.height, 4), round(math.degrees(pad.draft_angle), 2), len(pad.outlines))
# add None 1.0 4.0 1
# remove None 1.5 0.0 1
# add 0 0.4 0.0 1
# add 0 0.4 0.0 1
print(round(pads[0].outlines[0].signed_area, 3))
# 332.566
for group in group_local_pads(pads):
    print(group.pad_indices, group.mode, round(group.height, 4))
# (0,) add 1.0
# (1,) remove 1.5
# (2, 3) add 0.4

The pads come parents first: the two bars stand on the plaque, the pad at index 0. The plaque’s outline is read at the plate, where its sketch was drawn, so its area is that of the 24 by 14 rectangle with its rounded corners, not of the narrower section halfway up. group_local_pads gathers the pads that stand on one base at one height with one draft, such as the letters of a marking: the two bars are one group.

Member of LocalPad

Description

mode

"add" for a pad, "remove" for a pocket

base_face_id / base_kind

The largest face it stands on, and whether that base is a "plane" or a "cylinder"

frame

Its sketch frame on the base; frame.to_chart(points) carries points into it

height

The distance from the base to the top, or to the floor of a pocket

draft_angle

The angle in radians by which the walls lean, positive when the pad, or the hollow of a pocket, narrows away from the base

outlines

The closed outlines at the base, counter-clockwise, each boundary before the holes it encloses: a glyph O has a boundary and a hole

top_blend_radius / root_blend_radius

The rounding of the top edges and the blend where it meets its base, None when sharp

face_ids

The faces it owns: top, walls and blends, without those of the pads standing on it

top_blend_face_ids / root_blend_face_ids / island_face_ids

Its top blends, its root blends, and the faces of the base it encloses, such as the inside of an O

parent

The index, in the result, of the pad it stands on, None when it stands on the rest of the part

axisymmetric

Whether its outlines are one circle or concentric circles, which the features of revolution read as well

deviation

The largest distance between a wall and the drafted extrusion of its outlines

Pieces that are not pads#

split_local_features(reading), in the same module, returns every piece cut off along a closed loop: the pads, and an IsolatedPiece for each one that is not, with its kind ("boss" or "pocket"), its face_ids, parent, base_face_ids, root_blend_face_ids and the reason it is not a pad. A piece stands on a curved base that is not a cylinder, its tops lie at several heights, it has no top parallel to its base, or no wall, or it is taller than max_height_ratio times its widest side: half by default. Such a piece is left for the other techniques of this page.

A pin of radius 2.5 and 12 high added to the plate above is a piece far taller than it is wide. The features of revolution and the bosses both read it from its faces (download plaque_with_a_pin.step, in millimetres):

from volmdlr_tools.reverse_engineering.techniques.local_features import recognise_local_feature
from volmdlr_tools.reverse_engineering.techniques.local_pads import IsolatedPiece, split_local_features

pinned = VolumeModel.from_step("plaque_with_a_pin.step", reading_unit="MM").primitives[0]
reading = PartReading(pinned)
pieces = split_local_features(reading)
(pin,) = [piece for piece in pieces if isinstance(piece, IsolatedPiece)]
print(len(pieces), pin.kind, pin.reason)
# 5 boss the piece is 3.20 times as tall as it is wide
feature = recognise_local_feature(reading, pin.face_ids)
print(feature.mode, feature.end_kind, feature.height, round(feature.radius, 6))
# add flat 12.0 2.5
(boss,), unexplained = recognise_bosses(reading, pin.face_ids)
print(boss.height, boss.radius, unexplained)
# 12.0 2.5 frozenset()

A plate with a drafted plaque, two bars on it, a pocket and a pin

The plaque, a pad standing on the plate, in blue; the two bars standing on the plaque, one group of pads, in purple; the pocket in magenta; the pin, a piece too tall to be a pad, in teal.

recognise_local_pads and split_local_features also take face_ids, to keep only the pieces whose faces are all among them, and max_height_ratio, to accept taller pads. To read a set of faces already known to be a boss or a pocket as a pad, pass them to read_local_pad(reading.aag, face_ids, base_face_ids=..., kind="boss"), which returns the pad or an IsolatedPiece saying why the faces are not one.


See Also#