Example usage for org.apache.commons.math3.geometry.partitioning BSPTree insertCut

List of usage examples for org.apache.commons.math3.geometry.partitioning BSPTree insertCut

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.partitioning BSPTree insertCut.

Prototype

public boolean insertCut(final Hyperplane<S> hyperplane) 

Source Link

Document

Insert a cut sub-hyperplane in a node.

Usage

From source file:edu.stanford.cfuller.imageanalysistools.util.VoronoiDiagram.java

private void divideRecursive(BSPTree<Euclidean2D> leaf, List<PointPair> pairsToUse) {

    if (pairsToUse.isEmpty())
        return;//from  w w  w.j  a  v a 2 s  .  c  o  m

    PointPair p = pairsToUse.remove(0);

    while (!leaf.insertCut(this.constructBisectingHyperplane(p.getFirst(), p.getSecond()))) {
        if (pairsToUse.isEmpty())
            return;
        p = pairsToUse.remove(0);
    }

    leaf.setAttribute(null);

    BSPTree<Euclidean2D> minus = leaf.getMinus();
    BSPTree<Euclidean2D> plus = leaf.getPlus();

    minus.setAttribute(null);
    plus.setAttribute(null);

    List<PointPair> secondPairs = new java.util.ArrayList<PointPair>();
    secondPairs.addAll(pairsToUse);

    divideRecursive(minus, pairsToUse);
    divideRecursive(plus, secondPairs);

}