OCCT Edge Indexing: Identifying and Using Specific Edges
Introduction to Edge Indexing
In many CAD modeling scenarios, you'll need to select and operate on specific edges of a shape. For example, when applying a fillet (rounding) or a chamfer to particular edges of a solid or shell, you need a way to tell the system which edges to modify. This is where edge indexing comes into play.
Each edge on an OCCT shape has an index, which acts like an address or identifier for that specific edge within the context of that particular shape. Operations like filleting or chamfering often accept a list of these edge indexes to target the desired edges.
Important Note on Indexing Convention: Due to some legacy reasons, particularly related to Blockly integration, edge indexes in many Bitbybit OCCT operations start from 1, not 0 (which is more common in programming). Always be mindful of this 1-based indexing when providing edge indexes.
How to Know Which Index Applies to Which Edge?
To identify the index of a specific edge on your 3D model, Bitbybit provides a way to visualize these indexes directly in the 3D scene.
- When using a
drawAnyAsynccommand (or its equivalent in visual editors) with an OCCT shape as the entity, you can provide specific OCCT drawing options. - Within these options, there's a setting like "Draw Edge Indexes" (or
drawEdgeIndexesin TypeScript). - Turning this option on will render the numerical index next to each edge of the shape in the 3D view.
Caution: Index Instability After Modification Keep in mind that if you perform an operation that changes the topology of the shape (like applying a fillet or chamfer), the number of edges on your shape will likely change. Consequently, the old index values will no longer be valid or may refer to different edges on the modified shape. You would need to re-visualize the indexes on the new shape if further indexed operations are required.
Examples: Visualizing Edge Indexes
Below are examples in TypeScript, Blockly, and Rete that demonstrate creating a simple solid box and enabling the drawing of its edge indexes.
TypeScript Example: Drawing Edge Indexes
const start = async () => {
const boxOpt = new Bit.Inputs.OCCT.BoxDto();
boxOpt.width = 5;
boxOpt.length = 8;
boxOpt.height = 10;
const box = await bitbybit.occt.shapes.solid.createBox(boxOpt);
const drawOpt = new Bit.Inputs.Draw.DrawOcctShapeOptions();
drawOpt.drawEdgeIndexes = true;
drawOpt.faceOpacity = 0.3;
drawOpt.edgeOpacity = 0.3;
drawOpt.edgeIndexHeight = 0.24
bitbybit.draw.drawAnyAsync({
entity: box,
options: drawOpt
});
}
start();
Blockly Example: Drawing Edge Indexes
<xml xmlns="https://developers.google.com/blockly/xml"><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="UO^K1-FNciNjT{DsaF2S" x="-1052" y="-1219"><value name="Entity"><block type="bitbybit.occt.shapes.solid.createBox" id="kAPiNsy.MZ9?u8OMw:F{"><value name="Width"><block type="math_number" id="ps%ZB=Lg|=n2+WoN88L;"><field name="NUM">5</field></block></value><value name="Length"><block type="math_number" id="9AIhYC!Bl`qQ=@rx{Hvm"><field name="NUM">8</field></block></value><value name="Height"><block type="math_number" id="VA?PT:1w_do!EcPH3o`H"><field name="NUM">10</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="*C~h4g-MdUu*}L~6n9W;"><value name="X"><block type="math_number" id="HSM/v}`gGJkJyeK.OYgI"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="Co1x#c;yRR~3n8]irr}O"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="n.I1=AL{C-iE4{hZiuRz"><field name="NUM">0</field></block></value></block></value></block></value><value name="Options"><block type="bitbybit.draw.optionsOcctShape" id="C)_;nd+-yNa2tkQ=f.(j"><value name="FaceOpacity"><block type="math_number" id="WJFo/9(aQI[,F]A0,{nV"><field name="NUM">0.3</field></block></value><value name="EdgeOpacity"><block type="math_number" id="2xaR^pUK:5[w$[i*9iEJ"><field name="NUM">0.3</field></block></value><value name="EdgeColour"><block type="colour_picker" id="1Kbr5PB^wsuJ9`NhR,g("><field name="COLOUR">#ffffff</field></block></value><value name="FaceColour"><block type="colour_picker" id="OsgqgBob6so1DhNeQTzf"><field name="COLOUR">#ff0000</field></block></value><value name="EdgeWidth"><block type="math_number" id="S[;)nHF3kw,0T6.imOS:"><field name="NUM">2</field></block></value><value name="DrawEdges"><block type="logic_boolean" id="o~*ZYZY;JaHYEi`Cc$Zb"><field name="BOOL">TRUE</field></block></value><value name="DrawFaces"><block type="logic_boolean" id="Sg:lgzZ4(fSu^x%a#Sol"><field name="BOOL">TRUE</field></block></value><value name="Precision"><block type="math_number" id=",MwLCD$,blZsB`:NR`m_"><field name="NUM">0.01</field></block></value><value name="DrawEdgeIndexes"><block type="logic_boolean" id="NWp7H~{+?}[IWv/g{Im,"><field name="BOOL">TRUE</field></block></value><value name="EdgeIndexHeight"><block type="math_number" id="F5O^[n@Xq)6N-}71wc:_"><field name="NUM">0.24</field></block></value><value name="EdgeIndexColour"><block type="colour_picker" id="i*VgIX^h~3nr1S.o1-3y"><field name="COLOUR">#ff00ff</field></block></value><value name="DrawFaceIndexes"><block type="logic_boolean" id="|S~9#-TIn?ed*=]V?*1h"><field name="BOOL">FALSE</field></block></value><value name="FaceIndexHeight"><block type="math_number" id="G3,mdV2.$_lJl4,Uh/zF"><field name="NUM">0.06</field></block></value><value name="FaceIndexColour"><block type="colour_picker" id=";7fHMr6^$BfeQ3x(9Xy."><field name="COLOUR">#0000ff</field></block></value></block></value></block></xml>
Rete Example: Drawing Edge Indexes
{
"id": "rete-v2-json",
"nodes": {
"88e0333871f34e09": {
"id": "88e0333871f34e09",
"name": "bitbybit.occt.shapes.solid.createBox",
"customName": "box",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 5,
"length": 8,
"height": 10,
"center": [
0,
0,
0
],
"originOnCenter": true
},
"inputs": {},
"position": [
-846.1000022577027,
778.8093041611836
]
},
"76f7f3e52d369e97": {
"id": "76f7f3e52d369e97",
"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": "88e0333871f34e09",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "7561c973c8b2bfaa",
"output": "result",
"data": {}
}
]
}
},
"position": [
-431.68995025210455,
1062.6003327458436
]
},
"7561c973c8b2bfaa": {
"id": "7561c973c8b2bfaa",
"name": "bitbybit.draw.optionsOcctShape",
"customName": "options occt shape",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"faceOpacity": 0.3,
"edgeOpacity": 0.3,
"edgeColour": "#ffffff",
"faceColour": "#ff0000",
"vertexColour": "#ff00ff",
"edgeWidth": 2,
"vertexSize": 0.03,
"drawEdges": true,
"drawFaces": true,
"drawVertices": false,
"precision": 0.01,
"drawEdgeIndexes": true,
"edgeIndexHeight": 0.24,
"edgeIndexColour": "#ff00ff",
"drawFaceIndexes": false,
"faceIndexHeight": 0.06,
"faceIndexColour": "#0000ff"
},
"inputs": {},
"position": [
-903.5179710077027,
1229.3171166611837
]
}
}
}
Adjusting Edge Index Display
Sometimes, the default display of edge indexes might not be optimal:
- Indexes Not Visible (Geometry Too Large): If your geometry is very large, the default text size for indexes might be too small to see. You can adjust the
edgeIndexHeightproperty in the OCCT drawing options to make the index text larger. - Indexes Overlapping (Geometry Too Small or Dense): Conversely, if your geometry is small or has many edges close together, the index text might appear too large and overlap, making it unreadable. In this case, you can decrease the
edgeIndexHeight. - Visibility Through Faces: To see indexes on edges that might be obscured by faces, it's often helpful to make the faces semi-transparent. You can do this by setting the
faceOpacityproperty in the drawing options to a value less than 1 (e.g., 0.5). You can also adjustedgeOpacityif needed.
By using these visualization tools and understanding how edge indexing works, you can precisely target specific edges for various modeling operations in OCCT within the Bitbybit environment.



