visualdynamics.core.solids¶
solids
¶
Solids: the shapes a part is made of, before it is meshed.
A part is described most directly by its shapes. The frame of the
Frame-Wing example is a block with four windows and 41 holes taken out
of it, and a wing is a block less eighteen holes. So a geometry holds a
table of solids beside its nodes, coordinate systems and elements. Each
one is a primitive (a block or a cylinder, or a section or a hole made
of them, placed by a center and three angles), a boolean of others
(union, subtract or intersect), or a pattern of copies of others. Solids
are not elements: nothing that solves, animates or exports a geometry
reads them, and meshing them (Mesh Solids, extrusion_mesh) is what
turns them into elements.
The table holds recipes, the numbers a person typed, so a saved project
reopens editable and needs no geometry kernel to load. Evaluating a
solid (its volume, its surface for drawing, the boolean itself) is done
by OpenCASCADE (shape), through the OCP bindings the STEP importer
also uses, a dependency of the package. Whether a point is inside a solid, which is
what meshing asks, is worked out from the recipes without the kernel
(contains).
Lengths are held as the geometry holds its coordinates (meters once its
units are defined), and angles in degrees about the geometry's fixed X,
then Y, then Z axes, the rule the add pane turns a solid by
(rotate.frame_from_angles).
Classes:
| Name | Description |
|---|---|
Solid |
One row of a geometry's solids table. |
NotAnExtrusion |
The parts cannot be meshed into bricks: a solid is turned off |
Functions:
| Name | Description |
|---|---|
add_block |
Add a block to |
add_cylinder |
Add a cylinder to |
add_cone |
Add a cone to |
add_sphere |
Add a sphere to |
add_plate |
Add a plate to |
add_disk |
Add a disk to |
is_flat |
Whether a solid is flat: a plate or a disk, or a boolean or a |
add_section |
Add a section to |
add_hole |
Add a hole to |
edit |
Change a solid after it is made, in place. |
move |
Move solids whole, each with every solid it is made of, turned by |
combine |
Add a boolean of solids already there: their union, the first with |
reorder |
Put solids in a new order: the parts, or one solid's own. |
nothing_left |
Why a boolean leaves nothing (a subtraction whose first solid lies |
delete |
Delete solids, each with everything it is made of: a plate with |
copy |
Copy solids, recipe and all, into a geometry: |
separate |
Take booleans and patterns apart: each one is removed, and its |
pattern |
A pattern of solids: |
used_by |
{solid id: the id of the boolean or pattern it is part of}, for |
top_level |
The solids no boolean uses: the parts as they stand, which are the |
solid |
The solid with this id; KeyError if there is none. |
require_kernel |
The OCP bindings, or a ValueError whose message says why they |
shape |
The solid as an OpenCASCADE shape, in the units the geometry holds |
brick_count |
About how many bricks a mesh of these parts at |
volume |
The solid's volume, in the cube of the geometry's length unit (m³ |
area |
A flat solid's area, in the square of the geometry's length |
shape_triangles |
The corners of the triangles OpenCASCADE tessellates a shape's |
contains |
Which of |
distance |
The signed distance from each of |
distance_gradient |
|
extrusion_axis |
The axis (0, 1 or 2) the parts are extrusions along. |
mesh_size |
The element size an extrusion is meshed at by default: half the |
smallest_feature |
(the smallest radius, the thinnest wall) of the parts, in the |
refuse_parts_of_another |
Refuse a solid that is part of a boolean or a pattern: the one |
grid_cells |
How many bricks the grid |
extrusion_mesh |
The parts as eight-node bricks, ready to join to a geometry |
brick_mesh |
The parts as eight-node bricks: |
piece_cuts |
The pieces a brick mesh is made in, each with the solids cut |
meshed_as |
The id of the solid a piece is meshed as, while the block runs: |
pieces |
The pieces a brick mesh is made in when the parts together are |
piece_name |
The name a piece's element group takes: the solid's name, or |
piece_plan |
How |
turned_sweep |
A block, cylinder or section turned off the geometry's axes, |
meshed_elements |
The ids of the elements Mesh Solids makes, bricks, tetrahedra |
Classes¶
Solid
dataclass
¶
Solid(id: int, name: str, kind: str, center: tuple[float, float, float] = (0.0, 0.0, 0.0), angles: tuple[float, float, float] = (0.0, 0.0, 0.0), widths: tuple[float, float, float] = (0.0, 0.0, 0.0), radius: float = 0.0, length: float = 0.0, operands: tuple[int, ...] = (), corner: float = 0.0, counts: tuple[int, int, int] = (1, 1, 1), dimensions: tuple[float, ...] = ())
One row of a geometry's solids table.
A primitive is placed by its center and turned by angles. A block
is widths across along its own axes, and a cylinder is radius
about its own Z axis and length along it. A section or a hole is
sized by its dimensions (SECTIONS, HOLE_DIMENSIONS), and a
section is length along its own Z. A boolean names its operands
by id, in order (a subtraction takes the rest from the first), and
its own numbers are unused. A pattern names its solids as a boolean
does and holds counts copies along its own axes, widths apart,
turned by angles; the copies follow the originals, and the pattern
is changed as one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Unique within the geometry. |
required |
name
|
str
|
What a person calls it; may be empty. |
required |
kind
|
str
|
One of |
required |
center
|
tuple of float
|
The primitive's middle. |
(0.0, 0.0, 0.0)
|
angles
|
tuple of float
|
Degrees about the fixed X, then Y, then Z axes. |
(0.0, 0.0, 0.0)
|
widths
|
tuple of float
|
A block's three widths along its own axes, a plate's two along its own X and Y (and zero along Z); a pattern's spacing along its own. |
(0.0, 0.0, 0.0)
|
radius
|
float
|
A cylinder's; a cone's radius at its base (its own -Z end) and its height; a sphere's radius; a disk's radius, in its own XY plane. |
0.0
|
length
|
float
|
A cylinder's; a cone's radius at its base (its own -Z end) and its height; a sphere's radius; a disk's radius, in its own XY plane. |
0.0
|
operands
|
tuple of int
|
A boolean's solids, by id. |
()
|
corner
|
float
|
A block's corner radius, to which its four edges along its own Z are rounded, so a window cut with rounded corners leaves the fillets a part has there. |
0.0
|
counts
|
tuple of int
|
A pattern's copies along its own axes, the original counted. |
(1, 1, 1)
|
dimensions
|
tuple of float
|
A section's or a hole's, in the order |
()
|
Methods:
| Name | Description |
|---|---|
scaled |
The same solid with every length multiplied by |
as_record |
The solid as plain numbers, for a file. |
from_record |
The solid a file's record describes ( |
Methods:¶
scaled
¶
scaled(factor: float) -> Solid
The same solid with every length multiplied by factor, which
is what a change of the geometry's length unit does to it.
Source code in src/visualdynamics/core/solids.py
as_record
¶
The solid as plain numbers, for a file.
Source code in src/visualdynamics/core/solids.py
from_record
classmethod
¶
from_record(record: dict) -> Solid
The solid a file's record describes (as_record).
Source code in src/visualdynamics/core/solids.py
NotAnExtrusion
¶
Bases: ValueError
The parts cannot be meshed into bricks: a solid is turned off
the geometry's axes. Tetrahedra can mesh them (tetmesh).
Functions:¶
add_block
¶
add_block(geometry: Any, center, widths, angles=(0.0, 0.0, 0.0), name: str = '', corner: float = 0.0) -> int
Add a block to geometry's solids, widths across along its own
axes, with its middle at center and turned by angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers each, as the geometry holds its coordinates; every width positive. |
required |
widths
|
array_like
|
Three numbers each, as the geometry holds its coordinates; every width positive. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
corner
|
float
|
The radius its four edges along its own Z are rounded to, from zero to half the narrower of its widths along X and Y. |
0
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_cylinder
¶
add_cylinder(geometry: Any, center, radius: float, length: float, angles=(0.0, 0.0, 0.0), name: str = '') -> int
Add a cylinder to geometry's solids, radius about its own Z
axis and length along it, with its middle at center and turned by
angles. With no angles its axis is the geometry's Z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
radius
|
float
|
As the geometry holds its coordinates; both positive. |
required |
length
|
float
|
As the geometry holds its coordinates; both positive. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_cone
¶
add_cone(geometry: Any, center, base_radius: float, top_radius: float, height: float, angles=(0.0, 0.0, 0.0), name: str = '') -> int
Add a cone to geometry's solids: a frustum height along its own
Z, base_radius at its -Z end and top_radius at its +Z end, either
of them zero for a point, with its middle at center and turned by
angles. With no angles its axis is the geometry's Z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
base_radius
|
float
|
Not negative, not both zero, and not equal (that is a cylinder). |
required |
top_radius
|
float
|
Not negative, not both zero, and not equal (that is a cylinder). |
required |
height
|
float
|
Positive. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_sphere
¶
Add a sphere to geometry's solids, radius about center.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
radius
|
float
|
Positive. |
required |
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_plate
¶
Add a plate to geometry's solids: a flat rectangle widths
across along its own X and Y, in its own XY plane, with its middle at
center and turned by angles. With no angles it lies in the
geometry's XY plane.
A plate has no thickness of its own. It is meshed into plates (Mesh Solids, Shells), and the thickness is set on their element group. Solids subtracted from it cut it where they cross its plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
widths
|
array_like
|
Two numbers, both positive: along its own X, then Y. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_disk
¶
Add a disk to geometry's solids: a flat circle of radius in
its own XY plane, centered at center and turned by angles. With
no angles it lies in the geometry's XY plane.
A disk has no thickness of its own; as a plate's, it is set on the element group it is meshed into (Mesh Solids, Shells).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
radius
|
float
|
Positive. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
is_flat
¶
Whether a solid is flat: a plate or a disk, or a boolean or a pattern whose material is one, such as a plate with holes subtracted from it. A flat solid is meshed into plates on its plane, and a union of flat and solid ones is refused when it is made.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solid. |
required |
solid_id
|
int
|
Which. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/visualdynamics/core/solids.py
add_section
¶
add_section(geometry: Any, shape: str, center, dimensions, length: float, angles=(0.0, 0.0, 0.0), name: str = '') -> int
Add a section to geometry's solids: an I-beam, a channel, a tee,
an angle, or a rectangular or round tube, length along its own Z.
A section is one row, sized by its own dimensions, where a union of
blocks would be three rows changed one at a time. Its middle (the
middle of the box it fills) is at center, and with no angles it
runs along the geometry's Z.
Across, along its own axes: an I-beam's or a tee's depth runs along
Y and its flange width along X, with a tee's flange at +Y; a
channel's flanges run along +X from its web; an angle's long leg runs
along +X and its short leg along +Y from the heel; a rectangular tube
is width along X and height along Y. The dimensions are checked by
the beam section's rules (fem.Section.of_shape), so a shape refused
as a beam's section is refused here, and a round tube's wall must
also be under half its outer diameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
shape
|
str
|
One of |
required |
center
|
array_like
|
Three numbers, as the geometry holds its coordinates. |
required |
dimensions
|
sequence of float
|
In the order |
required |
length
|
float
|
As the geometry holds its coordinates; positive. |
required |
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
add_hole
¶
add_hole(geometry: Any, center, diameter: float, depth: float | None = None, angles=(0.0, 0.0, 0.0), name: str = '', counterbore=None) -> int
Add a hole to geometry's solids, to subtract from a part.
The hole enters at center, on the face it is drilled from, and runs
depth along its own -Z (down the geometry's Z with no angles).
With no depth it runs through the part it is cut from, however thick
that part is later made. A counterbore is a wider, shallower bore at
the entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
center
|
array_like
|
Where it enters, three numbers as the geometry holds its coordinates. |
required |
diameter
|
float
|
As the geometry holds its coordinates; positive. |
required |
depth
|
float
|
As the geometry holds its coordinates; None or zero for a hole through the part. |
None
|
angles
|
array_like
|
Degrees about the fixed X, then Y, then Z axes. |
(0, 0, 0)
|
name
|
str
|
What to call it. |
''
|
counterbore
|
(float, float)
|
Its diameter, wider than the hole's, and its depth, positive and (for a blind hole) shallower than the hole's. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
edit
¶
Change a solid after it is made, in place.
What can be changed is a block's center, angles, widths and corner; a cylinder's center, angles, radius and length; a cone's center, angles, radius (at its base), top radius and length (its height); a sphere's center and radius; a plate's center, angles and widths; a disk's center, angles and radius; a section's center, angles, dimensions and length; a hole's center, angles and dimensions; a pattern's counts, spacing and angles; and any solid's name. The rest are kept. The solid keeps its id, so a boolean it is part of takes the change: a hole made larger is a larger hole in the plate it was subtracted from. A mesh already made from it is not changed; running Mesh Solids again meshes the change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solid; changed in place. |
required |
solid_id
|
int
|
Which. |
required |
**changes
|
The numbers to change, as |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For a number its kind does not have (a boolean's shape is its
solids', changed one at a time, and a boolean is moved whole by
|
KeyError
|
If there is no solid |
Source code in src/visualdynamics/core/solids.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
move
¶
Move solids whole, each with every solid it is made of, turned by
turn about the middle of their extent and then moved by offset.
A boolean has no position of its own to change, so its solids are moved, each center turned about that middle and each solid turned by the same angles, and the part is the same shape in a new place. A pattern's originals move, and its axes turn with them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids; changed in place. |
required |
ids
|
sequence of int
|
The solids, by id. |
required |
offset
|
array_like
|
How far, as the geometry holds its coordinates. |
(0, 0, 0)
|
turn
|
array_like
|
Degrees about the fixed X, then Y, then Z axes, as a solid's angles are. |
(0, 0, 0)
|
Returns:
| Type | Description |
|---|---|
int
|
How many primitives moved. |
Source code in src/visualdynamics/core/solids.py
combine
¶
Add a boolean of solids already there: their union, the first with the rest subtracted from it, or what they share.
Each solid goes into one boolean only, so a solid already part of
another is refused. So is a boolean that would leave nothing: a
subtraction whose first solid lies inside the rest, or an
intersection of solids that do not meet. The operands become part of the new solid, and
the table lists only the solids nothing else uses (top_level).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Where it goes; changed in place. |
required |
operation
|
str
|
One of |
required |
ids
|
sequence of int
|
Two solids or more, by id, the first first. |
required |
name
|
str
|
What to call it; the first solid's name when not given, so a plate named 'frame' with its holes subtracted is still 'frame', and so is the element group it meshes into. |
''
|
Returns:
| Type | Description |
|---|---|
int
|
The new solid's id. |
Source code in src/visualdynamics/core/solids.py
reorder
¶
Put solids in a new order: the parts, or one solid's own.
The order is what a boolean made from a pick reads first to last, and
a subtraction takes every solid after the first from the first, so
which solid comes first decides what is cut. With within, the ids
are that boolean's (or pattern's) solids in their new order, and an
existing subtraction then cuts the new first solid. Without it, they
are the parts (top_level) in their new order; the solids a boolean
uses stay where they are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids; changed in place. |
required |
ids
|
sequence of int
|
Every one of the solids being ordered, each once, in the order wanted. |
required |
within
|
int
|
The boolean or pattern whose solids these are. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Source code in src/visualdynamics/core/solids.py
nothing_left
¶
Why a boolean leaves nothing (a subtraction whose first solid lies inside the rest, an intersection of solids that do not meet), or None when something is left.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
|
Source code in src/visualdynamics/core/solids.py
delete
¶
Delete solids, each with everything it is made of: a plate with
holes cut in it is deleted whole, with the cylinders that cut them.
A solid that a boolean still uses is refused, by name, unless that
boolean is deleted with it; take the boolean apart first
(separate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids; changed in place. |
required |
ids
|
sequence of int
|
The solids, by id. |
required |
Returns:
| Type | Description |
|---|---|
int
|
How many solids went, those inside included. |
Source code in src/visualdynamics/core/solids.py
copy
¶
Copy solids, recipe and all, into a geometry: geometry itself,
or into. Returns the new top-level ids, in the order of ids.
A boolean or a pattern is copied with every solid it is made of,
each under a new id, so the copy is its own: editing a cylinder of
the copy leaves the original. A named solid's copy is named
'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The solids to copy, by id. |
required |
into
|
Geometry
|
Where the copies go; |
None
|
Returns:
| Type | Description |
|---|---|
list of int
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
With no ids, an id the geometry does not hold, or geometries whose units differ. |
Source code in src/visualdynamics/core/solids.py
separate
¶
Take booleans and patterns apart: each one is removed, and its operands stand as parts again, which undoes a subtraction made by mistake. A primitive has nothing to take apart and is refused, and so is a solid that is still part of another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids; changed in place. |
required |
ids
|
sequence of int
|
The booleans or patterns, by id. |
required |
Returns:
| Type | Description |
|---|---|
int
|
How many solids stand again. |
Source code in src/visualdynamics/core/solids.py
pattern
¶
A pattern of solids: counts copies along the geometry's X, Y and
Z, spacing apart, with the originals as the first of each.
Thirteen holes along a rail are one hole and counts of (13, 1, 1) at
the insert pitch. The pattern is one solid, made of the originals as
a boolean is, so changing the hole changes every copy, and the
pattern's counts and spacing are changed as one (edit). It takes
its first solid's name, as a boolean does. A pattern of a pattern is
a grid of grids: the row of 13, then two rows across the rails. More
than PATTERN_LIMIT (10,000) copies is refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids; changed in place. |
required |
ids
|
sequence of int
|
The solids to copy, by id: solids nothing else uses. |
required |
counts
|
sequence of int
|
How many along X, Y and Z, the original included; each one or more. |
required |
spacing
|
sequence of float
|
How far apart along X, Y and Z, as the geometry holds its coordinates; it may be zero only along an axis with one copy. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The pattern's id. |
Source code in src/visualdynamics/core/solids.py
used_by
¶
{solid id: the id of the boolean or pattern it is part of}, for every solid that is an operand of another.
Source code in src/visualdynamics/core/solids.py
top_level
¶
top_level(geometry: Any) -> list[Solid]
The solids no boolean uses: the parts as they stand, which are the ones a person sees, edits and meshes.
Source code in src/visualdynamics/core/solids.py
solid
¶
solid(geometry: Any, solid_id: int) -> Solid
The solid with this id; KeyError if there is none.
require_kernel
¶
The OCP bindings, or a ValueError whose message says why they did not import and how to reinstall them.
Source code in src/visualdynamics/core/solids.py
shape
¶
The solid as an OpenCASCADE shape, in the units the geometry holds its coordinates in.
A block or a cylinder is built and placed, a section or a hole is built from the blocks and cylinders it is made of, and a boolean or a pattern is computed from its operands' shapes. A boolean the kernel cannot compute raises ValueError naming the solid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
Returns:
| Type | Description |
|---|---|
TopoDS_Shape
|
|
Source code in src/visualdynamics/core/solids.py
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | |
brick_count
¶
About how many bricks a mesh of these parts at size holds:
their volume over the cube of the size, the volume read by sampling
their box on a grid as fine as the size or _SAMPLES points along
each axis, whichever is coarser. Kernel-free and quick, for the
limit (MESH_LIMIT) and the pane's preview; a part thinner than the
samples' spacing can be undercounted, so the meshers count the
bricks they keep again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The brick size, as the geometry holds its coordinates. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|
Source code in src/visualdynamics/core/solids.py
volume
¶
The solid's volume, in the cube of the geometry's length unit (m³ once units are defined).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/visualdynamics/core/solids.py
area
¶
A flat solid's area, in the square of the geometry's length unit (m² once units are defined): what a plate or a disk reads as, having no volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/visualdynamics/core/solids.py
shape_triangles
¶
The corners of the triangles OpenCASCADE tessellates a shape's
faces into, with deflection a fraction of the shape's size. This is
what draws a solid, and how the STEP importer reads a part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
TopoDS_Shape
|
The shape. |
required |
deflection
|
float
|
How far a triangle may stand off the surface, as a fraction of the shape's size. |
DEFLECTION
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(n, 3, 3): each triangle's three corners; none for a shape with nothing in it, such as a subtraction whose first solid lies inside the rest. |
Source code in src/visualdynamics/core/solids.py
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 | |
contains
¶
Which of points lie inside the solid, worked out from its recipe
without the kernel: a block's box and a cylinder's radius and length,
combined as its booleans say. A point on a face counts as inside.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
points
|
array_like
|
(n, 3), as the geometry holds its coordinates. |
required |
ignore
|
collection of int
|
Solids read as holding nothing: a cylinder subtracted is not cut, one unioned adds nothing. The mesher reads a part this way without the cylinders that run across its extrusion. |
()
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray of bool
|
|
Source code in src/visualdynamics/core/solids.py
distance
¶
The signed distance from each of points to the solid's surface,
negative inside, worked out from its recipe: a block's and a
cylinder's exact distances, a union the least of its operands', an
intersection the greatest, a subtraction the greater of the first's
and the negatives of the rest's. Exact for a block and a cylinder;
for a boolean, exact outside and at the surface, and a bound
inside, which is what a mesher needs: where the surface is and
which way is out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
points
|
array_like
|
(n, 3), as the geometry holds its coordinates. |
required |
ignore
|
collection of int
|
Solids read as holding nothing, as |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(n,), in the geometry's length unit. |
Source code in src/visualdynamics/core/solids.py
distance_gradient
¶
distance and its gradient together: the unit direction out of
the material at each point, exact where the distance is smooth and
one side's value on an edge or a corner. A boolean's gradient is
the gradient of the operand that decided its distance, a cut
operand's turned inward. Four distance evaluations a point by
finite differences were most of a fit's projection cost (hexmesh,
2026-10-19).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
The geometry whose solids table holds it. |
required |
solid_id
|
int
|
The solid, by id. |
required |
points
|
array_like
|
(n, 3), as the geometry holds its coordinates. |
required |
ignore
|
collection of int
|
Solids read as holding nothing, as |
()
|
Returns:
| Type | Description |
|---|---|
(ndarray, ndarray)
|
The distances, (n,), and the gradients, (n, 3). |
Source code in src/visualdynamics/core/solids.py
extrusion_axis
¶
The axis (0, 1 or 2) the parts are extrusions along.
Every block must be square to the geometry's axes; a solid turned
off them raises NotAnExtrusion naming it. The axis is the one most of
the cylinders and rounded corners run along, the largest radius
deciding a tie; the rest run across the extrusion and are pulled
round from the grid rather than ringed. Blocks alone are an
extrusion along any axis, and the axis along which their extent is
thinnest is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|
Source code in src/visualdynamics/core/solids.py
mesh_size
¶
The element size an extrusion is meshed at by default: half the thinnest feature, so every feature is two bricks across.
The thinnest feature is the shortest span between two flat faces (a
cylinder's end along an axis counts as one), or the narrowest
cylinder or rounded corner across (smallest_feature). With
nothing to measure, the size is 1.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/visualdynamics/core/solids.py
smallest_feature
¶
(the smallest radius, the thinnest wall) of the parts, in the geometry's length unit: the narrowest cylinder or rounded corner, and the shortest span between two flat faces. Infinite where there is none.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
Returns:
| Type | Description |
|---|---|
(float, float)
|
|
Source code in src/visualdynamics/core/solids.py
2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 | |
refuse_parts_of_another
¶
Refuse a solid that is part of a boolean or a pattern: the one to mesh is the one it is part of.
Source code in src/visualdynamics/core/solids.py
grid_cells
¶
How many bricks the grid extrusion_mesh would lay for these
parts at size holds, voids included: the count before any
ownership is asked, so a pane can decide whether to preview a mesh
before paying for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The element size, as the geometry holds its coordinates. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
As |
Source code in src/visualdynamics/core/solids.py
extrusion_mesh
¶
extrusion_mesh(geometry: Any, ids, size: float, parts_apart: bool = False, progress: Any = None, piece: bool = False, cuts_from=()) -> tuple[Any, dict]
The parts as eight-node bricks, ready to join to a geometry
(mesh.join).
Each part gets one element group, named for it (or for its kind and
id when it has no name). Parts that touch share their nodes there,
or, with parts_apart, each keeps its own on the same grid, so the
nodes of one lie on the other's and bolts can be merged there later.
The grid is cut at every flat face of every block along every axis,
and each span is divided into the whole number of bricks nearest
size, so flat faces fall on grid lines. A brick goes to the part
whose recipe holds its center (contains), to the later part where
parts overlap (a steel screw added over the insert it is threaded
into makes those bricks steel), and to no part in a void. A hole, a
boss or an insert is meshed round, not stair-stepped. About each
circle with room, a ring mesh with its nodes evenly spaced on the
circle replaces the grid. About a circle without room, or a rounded
corner's arc, the nodes between its inside and the material beside
it are moved radially onto it, except where the move would turn a
brick inside out.
The extrusion runs along the axis most of the cylinders and rounded
corners run along (extrusion_axis); a cylinder drilled across it
is cut from the grid and its nodes pulled round in its own plane,
without a ring, and where it meets a hole along the extrusion the
bricks between the two walls are skewed. A solid turned off the
axes is refused with the solid named, and so are a solid that is
part of another, a size that is not positive, and a grid of more
than MESH_LIMIT (2,000,000) bricks by its volume (brick_count)
or a grid of more than GRID_LIMIT (10,000,000) cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id; each a solid nothing else uses. Where two overlap, the later takes the bricks. |
required |
size
|
float
|
The element size aimed at, as the geometry holds its coordinates. |
required |
parts_apart
|
bool
|
Each part keeps its own nodes where it touches another. |
False
|
progress
|
callable
|
Told |
None
|
piece
|
bool
|
The part is a union's operand meshed on its own ( |
False
|
cuts_from
|
sequence of int
|
Solids whose flat faces the grid is cut at too, where they fall within the parts: the earlier pieces of a union, so the sweep ends where it meets them. |
()
|
Returns:
| Type | Description |
|---|---|
(Geometry, dict)
|
The bricks, in the geometry's length unit; and what was made: 'bricks' and 'nodes', the counts; 'axis' (0, 1 or 2); 'rounded', the number of nodes moved onto a circle; 'rings', the number of rings laid, one about each circle with room; and 'shortest', the shortest brick edge. |
Source code in src/visualdynamics/core/solids.py
2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 | |
brick_mesh
¶
brick_mesh(geometry: Any, ids, size: float, parts_apart: bool = False, progress: Any = None, sizes: Any = None) -> tuple[Any, dict]
The parts as eight-node bricks: extrusion_mesh where they are
an extrusion along X, Y or Z, with rings about the holes; where
they are not and are a union, its operands one at a time (pieces),
each swept where it is an extrusion and fitted where it is not, at
its own size, joined where their nodes coincide and tied at the
seams where they do not; and hexmesh.overlay_mesh, a grid fitted
to the shape, for a lone part that is no extrusion. What Mesh
Solids runs for Hexes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id; each a solid nothing else uses. |
required |
size
|
float
|
The element size aimed at, as the geometry holds its coordinates. |
required |
parts_apart
|
bool
|
Each part keeps its own nodes where it touches another; the extrusion mesher's option, not the fitted grid's. |
False
|
progress
|
callable
|
Told |
None
|
sizes
|
mapping of int to float
|
A size per piece, by solid id, for a union meshed in pieces;
a piece without one takes |
None
|
Returns:
| Type | Description |
|---|---|
(Geometry, dict)
|
The bricks and what was made, as the mesher that ran says it,
with 'method': 'extrusion', 'overlay' or 'pieces'. In pieces,
'pieces' lists each piece's readings with its 'name', 'method',
'size' and 'dropped' (its bricks inside the pieces before it),
'seam_shared' counts the nodes the pieces share at their seams,
'ties' the nodes joined there by rigid links and 'seams' the
mated surfaces that join them ( |
Source code in src/visualdynamics/core/solids.py
piece_cuts
¶
The pieces a brick mesh is made in, each with the solids cut from it: (piece, cuts).
A lone union gives up its operands, and a union among them gives up its own, all the way down, so a part unioned again with something keeps its pieces (Brandon, 2026-10-20: a table unioned with a sphere was fitted whole, its legs and rod with it). A subtraction whose first operand holds a union is split the same way, each member less what the subtraction takes: (A + B) - C is A - C and B - C. Any other solid, and a subtraction of no union, is one piece; so are parts given together, each its own.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
Returns:
| Type | Description |
|---|---|
list of (int, tuple of int)
|
|
Source code in src/visualdynamics/core/solids.py
meshed_as
¶
The id of the solid a piece is meshed as, while the block runs:
the piece itself, or the subtraction of cuts from it, made for the
while and taken off after, so a reading of the piece (its likely
size, whether a fit is likely to fold) is a reading of what is
meshed, a hole included.
Source code in src/visualdynamics/core/solids.py
pieces
¶
The pieces a brick mesh is made in when the parts together are
not an extrusion (piece_cuts), without what is cut from them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
|
Source code in src/visualdynamics/core/solids.py
piece_name
¶
The name a piece's element group takes: the solid's name, or its kind and id.
Source code in src/visualdynamics/core/solids.py
piece_plan
¶
How brick_mesh would mesh these parts in pieces: for each
piece its id, 'name', 'method' ('extrusion' for a sweep, 'overlay'
for a fit), 'size', 'cells', the grid's cells at that size (voids
included), and 'bricks', about how many the mesh holds
(brick_count), and 'cuts', the solids cut from the piece. The
pieces are piece_cuts', as deep as unions go.
One entry, for the parts together, where they are one extrusion or
no union to take apart; the pane reads it for its preview budget
and its sizes per piece.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The size for every piece not given its own, as the geometry holds its coordinates. |
required |
sizes
|
mapping of int to float
|
A size per piece, by solid id. |
None
|
Returns:
| Type | Description |
|---|---|
list of dict
|
|
Source code in src/visualdynamics/core/solids.py
turned_sweep
¶
turned_sweep(geometry: Any, piece: int, size: float, earlier=(), progress: Any = None) -> tuple[Any, dict]
A block, cylinder or section turned off the geometry's axes,
swept along its own axis: meshed as an extrusion unturned at the
origin (extrusion_mesh), its end where it runs into the pieces
before it put on their surface, and turned and placed back.
The end goes on the earlier pieces' surface line by line: each line
of nodes along the sweep is cut where it leaves them and its nodes
spread evenly between there and its free end, so a rod entering a
block at a slant is sheared over its length, its last layer on the
block's face. A block or a section is a grid along all three of its
own axes, so the sweep runs along whichever of them meets the
earlier pieces at one end; a cylinder's rings run along its own Z.
The bricks' quality is the worst scaled Jacobian (hexmesh), and a
brick folded by the shear refuses the sweep, as does a piece that
meets the earlier pieces other than at one end (NotAnExtrusion,
saying why): the piece is then fitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
piece
|
int
|
The piece, by id: one primitive nothing else uses. |
required |
size
|
float
|
The brick size, as the geometry holds its coordinates. |
required |
earlier
|
sequence of int
|
The pieces meshed before it, which it runs into. |
()
|
progress
|
callable
|
Told |
None
|
Returns:
| Type | Description |
|---|---|
(Geometry, dict)
|
The bricks, in the geometry's frame, and what |
Source code in src/visualdynamics/core/solids.py
2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 | |
meshed_elements
¶
The ids of the elements Mesh Solids makes, bricks, tetrahedra
and shells, in the element groups named names: what meshing
those parts again replaces (Project.mesh_solids, and the pane's
reading before Mesh is pressed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose elements. |
required |
names
|
iterable of str
|
The element groups' names; an empty one names none. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray of int
|
|