Skip to content

Commit 22be99e

Browse files
face tutorials
1 parent 7993ffd commit 22be99e

File tree

9 files changed

+326
-3
lines changed

9 files changed

+326
-3
lines changed

docs/learn/code/common/occt/shapes/compound/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"label": "Compound",
3-
"position": 6,
3+
"position": 7,
44
"link": {
55
"type": "generated-index",
66
"title": "Compound Shapes",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"label": "Face",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index",
6+
"title": "Faces",
7+
"description": "Faces are one of the most fundamental pieces of geometry that you can create inside OCCT kernel. These tutorials will help you understand how to create and manipulate faces in your 3D models.",
8+
"slug": "/code/common/occt/shapes/face"
9+
}
10+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
sidebar_position: 2
3+
title: Face Basic Primitives
4+
sidebar_label: Face Basic Primitives
5+
description: Learn how to create basic face primitives that define surfaces and areas
6+
tags: [code, occt, rete, blockly, typescript]
7+
---
8+
9+
import Tabs from '@theme/Tabs';
10+
import TabItem from '@theme/TabItem';
11+
import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas';
12+
13+
<img
14+
class="category-icon-small"
15+
src="https://s.bitbybit.dev/assets/icons/white/occt-icon.svg"
16+
alt="OCCT category icon with a stylized logo representation"
17+
title="OCCT category icon" />
18+
19+
# Introduction to OCCT Face Basic Primitives
20+
21+
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.
22+
23+
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.
24+
25+
<Tabs groupId="creating-basic-face-primitives">
26+
<TabItem value="rete" label="Rete">
27+
<BitByBitRenderCanvas
28+
requireManualStart={true}
29+
script={{"script":"{\"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]}}}","version":"0.20.7","type":"rete"}}
30+
title="Creating basic face primitives"
31+
/>
32+
</TabItem>
33+
<TabItem value="blockly" label="Blockly">
34+
<BitByBitRenderCanvas
35+
requireManualStart={true}
36+
script={{"script":"<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>","version":"0.20.7","type":"blockly"}}
37+
title="Creating basic face primitives"
38+
/>
39+
</TabItem>
40+
<TabItem value="typescript" label="TypeScript">
41+
<BitByBitRenderCanvas
42+
requireManualStart={true}
43+
script={{"script":"// Import required DTOs and types for face creation\nconst { CircleDto, SquareDto, RectangleDto, EllipseDto } = Bit.Inputs.OCCT;\ntype Point3 = Bit.Inputs.Base.Point3;\ntype Vector3 = Bit.Inputs.Base.Vector3;\n\n// Get access to OCCT face creation functions\nconst { face } = bitbybit.occt.shapes;\n\n// Define the main function to create various primitive faces\nconst start = async () => {\n // Create a circle face\n const circleOptions = new CircleDto();\n circleOptions.radius = 4;\n circleOptions.center = [0, 0, 0] as Point3;\n circleOptions.direction = [0, 1, 0] as Vector3;\n\n const circleFace = await face.createCircleFace(circleOptions);\n\n // Create a square face at a different position\n const squareOptions = new SquareDto();\n squareOptions.size = 3;\n squareOptions.center = [7, 0, 0] as Point3;\n squareOptions.direction = [0, 1, 0] as Vector3;\n\n const squareFace = await face.createSquareFace(squareOptions);\n\n // Create a rectangle face\n const rectangleOptions = new RectangleDto();\n rectangleOptions.width = 3;\n rectangleOptions.length = 7;\n rectangleOptions.center = [-7, 0, 0] as Point3;\n rectangleOptions.direction = [0, 1, 0] as Vector3;\n\n const rectangleFace = await face.createRectangleFace(rectangleOptions);\n\n // Create an ellipse face\n const ellipseOptions = new EllipseDto();\n ellipseOptions.center = [0, 0, -9] as Point3;\n ellipseOptions.direction = [0, 1, 0] as Vector3;\n ellipseOptions.radiusMinor = 1;\n ellipseOptions.radiusMajor = 3;\n\n const ellipseFace = await face.createEllipseFace(ellipseOptions);\n\n // Draw all the created faces\n bitbybit.draw.drawAnyAsync({ entity: circleFace });\n bitbybit.draw.drawAnyAsync({ entity: squareFace });\n bitbybit.draw.drawAnyAsync({ entity: rectangleFace });\n bitbybit.draw.drawAnyAsync({ entity: ellipseFace });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}}
44+
title="Creating basic face primitives"
45+
/>
46+
</TabItem>
47+
</Tabs>
48+
49+
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.
50+
51+
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.

0 commit comments

Comments
 (0)