Part Reading#
The one reading of a part that every reverse-engineering technique takes: its faces and how they touch, its blends, its size, and the directions and axes it was built along.
Note
Prerequisites: Attributed Adjacency Graph (AAG)
Part Reading#
Every technique that reads how a part was built starts from the same facts about it: which faces touch which, which
faces are blends, which closed loops of edges bound its regions, how large the part is, and which directions and axes
it was built along. A PartReading, in
volmdlr_tools.features.part_reading, holds those facts for one part. It reads each one the first time a
technique asks for it and keeps it, so a part is read once however many techniques try it.
A reading is not a technique and recognises nothing by itself. It is what every technique takes in place of the bare
shape: straight prisms, technique domains, bosses and local features, drafted slabs and offset shells, sweeps,
lofts, ribs, pipes and revolutions all take the part’s PartReading.
Quick Start#
A plate 60 by 40 and 10 thick, with a hub of radius 10 standing 15 high on it, its foot rounded R2 and a bore of
radius 5 through it
(download hub_on_plate.step, in millimetres):
from volmdlr.model import VolumeModel
from volmdlr_tools.features.part_reading import PartReading
bracket = VolumeModel.from_step("hub_on_plate.step", reading_unit="MM").primitives[0]
reading = PartReading(bracket)
print(reading.face_count, round(reading.size, 2))
# 10 76.32
for face, blend in reading.blends.items():
print(face, round(blend.radius, 2))
# 1 2.0
for axis in reading.dominant_axes[:2]:
print(tuple(round(c, 3) for c in axis.direction), axis.axial_count, axis.plane_count)
# (0.0, 0.0, 1.0) 3 3
# (0.0, 1.0, 0.0) 0 2
for candidate in reading.axis_candidates:
print(tuple(round(c, 3) for c in candidate.origin), tuple(round(c, 3) for c in candidate.direction),
candidate.face_count)
# (0.0, 0.0, 12.5) (0.0, 0.0, 1.0) 3
The part has ten faces. The rounded foot of the hub is its one blend. The strongest direction is Z, which the hub, the bore and the foot turn about and the plate’s top and bottom and the hub’s top face; the hub, the bore and the foot also give the one axis the part turns about.

What a reading holds#
Member |
Description |
|---|---|
|
The part read |
|
How many faces the part has |
|
The part’s smooth adjacency graph: each edge carries the angle at which its two faces meet, and an edge where two faces meet tangent is read as smooth |
|
The same graph with every edge read as convex or concave, even where two faces meet tangent: the graph the feature readers read, and the one |
|
The faces sharing an edge with |
|
|
|
The faces that are blends, each with what it blends, as a value; free-form faces are read by their curvature, so the blends of a moulded part are found as well as those of a machined one |
|
The closed loops of edges that bound regions of the part, read once with the part’s |
|
The diagonal of a box holding the part, not fitted tightly to its faces: a length to scale reaches and probes by |
|
The diagonal of the box fitted tightly to the part’s faces |
|
How far apart two points may be and count as one when a curve is fitted to the part’s sections: a fixed share of |
|
How far apart two faces, surfaces or thicknesses may be and count as one: a fixed multiple of |
|
The directions the part’s faces were built along, strongest first |
|
The lines the part’s rotational faces turn about, largest turning area first |
Both tolerances derive from fitted_size, so that the same reading suits a part modelled in millimetres and one
modelled in metres. Use size where only the part’s scale matters, not its exact extent: how far past the part a
section reaches, how deep a probe goes, how long a path may be. The loose box can be larger than the part, which
does no harm to a reach but would loosen a tolerance; compare geometry with tolerance or face_tolerance.
Faces are numbered the way the part’s adjacency graph numbers them: face i is node i. Every technique returns
faces in that numbering, so the faces one technique returns can be handed to another, or coloured on the part, as
they are:
print(sorted(reading.neighbours(1)))
# [0, 6]
print(reading.pieces(set(range(reading.face_count)) - set(reading.blends)))
# (frozenset({0, 2, 3, 4, 5, 6, 7, 8, 9}),)
The foot blend touches the plate’s top (face 0) and the hub’s wall (face 6). Without it, the other nine faces still make one piece: the hub and the plate meet nowhere else, but the bore runs from the plate’s bottom to the hub’s top and joins them.
One reading, several techniques#
Make the reading once and hand it to each technique that should read the part. Each one reads what it needs from it; what one technique asked for is already there for the next:
import numpy as np
from volmdlr_tools.reverse_engineering.techniques.domains import technique_domains
from volmdlr_tools.reverse_engineering.techniques.straight_prisms import recognise_prisms
tree = technique_domains(reading)
for domain in tree.domains:
print(domain.index, domain.kind, domain.role, domain.parent, len(domain.face_ids))
# 0 extrusion base None 6
# 1 revolution add 0 3
prisms, refusals = recognise_prisms(reading, np.array((0.0, 0.0, 1.0)))
for prism in prisms:
print(prism.additive, prism.start, prism.end)
# True 0.0 10.0
# False 0.0 25.0
# True 10.0 25.0
The plate is an extrusion and the hub a revolution standing on it; along Z the plate and the hub are two material prisms, and the bore one void through both. The foot blend belongs to neither domain: it is the junction blend between them (see Technique Domains).

The adjacency graph belongs to the reading and is shared by every technique handed it: a technique reads it and
marks nothing on it, and neither does the reading. The blends are a value the reading returns, read once and the same
for every technique, so what one technique reads never depends on which ran before it. A technique that wants fewer
blends counts them up to a smaller radius with reading.blends.within(radius).
What a reading refuses#
A reading reads one solid with faces, alone or as the only thing in a compound. Anything else is refused when the reading is made, not when a technique first asks for a fact:
from volmdlr import Vector3D, shapes
from volmdlr_tools.errors import ShapeTypeError
two_brackets = shapes.Compound.make_compound([bracket, bracket.translation(Vector3D(100, 0, 0))])
try:
PartReading(two_brackets)
except ShapeTypeError as error:
print(error)
# PartReading reads one solid; this shape holds 2.
Refusal |
When |
|---|---|
|
The shape is not a shape, holds no solid or several, or holds faces beside its solid |
|
The solid has no faces |
A reading belongs to the copy of the part it was made from, at that copy’s scale, and to the process that made it. It cannot be pickled: to read a part in another process, hand that process the part and make a reading there.
import pickle
try:
pickle.dumps(reading)
except TypeError as error:
print(error)
# A part reading stays in the process that made it: hand the part to another process instead.
See Also#
Technique Domains - The regions each made by one technique
Straight Prisms - The straight extrusions along one direction