+(define (partitioning voronoi)
+ (define (is-real-triangle triangle)
+ ;; real triangle points cannot be frame points
+ (let ((frame (voronoi-mesh-frame voronoi)))
+ (let check-points ((points (triangle-points triangle)))
+ (cond ((null? points)
+ #t) ; triangle is real
+ (else
+ (and (not (member (car points) frame))
+ (check-points (cdr points))))))))
+
+ (define (is-real-region region)
+ ;; real region points cannot be frame points
+ (let check-vertices ((vertices (voronoi-region-vertices region)))
+ (cond ((null? vertices)
+ #t) ; region is real
+ (else
+ (and (is-real-triangle (car vertices))
+ (check-vertices (cdr vertices)))))))
+
+ (let* ((points (voronoi-mesh-points voronoi))
+ (regions (voronoi-mesh-regions voronoi))
+ ;; we need the regions in the same order as points are
+ (ordered-regions
+ (map-in-order
+ (lambda (p)
+ (assoc-ref regions p))
+ points))
+ ;; only real regions without frame points
+ (filtered-regions
+ (filter (lambda (r) (is-real-region r))
+ ordered-regions)))
+ filtered-regions))
+