List of usage examples for org.apache.commons.math3.geometry.euclidean.twod.hull ConvexHull2D createRegion
public Region<Euclidean2D> createRegion() throws InsufficientDataException
From source file:org.micromanager.plugins.magellan.surfacesandregions.SurfaceInterpolator.java
private synchronized void updateConvexHullAndInterpolate() { //duplicate points for use on caluclation thread final LinkedList<Point3d> points = new LinkedList<Point3d>(points_); if (currentInterpolationTask_ != null && !currentInterpolationTask_.isDone()) { //cancel current interpolation because interpolation points have changed, call does not block currentInterpolationTask_.cancel(true); }//ww w .j a va 2 s . co m //don't want one of the get methods returning a null object thinking it has a value synchronized (convexHullLock_) { convexHullVertices_ = null; convexHullRegion_ = null; } synchronized (interpolationLock_) { currentInterpolation_ = null; } synchronized (xyPositionLock_) { xyPositions_ = null; } numRows_ = 0; numCols_ = 0; currentInterpolationTask_ = executor_.submit(new Runnable() { @Override public void run() { if (points.size() > 2) { try { //convert xyPoints to a vector2d for convex hull calculation LinkedList<Vector2D> xyPoints = new LinkedList<Vector2D>(); for (Point3d p : points) { xyPoints.add(new Vector2D(p.x, p.y)); } ConvexHull2D hull = null; hull = mChain_.generate(xyPoints); if (Thread.interrupted()) { throw new InterruptedException(); } synchronized (convexHullLock_) { convexHullVertices_ = hull.getVertices(); convexHullLock_.notifyAll(); } if (Thread.interrupted()) { throw new InterruptedException(); } convexHullRegion_ = hull.createRegion(); if (Thread.interrupted()) { throw new InterruptedException(); } calculateConvexHullBounds(); if (Thread.interrupted()) { throw new InterruptedException(); } //use the most recently set overlap value for display purposes. When it comes time to calc the real thing, //get it from the acquisition settings fitXYPositionsToConvexHull(FixedAreaAcquisitionSettings.getStoredTileOverlapPercentage()); //Interpolate surface as specified by the subclass method interpolateSurface(points); //let manager handle event firing to acquisitions using surface manager_.surfaceUpdated(SurfaceInterpolator.this); } catch (InterruptedException e) { return; } } } }); }