/** Check if an internal node corresponds to the end abscissa of an interval. * @param node internal node to check * @return true if the node corresponds to the end abscissa of an interval */ private boolean isIntervalEnd(final BSPTree<Euclidean1D> node) { if (!(Boolean) leafBefore(node).getAttribute()) { // it has an outside cell before it, it may start an interval but not end it return false; } if ((Boolean) leafAfter(node).getAttribute()) { // it has an inside cell after it, it is a dummy cut in the middle of an interval return false; } // the cell has an inside before and an outside after it // it is the end of an interval return true; }
/** Check if an internal node corresponds to the start abscissa of an interval. * @param node internal node to check * @return true if the node corresponds to the start abscissa of an interval */ private boolean isIntervalStart(final BSPTree<Euclidean1D> node) { if ((Boolean) leafBefore(node).getAttribute()) { // it has an inside cell before it, it may end an interval but not start it return false; } if (!(Boolean) leafAfter(node).getAttribute()) { // it has an outside cell after it, it is a dummy cut away from real intervals return false; } // the cell has an outside before and an inside after it // it is the start of an interval return true; }
/** Get the next internal node. * @param node current internal node * @return next internal node in ascending order, or null * if this is the last internal node */ private BSPTree<Euclidean1D> nextInternalNode(BSPTree<Euclidean1D> node) { if (childAfter(node).getCut() != null) { // the next node is in the sub-tree return leafAfter(node).getParent(); } // there is nothing left deeper in the tree, we backtrack while (isAfterParent(node)) { node = node.getParent(); } return node.getParent(); }
/** Check if an internal node corresponds to the start abscissa of an interval. * @param node internal node to check * @return true if the node corresponds to the start abscissa of an interval */ private boolean isIntervalStart(final BSPTree<Euclidean1D> node) { if ((Boolean) leafBefore(node).getAttribute()) { // it has an inside cell before it, it may end an interval but not start it return false; } if (!(Boolean) leafAfter(node).getAttribute()) { // it has an outside cell after it, it is a dummy cut away from real intervals return false; } // the cell has an outside before and an inside after it // it is the start of an interval return true; }
/** Check if an internal node corresponds to the end abscissa of an interval. * @param node internal node to check * @return true if the node corresponds to the end abscissa of an interval */ private boolean isIntervalEnd(final BSPTree<Euclidean1D> node) { if (!(Boolean) leafBefore(node).getAttribute()) { // it has an outside cell before it, it may start an interval but not end it return false; } if ((Boolean) leafAfter(node).getAttribute()) { // it has an inside cell after it, it is a dummy cut in the middle of an interval return false; } // the cell has an inside before and an outside after it // it is the end of an interval return true; }
/** Get the next internal node. * @param node current internal node * @return next internal node in ascending order, or null * if this is the last internal node */ private BSPTree<Euclidean1D> nextInternalNode(BSPTree<Euclidean1D> node) { if (childAfter(node).getCut() != null) { // the next node is in the sub-tree return leafAfter(node).getParent(); } // there is nothing left deeper in the tree, we backtrack while (isAfterParent(node)) { node = node.getParent(); } return node.getParent(); }