Q:

Use of a Polygon for VoronoiDiagramBuilder.setClipEnvelope instead of rectangle

I am generating voronoi polygons from large number of points(coordinates) using the JTS topology suite.
VoronoiDiagramBuilder voronoi=new VoronoiDiagramBuilder();
voronoi.setTolerance(0.001);
voronoi.setSites(coordinates);
voronoi.setClipEnvelope(...);
Geometry geo =voronoi.getDiagram(new GeometryFactory()); 

the method  voronoi.setClipEnvelope only accepts rectangle(boundingbox), however I want a custom polygon instead of a bounding box so no voronoi diagrams are generated that are larger than the custom polygon.  
is this possible? using this API, or perhaps another component.

A:

The best (only?) way to do this is to compute the voronoi diagram for the envelope and then clip it to your polygon using something like:
Geometry out = geo.intersection(polygon);

