Class MorphEngine

java.lang.Object
mgui.morph.sections.MorphEngine

public class MorphEngine
extends java.lang.Object
Engine class implementing algorithms to create polygons which represent the intermediate positions of a morphing between two polygons on adjacent sections. The algorithm is essentially:
  • Given a section set, filter that set for instances of Polygon2DInt
  • If a selection set is specified, filter for shapes in this set
  • Map between the nodes of adjacent polygons using a radial representation
  • If a spline is requested, calculate the tangents of the map-paths of the set of mapped polygons
  • For each pair of mapped polygons, create a specified number of intermediate polygons whose nodes lie along the path (linear or spline) between mapped nodes.
  • For unequal node counts, remove iter/deltaN nodes per iteration, based upon either segment length, node angle, or some other measure of priority (this still needs tweaking)
A Mesh3DInt surface can also be generated from a section set of polygons, e.g., the morphed set obtained from the above steps (the mesh routine must be called separately). This algorithm:
  • Maps polygons using radial representations, as above
  • Triangulates each polygon pair using the Java3D triangulator (NOTE: triangulation might be improved by making use of the mapping information)
Author:
Andrew Reid
See Also:
ar.morph.sections.RadialRepresention
  • Field Details

  • Constructor Details

    • MorphEngine

      public MorphEngine()
  • Method Details

    • getMorphSections

      public SectionSet3DInt getMorphSections​(SectionSet3DInt sections, double weight_thres)
    • getCornerPoints

      public SectionSet3DInt getCornerPoints​(SectionSet3DInt sections)
    • getPolygonSet

      public SectionSet3DInt getPolygonSet​(SectionSet3DInt sections)
    • getMappedPolygons

      public java.util.ArrayList<MappedPolygon2DPath> getMappedPolygons​(SectionSet3DInt polySet, double weight_thres)
    • getMappedPolygons

      public java.util.ArrayList<MappedPolygon2DPath> getMappedPolygons​(SectionSet3DInt polySet, double weight_thres, boolean mapMulti)
      Maps the set of polygons in polyset between each neighbouring section.
      Parameters:
      polySet -
      weight_thres -
      mapMulti -
      Returns:
    • getMultiPolygonMapping

      protected boolean[][] getMultiPolygonMapping​(java.util.ArrayList<Polygon2D> polys0, java.util.ArrayList<Polygon2D> polys1)
    • getPolygonDistances

      protected double[][] getPolygonDistances​(java.util.ArrayList<Polygon2D> polys0, java.util.ArrayList<Polygon2D> polys1)
    • getNodeTangents

      public java.util.ArrayList<MappedPolygon2DPath> getNodeTangents​(java.util.ArrayList<MappedPolygon2DPath> paths, double spacing, double endFactor)
      Given a list of mapped polygons, assign tangents to nodes based upon the mapping vectors. Tangents can be used to smooth (spline) these lines and thus smooth a given morphing transition.
      Parameters:
      maps - - a list of MappedPolygon2D objects
      Returns:
      maps with tangent values assigned (using the "TangentX" and "TangentY" Attributes).
    • getSubsections

      public SectionSet3DInt getSubsections​(java.util.ArrayList<MappedPolygon2DPath> paths, int iters, AttributeList attr)
      Given a set of mapped polygons, generate new subsections for each section s, which morph from polygon i to polygon j.
      Parameters:
      mappedPolys - set of polygons whose nodes are mapped between sections
      iters - number of subsections to generate
      Returns:
      a MorphSections3DInt object containing generated subsections
    • getMorphMesh

      public Mesh3DInt getMorphMesh​(SectionSet3DInt morphSections, double weight_thres)
      Given a set of sections, map nodes using radial rep and then triangulate between sections based upon this mapping, and each polygon's direction (CW or CCW)
      Parameters:
      morphSections - section set containing polygons (and only polygons) with which to generate the mesh.
      Returns:
      Mesh3DInt object representing the surface connecting these section polygons