Skip to main content

Overview

The extrude operation transforms a 2D polygon into a 3D solid by extending it along a height vector. This creates a prismatic geometry with the original polygon as the base, vertical side faces connecting the base to the top, and a parallel top face.

Function Signature

extrude_polygon_by_buffer_geometry

Extrudes a polygon defined by buffer geometry to create a 3D mesh.
geom_buf
BaseGeometry
required
The base geometry containing the polygon vertices to extrude. Must have at least 3 vertices to form a valid polygon.
height
f64
required
The extrusion height in the vertical (Y) direction. Positive values extrude upward, negative values extrude downward.

extrude_brep_face

Extrudes a BREP (Boundary Representation) face to create a new BREP object with topological information.
brep_face
Brep
required
The BREP face to extrude. Must contain at least 3 vertices.
height
f64
required
The extrusion height in the Y direction.

Return Type

Geometry Structure

The extrude_polygon_by_buffer_geometry function returns a Geometry object with:
  • vertices: Complete vertex list including both base and top vertices
  • edges: All edges forming the bottom face, top face, and vertical connections
  • faces: Bottom face, all side faces (one per edge of the original polygon), and top face

Brep Structure

The extrude_brep_face function returns a Brep object with:
  • vertices: Vector of Vertex objects with unique IDs and positions
  • edges: Vector of Edge objects connecting vertices
  • faces: Vector of Face objects containing vertex indices

How It Works

  1. Winding Order: The input vertices are sorted to counter-clockwise (CCW) order to ensure consistent face normals
  2. Bottom Face: Creates edges and a face from the original polygon vertices
  3. Vertical Edges: Generates new vertices offset by the height vector (0, height, 0) and connects them to base vertices
  4. Side Faces: Creates quadrilateral faces connecting each edge of the base to the corresponding edge on top
  5. Top Face: Constructs the top face with reversed vertex order for correct normal orientation

Code Examples

Basic Extrusion

Extruding a Triangle

Using BREP Extrusion

Visual Examples

Implementation Details

Edge Cases

  • Minimum Vertices: Polygons with fewer than 3 vertices are technically invalid, but the function proceeds (returns incomplete geometry)
  • Direction: Currently extrudes only in the Y direction; future versions may support arbitrary extrusion vectors
  • Winding Order: Automatically corrects to CCW to ensure proper face orientation

See Also

  • Sweep - Extrude a profile along an arbitrary path
  • Offset - Create parallel offset curves
Last modified on March 14, 2026