private RegionCutBoundary computeBoundary()

in commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java [698:735]


        private RegionCutBoundary<P> computeBoundary() {
            final HyperplaneConvexSubset<P> sub = getCut();

            // find the portions of the node cut hyperplane subset that touch inside and
            // outside cells in the minus sub-tree
            final List<HyperplaneConvexSubset<P>> minusIn = new ArrayList<>();
            final List<HyperplaneConvexSubset<P>> minusOut = new ArrayList<>();

            characterizeHyperplaneSubset(sub, getMinus(), minusIn, minusOut);

            final ArrayList<HyperplaneConvexSubset<P>> insideFacing = new ArrayList<>();
            final ArrayList<HyperplaneConvexSubset<P>> outsideFacing = new ArrayList<>();

            if (!minusIn.isEmpty()) {
                // Add to the boundary anything that touches an inside cell in the minus sub-tree
                // and an outside cell in the plus sub-tree. These portions are oriented with their
                // plus side pointing to the outside of the region.
                for (final HyperplaneConvexSubset<P> minusInFragment : minusIn) {
                    characterizeHyperplaneSubset(minusInFragment, getPlus(), null, outsideFacing);
                }
            }

            if (!minusOut.isEmpty()) {
                // Add to the boundary anything that touches an outside cell in the minus sub-tree
                // and an inside cell in the plus sub-tree. These portions are oriented with their
                // plus side pointing to the inside of the region.
                for (final HyperplaneConvexSubset<P> minusOutFragment : minusOut) {
                    characterizeHyperplaneSubset(minusOutFragment, getPlus(), insideFacing, null);
                }
            }

            insideFacing.trimToSize();
            outsideFacing.trimToSize();

            return new RegionCutBoundary<>(
                    insideFacing.isEmpty() ? null : insideFacing,
                    outsideFacing.isEmpty() ? null : outsideFacing);
        }