solid.Shape
drafting: solid.Shape
A solid in millimetres, modelled through Open CASCADE.
solid.Shape holds the exact boundary of one or more solids: every
face a plane, cylinder, cone, sphere, torus or spline surface, every edge
a line, circle or curve, with nothing approximated by facets. It is what
the functions of the solid namespace create, what the boolean
operators combine, and what its write method saves as STEP for
exchange or STL for printing.
Primitives are made by
solid.box
solid.cylinder
solid.cone
solid.sphere
solid.ellipsoid
solid.torus
solid.wedge
and solids from +geom objects by
solid.extrude
solid.revolve
solid.loft
solid.sweep
solid.helix
A solid is made from a closed triangle mesh by solid.polyhedron,
and from a grid of points by solid.surface, which fits a surface
through the grid and thickens it. hull wraps shapes and points in
their convex hull, and solid.read loads solids from a STEP file.
Finally, shapes can be combined by the three boolean CAD operations, each taking any number of shapes:
| Method | Result |
|---|---|
union | the material of any of them |
subtract | the material of the first that is in none of the others |
intersect | the material common to all of them |
Features are worked on a shape by methods: hole drills plain,
counterbored, countersunk and tapping holes, pocket cuts a region
into it, fillet and chamfer round or bevel edges, and
shell hollows the shape. The edges and faces they act on are
chosen by edges and faces, by the kind of curve or surface,
by direction and by position. section cuts a shape with a plane
into regions, which the solid functions build from again, and
projection gives the outline of a shape seen along a direction as
regions in the same way.
The class is a value class. Every operation returns a new shape and leaves its operands unchanged, and a copy is independent of the original. The empty shape adds nothing to a union and empties an intersection, and a boolean whose result holds no material, such as the intersection of two solids that do not meet, returns it.
Octave’s save does not keep a classdef object, so a shape is not
saved as a value. Save its Data, and make it again with
solid.Shape (DATA), its Colour and Name set
again; or write it to a STEP file with solid.Shape.write, which
keeps both, and read it back with solid.read.
See also: solid.box, solid.read, solid.Shape.write, solid.Shape.show
Source Code: solid.Shape
The solid.Shape class contains the following properties:
An N-by-3 matrix of red, green and blue from 0 to 1, a row for
each of the shape’s N solids in the order
solid.Shape.numsolids counts them, a row of NaN for a
solid without a colour, or empty when none has one. Assigning a single
row colours every solid. The viewer shows it, and a STEP file carries
it out and in. A transform keeps it, and each solid a boolean or a
feature makes takes the colour of the first coloured solid it came
from, so parts apart keep their own; the tools of subtract give
none.
A cell column of character vectors, one for each of the shape’s
N solids in the order solid.Shape.numsolids counts them,
'' for a solid without a name, or empty when none has one.
Assigning a single character vector, or a cell of one, names every
solid; a cell of N names each in turn. A name is free text,
kept as it is given and never read for meaning. A STEP file carries
it out and in, and a 3MF file out, as solid.Shape.write
describes. A transform keeps it, and each solid a boolean or a
feature makes takes the name of the first named solid it came from, as
it takes its colour by solid.Shape.Colour; the tools of
subtract give none.
The solid.Shape class offers the following public methods:
tessellate |
A triangle mesh of a shape. |
show |
Show a shape in a viewer of its own, redrawing in place. |
write |
Write a solid to a STEP, STL, OBJ, PLY or 3MF file. |
isvalid |
True if a shape passes Open CASCADE's validity check. |
isempty |
True for the empty shape, which holds no material. |
numsolids |
The number of separate solids in a shape. |
numfaces |
The number of faces of a shape. |
numedges |
The number of edges of a shape, each counted once. |
solids |
The solids of a shape, one by one. |
fillet |
Round edges of a shape to a radius. |
facefillet |
Round a shape between faces chosen by index. |
chamfer |
Bevel edges of a shape. |
shell |
Hollow a shape to a uniform wall thickness. |
hole |
Drill holes into a shape. |
thread |
Cut screw threads into a shape. |
pocket |
Cut a pocket into a shape. |
knurl |
Knurl a cylindrical face of a shape. |
section |
Cut a shape with a plane. |
projection |
Outline of a shape seen along a direction. |
hull |
The convex hull of shapes and points. |
resize |
Scale a shape to a size. |
copy |
Copies of a shape, united. |
rectarray |
Copies of a shape in rows, columns and layers, united. |
polararray |
Copies of a shape round an axis, united. |