Introduction to OCCT Face Basic Primitives
Faces are two-dimensional surfaces that fill geometric boundaries to create areas in 3D space. While wires define outlines and curves, faces create actual surfaces that can be visualized with materials, analyzed for properties, and used to build 3D solids.
Think of wires as the frame of a window, and faces as the glass that fills the frame. This tutorial demonstrates creating circle, square, rectangle, and ellipse faces using different programming approaches.
- Rete
- Blockly
- TypeScript
{
"id": "rete-v2-json",
"nodes": {
"9d2950eb42d026eb": {
"id": "9d2950eb42d026eb",
"name": "bitbybit.occt.shapes.face.createCircleFace",
"customName": "circle face",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 4,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
913.703125,
436.41015625
]
},
"c863eef64ddee2c8": {
"id": "c863eef64ddee2c8",
"name": "bitbybit.occt.shapes.face.createEllipseFace",
"customName": "ellipse face",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"radiusMinor": 1,
"radiusMajor": 3
},
"inputs": {
"center": {
"connections": [
{
"node": "5f27a0fdde38d7ea",
"output": "result",
"data": {}
}
]
}
},
"position": [
905.5502310832453,
1678.0205681556072
]
},
"ddacad79d6942524": {
"id": "ddacad79d6942524",
"name": "bitbybit.occt.shapes.face.createSquareFace",
"customName": "square face",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"size": 3,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "2014565152a68ddc",
"output": "result",
"data": {}
}
]
}
},
"position": [
916.0273536742325,
838.3467683139284
]
},
"915c753679d2ae7b": {
"id": "915c753679d2ae7b",
"name": "bitbybit.occt.shapes.face.createRectangleFace",
"customName": "rectangle face",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 3,
"length": 7,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "305e88c644ea099a",
"output": "result",
"data": {}
}
]
}
},
"position": [
910.5168109763998,
1219.3530266682635
]
},
"2014565152a68ddc": {
"id": "2014565152a68ddc",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 7,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
501.7924955588585,
880.408747068502
]
},
"305e88c644ea099a": {
"id": "305e88c644ea099a",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -7,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
518.7778459924483,
1299.4829635556591
]
},
"5f27a0fdde38d7ea": {
"id": "5f27a0fdde38d7ea",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 0,
"y": 0,
"z": -9
},
"inputs": {},
"position": [
507.829978040304,
1682.2323868383787
]
}
}
}
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="circleFace">circleFace</variable><variable id="squareFace">squareFace</variable><variable id="rectangleFace">rectangleFace</variable><variable id="ellipseFace">ellipseFace</variable></variables><block type="variables_set" id="create_circle_face" x="50" y="50"><field name="VAR" id="circleFace">circleFace</field><value name="VALUE"><block type="bitbybit.occt.shapes.face.createCircleFace" id="circle_face"><value name="Radius"><block type="math_number" id="circle_radius"><field name="NUM">4</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="circle_center"><value name="X"><block type="math_number" id="circle_center_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="circle_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="circle_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="circle_direction"><value name="X"><block type="math_number" id="circle_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="circle_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="circle_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_square_face" x="50" y="150"><field name="VAR" id="squareFace">squareFace</field><value name="VALUE"><block type="bitbybit.occt.shapes.face.createSquareFace" id="square_face"><value name="Size"><block type="math_number" id="square_size"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="square_center"><value name="X"><block type="math_number" id="square_center_x"><field name="NUM">7</field></block></value><value name="Y"><block type="math_number" id="square_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="square_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="square_direction"><value name="X"><block type="math_number" id="square_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="square_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="square_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_rectangle_face" x="50" y="250"><field name="VAR" id="rectangleFace">rectangleFace</field><value name="VALUE"><block type="bitbybit.occt.shapes.face.createRectangleFace" id="rectangle_face"><value name="Width"><block type="math_number" id="rectangle_width"><field name="NUM">3</field></block></value><value name="Length"><block type="math_number" id="rectangle_length"><field name="NUM">7</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="rectangle_center"><value name="X"><block type="math_number" id="rectangle_center_x"><field name="NUM">-7</field></block></value><value name="Y"><block type="math_number" id="rectangle_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="rectangle_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="rectangle_direction"><value name="X"><block type="math_number" id="rectangle_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="rectangle_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="rectangle_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_ellipse_face" x="50" y="350"><field name="VAR" id="ellipseFace">ellipseFace</field><value name="VALUE"><block type="bitbybit.occt.shapes.face.createEllipseFace" id="ellipse_face"><value name="Center"><block type="bitbybit.point.pointXYZ" id="ellipse_center"><value name="X"><block type="math_number" id="ellipse_center_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ellipse_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="ellipse_center_z"><field name="NUM">-9</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="ellipse_direction"><value name="X"><block type="math_number" id="ellipse_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ellipse_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="ellipse_dir_z"><field name="NUM">0</field></block></value></block></value><value name="RadiusMinor"><block type="math_number" id="ellipse_radius_minor"><field name="NUM">1</field></block></value><value name="RadiusMajor"><block type="math_number" id="ellipse_radius_major"><field name="NUM">3</field></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_circle_face" x="50" y="450"><value name="Entity"><block type="variables_get" id="get_circle_face"><field name="VAR" id="circleFace">circleFace</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_square_face" x="50" y="550"><value name="Entity"><block type="variables_get" id="get_square_face"><field name="VAR" id="squareFace">squareFace</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_rectangle_face" x="50" y="650"><value name="Entity"><block type="variables_get" id="get_rectangle_face"><field name="VAR" id="rectangleFace">rectangleFace</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_ellipse_face" x="50" y="750"><value name="Entity"><block type="variables_get" id="get_ellipse_face"><field name="VAR" id="ellipseFace">ellipseFace</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></xml>
// Import required DTOs and types for face creation
const { CircleDto, SquareDto, RectangleDto, EllipseDto } = Bit.Inputs.OCCT;
type Point3 = Bit.Inputs.Base.Point3;
type Vector3 = Bit.Inputs.Base.Vector3;
// Get access to OCCT face creation functions
const { face } = bitbybit.occt.shapes;
// Define the main function to create various primitive faces
const start = async () => {
// Create a circle face
const circleOptions = new CircleDto();
circleOptions.radius = 4;
circleOptions.center = [0, 0, 0] as Point3;
circleOptions.direction = [0, 1, 0] as Vector3;
const circleFace = await face.createCircleFace(circleOptions);
// Create a square face at a different position
const squareOptions = new SquareDto();
squareOptions.size = 3;
squareOptions.center = [7, 0, 0] as Point3;
squareOptions.direction = [0, 1, 0] as Vector3;
const squareFace = await face.createSquareFace(squareOptions);
// Create a rectangle face
const rectangleOptions = new RectangleDto();
rectangleOptions.width = 3;
rectangleOptions.length = 7;
rectangleOptions.center = [-7, 0, 0] as Point3;
rectangleOptions.direction = [0, 1, 0] as Vector3;
const rectangleFace = await face.createRectangleFace(rectangleOptions);
// Create an ellipse face
const ellipseOptions = new EllipseDto();
ellipseOptions.center = [0, 0, -9] as Point3;
ellipseOptions.direction = [0, 1, 0] as Vector3;
ellipseOptions.radiusMinor = 1;
ellipseOptions.radiusMajor = 3;
const ellipseFace = await face.createEllipseFace(ellipseOptions);
// Draw all the created faces
bitbybit.draw.drawAnyAsync({ entity: circleFace });
bitbybit.draw.drawAnyAsync({ entity: squareFace });
bitbybit.draw.drawAnyAsync({ entity: rectangleFace });
bitbybit.draw.drawAnyAsync({ entity: ellipseFace });
}
// Execute the function
start();
Each face primitive requires basic parameters: a center point for positioning, a direction vector for orientation (typically [0,1,0] for horizontal faces), and size parameters like radius for circles or width/length for rectangles. The examples create four different face types at separate positions so you can see them clearly.
These face primitives serve as building blocks for more complex modeling operations. You can extrude them into 3D solids, combine them with boolean operations, or use them as surfaces for analysis and visualization. They're commonly used in architectural modeling, manufacturing design, and any application where you need precise geometric surfaces.



