src/main/java/de/javagl/geom/Shapes.java
/**
     * Compute all closed regions that occur in the given shape, as
     * lists of points, each describing one polygon
     * 
     * @param shape The shape
     * @param flatness The flatness for the shape path iterator
     * @return The regions
     */
Compute all closed regions that occur in the given shape, as
lists of points, each describing one polygon

@param shape The shape
@param flatness The flatness for the shape path iterator
@return The regions
Compute all closed regions that occur in the given shape as lists of points each describing one polygon @param shape The shape @param flatness The flatness for the shape path iterator @return The regions
static List<List<Point2D>> computeRegions(
        Shape shape, double flatness)
    {
        List<List<Point2D>> regions = new ArrayList<List<Point2D>>();
        PathIterator pi = shape.getPathIterator(null, flatness);
        double coords[] = new double[6];
        List<Point2D> region = Collections.emptyList();
        while (!pi.isDone())
        {
            switch (pi.currentSegment(coords))
            {
                case PathIterator.SEG_MOVETO:
                    region = new ArrayList<Point2D>();
                    region.add(new Point2D.Double(coords[0], coords[1]));
                    break;
                case PathIterator.SEG_LINETO:
                    region.add(new Point2D.Double(coords[0], coords[1]));
                    break;
                case PathIterator.SEG_CLOSE:
                    regions.add(region);
                    break;
                case PathIterator.SEG_CUBICTO:
                case PathIterator.SEG_QUADTO:
                default:
                    throw new AssertionError(
                        "Invalid segment in flattened path");
            }
            pi.next();
        }
        return regions;
    }
static List < List < Point2D > > computeRegions ( Shape shape , double flatness ) { List < List < Point2D > > regions = new ArrayList < List < Point2D > > ( ) ; PathIterator pi = shape . getPathIterator ( null , flatness ) ; double coords [ ] = new double [ 6 ] ; List < Point2D > region = Collections . emptyList ( ) ; while ( ! pi . isDone ( ) ) { switch ( pi . currentSegment ( coords ) ) { case PathIterator . SEG_MOVETO : region = new ArrayList < Point2D > ( ) ; region . add ( new Point2D . Double ( coords [ 0 ] , coords [ 1 ] ) ) ; break ; case PathIterator . SEG_LINETO : region . add ( new Point2D . Double ( coords [ 0 ] , coords [ 1 ] ) ) ; break ; case PathIterator . SEG_CLOSE : regions . add ( region ) ; break ; case PathIterator . SEG_CUBICTO : case PathIterator . SEG_QUADTO : default : throw new AssertionError ( "Invalid segment in flattened path" ) ; } pi . next ( ) ; } return regions ; }
Compute all closed regions that occur in the given shape, as
 lists of points, each describing one polygon
Compute all closed regions that occur in the given shape as lists of points each describing one polygon