jvx.geom

## Class PwSymmetry

- java.lang.Object
- - jv.object.PsObject
  - - jvx.project.PjWorkshop
    - - jvx.geom.PwSymmetry

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, PsUpdateIf, PjWorkshopIf

      public class PwSymmetry
      extends PjWorkshop

  This workshop allows to automatically mirror objects which have a certain symmetry.
  Geometries can be mirrored along edges or planes which are defined through the boundary of the geometry.
  Also boundaries can be selected to be selectively mirrored.
  In automatic reflection mode, the combination of matrices which create the same planes can be returned (equivalent words).
  See Also:
    Serialized Form
  Author:
    Janis Bode
  Version:
    18.09.08, 1.01 revised (jb) Replaced PwCleanMesh.removeMarks with PwIdentify.removeMarks
    31.08.07, 1.00 created (jb)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `serialVersionUID` Set to indicate serialization compatibility with a previous version of the class.

    - ### Fields inherited from class jv.object.PsObject

      `HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS`

    - ### Fields inherited from interface jv.project.PjWorkshopIf

      `MODE_BUG, MODE_STANDARD, MODE_VALIDATE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PwSymmetry()` Initialize and set names of project and sliders.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PdVector` | `approxNormal(PdVector p, PdVector q, PdVector r)` Approximate normal of plane derived from the PdVector class but with an epsilon-tolerance.
    `void` | `colorGeoms(boolean show)` Colors different geometries in different colors if show is true and resets to the original coloring if false.
    `void` | `createGeo(PdMatrix[] mat)` Create mirrored geometries from matrices given.
    `boolean` | `epsEqual(PdVector vec1, PdVector vec2, double eps)` Compares the two PdVectors vec1 and vec2 component-wise and marks them equal if they differ maximally by eps in each component.
    `jvx.geom.EquiPoint[]` | `getEquivalents(PdVector start, PdMatrix[] M, int numMatrices, double eps)` Returns pairs of words which are equivalent.
    `jvx.geom.EquiPoint` | `getEquiWords(int i, int j, int k, java.util.Vector list)` Returns two equivalent words of points which are already known to be the same.
    `PdVector` | `getHomogCenter(PgElementSet geom)` Get the center of a geometry in homogeneous coordinates.
    `int` | `getPolyDimension(PgPointSet poly)` This method returns the dimension of a given PgPointSet, which it spans in space.
    `double` | `getShortestPointDist(PgElementSet geom)` Get the shortest distance between two points of a geometry (faster with kdtree?).
    `void` | `getSymmAndGeom()` Computes the symmetries of m_geom and shows its mirrored geometries.
    `PdMatrix[]` | `getSymmetries(int m_maxdepth, int critAngle, double eps)` Computes the symmetries of a given object.
    `PdMatrix[]` | `getSymmetryMatrices(PgPolygon[] bound)` Creates symmetry matrices from the planes given in bound.
    `void` | `getTreeAndEqui(PdVector start, PdMatrix[] M, int numMatrices, double eps, int m_maxdepth)` Returns equivalent words in "eq" and the tree in "tmplist" in the variables given.
    `PiVector` | `getWord(int i, java.util.Vector list)` Returns the word for a single element of the tree.
    `PiVector` | `getWord(int i, jvx.geom.WordPoint[] list)` Returns the word for a single element of the tree.
    `PdMatrix[]` | `getWordMatrices(PiVector[] words, PdMatrix[] M)` Returns the matrices which generate the whole space.
    `PdMatrix[]` | `getWordMatrices(jvx.geom.WordPoint[] list, PdMatrix[] M)` Returns the matrices which generate the whole space.
    `PiVector[]` | `getWords(jvx.geom.WordPoint[] list)` Returns the words of a matrix composition given through a tree containing letters.
    `int` | `hasEquivPoint(java.util.Vector list, PdVector check, double eps)` Method that checks if a given point is already contained in a wordlist or not.
    `void` | `init()` Configure and initialize the viewer and the panel.
    `PgBndPolygon[]` | `makeBoundaries(int critAngle, PgElementSet geom)` Creates the boundary for an ElementSet adding a neighbour relation and splitting at points which do not fulfill the angle criterion (i.e. mostly that the polygon is not planar there).
    `jvx.geom.WordPoint[]` | `makeTree(PdVector start, PdMatrix[] M, int numMatrices, double eps)` Creates a tree in a vector of self-referring entries of type WordPoint.
    `PdVector` | `matmult(PdMatrix M, PdVector x)` Multiply PdMatrix with PdVector and get a PdVector.
    `void` | `mergeVis()` Merges the currently visible geometries and removes the invisible ones from the workshop.
    `void` | `mirrorAlongSelected()` Mirrors the geometry along all those edges which have at least two vertices marked.
    `PdMatrix` | `mirrorBoundary(int i, PgBndPolygon[] bound, PgElementSet geom)` This function computes a reflection matrix if the i-th component of m_bound is 2 dimensional, a matrix which rotates by Pi if it is 1-dimensional or returns the zero matrix in any other cases.
    `void` | `partialMerge()` Merges geometries into an overlay geometry which makes it possible to mark all vertices of the mirrored geometries but leaves the mirrored parts for further work.
    `void` | `reset()` Resets to the initial state, which the workshop had at startup.
    `void` | `resetOptions()` Resets the Checkboxes and their actions in the display.
    `void` | `restoreColors(PgElementSet geom)` Restores original coloring of the geometry.
    `void` | `saveColors()` Saves the color and properties of the generating geometry.
    `int[]` | `selectBoundaries(PgPolygon[] bound, PgPointSet selPoints)` This method returns an integer-array which contains the indices of the polygons which contain at least two points from the pointcloud "selpoints".
    `PgPointSet` | `selectPoints(PgElementSet geom)` Returns a pointset which contains all selected points of the given geometry.
    `void` | `setCheckGeometricOverlap(boolean check)`
    `void` | `setGeometry(PgGeometry geom)` Set the geometry for this workshop, adjust sliders and viewer accurately.
    `void` | `showAllGeoms()` Show all of the mirrored geometries and merge them.
    `void` | `showBoundaries(boolean show)` Show or hide the boundaries of a geometry.
    `void` | `showBoundaries(PgBndPolygon[] bound)` Shows the given boundaries in different coloring.
    `void` | `showMirroredGeoms(int elemNum, PgElementSet geom)` Shows mirrored geometries.
    `boolean` | `update(java.lang.Object event)` Handles the slider-events.

    - ### Methods inherited from class jvx.project.PjWorkshop

      `cancel, close, getDisplay, getDisplays, getGeometry, getMode, getSavedGeometry, getViewer, isModal, isStandalone, ok, removeGeometry, setDisplay, setDisplays, setModal, setMode, setStandalone, setViewer`

    - ### Methods inherited from class jv.object.PsObject

      `addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels`

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface jv.object.PsUpdateIf

      `getFather, getName, setParent`

- - ### Field Detail

    - #### serialVersionUID

          public static final long serialVersionUID

      Set to indicate serialization compatibility with a previous version of the class.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PwSymmetry

          public PwSymmetry()

      Initialize and set names of project and sliders.

  - ### Method Detail

    - #### init

          public void init()

      Configure and initialize the viewer and the panel.
      Overrides:
        `init` in class `PjWorkshop`

    - #### setGeometry

          public void setGeometry(PgGeometry geom)

      Set the geometry for this workshop, adjust sliders and viewer accurately.
      Specified by:
        `setGeometry` in interface `PjWorkshopIf`
      Overrides:
        `setGeometry` in class `PjWorkshop`
      Parameters:
        `geom` - the workshop modifies this geometry.

    - #### update

          public boolean update(java.lang.Object event)

      Handles the slider-events.
      Specified by:
        `update` in interface `PsUpdateIf`
      Overrides:
        `update` in class `PjWorkshop`
      Parameters:
        `event` - sender of this update.
      Returns:
        true if update was correctly handled by superclass.
      See Also:
        `PsObject.setParent(PsUpdateIf)`, `PsObject.getFather()`, `PsObject.addUpdateListener(PsUpdateIf)`

    - #### reset

          public void reset()

      Resets to the initial state, which the workshop had at startup.
      Overrides:
        `reset` in class `PjWorkshop`

    - #### resetOptions

          public void resetOptions()

      Resets the Checkboxes and their actions in the display.

    - #### setCheckGeometricOverlap

          public void setCheckGeometricOverlap(boolean check)

      Parameters:
        `check` -

    - #### showMirroredGeoms

          public void showMirroredGeoms(int elemNum,
                                        PgElementSet geom)

      Shows mirrored geometries.
      Parameters:
        `elemNum` - is the number of elements which are supposed to be drawn- in order of the tree.
        `geom` - is the geometry, which was mirrored.

    - #### showAllGeoms

          public void showAllGeoms()

      Show all of the mirrored geometries and merge them.

    - #### partialMerge

          public void partialMerge()

      Merges geometries into an overlay geometry which makes it possible to mark all vertices of the mirrored geometries but leaves the mirrored parts for further work.

    - #### mergeVis

          public void mergeVis()

      Merges the currently visible geometries and removes the invisible ones from the workshop.

    - #### approxNormal

          public PdVector approxNormal(PdVector p,
                                       PdVector q,
                                       PdVector r)

      Approximate normal of plane derived from the PdVector class but with an epsilon-tolerance.
      Parameters:
        `p` - is the first vector defining the plane.
        `q` - is the second vector defining the plane.
        `r` - is the third vector defining the plane.
      Returns:
        the approximate normal vector of the given plane.

    - #### colorGeoms

          public void colorGeoms(boolean show)

      Colors different geometries in different colors if show is true and resets to the original coloring if false.
      Parameters:
        `show` - Indicates if geometries will be colored differently or not.

    - #### saveColors

          public void saveColors()

      Saves the color and properties of the generating geometry.

    - #### restoreColors

          public void restoreColors(PgElementSet geom)

      Restores original coloring of the geometry.
      Parameters:
        `geom` - geometry, whose color is to be restored.

    - #### selectBoundaries

          public int[] selectBoundaries(PgPolygon[] bound,
                                        PgPointSet selPoints)

      This method returns an integer-array which contains the indices of the polygons which contain at least two points from the pointcloud "selpoints".
      Parameters:
        `bound` - the bpolygon (boundary) to be compared with the given pointcloud
        `selPoints` - the currently by user selected vertices.
      Returns:
        an array which states if which boundary is selected and which not.

    - #### makeBoundaries

          public PgBndPolygon[] makeBoundaries(int critAngle,
                                               PgElementSet geom)

      Creates the boundary for an ElementSet adding a neighbour relation and splitting at points which do not fulfill the angle criterion (i.e. mostly that the polygon is not planar there).
      Parameters:
        `critAngle` - is the critical angle for splitting of the boundary.
        `geom` - is the geometry, of which a boundary will be created.
      Returns:
        the boundary of geom with respect to the critical angle.

    - #### showBoundaries

          public void showBoundaries(boolean show)

      Show or hide the boundaries of a geometry.
      Parameters:
        `show` - indicates whether the boundary will be shown or not.

    - #### showBoundaries

          public void showBoundaries(PgBndPolygon[] bound)

      Shows the given boundaries in different coloring.
      Parameters:
        `bound` - is a set of boundary-polygons to be highlighted in different colors.

    - #### selectPoints

          public PgPointSet selectPoints(PgElementSet geom)

      Returns a pointset which contains all selected points of the given geometry.
      Parameters:
        `geom` - geometry which is checked for selected points.
      Returns:
        the selected points of `geom`.

    - #### mirrorAlongSelected

          public void mirrorAlongSelected()

      Mirrors the geometry along all those edges which have at least two vertices marked.

    - #### mirrorBoundary

          public PdMatrix mirrorBoundary(int i,
                                         PgBndPolygon[] bound,
                                         PgElementSet geom)

      This function computes a reflection matrix if the i-th component of m_bound is 2 dimensional, a matrix which rotates by Pi if it is 1-dimensional or returns the zero matrix in any other cases. When the zero matrix is returned (means error), the variable m_badBound is set to true as the boundary is "bad" in consideration of its ability to be mirrored.
      Parameters:
        `i` - is the index of the boundary for which the reflection matrix will be computed.
        `bound` - is the boundary of geom.
        `geom` - is the geometry working with.

    - #### getPolyDimension

          public int getPolyDimension(PgPointSet poly)

      This method returns the dimension of a given PgPointSet, which it spans in space.
      Parameters:
        `poly` - Given pointset which is to be checked for dimension
      Returns:
        "-1" if the pointset is empty
        "0" if there is only one vertex
        "1" if the pointset defines an edge
        "2" if the pointset defines a plane
        "3" if the pointset defines a volume.

    - #### getSymmAndGeom

          public void getSymmAndGeom()

      Computes the symmetries of m_geom and shows its mirrored geometries.

    - #### createGeo

          public void createGeo(PdMatrix[] mat)

      Create mirrored geometries from matrices given.
      Parameters:
        `mat` - Reflection matrices that define the mirrored geometries generated from m_elSet.

    - #### getSymmetries

          public PdMatrix[] getSymmetries(int m_maxdepth,
                                          int critAngle,
                                          double eps)

      Computes the symmetries of a given object.
      Parameters:
        `m_maxdepth` - is the maximal tree depth to which the symmetries are computed.
        `critAngle` - is the critical angle for the boundary splitting.
        `eps` - is the tolerance for the tree computation.
      Returns:
        an array of matrices which describe the mirror planes.

    - #### getSymmetryMatrices

          public PdMatrix[] getSymmetryMatrices(PgPolygon[] bound)

      Creates symmetry matrices from the planes given in bound. Bound must be split into planes.
      Parameters:
        `bound` - is a boundary polygon.
      Returns:
        all matrices which are defined by the boundary.

    - #### getTreeAndEqui

          public void getTreeAndEqui(PdVector start,
                                     PdMatrix[] M,
                                     int numMatrices,
                                     double eps,
                                     int m_maxdepth)

      Returns equivalent words in "eq" and the tree in "tmplist" in the variables given. The vars must be initialized in the main program before used here. Does the same as makeTree and getEquivalents together. m_maxdepth = 0 means there is no maximal depth.
      Parameters:
        `start` - Startpoint
        `M` - Matrices
        `numMatrices` - Number of Matrices used
        `eps` - Tolerance
        `m_maxdepth` - maximal tree depth.

    - #### makeTree

          public jvx.geom.WordPoint[] makeTree(PdVector start,
                                               PdMatrix[] M,
                                               int numMatrices,
                                               double eps)

      Creates a tree in a vector of self-referring entries of type WordPoint. The algorithm tries for a flat approach of the tree means that each level is completely checked before it goes a level deeper. That results in shorter words in the end but may require more of the given matrices. The long approach would generate the same matrices but through other words.
      Parameters:
        `start` - The (well chosen) starting point
        `M` - The base-matrices to generate the symmetries with
        `numMatrices` - The number of matrices given (hopefully obsolete in the future)
        `eps` - The tolerance below which the difference between two vectors is (component wise) considered equal.
      Returns:
        the tree in form of a WordPoint-Array. Through parents and letters the words can be constructed from this structure.

    - #### getEquivalents

          public jvx.geom.EquiPoint[] getEquivalents(PdVector start,
                                                     PdMatrix[] M,
                                                     int numMatrices,
                                                     double eps)

      Returns pairs of words which are equivalent.
      Parameters:
        `start` - is the startpoint for the geometrical equivalence check.
        `M` - is an array of matrices which is to be checked for equivalence.
        `numMatrices` - is the number of matrices in M.
        `eps` - is the tolerance for the computation.
      Returns:
        the equivalent words.

    - #### getEquiWords

          public jvx.geom.EquiPoint getEquiWords(int i,
                                                 int j,
                                                 int k,
                                                 java.util.Vector list)

      Returns two equivalent words of points which are already known to be the same.
      Parameters:
        `i` - letter of dead end
        `j` - index of first point with same coordinates
        `k` - index of second point with same coordinates
        `list` - the tree
      Returns:
        two equivalent words.

    - #### getWordMatrices

          public PdMatrix[] getWordMatrices(PiVector[] words,
                                            PdMatrix[] M)

      Returns the matrices which generate the whole space. Faster than other method but needs "better" input.
      Parameters:
        `words` - The words which generate an element
        `M` - The base-matrices.
      Returns:
        an array of matrices which generate the whole space.

    - #### getWordMatrices

          public PdMatrix[] getWordMatrices(jvx.geom.WordPoint[] list,
                                            PdMatrix[] M)

      Returns the matrices which generate the whole space.
      Parameters:
        `list` - The list which contains the tree
        `M` - The base-matrices
      Returns:
        an array of matrices which generate the whole space.

    - #### getWord

          public PiVector getWord(int i,
                                  java.util.Vector list)

      Returns the word for a single element of the tree. For identity "-1" is returned - the numbers starting from 0 are the matrices given.
      Parameters:
        `i` - The index of the element to get the word for
        `list` - The tree.
      Returns:
        the word for a single element.

    - #### getWord

          public PiVector getWord(int i,
                                  jvx.geom.WordPoint[] list)

      Returns the word for a single element of the tree. For identity "-1" is returned - the numbers starting from 0 are the matrices given.
      Parameters:
        `i` - The index of the element to get the word for
        `list` - The tree.
      Returns:
        the word for a single element.

    - #### getWords

          public PiVector[] getWords(jvx.geom.WordPoint[] list)

      Returns the words of a matrix composition given through a tree containing letters.
      Parameters:
        `list` - The tree to generate words from.
      Returns:
        an array of (usually differently sized) vectors which contain the words

    - #### getShortestPointDist

          public double getShortestPointDist(PgElementSet geom)

      Get the shortest distance between two points of a geometry (faster with kdtree?). Only exact to 3 digits. HACK (kp, 2011-02-05) This algorithm is quadratic and uses inefficient comparisons for length and in copyNew (sqrt!!!)
      Parameters:
        `geom` - geometry whose edge is to be checked.
      Returns:
        the length of the shortest edge

    - #### getHomogCenter

          public PdVector getHomogCenter(PgElementSet geom)

      Get the center of a geometry in homogeneous coordinates.
      Parameters:
        `geom` - geometry whose center is to be found.
      Returns:
        center of the geometry in homogeneous coordinates.

    - #### hasEquivPoint

          public int hasEquivPoint(java.util.Vector list,
                                   PdVector check,
                                   double eps)

      Method that checks if a given point is already contained in a wordlist or not.
      Parameters:
        `list` - the list, which contains the points.
        `check` - the vector to be compared with the list
        `eps` - tolerance for equality-check
      Returns:
        index of the point in the wordlist which is equal.

    - #### epsEqual

          public boolean epsEqual(PdVector vec1,
                                  PdVector vec2,
                                  double eps)

      Compares the two PdVectors vec1 and vec2 component-wise and marks them equal if they differ maximally by eps in each component.
      Parameters:
        `vec1` - first vector to be checked for equality
        `vec2` - second vector to be checked for equality
        `eps` - equality-threshold
      Returns:
        true if vectors are considers equal or false if not.

    - #### matmult

          public PdVector matmult(PdMatrix M,
                                  PdVector x)

      Multiply PdMatrix with PdVector and get a PdVector.
      Parameters:
        `M` - Matrix to multiply vector with
        `x` - Vector to be multiplied
      Returns:
        Matrix-Vector product

"

The software JavaView? is copyright protected. All Rights Reserved.
"