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
The base geometry containing the polygon vertices to extrude. Must have at least 3 vertices to form a valid polygon.
The extrusion height in the vertical (Y) direction. Positive values extrude upward, negative values extrude downward.
extrude_brep_face
The BREP face to extrude. Must contain at least 3 vertices.
The extrusion height in the Y direction.
Return Type
Geometry Structure
Theextrude_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
Theextrude_brep_face function returns a Brep object with:
- vertices: Vector of
Vertexobjects with unique IDs and positions - edges: Vector of
Edgeobjects connecting vertices - faces: Vector of
Faceobjects containing vertex indices
How It Works
- Winding Order: The input vertices are sorted to counter-clockwise (CCW) order to ensure consistent face normals
- Bottom Face: Creates edges and a face from the original polygon vertices
- Vertical Edges: Generates new vertices offset by the height vector (0, height, 0) and connects them to base vertices
- Side Faces: Creates quadrilateral faces connecting each edge of the base to the corresponding edge on top
- 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
Source Location
~/workspace/source/main/opengeometry/src/operations/extrude.rs:9
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
- Triangulate - Convert polygons to triangle meshes