Initial commit for historical purposes
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package com.aaaaahhhhhhh.bananapuncher714.tess4j;
|
||||
|
||||
public class HalfWing {
|
||||
protected HalfWing sym;
|
||||
protected HalfWing prev;
|
||||
protected HalfWing next;
|
||||
|
||||
protected Vertex origin;
|
||||
|
||||
public HalfWing() {
|
||||
init();
|
||||
|
||||
new HalfWing( this );
|
||||
}
|
||||
|
||||
private HalfWing( HalfWing o ) {
|
||||
init();
|
||||
|
||||
sym = o;
|
||||
o.sym = this;
|
||||
|
||||
next = o;
|
||||
o.next = this;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
origin = new Vertex( this );
|
||||
prev = this;
|
||||
}
|
||||
|
||||
public Vertex getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public HalfWing setOrigin( Vertex vert ) {
|
||||
origin = vert;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HalfWing getSym() {
|
||||
return sym;
|
||||
}
|
||||
|
||||
public HalfWing getPrev() {
|
||||
return prev;
|
||||
}
|
||||
|
||||
public HalfWing setPrev( HalfWing wing ) {
|
||||
this.prev = wing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HalfWing getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
public HalfWing setNext( HalfWing wing ) {
|
||||
this.next = wing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vertex getDest() {
|
||||
return sym.origin;
|
||||
}
|
||||
|
||||
public Vector2d toVector2d() {
|
||||
return getDest().getPosition().subtracted( getOrigin().getPosition() );
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
return getOrigin().equals( getDest() );
|
||||
}
|
||||
|
||||
// Split this edge in half, and return the new edge
|
||||
public HalfWing split() {
|
||||
HalfWing wing = new HalfWing();
|
||||
|
||||
splice( wing, getNext() );
|
||||
|
||||
splice( getSym(), getNext() );
|
||||
splice( getSym(), wing.getSym() );
|
||||
|
||||
wing.setOrigin( getDest() );
|
||||
wing.getOrigin().setWing( wing );
|
||||
|
||||
getSym().setOrigin( wing.getDest() );
|
||||
getDest().setWing( getSym() );
|
||||
|
||||
wing.getOrigin().update();
|
||||
wing.getDest().update();
|
||||
|
||||
return wing.getSym();
|
||||
}
|
||||
|
||||
public static void splice( HalfWing a, HalfWing b ) {
|
||||
HalfWing ap = a.prev;
|
||||
HalfWing bp = b.prev;
|
||||
|
||||
a.prev = bp;
|
||||
b.prev = ap;
|
||||
|
||||
ap.sym.next = b;
|
||||
bp.sym.next = a;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user