public void ensureClockwiseOrdering() { ConcaveHullTools.ensureClockwiseOrdering(hullVertices); }
public boolean computeConcaveHullPocket(int concaveVertexIndex, ConcaveHullPocket pocketToPack) { return ConcaveHullTools.computeConcaveHullPocket(concaveVertexIndex, pocketToPack, hullVertices); }
public double computePerimeter() { return ConcaveHullTools.computePerimeter(hullVertices); }
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; }
if (ConcaveHullTools.isHullConvex(concaveHullVertices)) pocket = ConcaveHullTools.findFirstConcaveHullPocket(concaveHullVertices); int endBridgeIndex = pocket.getEndBridgeIndex(); int otherVertexIndexForCutting = findClosestIntersectionWithRay(deepestVertex, cutDirection, endBridgeIndex, startBridgeIndex, concaveHullVertices, otherVertexForCutting); otherVertexIndexForCutting = next(otherVertexIndexForCutting, concaveHullVertices);
public static int flattenShallowPockets(double depthThreshold, List<Point2D> concaveHullVerticesToFilter) { int numberOfVerticesRemoved = 0; ConcaveHullPocket pocket = new ConcaveHullPocket(); Vector2D shift = new Vector2D(); for (int currentIndex = 0; currentIndex < concaveHullVerticesToFilter.size(); currentIndex++) { if (isConvexAtVertex(currentIndex, concaveHullVerticesToFilter)) continue; boolean success = computeConcaveHullPocket(currentIndex, pocket, concaveHullVerticesToFilter); if (!success) continue; double maxDepth = pocket.getMaxDepth(); if (maxDepth > depthThreshold) continue; Point2D startBridgeVertex = new Point2D(pocket.getStartBridgeVertex()); Point2D endBridgeVertex = new Point2D(pocket.getEndBridgeVertex()); shift.sub(endBridgeVertex, startBridgeVertex); shift.normalize(); // Rotate to the right shift.set(shift.getY(), -shift.getX()); shift.scale(maxDepth); startBridgeVertex.add(shift); endBridgeVertex.add(shift); int startBridgeVertexIndex = pocket.getStartBridgeIndex(); int endBridgeVertexIndex = pocket.getEndBridgeIndex(); numberOfVerticesRemoved += removeAllExclusive(startBridgeVertexIndex, endBridgeVertexIndex, concaveHullVerticesToFilter); } return numberOfVerticesRemoved; }
public static ConcaveHullPocket findFirstConcaveHullPocket(List<? extends Point2DReadOnly> concaveHullVertices) { return findFirstConcaveHullPocket(concaveHullVertices, 0); }
public void ensureCounterClockwiseOrdering() { ConcaveHullTools.ensureCounterClockwiseOrdering(hullVertices); }
public Set<ConcaveHullPocket> findConcaveHullPockets(double depthThreshold) { return ConcaveHullTools.findConcaveHullPockets(hullVertices, depthThreshold); }
int edgeFirstVertexIndex = findClosestIntersectionWithRay(rayOrigin, rayDirection, startSearchIndex, endSearchIndex, concaveHullVerticesToFilter, intersection);
public static boolean computeConcaveHullPocket(int concaveVertexIndex, ConcaveHullPocket pocketToPack, List<? extends Point2DReadOnly> concaveHullVertices) { pocketToPack.clear(); boolean success = findBridgeVertices(concaveVertexIndex, pocketToPack, concaveHullVertices); if (!success) { pocketToPack.clear(); return false; } success = findDeepestVertexInPocket(pocketToPack, concaveHullVertices); if (!success) { pocketToPack.clear(); return false; } return true; }
public ConcaveHullPocket findFirstConcaveHullPocket(int startIndex) { return ConcaveHullTools.findFirstConcaveHullPocket(hullVertices, startIndex); }
public static List<PlanarRegion> ensureClockwiseOrder(List<PlanarRegion> planarRegions) { List<PlanarRegion> copies = new ArrayList<>(planarRegions.size()); for (PlanarRegion planarRegion : planarRegions) { PlanarRegion copy = planarRegion.copy(); List<Point2DReadOnly> concaveHullVertices = Arrays.asList(copy.getConcaveHull()); ConcaveHullTools.ensureClockwiseOrdering(concaveHullVertices); copies.add(copy); } return copies; }
public ConcaveHullPocket computeConcaveHullPocket(int concaveVertexIndex) { return ConcaveHullTools.computeConcaveHullPocket(concaveVertexIndex, hullVertices); }
public static Set<ConcaveHullPocket> findConcaveHullPockets(List<? extends Point2DReadOnly> concaveHullVertices, double depthThreshold) { Set<ConcaveHullPocket> pockets = new HashSet<>(); int startIndex = 0; while (startIndex < concaveHullVertices.size()) { ConcaveHullPocket newPocket = findFirstConcaveHullPocket(concaveHullVertices, startIndex); if (newPocket == null) break; if (newPocket.getMaxDepth() >= depthThreshold) { if (!pockets.add(newPocket)) break; } startIndex = newPocket.getEndBridgeIndex() + 1; } return pockets; }
private Node createConcavePocketsGraphics(PlanarRegionSegmentationRawData rawData, ConcaveHullFactoryResult concaveHullFactoryResult) { JavaFXMeshBuilder meshBuilder = new JavaFXMeshBuilder(); ConcaveHullCollection concaveHullCollection = concaveHullFactoryResult.getConcaveHullCollection(); RigidBodyTransform transform = rawData.getTransformFromLocalToWorld(); for (ConcaveHull concaveHull : concaveHullCollection) { Set<ConcaveHullPocket> pockets = concaveHull.findConcaveHullPockets(polygonizerParameters.getDepthThreshold()); for (ConcaveHullPocket pocket : pockets) { List<Point2D> pocketVertices = ListWrappingIndexTools.subListInclusive(pocket.getStartBridgeIndex(), pocket.getEndBridgeIndex(), concaveHull.getConcaveHullVertices()); Point2D average = new Point2D(); average.interpolate(pocket.getStartBridgeVertex(), pocket.getEndBridgeVertex(), 0.5); pocketVertices.add(0, average); ConcaveHullTools.ensureClockwiseOrdering(pocketVertices); meshBuilder.addPolygon(transform, pocketVertices); } } MeshView meshView = new MeshView(meshBuilder.generateMesh()); meshView.setMaterial(new PhongMaterial(OcTreeMeshBuilder.getRegionColor(rawData.getRegionId()))); return meshView; }
public static ConcaveHullPocket findFirstConcaveHullPocket(List<? extends Point2DReadOnly> concaveHullVertices, int startIndex) { if (startIndex < 0 || startIndex >= concaveHullVertices.size()) throw new IndexOutOfBoundsException("Expected startIndex in [0, " + concaveHullVertices.size() + "[, received: " + startIndex); ConcaveHullPocket pocket = null; for (int i = startIndex; i < concaveHullVertices.size() && pocket == null; i++) pocket = ConcaveHullTools.computeConcaveHullPocket(i, concaveHullVertices); return pocket; }