Skip to content

Commit 977bcde

Browse files
committed
add support to extrude for line, rect, and triangle. That should cover all the geo types
1 parent 7934529 commit 977bcde

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/extrudes.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,34 @@ where S: Clone + Send + Sync {
131131
], metadata.clone()));
132132
}
133133
}
134+
// Line: single segment ribbon
135+
geo::Geometry::Line(line) => {
136+
let c0 = line.start;
137+
let c1 = line.end;
138+
let b0 = Point3::new(c0.x, c0.y, 0.0);
139+
let b1 = Point3::new(c1.x, c1.y, 0.0);
140+
let t0 = b0 + direction;
141+
let t1 = b1 + direction;
142+
let normal = (b1 - b0).cross(&(t0 - b0)).normalize();
143+
out_polygons.push(Polygon::new(vec![
144+
Vertex::new(b0, normal),
145+
Vertex::new(b1, normal),
146+
Vertex::new(t1, normal),
147+
Vertex::new(t0, normal),
148+
], metadata.clone()));
149+
}
150+
151+
// Rect: convert to polygon and extrude
152+
geo::Geometry::Rect(rect) => {
153+
let poly2d = rect.to_polygon();
154+
extrude_geometry(&geo::Geometry::Polygon(poly2d), direction, metadata, out_polygons);
155+
}
156+
157+
// Triangle: convert to polygon and extrude
158+
geo::Geometry::Triangle(tri) => {
159+
let poly2d = tri.to_polygon();
160+
extrude_geometry(&geo::Geometry::Polygon(poly2d), direction, metadata, out_polygons);
161+
}
134162
// Other geometry types (LineString, Point, etc.) are skipped or could be handled differently:
135163
_ => { /* skip */ }
136164
}

0 commit comments

Comments
 (0)