Measuring and analysing shapes
bitbybit.occt.analysis asks questions of shapes and answers with numbers, points and lists, not new shapes. Use it to size a part, check a fit, find where to put the next feature, or make sure parts do not collide.
Measure
analysis.measure holds the measurements a designer reaches for:
tightBoundingBox,orientedBoundingBoxandboundingBoxInFrame: the box around a shape, aligned with the world, turned to fit it as closely as possible, or in a frame of your own;extrema: the nearest points between two shapes, and their distance;angleBetweenanddihedralAngle: angles between directions and between faces;principalFrame: a shape's centre of mass and principal axes;minCurvatureRadius: the tightest bend of a shape, and where it is.
Volume and area are with the shapes themselves: bitbybit.occt.shapes.solid.getSolidVolume and getSolidSurfaceArea.
Clashes
analysis.clashes.betweenShapes checks a list of parts against each other and names every pair that overlaps, touches or comes within a clearance, with their distance and the volume two solids share. selfIntersections finds a shape that cuts through itself, and facesWithin the faces of one shape that come within a clearance of the faces of another.
Here two blocks overlap. The clash names the pair by their places in the list, 0 and 1, with a distance of 0 and the volume they share:
- Rete
- Blockly
- TypeScript
{
"id": "rete-v2-json",
"nodes": {
"first": {
"id": "first",
"name": "bitbybit.occt.shapes.solid.createBox",
"customName": "box",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 3,
"length": 3,
"height": 3,
"center": [
0,
0,
0
],
"originOnCenter": true
},
"inputs": {},
"position": [
40,
40
]
},
"second": {
"id": "second",
"name": "bitbybit.occt.shapes.solid.createBox",
"customName": "box",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 3,
"length": 3,
"height": 3,
"center": [
2,
1,
0
],
"originOnCenter": true
},
"inputs": {},
"position": [
40,
460
]
},
"parts": {
"id": "parts",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "first",
"output": "result",
"data": {}
},
{
"node": "second",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
260
]
},
"clashes": {
"id": "clashes",
"name": "bitbybit.occt.analysis.clashes.betweenShapes",
"customName": "clashes between shapes",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"clearance": 0
},
"inputs": {
"shapes": {
"connections": [
{
"node": "parts",
"output": "list",
"data": {}
}
]
}
},
"position": [
880,
260
]
}
},
"modules": {}
}
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="first">first</variable><variable id="second">second</variable><variable id="parts">parts</variable><variable id="clashes">clashes</variable></variables><block type="variables_set" x="40" y="40"><field name="VAR" id="first">first</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createBox"><value name="Width"><block type="math_number"><field name="NUM">3</field></block></value><value name="Length"><block type="math_number"><field name="NUM">3</field></block></value><value name="Height"><block type="math_number"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ"><value name="X"><block type="math_number"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="OriginOnCenter"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="second">second</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createBox"><value name="Width"><block type="math_number"><field name="NUM">3</field></block></value><value name="Length"><block type="math_number"><field name="NUM">3</field></block></value><value name="Height"><block type="math_number"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ"><value name="X"><block type="math_number"><field name="NUM">2</field></block></value><value name="Y"><block type="math_number"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="OriginOnCenter"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="parts">parts</field><value name="VALUE"><block type="bitbybit.lists.addItem"><value name="List"><block type="bitbybit.lists.addItem"><value name="List"><block type="bitbybit.lists.createEmptyList"></block></value><value name="Item"><block type="variables_get"><field name="VAR" id="first">first</field></block></value><value name="Clone"><block type="logic_boolean"><field name="BOOL">FALSE</field></block></value></block></value><value name="Item"><block type="variables_get"><field name="VAR" id="second">second</field></block></value><value name="Clone"><block type="logic_boolean"><field name="BOOL">FALSE</field></block></value></block></value><next><block type="variables_set"><field name="VAR" id="clashes">clashes</field><value name="VALUE"><block type="bitbybit.occt.analysis.clashes.betweenShapes"><value name="Shapes"><block type="variables_get"><field name="VAR" id="parts">parts</field></block></value><value name="Clearance"><block type="math_number"><field name="NUM">0</field></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn"><value name="Entity"><block type="variables_get"><field name="VAR" id="parts">parts</field></block></value></block></next></block></next></block></next></block></next></block></xml>
const first = await bitbybit.occt.shapes.solid.createBox({ width: 3, length: 3, height: 3, center: [0, 0, 0] });
const second = await bitbybit.occt.shapes.solid.createBox({ width: 3, length: 3, height: 3, center: [2, 1, 0] });
const clashes = await bitbybit.occt.analysis.clashes.betweenShapes({ shapes: [first, second], clearance: 0 });
console.log(JSON.stringify(clashes));
await bitbybit.draw.drawAnyAsync({ entity: [first, second] });
In TypeScript the clashes are written to the console. In Rete, point at the output of clashes between shapes to read them.
Curves and surfaces
analysis.curves and analysis.surfaces read the geometry under edges and faces: the kind of curve or surface, curvature along a curve or at points on a surface, the closest points, where a curve crosses a face or another curve, and the kinks where a wire turns sharply. They are the tools for checking smoothness and for placing things exactly on a surface.
Every analysis
| Function | What it does |
|---|---|
clashes.betweenShapes | Finds every pair among a list of shapes that overlap, touch or come within a clearance of each other, such as colliding parts. |
clashes.facesWithin | Finds the faces of one shape that come within a clearance of faces of another, each pair measured exactly. |
clashes.selfIntersections | Finds the pairs of faces of one shape that cross each other anywhere but along an edge they share. |
curves.closestPoints | Finds the point of an edge or a wire nearest each given point, with where it lies along the curve. |
curves.curvatureComb | Draws a curvature comb along an edge or a wire: teeth standing on the curve, as long as the curvature there, pointing away from its center. |
curves.curvaturesAtLengths | Reads how an edge or a wire bends at places given as lengths along it from its start, in model units. |
curves.curvaturesAtParams | Reads how an edge or a wire bends at places given as fractions from 0 at its start to 1 at its end. |
curves.curveType | Tells what kind of curve an edge runs along: a line, a circle, an ellipse, a hyperbola, a parabola, a Bezier curve, a B-spline, an offset curve or another kind. |
curves.extremesAlong | Finds the highest and lowest points of an edge or a wire along a direction, such as the crests of a wave. |
curves.intersectCurves | Finds where two edges or wires cross or touch, with the parameter and the edge of each point on both curves. |
curves.intersectCurveWithFace | Finds where an edge or a wire passes through a face or lies on it, within the face's edges. |
curves.kinks | Finds the corners of an edge or a wire where the tangent turns by more than an angle, such as the corners of a polyline. |
measure.angleBetween | Measures the angle in degrees between two faces or edges where they come nearest each other. |
measure.boundingBoxInFrame | Finds the box that just holds a shape with its sides along a frame's axes instead of the world's. |
measure.dihedralAngle | Measures the angle through the material between the two faces that meet at an edge. |
measure.extrema | Finds every nearest pair of points between two shapes, with the vertex, edge or face each point lies on and where on it. |
measure.minCurvatureRadius | Finds the tightest bend of a shape, sampled over its faces and edges, and where it is. |
measure.orientedBoundingBox | Finds the smallest box that fits around a shape, turned to follow it rather than the axes: a frame at the box's centre, its direction along the longest side and its normal along the shortest, with half the box's size along each. |
measure.principalFrame | Finds a shape's principal axes of inertia as a frame at its centre of mass: the direction is the axis it turns about most easily, the normal the one it resists most. |
measure.tightBoundingBox | Finds the box lined up with the axes that just holds a shape's exact geometry. |
signatures | Describes every face and edge of a shape in one pass: each face's surface kind, area, centre, outward normal and box, and each edge's curve kind, length, midpoint and direction there. |
surfaces.closestPoints | Finds the point of a face nearest each given point, with its (u, v) and the face's normal there. |
surfaces.curvaturesOnUVs | Reads how a face bends at (u, v) pairs: its largest and smallest curvature with their directions, their mean and product, and the normal. |
surfaces.surfaceType | Tells what kind of surface a face lies on, such as a plane, a cylinder or a B-spline. |



