Search in sources :

Example 1 with BSPTree

use of org.hipparchus.geometry.partitioning.BSPTree in project Orekit by CS-SI.

the class SphericalPolygonsSetTransferObject method rebuildZone.

/**
 * Rebuild the zone from saved data.
 * @return rebuilt zone
 */
public SphericalPolygonsSet rebuildZone() {
    // rebuild the tree from the flattened arrays
    BSPTree<Sphere2D> node = new BSPTree<Sphere2D>();
    final int nbNodes = cuts.length / 3 + leafs.length;
    cutIndex = 0;
    flagIndex = 0;
    for (nodeIndex = 0; nodeIndex < nbNodes; ++nodeIndex) {
        if (leafs[flagIndex] == nodeIndex) {
            // this is a leaf node
            node.setAttribute(Boolean.valueOf(flags[flagIndex++]));
            while (node.getParent() != null) {
                final BSPTree<Sphere2D> parent = node.getParent();
                if (node == parent.getMinus()) {
                    node = parent.getPlus();
                    break;
                } else {
                    node = parent;
                }
            }
        } else {
            // this is an internal node
            final double x = cuts[cutIndex++];
            final double y = cuts[cutIndex++];
            final double z = cuts[cutIndex++];
            node.insertCut(new Circle(new Vector3D(x, y, z), tolerance));
            node = node.getMinus();
        }
    }
    return new SphericalPolygonsSet(node, tolerance);
}
Also used : BSPTree(org.hipparchus.geometry.partitioning.BSPTree) Circle(org.hipparchus.geometry.spherical.twod.Circle) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Sphere2D(org.hipparchus.geometry.spherical.twod.Sphere2D) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)

Aggregations

Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1 BSPTree (org.hipparchus.geometry.partitioning.BSPTree)1 Circle (org.hipparchus.geometry.spherical.twod.Circle)1 Sphere2D (org.hipparchus.geometry.spherical.twod.Sphere2D)1 SphericalPolygonsSet (org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet)1