Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easy to build polygonal faces #1905

Closed
hannobraun opened this issue Jun 20, 2023 · 1 comment
Closed

Make it easy to build polygonal faces #1905

hannobraun opened this issue Jun 20, 2023 · 1 comment
Labels
topic: core Issues relating to core geometry, operations, algorithms type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

There are straight-forward methods in the operations API to build polygonal Cycles and Regions. However, for Faces, there is only this:

/// Build a triangle
fn triangle(
points: [impl Into<Point<3>>; 3],
services: &mut Services,
) -> Polygon<3> {
let [a, b, c] = points.map(Into::into);
let surface = Surface::plane_from_points([a, b, c]).insert(services);
let (exterior, edges, vertices) = {
let half_edges = [[a, b], [b, c], [c, a]].map(|points| {
let half_edge = HalfEdge::line_segment_from_global_points(
points, &surface, None, services,
);
half_edge.insert(services)
});
let vertices = half_edges
.each_ref_ext()
.map(|half_edge| half_edge.start_vertex().clone());
let cycle = Cycle::new(half_edges.clone()).insert(services);
(cycle, half_edges, vertices)
};
let region = Region::new(exterior, [], None).insert(services);
let face = Face::new(surface, region);
Polygon {
face,
edges,
vertices,
}
}
}

This method could be generalized to build polygons instead of just triangles, but there is one thing to figure out: This method takes 3D points (since a Face is a 3D object), and exactly 3 points define a plane. If generalizing this method for polygons, we have to handle the case that the user provides points that don't lie in the plane defined by the first three points.

@hannobraun hannobraun added type: feature New features and improvements to existing features topic: core Issues relating to core geometry, operations, algorithms labels Jun 20, 2023
@hannobraun
Copy link
Owner Author

Addressed in #1912.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Issues relating to core geometry, operations, algorithms type: feature New features and improvements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant