Package mgui.morph.sections
Class MappedPolygon2D
java.lang.Object
mgui.morph.sections.MappedPolygon2D
- All Implemented Interfaces:
java.lang.Cloneable
public class MappedPolygon2D
extends java.lang.Object
implements java.lang.Cloneable
Implements a node mapping between two Polygon2D shapes. Mapping uses radial representation
to assign similarity weights to node pairs, and maps between nodes based upon these weights.
This allows mappings between polygons with unequal node counts. The algorithm:
- Gets the radial representation of each polygon
- Assigns weights to node pairs based upon angle similarity
- First maps nMin nodes, where nMin = min(nA, nB), ensuring that each node gets mapped at least once
- Secondly maps remaining unmapped nodes based upon their weights and positions relative to already mapped nodes (ensuring that node order is preserved)
- Author:
- Andrew Reid
- See Also:
RadialRepresentation
-
Field Summary
-
Constructor Summary
Constructors Constructor Description MappedPolygon2D()
MappedPolygon2D(Polygon2D a, Polygon2D b, int psect, int nsect)
Constructor passing a source (A) and target (B) polygon. -
Method Summary
Modifier and Type Method Description java.lang.Object
clone()
Polygon2D
getA()
Polygon2D
getB()
Polygon2D
getOrderedA()
Polygon2D
getOrderedB()
void
mapPolygons(double threshold)
void
printMap()
void
printWeights(double[][] weights)
void
removeNode(int i)
int
removeNodeByCount(double minAngle)
int
removeNodeByCount(double minAngle, double minLength)
Remove a node from A, selected by the criteria that its target has a maximum source count (i.e., multiple source (A) nodes mapped to a single target (B) node), and is attached to a minimal length edge.void
setNodeList(MappedPolygon2D prevMap)
Sets the nodes in nodesA or nodesB from the previous polygon map in this series.void
setPolygons(Polygon2D a, Polygon2D b)
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
isReversed
public boolean isReversed -
isMapped
public boolean isMapped -
A
-
B
-
prevSect
public int prevSect -
nextSect
public int nextSect
-
-
Constructor Details
-
MappedPolygon2D
public MappedPolygon2D() -
MappedPolygon2D
Constructor passing a source (A) and target (B) polygon.- Parameters:
a
- Source polygonb
- Target polygon
-
-
Method Details
-
setPolygons
- Parameters:
a
-b
-
-
getOrderedA
-
getOrderedB
-
getA
-
getB
-
mapPolygons
public void mapPolygons(double threshold) -
setNodeList
Sets the nodes in nodesA or nodesB from the previous polygon map in this series.- Parameters:
prevMap
-
-
removeNodeByCount
public int removeNodeByCount(double minAngle) -
removeNodeByCount
public int removeNodeByCount(double minAngle, double minLength)Remove a node from A, selected by the criteria that its target has a maximum source count (i.e., multiple source (A) nodes mapped to a single target (B) node), and is attached to a minimal length edge.- Parameters:
minAngle
- the minimum node angle at which a node remove a node is allowed (may no longer be necessary...)
-
removeNode
public void removeNode(int i) -
clone
public java.lang.Object clone()- Overrides:
clone
in classjava.lang.Object
-
printWeights
public void printWeights(double[][] weights) -
printMap
public void printMap()
-