/** * Removes vertices to filter short edges. Only convex vertices are removed, meaning the polygon area can only decrease when calling this method. * @param concaveAngleLimit threshold to define a concavity. 0 rad being flat, negative convex, positive concave. * @param lengthThreshold any edge shorter than that will be removed, if possible. * @param concaveHullVerticesToFilter the vertices of the concave hull to filter. * @return the number of vertices removed. */ public static int filterOutShortEdges(double lengthThreshold, ConcaveHull concaveHullToFilter) { return filterOutShortEdges(lengthThreshold, concaveHullToFilter.getConcaveHullVertices()); }
public static ConcaveHullPocket computeConcaveHullPocket(int concaveVertexIndex, List<? extends Point2DReadOnly> concaveHullVertices) { ConcaveHullPocket pocketToReturn = new ConcaveHullPocket(); boolean success = findBridgeVertices(concaveVertexIndex, pocketToReturn, concaveHullVertices); if (!success) return null; success = findDeepestVertexInPocket(pocketToReturn, concaveHullVertices); if (!success) return null; return pocketToReturn; }
@Override public String toString() { return "Size: " + getNumberOfVertices() + "\n" + ConcaveHullTools.vertexListToString(hullVertices); } }
/** * Inspired from the SL-decomposition in the paper * <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjZlOab96XPAhXBQD4KHcXeB4MQFggsMAE&url=https%3A%2F%2Fparasol.tamu.edu%2Fpublications%2Fdownload.php%3Ffile_id%3D390&usg=AFQjCNF3wXvuCxXNREhu4CW-oNyd1caa0A&sig2=X-zxaHykED7EuqkYhkfUgg"> * Approximate Convex Decomposition of Polygons</a>. * @param concaveHull [input] the concave hull to be decomposed into convex polygons. * @param depthThreshold [input] the algorithm determines whether the polygon is to split or not by looking at the maximum depth of concave pockets in the concave hull. * When a pocket is deeper than {@code depthThreshold} the concave hull will be split in two. * Otherwise, the pocket vertices will be removed. * @param convexPolygonsToPack [output] the convex polygons approximating the concave hull. */ public static void recursiveApproximateDecomposition(ConcaveHull concaveHull, double depthThreshold, List<ConvexPolygon2D> convexPolygonsToPack) { recursiveApproximateDecomposition(concaveHull.getConcaveHullVertices(), depthThreshold, convexPolygonsToPack); }
public void update(double x, double y, double z, int updateSize) { sampleSize += updateSize; double nInv = (double) updateSize / (double) sampleSize; this.setX(this.getX() + (x - this.getX()) * nInv); this.setY(this.getY() + (y - this.getY()) * nInv); this.setZ(this.getZ() + (z - this.getZ()) * nInv); }
public static ConcaveHullCollection createConcaveHullCollection(List<Point2D> pointCloud2d, List<LineSegment2D> lineConstraints, ConcaveHullFactoryParameters parameters) { if (pointCloud2d.size() <= 3) return new ConcaveHullCollection(pointCloud2d); return createConcaveHull(pointCloud2d, lineConstraints, parameters).getConcaveHullCollection(); }
public ConcaveHullCollection(ConcaveHullCollection other) { other.forEach(concaveHull -> add(new ConcaveHull(concaveHull))); }
/** * Filter out vertices that create "peaks" or barely stick out the line described by the previous and next vertices. * Peaks are identified by a threshold on the angle between two consecutive edges. * Only convex peaks or shallow angles are removed, meaning this filter only reduces the area of the concave hull. * @param shallowAngleThreshold should be a small positive angle in radians. 0 will not remove any vertex. * @param peakAngleThreshold should be close to {@link Math#PI}. * @param concaveHullToFilter the concave hull to filter. * @return the number of vertices removed. */ public static int filterOutPeaksAndShallowAngles(double shallowAngleThreshold, double peakAngleThreshold, ConcaveHull concaveHullToFilter) { return filterOutPeaksAndShallowAngles(shallowAngleThreshold, peakAngleThreshold, concaveHullToFilter.getConcaveHullVertices()); }
public boolean add(List<Point2D> newConcaveHullVertices) { return add(new ConcaveHull(newConcaveHullVertices)); }
@Override protected ConcaveHullFactoryParameters getValueCopy(ConcaveHullFactoryParameters valueToCopy) { return new ConcaveHullFactoryParameters(valueToCopy); } }
public PolygonizerVisualizer() throws IOException { parameters.setEdgeLengthThreshold(0.05); // parameters.setAllowSplittingConcaveHull(false); // parameters.setRemoveAllTrianglesWithTwoBorderEdges(false); // parameters.setMaxNumberOfIterations(0); }
@Override public boolean equals(Object object) { if (object instanceof ConcaveHull) return equals((ConcaveHull) object); else return false; }
public void clear() { startBridgeIndex = -1; endBridgeIndex = -1; startBridgeVertex = null; endBridgeVertex = null; clearDepthParameters(); }
public void clear() { sampleSize = 0; set(0.0, 0.0, 0.0); }
public void clear() { sampleSize = 0; set(0.0, 0.0, 0.0); }
/** * Returns true only if removing the vertex would generate a kink in the concave polygon. * Meaning, it would cause several edges to cross each other. */ public boolean isVertexPreventingKink(int vertexIndex) { return ConcaveHullTools.isVertexPreventingKink(vertexIndex, hullVertices); }
public static void main(String[] args) { launch(args); } }
/** * Inspired from the SL-decomposition in the paper * <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjZlOab96XPAhXBQD4KHcXeB4MQFggsMAE&url=https%3A%2F%2Fparasol.tamu.edu%2Fpublications%2Fdownload.php%3Ffile_id%3D390&usg=AFQjCNF3wXvuCxXNREhu4CW-oNyd1caa0A&sig2=X-zxaHykED7EuqkYhkfUgg"> * Approximate Convex Decomposition of Polygons</a>. * @param concaveHullCollection [input] the collection of concave hulls to be decomposed into convex polygons. * @param depthThreshold [input] the algorithm determines whether the polygon is to split or not by looking at the maximum depth of concave pockets in the concave hull. * When a pocket is deeper than {@code depthThreshold} the concave hull will be split in two. * Otherwise, the pocket vertices will be removed. * @param convexPolygonsToPack [output] the convex polygons approximating the concave hull. */ public static void recursiveApproximateDecomposition(ConcaveHullCollection concaveHullCollection, double depthThreshold, List<ConvexPolygon2D> convexPolygonsToPack) { for (ConcaveHull concaveHull : concaveHullCollection) recursiveApproximateDecomposition(concaveHull.getConcaveHullVertices(), depthThreshold, convexPolygonsToPack); }
/** * Removes vertices to filter short edges. Only convex vertices are removed, meaning the polygon area can only decrease when calling this method. * @param concaveAngleLimit threshold to define a concavity. 0 rad being flat, negative convex, positive concave. * @param lengthThreshold any edge shorter than that will be removed, if possible. * @param concaveHullVerticesToFilter the vertices of the concave hull to filter. * @return the number of vertices removed. */ public static int filterOutShortEdges(double lengthThreshold, ConcaveHullCollection concaveHullCollectionToFilter) { int numberOfRemovedVertices = 0; for (ConcaveHull concaveHullToFilter : concaveHullCollectionToFilter) numberOfRemovedVertices += filterOutShortEdges(lengthThreshold, concaveHullToFilter.getConcaveHullVertices()); return numberOfRemovedVertices; }