Class PolyhedronsSet

    • Field Detail

      • DEFAULT_TOLERANCE

        private static final double DEFAULT_TOLERANCE
        Default value for tolerance.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PolyhedronsSet

        public PolyhedronsSet​(double tolerance)
        Build a polyhedrons set representing the whole real line.
        Parameters:
        tolerance - tolerance below which points are considered identical
        Since:
        3.3
      • PolyhedronsSet

        public PolyhedronsSet​(BSPTree<Euclidean3D> tree,
                              double tolerance)
        Build a polyhedrons set from a BSP tree.

        The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE

        This constructor is aimed at expert use, as building the tree may be a difficult task. It is not intended for general use and for performances reasons does not check thoroughly its input, as this would require walking the full tree each time. Failing to provide a tree with the proper attributes, will therefore generate problems like NullPointerException or ClassCastException only later on. This limitation is known and explains why this constructor is for expert use only. The caller does have the responsibility to provided correct arguments.

        Parameters:
        tree - inside/outside BSP tree representing the region
        tolerance - tolerance below which points are considered identical
        Since:
        3.3
      • PolyhedronsSet

        public PolyhedronsSet​(java.util.Collection<SubHyperplane<Euclidean3D>> boundary,
                              double tolerance)
        Build a polyhedrons set from a Boundary REPresentation (B-rep) specified by sub-hyperplanes.

        The boundary is provided as a collection of sub-hyperplanes. Each sub-hyperplane has the interior part of the region on its minus side and the exterior on its plus side.

        The boundary elements can be in any order, and can form several non-connected sets (like for example polyhedrons with holes or a set of disjoint polyhedrons considered as a whole). In fact, the elements do not even need to be connected together (their topological connections are not used here). However, if the boundary does not really separate an inside open from an outside open (open having here its topological meaning), then subsequent calls to the checkPoint method will not be meaningful anymore.

        If the boundary is empty, the region will represent the whole space.

        Parameters:
        boundary - collection of boundary elements, as a collection of SubHyperplane objects
        tolerance - tolerance below which points are considered identical
        Since:
        3.3
      • PolyhedronsSet

        public PolyhedronsSet​(java.util.List<Vector3D> vertices,
                              java.util.List<int[]> facets,
                              double tolerance)
        Build a polyhedrons set from a Boundary REPresentation (B-rep) specified by connected vertices.

        The boundary is provided as a list of vertices and a list of facets. Each facet is specified as an integer array containing the arrays vertices indices in the vertices list. Each facet normal is oriented by right hand rule to the facet vertices list.

        Some basic sanity checks are performed but not everything is thoroughly assessed, so it remains under caller responsibility to ensure the vertices and facets are consistent and properly define a polyhedrons set.

        Parameters:
        vertices - list of polyhedrons set vertices
        facets - list of facets, as vertices indices in the vertices list
        tolerance - tolerance below which points are considered identical
        Throws:
        MathIllegalArgumentException - if some basic sanity checks fail
        Since:
        3.5
      • PolyhedronsSet

        public PolyhedronsSet​(double xMin,
                              double xMax,
                              double yMin,
                              double yMax,
                              double zMin,
                              double zMax,
                              double tolerance)
        Build a parallellepipedic box.
        Parameters:
        xMin - low bound along the x direction
        xMax - high bound along the x direction
        yMin - low bound along the y direction
        yMax - high bound along the y direction
        zMin - low bound along the z direction
        zMax - high bound along the z direction
        tolerance - tolerance below which points are considered identical
        Since:
        3.3
      • PolyhedronsSet

        @Deprecated
        public PolyhedronsSet()
        Deprecated.
        as of 3.3, replaced with PolyhedronsSet(double)
        Build a polyhedrons set representing the whole real line.
      • PolyhedronsSet

        @Deprecated
        public PolyhedronsSet​(BSPTree<Euclidean3D> tree)
        Deprecated.
        as of 3.3, replaced with PolyhedronsSet(BSPTree, double)
        Build a polyhedrons set from a BSP tree.

        The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE

        Parameters:
        tree - inside/outside BSP tree representing the region
      • PolyhedronsSet

        @Deprecated
        public PolyhedronsSet​(java.util.Collection<SubHyperplane<Euclidean3D>> boundary)
        Deprecated.
        as of 3.3, replaced with PolyhedronsSet(Collection, double)
        Build a polyhedrons set from a Boundary REPresentation (B-rep).

        The boundary is provided as a collection of sub-hyperplanes. Each sub-hyperplane has the interior part of the region on its minus side and the exterior on its plus side.

        The boundary elements can be in any order, and can form several non-connected sets (like for example polyhedrons with holes or a set of disjoint polyhedrons considered as a whole). In fact, the elements do not even need to be connected together (their topological connections are not used here). However, if the boundary does not really separate an inside open from an outside open (open having here its topological meaning), then subsequent calls to the checkPoint method will not be meaningful anymore.

        If the boundary is empty, the region will represent the whole space.

        Parameters:
        boundary - collection of boundary elements, as a collection of SubHyperplane objects
      • PolyhedronsSet

        @Deprecated
        public PolyhedronsSet​(double xMin,
                              double xMax,
                              double yMin,
                              double yMax,
                              double zMin,
                              double zMax)
        Build a parallellepipedic box.
        Parameters:
        xMin - low bound along the x direction
        xMax - high bound along the x direction
        yMin - low bound along the y direction
        yMax - high bound along the y direction
        zMin - low bound along the z direction
        zMax - high bound along the z direction
    • Method Detail

      • buildBoundary

        private static BSPTree<Euclidean3D> buildBoundary​(double xMin,
                                                          double xMax,
                                                          double yMin,
                                                          double yMax,
                                                          double zMin,
                                                          double zMax,
                                                          double tolerance)
        Build a parallellepipedic box boundary.
        Parameters:
        xMin - low bound along the x direction
        xMax - high bound along the x direction
        yMin - low bound along the y direction
        yMax - high bound along the y direction
        zMin - low bound along the z direction
        zMax - high bound along the z direction
        tolerance - tolerance below which points are considered identical
        Returns:
        boundary tree
        Since:
        3.3
      • buildBoundary

        private static java.util.List<SubHyperplane<Euclidean3D>> buildBoundary​(java.util.List<Vector3D> vertices,
                                                                                java.util.List<int[]> facets,
                                                                                double tolerance)
        Build boundary from vertices and facets.
        Parameters:
        vertices - list of polyhedrons set vertices
        facets - list of facets, as vertices indices in the vertices list
        tolerance - tolerance below which points are considered identical
        Returns:
        boundary as a list of sub-hyperplanes
        Throws:
        MathIllegalArgumentException - if some basic sanity checks fail
        Since:
        3.5
      • findReferences

        private static int[][] findReferences​(java.util.List<Vector3D> vertices,
                                              java.util.List<int[]> facets)
        Find the facets that reference each edges.
        Parameters:
        vertices - list of polyhedrons set vertices
        facets - list of facets, as vertices indices in the vertices list
        Returns:
        references array such that r[v][k] = f for some k if facet f contains vertex v
        Throws:
        MathIllegalArgumentException - if some facets have fewer than 3 vertices
        Since:
        3.5
      • successors

        private static int[][] successors​(java.util.List<Vector3D> vertices,
                                          java.util.List<int[]> facets,
                                          int[][] references)
        Find the successors of all vertices among all facets they belong to.
        Parameters:
        vertices - list of polyhedrons set vertices
        facets - list of facets, as vertices indices in the vertices list
        references - facets references array
        Returns:
        indices of vertices that follow vertex v in some facet (the array may contain extra entries at the end, set to negative indices)
        Throws:
        MathIllegalArgumentException - if the same vertex appears more than once in the successors list (which means one facet orientation is wrong)
        Since:
        3.5
      • buildNew

        public PolyhedronsSet buildNew​(BSPTree<Euclidean3D> tree)
        Build a region using the instance as a prototype.

        This method allow to create new instances without knowing exactly the type of the region. It is an application of the prototype design pattern.

        The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE. The tree also must have either null internal nodes or internal nodes representing the boundary as specified in the getTree method).

        Specified by:
        buildNew in interface Region<Euclidean3D>
        Specified by:
        buildNew in class AbstractRegion<Euclidean3D,​Euclidean2D>
        Parameters:
        tree - inside/outside BSP tree representing the new region
        Returns:
        the built region
      • firstIntersection

        public SubHyperplane<Euclidean3D> firstIntersection​(Vector3D point,
                                                            Line line)
        Get the first sub-hyperplane crossed by a semi-infinite line.
        Parameters:
        point - start point of the part of the line considered
        line - line to consider (contains point)
        Returns:
        the first sub-hyperplane crossed by the line after the given point, or null if the line does not intersect any sub-hyperplane
      • recurseFirstIntersection

        private SubHyperplane<Euclidean3D> recurseFirstIntersection​(BSPTree<Euclidean3D> node,
                                                                    Vector3D point,
                                                                    Line line)
        Get the first sub-hyperplane crossed by a semi-infinite line.
        Parameters:
        node - current node
        point - start point of the part of the line considered
        line - line to consider (contains point)
        Returns:
        the first sub-hyperplane crossed by the line after the given point, or null if the line does not intersect any sub-hyperplane
      • boundaryFacet

        private SubHyperplane<Euclidean3D> boundaryFacet​(Vector3D point,
                                                         BSPTree<Euclidean3D> node)
        Check if a point belongs to the boundary part of a node.
        Parameters:
        point - point to check
        node - node containing the boundary facet to check
        Returns:
        the boundary facet this points belongs to (or null if it does not belong to any boundary facet)
      • rotate

        public PolyhedronsSet rotate​(Vector3D center,
                                     Rotation rotation)
        Rotate the region around the specified point.

        The instance is not modified, a new instance is created.

        Parameters:
        center - rotation center
        rotation - vectorial rotation operator
        Returns:
        a new instance representing the rotated region
      • translate

        public PolyhedronsSet translate​(Vector3D translation)
        Translate the region by the specified amount.

        The instance is not modified, a new instance is created.

        Parameters:
        translation - translation to apply
        Returns:
        a new instance representing the translated region