Drafted Slabs and Offset Shells#
Read the walls a moulded part owes to its mould: the slabs whose walls lean by a draft angle, and the walls of one thickness whose two skins are offsets of each other.
Note
Prerequisites: Attributed Adjacency Graph (AAG), Part Reading
Drafted Slabs and Offset Shells#
A moulded or cast part is shaped by the mould it comes out of, and its walls show it in two ways. They lean by a draft angle, so that the part can be pulled out of the mould. And they are often thin and of one thickness: the part is a cavity wrapped in a wall whose outer skin is its inner skin pushed out by one distance.
Two techniques in volmdlr_tools.reverse_engineering.techniques read those walls. Both take the part’s
PartReading:
recognise_drafted_slabs(reading, direction)reads the part as a stack of drafted slabs along one direction: extrusions whose walls lean, each slab with its own draft.recognise_offset_shells(reading)reads the offset shells of the part: the walls whose two skins stay one thickness apart.
A drafted extrusion is also one of the kinds of region Technique Domains splits a part into. Drafted slabs give the detail of such a region: where each slab starts and ends, and how much each of its walls leans.
Drafted slabs#
Cut a drafted extrusion square to its direction at any height and the section is the same outline, each wall of it moved sideways in proportion to the height: a flat wall moves parallel to itself, a round corner keeps its centre and changes its radius. A draft of zero is a straight extrusion. A slab is the range of heights over which the section keeps to that rule. It ends where another slab with another draft starts, or where a blend begins to round the rim off. A round belongs to no slab: where one rounds the foot of a wall, as at the floor of a pocket or the root of a boss, the slab starts at the top of the round, not partway up it. A slab also has a least thickness: it spans at least three of the heights the part is read at, and at least a hundredth of the part’s extent along the direction. A thinner stretch of straight wall is not a slab.
Quick Start#
A plate 40 by 24 with corners of radius 3 and a hole of radius 4 through it, extruded 10 high with a taper of 3
degrees (download drafted_plate.step, in millimetres):
import math
from volmdlr.model import VolumeModel
from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.reverse_engineering.techniques.drafted_extrusion import recognise_drafted_slabs
plate = VolumeModel.from_step("drafted_plate.step", reading_unit="MM").primitives[0]
slabs = recognise_drafted_slabs(PartReading(plate), (0, 0, 1))
(slab,) = slabs
print(round(slab.start, 1), round(slab.end, 1), slabs.timed_out)
# 0.0 10.0 False
print([len(loop.primitives) for loop in slab.loops])
# [8, 1]
print([round(math.degrees(angle), 1) for angle in slab.draft_angles])
# [-3.0, 3.0]
print(slab.unpaired_share, slab.untracked_loops, slab.interruptions)
# 0.0 0 ()
The plate is one slab from 0 to 10. Its section has two outlines: the rounded rectangle, four sides and four corners, and the hole. A draft is positive when the outline grows with the height, so the outside, which narrows as it rises, leans by -3 degrees, and the hole, which widens, by +3. Every wall was followed from the bottom to the top.
The slabs come back in order of height, as a tuple that also says, in timed_out, whether the time given by
deadline ran out before the part was read through. A part that is not an extrusion along the direction gives none.
DraftedSlab#
Member |
Description |
|---|---|
|
The unit direction the slab is stacked along |
|
The plane of the section at |
|
Where the slab starts and ends along the direction, and its height |
|
The section at |
|
One draft per outline, in radians: positive when the outline grows with the height |
|
Per outline, the widest difference between the drafts of two of its walls |
|
The draft of every wall of outline |
|
Whether every wall of outline |
|
The largest distance, over the heights checked, between a wall and where its draft puts it |
|
The share of the outline that could not be followed, at its worst height |
|
How many outlines of the section could not be followed at all |
|
How many heights were compared |
|
The stretches inside the slab where a feature fused across it hid its outline |
recognise_drafted_slabs also takes tol, the length below which two sections agree, levels, how many heights the
first scan cuts the part at (or the heights themselves), resolution, how closely the ends of a slab are located, and
deadline. It raises ValueError when the direction is the null vector or fewer than three levels are asked for.
A flange, a drafted body and a blended rim#
A housing stands on a straight flange 60 by 40 and 6 thick. Its body, 40 by 24 with corners of radius 4, rises 14
higher with a draft of 3 degrees, and the rim of its top is rounded with a radius of 2
(download flanged_housing.step, in millimetres):
housing = VolumeModel.from_step("flanged_housing.step", reading_unit="MM").primitives[0]
slabs = recognise_drafted_slabs(PartReading(housing), (0, 0, 1))
for slab in slabs:
print(round(slab.start, 1), round(slab.end, 1), [round(math.degrees(angle), 1) for angle in slab.draft_angles])
# 0.0 6.0 [0.0]
# 6.0 18.2 [-3.0]

The flange is a straight slab (teal walls) and the body a drafted one (blue walls). The body’s slab stops at 18.2, where the rim blend (magenta) starts to round its walls off; the flat faces are grey.
The draft changes at the top of the flange, so the stack is two slabs. The body does not reach 20: above 18.2 its section no longer keeps to the draft, because the blend is rounding it off.
A round at the foot of a wall#
A block stands on a plate 60 by 40 and 6 thick. It is 30 by 20 with corners of radius 4, rises 14 higher with
straight walls, and its root is rounded with a radius of 4
(download rounded_root.step, in millimetres):
from volmdlr.model import VolumeModel
solid = VolumeModel.from_step("rounded_root.step", reading_unit="MM").primitives[0]
slabs = recognise_drafted_slabs(PartReading(solid), (0, 0, 1))
for slab in slabs:
print(round(slab.start, 1), round(slab.end, 1), [round(math.degrees(angle), 1) for angle in slab.draft_angles])
# 0.0 6.0 [0.0]
# 9.8 20.0 [0.0]

The plate and the block are two straight slabs (teal walls). Between them, from 6 to 10, the round at the root of the block (magenta) belongs to neither.
The block’s slab starts at 9.8, close to the top of the round at 10, not partway up it. Near its top, where it turns into the wall it is tangent to, a round bends so little from one height to the next that a few heights there could pass for a straight wall. Those heights are still read as part of the round: a slab that starts inside a round has to carry well past it. The same holds for a pocket whose floor is rounded, read from the floor up.
Which way a slab comes out of the mould#
A part moulded in two halves is drafted away from the plane where the halves meet: the walls of each half narrow as
they leave that plane. Here a block 40 by 24 is drafted 3 degrees down from the plane at height 10 and 3 degrees up
from it, reaching 10 below that plane and 8 above it
(download two_half_moulding.step, in millimetres):
from volmdlr_tools.reverse_engineering.techniques.drafted_extrusion import parting_runs, release_of
from volmdlr_tools.reverse_engineering.techniques.sections import hole_flags
moulding = VolumeModel.from_step("two_half_moulding.step", reading_unit="MM").primitives[0]
slabs = recognise_drafted_slabs(PartReading(moulding), (0, 0, 1))
holes = [hole_flags(list(slab.loops)) for slab in slabs]
for slab, flags in zip(slabs, holes):
print(round(slab.start, 1), round(slab.end, 1), round(math.degrees(slab.draft_angles[0]), 1), release_of(slab, flags))
# 0.0 10.0 3.0 down
# 10.0 18.0 -3.0 up
print(parting_runs(slabs, holes))
# [('down', (0,)), ('up', (1,))]
release_of(slab, holes) says which way a slab comes out of the mould, given which of its outlines are holes:
"up" when its material narrows as it rises, "down" when it narrows the other way, and None when no wall leans,
or when walls lean both ways. parting_runs(slabs, holes) groups neighbouring slabs that come out the same way. The
lower half comes out downward and the upper half upward, so they meet at the parting plane, height 10: the top of
the downward run and the bottom of the upward one.
Walls that lean by different drafts#
A draft need not be applied to every wall of an outline. Here only the two long sides of a block 40 by 24 and 12 high
are drafted, by 5 degrees, leaning in from the bottom face
(download partly_drafted_block.step, in millimetres):
block = VolumeModel.from_step("partly_drafted_block.step", reading_unit="MM").primitives[0]
(slab,) = recognise_drafted_slabs(PartReading(block), (0, 0, 1))
print(round(math.degrees(slab.draft_angles[0]), 1), round(math.degrees(slab.draft_spread[0]), 1), slab.uniform(0))
# -5.0 5.0 False
for line, angle in zip(slab.loops[0].primitives, slab.piece_angles(0)):
print(round(line.length, 1), round(math.degrees(angle), 1))
# 24.0 0.0
# 40.0 -5.0
# 24.0 0.0
# 40.0 -5.0
The outline’s draft is the one most of its length leans by, here the long sides’. draft_spread and uniform say
that its walls do not all agree, and piece_angles gives each wall its own: the short sides stand straight.
A flange fused across a slab#
A post 40 by 24, drafted 3 degrees and 20 high, carries a flange 50 by 34 and 2 thick at mid-height. Over the
flange’s thickness the post’s outline is hidden, but above it the post’s walls come back where the same draft puts
them (download post_with_flange.step, in millimetres):
post = VolumeModel.from_step("post_with_flange.step", reading_unit="MM").primitives[0]
(slab,) = recognise_drafted_slabs(PartReading(post), (0, 0, 1))
print(round(slab.start, 1), round(slab.end, 1), round(math.degrees(slab.draft_angles[0]), 1))
# 0.0 20.0 -3.0
for gap in slab.interruptions:
print(round(gap.start, 1), round(gap.end, 1), len(gap.lost), round(gap.lost_share, 2))
# 8.0 10.0 4 1.0
The post is one slab from 0 to 20, with one SlabInterruption from 8 to 10. Its lost pieces are the walls of the
outline that were not found inside it, here all four, and lost_share the share of the outline’s length they make
up. Had the post come back with another draft above the flange, it would have been two slabs.
What gives no slab#
A part that no section along the direction follows, such as a sphere of radius 10
(download sphere.step, in millimetres), has no slab:
sphere = VolumeModel.from_step("sphere.step", reading_unit="MM").primitives[0]
print(recognise_drafted_slabs(PartReading(sphere), (0, 0, 1)))
# Readings((), timed_out=False)
Offset shells#
A wall of one thickness has two skins, and every point of one skin faces a point of the other at the same distance, straight across the material. Its faces need not match one to one: a blend on the outside may face several faces on the inside. An offset shell is such a wall: its inner skin, the one facing the void the wall wraps, its outer skin, and the rims where the wall is open, each joining the two skins. The thickness may also change steadily along one direction, as it does when the inside and the outside of a moulded part are drafted by different angles.
Quick Start#
A box 40 by 30 and 20 high, hollowed out with a wall 2 thick and left open at the top
(download open_tray.step, in millimetres):
from volmdlr.model import VolumeModel
from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.reverse_engineering.techniques.offset_shell import recognise_offset_shells
tray = VolumeModel.from_step("open_tray.step", reading_unit="MM").primitives[0]
shells = recognise_offset_shells(PartReading(tray))
(shell,) = shells
print(shell.thickness, shells.timed_out)
# 2.0 False
print(sorted(shell.inner_face_ids), sorted(shell.outer_face_ids), sorted(shell.opening_face_ids))
# [6, 7, 8, 9, 10] [0, 1, 2, 3, 4] [5]
print(shell.coverage_inner, round(shell.coverage_outer, 2), shell.deviation)
# 1.0 0.89 0.0
print(shell.enclosure_inner, shell.enclosure_outer, len(shell.opening_edge_ids))
# 0.75 0.0 8
The tray is one wall 2 thick. Its inner skin is the floor and the four sides of the cavity, its outer skin the bottom and the four sides outside, and its rim the flat face at the top. Every point of the inner skin faces the outer skin; the outer skin, larger by the wall’s thickness at every corner, has strips along its edges with nothing straight across them. Lines leaving the inner skin away from the material meet the part again three times out of four, those leaving the outer skin never: that is how the inner skin is told from the outer one. The rim meets the two skins along eight edges.
The walls come back thickest first, as a tuple that also says, in timed_out, whether the time given by deadline
ran out before every thickness was read.
OffsetShell#
Member |
Description |
|---|---|
|
The faces of the skin facing the void the wall wraps |
|
The faces of the other skin |
|
The faces of the rims where the wall is open, each joining the two skins |
|
The edges where the skins meet the rims |
|
The distance between the skins; when it changes, its value at |
|
How much the thickness changes per unit of length along |
|
The direction the thickness changes along, and the position at which it is |
|
The share of each skin’s area that faces the other skin at the thickness |
|
The largest difference between the thickness and a distance measured across the wall |
|
The share of the lines leaving each skin away from the material that meet the part again |
|
Faces that could not be examined; a thickness across them may be that of a farther skin |
Face and edge ids are those of the part’s adjacency graph, as the reading numbers them. recognise_offset_shells
also takes tol, the length below which two thicknesses are equal, min_area_share, the smallest share of the part’s
surface a wall must cover, min_face_share, the share of a face’s area that must face the other skin for the face to
join the wall, max_relative_thickness, how thick a wall may be for its size, samples_per_face, how many points of
each face are examined, angle_sine, how far off straight across two facing points may be, and deadline. It raises
ValueError when one of them is out of range.
A moulded cover#
A cover 60 by 40 with corners of radius 6, 20 high with a draft of 3 degrees and the rim of its top rounded with a
radius of 3, shelled to a wall 2 thick and left open underneath
(download moulded_cover.step, in millimetres):
cover = VolumeModel.from_step("moulded_cover.step", reading_unit="MM").primitives[0]
reading = PartReading(cover)
(shell,) = recognise_offset_shells(reading)
print(reading.aag.face_count, len(shell.inner_face_ids), len(shell.outer_face_ids), len(shell.opening_face_ids))
# 35 17 17 1
print(round(shell.thickness, 3), shell.coverage_inner, shell.coverage_outer)
# 2.0 1.0 1.0

The cover from underneath: the inner skin (blue) lines the cavity, the outer skin (sand) wraps it, and the open rim (magenta) joins the two.
The drafted sides, the round corners and the blended top all keep the wall 2 thick, so every face of the cover but its rim belongs to one wall, 17 faces to a skin.
Walls drafted differently inside and out#
A cup 25 high and of radius 15 at its foot has its outside drafted 3 degrees, and its cavity, of radius 13 at its
floor, only 1.5 degrees: its side wall thins as it rises. Its floor, 2 thick, is a wall of another kind
(download drafted_cup.step, in millimetres):
cup = VolumeModel.from_step("drafted_cup.step", reading_unit="MM").primitives[0]
for shell in recognise_offset_shells(PartReading(cup)):
print(sorted(shell.inner_face_ids), sorted(shell.outer_face_ids), sorted(shell.opening_face_ids))
if shell.thickness_gradient is None:
print(" constant", round(shell.thickness, 2))
else:
print(" ", round(shell.thickness, 2), "at", round(shell.thickness_station, 1), "along", shell.pull_direction)
print(" ", round(shell.thickness_gradient, 4), "per unit")
# [4] [0] []
# constant 2.0
# [3] [1] [2]
# 1.62 at 12.4 along (0.0, 0.0, 1.0)
# -0.0262 per unit

The side wall: inner skin blue, outer skin sand, rim magenta. The floor, read as a wall of its own, is teal: the cavity’s floor seen here, and the cup’s bottom underneath.
The side wall is 1.62 thick at height 12.4 and loses 0.0262 for every unit it rises: the difference between the slopes of the two drafts. The floor keeps one thickness, so it is a wall of its own, with no rim. Two walls that keep to one thickness but do not touch are two walls as well.
The wall gives its thickness anywhere along its law. thickness_at takes some points of either skin, all at one
height, and returns the thickness there; thickness_slope_along returns how much it changes per unit of length
along any direction, the law’s gradient times the cosine between that direction and the pull, so nothing square to
the pull. A wall of constant thickness returns thickness and a slope of zero:
import math
import numpy as np
(side,) = (s for s in recognise_offset_shells(PartReading(cup)) if s.thickness_gradient)
for height in (5, 21):
radius = 13 - (height - 2) * math.tan(math.radians(1.5)) # the cavity's radius at that height
ring = [(radius * math.cos(a), radius * math.sin(a), height) for a in np.linspace(0, 2 * math.pi, 12)]
print(height, round(side.thickness_at(np.array(ring)), 2))
print(round(side.thickness_slope_along((0, 0, 1)), 4), round(side.thickness_slope_along((0, 1, 1)), 4))
# 5 1.82
# 21 1.4
# -0.0262 -0.0185
The wall is 1.82 thick near the floor and 1.4 near the rim. Points spread over several heights are read at their mean height, and no point at all is refused.
What is not a wall#
Opposite faces of a solid block are as far apart as the block is thick, which is no wall for its size. Here a block
30 by 20 and 10 thick (download solid_block.step, in
millimetres):
block = VolumeModel.from_step("solid_block.step", reading_unit="MM").primitives[0]
print(recognise_offset_shells(PartReading(block)))
# Readings((), timed_out=False)
See Also#
Part Reading - The one reading of a part every technique shares
Technique Domains - The regions of a part each made by one technique
Straight Prisms - The straight extrusions a part is made of along one direction