Skip to main content

OCCT vertices

A vertex is OpenCascade's own point: the smallest piece of a shape, where edges start and end. A plain point, [x, y, z], is just three numbers in your script; a vertex is a shape that lives in the kernel (see Shapes live in a worker) and can be drawn, put in a compound, measured against other shapes or exported with them.

Most of the time you work with plain points and let the kernel make vertices where it needs them. The bitbybit.occt.shapes.vertex functions are for the moments in between: turning points into vertices and back, and finding where points land on a shape.

Here a honeycomb of points on the ground is cast straight down onto a sphere sunk below it. Each point that hits the sphere lands on its top, and the landing points become one compound of vertices, a dome of yellow dots under the flat grid:

Bitbybit Platform

A grid of points cast onto a dome in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"grid": {
"id": "grid",
"name": "bitbybit.point.hexGrid",
"customName": "hex grid",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"nrHexagonsY": 16,
"nrHexagonsX": 16,
"radiusHexagon": 0.25,
"orientOnCenter": true,
"pointsOnGround": true
},
"inputs": {},
"position": [
40,
40
]
},
"dome": {
"id": "dome",
"name": "bitbybit.occt.shapes.solid.createSphere",
"customName": "sphere",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 3.5,
"center": [
0,
-4,
0
]
},
"inputs": {},
"position": [
40,
560
]
},
"landed": {
"id": "landed",
"name": "bitbybit.occt.shapes.vertex.projectPoints",
"customName": "project points",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"direction": [
0,
-10,
0
],
"projectionType": "closest"
},
"inputs": {
"points": {
"connections": [
{
"node": "grid",
"output": "result",
"data": {}
}
]
},
"shape": {
"connections": [
{
"node": "dome",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
40
]
},
"vertices": {
"id": "vertices",
"name": "bitbybit.occt.shapes.vertex.verticesCompoundFromPoints",
"customName": "vertices compound from points",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"points": {
"connections": [
{
"node": "landed",
"output": "result",
"data": {}
}
]
}
},
"position": [
880,
40
]
},
"dots": {
"id": "dots",
"name": "bitbybit.draw.optionsOcctShape",
"customName": "options occt shape",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"faceOpacity": 1,
"edgeOpacity": 1,
"edgeColour": "#ffffff",
"faceColour": "#ff0000",
"vertexColour": "#ffc845",
"edgeWidth": 2,
"vertexSize": 0.08,
"drawEdges": true,
"drawFaces": true,
"drawVertices": true,
"precision": 0.01,
"angularDeflection": 0.5,
"relativeDeflection": false,
"drawEdgeIndexes": false,
"edgeIndexHeight": 0.06,
"edgeIndexColour": "#ff00ff",
"drawFaceIndexes": false,
"faceIndexHeight": 0.06,
"faceIndexColour": "#0000ff",
"drawTwoSided": true,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1,
"edgeArrowSize": 0,
"edgeArrowAngle": 15,
"keepMeshData": false,
"allowQualityDecrease": true,
"forceFaceDeflection": false,
"drawIsoCurves": false,
"isoCurvesU": 5,
"isoCurvesV": 5,
"isoCurvesColour": "#808080",
"surfaceAnalysis": "none",
"draftDirection": [
0,
1,
0
]
},
"inputs": {},
"position": [
880,
400
]
},
"drawVertices": {
"id": "drawVertices",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "vertices",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "dots",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
40
]
}
},
"modules": {}
}

Points and vertices​

  • vertexFromPoint and vertexFromXYZ make one vertex; verticesFromPoints makes one per point.
  • verticesCompoundFromPoints makes one vertex per point and bundles them into a single compound, so a whole point cloud is one shape to draw, translate or export. A shape's vertices are not drawn unless the draw options say drawVertices: true, so a compound of vertices alone draws nothing without it; vertexSize and vertexColour set how they look.
  • vertexToPoint and verticesToPoints read vertices back as plain points.
  • getVertices lists the vertices of any shape as the kernel walks it, and getVerticesAsPoints gives them as plain points straight away. A closed wire's first vertex is also its last, so it is listed once.

Casting points onto a shape​

projectPoints casts each point along direction and keeps where it lands on the shape. The direction is also the reach: [0, -10, 0] casts down, as far as 10 units, so a point farther than that from the shape lands nowhere. A point that crosses the shape more than once, through a sphere for instance, lands where projectionType says: all keeps every hit, closest the first one, furthest the last, and closestAndFurthest both ends. Points that miss are left out, so the result can be shorter than the list you gave.

To lay a whole wire onto a shape rather than single points, bitbybit.occt.shapes.wire.project casts it along a direction in the same way.

Every function​

FunctionWhat it does
getVerticesLists every vertex of a shape as the kernel walks it.
getVerticesAsPointsLists every vertex of a shape as a plain [x, y, z] point, as the kernel walks it.
projectPointsProjects points onto a shape along a direction and gives the points where they land.
vertexFromPointMakes a vertex, the kernel's own point, from a plain [x, y, z] point.
vertexFromXYZMakes a vertex from x, y and z values.
vertexToPointReads the coordinates of a vertex as a plain [x, y, z] point.
verticesCompoundFromPointsMakes one vertex per point and bundles them into a single compound, so a whole point cloud can be drawn or transformed as one shape.
verticesFromPointsMakes one vertex, the kernel's own point, for each plain [x, y, z] point.
verticesToPointsReads the coordinates of each vertex as a plain [x, y, z] point.