org.apache.commons.math3.geometry.partitioning

## Class RegionFactory<S extends Space>

- java.lang.Object
- - org.apache.commons.math3.geometry.partitioning.RegionFactory<S>

- Type Parameters:
    `S` - Type of the space.

      public class RegionFactory<S extends Space>
      extends java.lang.Object

  This class is a factory for `Region`.
  Since:
    3.0
  Version:
    $Id: RegionFactory.java 1416643 2012-12-03 19:37:14Z tn $

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private class` | `RegionFactory.DifferenceMerger` BSP tree leaf merger computing union of two regions.
    `private class` | `RegionFactory.IntersectionMerger` BSP tree leaf merger computing union of two regions.
    `private class` | `RegionFactory.NodesCleaner` Visitor removing internal nodes attributes.
    `private class` | `RegionFactory.UnionMerger` BSP tree leaf merger computing union of two regions.
    `private class` | `RegionFactory.XorMerger` BSP tree leaf merger computing union of two regions.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private RegionFactory.NodesCleaner` | `nodeCleaner` Visitor removing internal nodes attributes.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegionFactory()` Simple constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Region<S>` | `buildConvex(Hyperplane<S>... hyperplanes)` Build a convex region from a collection of bounding hyperplanes.
    `Region<S>` | `difference(Region<S> region1, Region<S> region2)` Compute the difference of two regions.
    `Region<S>` | `getComplement(Region<S> region)` Get the complement of the region (exchanged interior/exterior).
    `Region<S>` | `intersection(Region<S> region1, Region<S> region2)` Compute the intersection of two regions.
    `private BSPTree<S>` | `recurseComplement(BSPTree<S> node)` Recursively build the complement of a BSP tree.
    `Region<S>` | `union(Region<S> region1, Region<S> region2)` Compute the union of two regions.
    `Region<S>` | `xor(Region<S> region1, Region<S> region2)` Compute the symmetric difference (exclusive or) of two regions.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### nodeCleaner

          private final RegionFactory.NodesCleaner nodeCleaner

      Visitor removing internal nodes attributes.

  - ### Constructor Detail

    - #### RegionFactory

          public RegionFactory()

      Simple constructor.

  - ### Method Detail

    - #### buildConvex

          public Region<S> buildConvex(Hyperplane<S>... hyperplanes)

      Build a convex region from a collection of bounding hyperplanes.
      Parameters:
        `hyperplanes` - collection of bounding hyperplanes
      Returns:
        a new convex region, or null if the collection is empty

    - #### union

          public Region<S> union(Region<S> region1,
                        Region<S> region2)

      Compute the union of two regions.
      Parameters:
        `region1` - first region (will be unusable after the operation as parts of it will be reused in the new region)
        `region2` - second region (will be unusable after the operation as parts of it will be reused in the new region)
      Returns:
        a new region, result of `region1 union region2`

    - #### intersection

          public Region<S> intersection(Region<S> region1,
                               Region<S> region2)

      Compute the intersection of two regions.
      Parameters:
        `region1` - first region (will be unusable after the operation as parts of it will be reused in the new region)
        `region2` - second region (will be unusable after the operation as parts of it will be reused in the new region)
      Returns:
        a new region, result of `region1 intersection region2`

    - #### xor

          public Region<S> xor(Region<S> region1,
                      Region<S> region2)

      Compute the symmetric difference (exclusive or) of two regions.
      Parameters:
        `region1` - first region (will be unusable after the operation as parts of it will be reused in the new region)
        `region2` - second region (will be unusable after the operation as parts of it will be reused in the new region)
      Returns:
        a new region, result of `region1 xor region2`

    - #### difference

          public Region<S> difference(Region<S> region1,
                             Region<S> region2)

      Compute the difference of two regions.
      Parameters:
        `region1` - first region (will be unusable after the operation as parts of it will be reused in the new region)
        `region2` - second region (will be unusable after the operation as parts of it will be reused in the new region)
      Returns:
        a new region, result of `region1 minus region2`

    - #### getComplement

          public Region<S> getComplement(Region<S> region)

      Get the complement of the region (exchanged interior/exterior).
      Parameters:
        `region` - region to complement, it will not modified, a new region independent region will be built
      Returns:
        a new region, complement of the specified one

    - #### recurseComplement

          private BSPTree<S> recurseComplement(BSPTree<S> node)

      Recursively build the complement of a BSP tree.
      Parameters:
        `node` - current node of the original tree
      Returns:
        new tree, complement of the node

Copyright (c) 2003-2013 Apache Software Foundation