org.reprap.geometry.polygons
Class BooleanGrid.iPolygon

java.lang.Object
  extended by org.reprap.geometry.polygons.BooleanGrid.iPolygon
Enclosing class:
BooleanGrid

 class BooleanGrid.iPolygon
extends java.lang.Object

Integer-point polygon

Author:
ensab

Field Summary
private  boolean closed
          Does the polygon loop back on itself?
private  java.util.List<BooleanGrid.iPoint> points
          Auto-extending list of points
 
Constructor Summary
BooleanGrid.iPolygon(boolean c)
           
BooleanGrid.iPolygon(BooleanGrid.iPolygon a)
          Deep copy
 
Method Summary
 void add(BooleanGrid.iPoint p)
          Add a new point on the end
 void add(BooleanGrid.iPolygon a)
          Add a whole polygon on the end
private  int findAngleStart(int v1)
          Find the furthest point from point v1 on the polygon such that the polygon between the two can be approximated by a DDA straight line from v1.
 int nearest(BooleanGrid.iPoint a, long tooFar2)
          Find the index of the point in the polygon nearest to another point as long as it's less than tooFar2.
 BooleanGrid.iPolygon negate()
          Negate (i.e.
 BooleanGrid.iPoint point(int i)
          Return the point at a given index
 RrPolygon realPolygon(Attributes a)
          Convert the polygon into a polygon in the real world.
 void remove(int i)
          Delete a point and close the resulting gap
 BooleanGrid.iPolygon simplify()
          Generate an equivalent polygon with fewer vertices by removing chains of points that lie in straight lines.
 int size()
          How many points?
 BooleanGrid.iPolygon translate(BooleanGrid.iPoint t)
          Transtate by vector t
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

points

private java.util.List<BooleanGrid.iPoint> points
Auto-extending list of points


closed

private boolean closed
Does the polygon loop back on itself?

Constructor Detail

BooleanGrid.iPolygon

public BooleanGrid.iPolygon(boolean c)

BooleanGrid.iPolygon

public BooleanGrid.iPolygon(BooleanGrid.iPolygon a)
Deep copy

Parameters:
a -
Method Detail

point

public BooleanGrid.iPoint point(int i)
Return the point at a given index

Parameters:
i -
Returns:

size

public int size()
How many points?

Returns:

add

public void add(BooleanGrid.iPoint p)
Add a new point on the end

Parameters:
p -

add

public void add(BooleanGrid.iPolygon a)
Add a whole polygon on the end

Parameters:
a -

remove

public void remove(int i)
Delete a point and close the resulting gap

Parameters:
i -

nearest

public int nearest(BooleanGrid.iPoint a,
                   long tooFar2)
Find the index of the point in the polygon nearest to another point as long as it's less than tooFar2. Set that to Long.MAX_VALUE for a complete search.

Parameters:
a -
tooFar2 -
Returns:

negate

public BooleanGrid.iPolygon negate()
Negate (i.e. reverse cyclic order)

Returns:
reversed polygon object

translate

public BooleanGrid.iPolygon translate(BooleanGrid.iPoint t)
Transtate by vector t

Parameters:
t -
Returns:

findAngleStart

private int findAngleStart(int v1)
Find the furthest point from point v1 on the polygon such that the polygon between the two can be approximated by a DDA straight line from v1.

Parameters:
v1 -
Returns:

simplify

public BooleanGrid.iPolygon simplify()
Generate an equivalent polygon with fewer vertices by removing chains of points that lie in straight lines.

Returns:

realPolygon

public RrPolygon realPolygon(Attributes a)
Convert the polygon into a polygon in the real world.

Parameters:
a -
Returns: