[ 
https://issues.apache.org/jira/browse/GEOMETRY-144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17530519#comment-17530519
 ] 

Matt Juntunen commented on GEOMETRY-144:
----------------------------------------

I'm thinking it would be useful to apply the builder pattern for convex hull 
construction. The current API in {{commons-geometry-hull}} only accepts a 
collection of points, which means that if callers do not have such a collection 
readily available, they must allocate memory for the collection, extract points 
from whatever data structure they are part of, and _then_ pass it to the convex 
hull algorithm. If we use the builder pattern, we can avoid this allocation 
overhead. For example,
{code:java}
// previous API
RegionBSPTree3D tree = ...
List<Vector3D> pts = new ArrayList<>();
tree.boundaryStream(b -> pts.addAll(pts.getVertices()); // pts could become 
quite large here
ConvexHull3D hull = ... // create from pts

// builder API
RegionBSPTree3D tree = ...
ConvexHull3D.Builder hullBuilder = ConvexHull3D.builder(precision);
tree.boundaryStream(b -> hullBuilder.addAll(b.getVertices()));
ConvexHull3D hull = hullBuilder.build();
{code}
It may also be possible for us completely ignore particular points (and not 
even store them within the builder) if the point can be immediately determined 
to not lie on the hull.

> Review API in "hull" module
> ---------------------------
>
>                 Key: GEOMETRY-144
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-144
>             Project: Commons Geometry
>          Issue Type: Task
>            Reporter: Gilles Sadowski
>            Assignee: Gilles Sadowski
>            Priority: Minor
>             Fix For: 1.1
>
>
> Review codes in the 
> [{{commons-geometry-hull}}|https://gitbox.apache.org/repos/asf?p=commons-geometry.git;a=tree;f=commons-geometry-hull;hb=HEAD]
>  module.
> (x) Minimize the public API



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to