Straight Prisms#
Read the straight extrusions a part is made of along one direction, from the walls each one leaves on the part’s surface.
Note
Prerequisites: Attributed Adjacency Graph (AAG)
Straight Prisms#
A part built from extrusions along several directions has no section that is one extrusion’s: a plane cut across a plate also cuts the boss standing on it and the lug running through it. What each extrusion leaves of itself is its walls: the faces that run along its direction, planes that contain it and cylinders about it. Each wall stands over a range of levels along the direction, and the walls that stand over the same range chain into the extrusion’s profile.
recognise_prisms(reading, direction), in volmdlr_tools.reverse_engineering.techniques.straight_prisms, reads the
straight prisms of a part along one direction that way, given the part’s PartReading. It returns the prisms,
material ones and voids, and the reasons for the walls it could not close into a profile.
Quick Start#
A block 30 by 20 and 10 high, centred on the origin, with a bore of radius 4 through it along Z:
import numpy as np
from volmdlr.shapes import Solid
from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.reverse_engineering.techniques.straight_prisms import recognise_prisms
block = Solid.from_brep("data/brep/straight_prisms/bored_block.brep")
prisms, refusals = recognise_prisms(PartReading(block), np.array((0.0, 0.0, 1.0)))
for prism in prisms:
print(prism.additive, prism.start, prism.end, round(prism.closures[0].signed_area, 2), prism.chords)
# False -5.0 5.0 -50.27 0
# True -5.0 5.0 600.0 0
print(refusals)
# ()
The bore is one void, its circle running clockwise, and the block one material prism, its 30 by 20 outline running counter-clockwise.
Prism#
Member |
Description |
|---|---|
|
The unit direction of the extrusion |
|
The sketch plane at |
|
Where the extrusion starts and ends along the direction, and its length |
|
The profile in |
|
Whether the prism is material (its first closure runs counter-clockwise) rather than a void cut from the part |
|
The wall faces the first closure runs along |
|
How many straight joints the first closure draws where no wall is |
A profile whose walls do not close, because its other walls stand inside the part, is closed by straight chords
with material on their left. A void open to the outside is closed across its mouth. Walls that cannot be closed
that way give a reason in refusals instead of a prism.
Every range of levels the walls stand over gives its prisms, so a part reads as several prisms along one direction, some of them overlapping. Pick the ones you need by their levels, as the examples below do with this helper:
def over(prisms, start, end, additive=True):
"""Return the prisms of one kind standing from *start* to *end*."""
return [p for p in prisms if p.additive == additive and (round(p.start, 6), round(p.end, 6)) == (start, end)]
Across a slot#
A slot cut through a plate splits each of its walls in two: a round corner becomes one face above the slot and one below, and so does a hole through both prongs. The two faces of one wall are the same wall seen across the slot, so the plate is one prism through both prongs, with round corners as well as flat sides, and the hole is one void through both.
Here the plate is 60 by 40 with corners of radius 8, and 20 thick from -10 to 10 along Z, with a hole of radius 4 through it. A slot 6 wide, from -3 to 3 along Z, runs in from one long side through the hole, as far as the hole’s centre:
part = Solid.from_brep("data/brep/straight_prisms/plate_split_by_a_slot.brep")
prisms, refusals = recognise_prisms(PartReading(part), np.array((0.0, 0.0, 1.0)))
(plate,), (hole,) = over(prisms, -10, 10), over(prisms, -10, 10, additive=False)
print(len(plate.closures[0].primitives), plate.chords, round(hole.closures[0].signed_area, 2))
# 8 0 -50.27
print(refusals)
# ('the open wall chains over levels -3 to 3 cannot be joined with material on the left of every chord',)

Left, the part: the faces of the plate’s walls, in two pieces each across the slot, are blue; the two pieces of the hole are orange. Right, the outlines read along Z from -10 to 10: one rounded rectangle and one circle, with no chord.
Each prong’s piece of the hole is also read over the prong’s own levels. The slot’s walls, open to the outside on
both of its sides, cannot be closed with material on the left of every chord, and say so in refusals.
A round wall that a taller prism shares is taken only over the stretch between the open ends of the prism’s own walls. A flat wall is taken only whole: two arms standing on a plate are not joined along the plate’s top, which runs on under and between them.
The envelope#
Some parts are not built by stacking extrusions but by cutting one extrusion with another: the outline seen from above is extruded, the outline seen from the side is extruded, and the part is what the two bodies share. Neither extrusion is a prism of the part: each is larger than it, and none of the part’s walls stands over its whole length.
recognise_envelope(reading, direction), in the same module, reads such an extrusion: the envelope of the part
along a direction. Its profile is the outline the part casts along the direction, drawn from the stretches of the
walls that lie on that outline, and closed by straight chords where a face leaning across the direction casts the
outline instead. It runs over the part’s whole length. The part lies inside it, so it is a body to intersect with
others, not one to build the part from alone. Only the outer outline is read: holes through the part are its voids.
It returns the envelope as a Prism, with an empty reason, or None with the reason it could not be read: no wall
lies on the outline, the walls on it cannot be joined, the part casts more than one outline, or it has no length along
the direction.
Here a rounded plate, 40 by 20 with corners of radius 5 and 30 tall along Z, is cut by a trapezoid drawn on the YZ
plane, 20 wide at its foot and 8 wide at its top
(download rounded_plate_cut_to_a_trapezoid.step,
in millimetres):
from volmdlr.model import VolumeModel
from volmdlr_tools.reverse_engineering.techniques.straight_prisms import recognise_envelope
solid = VolumeModel.from_step("rounded_plate_cut_to_a_trapezoid.step", reading_unit="MM").primitives[0]
reading = PartReading(solid)
for direction in ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0)):
envelope, reason = recognise_envelope(reading, np.array(direction))
print(round(envelope.start, 6), round(envelope.end, 6), round(envelope.closures[0].signed_area, 2), envelope.chords)
# -0.0 30.0 778.54 2
# -20.0 20.0 420.0 0

The part, which both envelopes enclose: the walls on the outline it casts along Z, its rounded corners and its two ends, in blue; the walls on the outline it casts along X, the faces of the trapezoid, in orange.
Along Z the envelope is the rounded rectangle, from 0 to 30. Its long sides lie on no wall: the trapezoid’s leaning faces cast them, so they are drawn as two chords. Along X it is the trapezoid, from -20 to 20, with no chord. Intersecting the two envelopes gives the part back.
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
Turned Parts - A body of revolution with features standing on it

