From: <adr...@us...> - 2009-12-30 01:33:58
|
Revision: 3409 http://reprap.svn.sourceforge.net/reprap/?rev=3409&view=rev Author: adrian-bowyer Date: 2009-12-30 00:37:41 +0000 (Wed, 30 Dec 2009) Log Message: ----------- More work on the boolean grid. Modified Paths: -------------- trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java Modified: trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java =================================================================== --- trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java 2009-12-28 16:49:32 UTC (rev 3408) +++ trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java 2009-12-30 00:37:41 UTC (rev 3409) @@ -286,13 +286,13 @@ RrCSGPolygonList offBorder = csgP.offset(layerConditions, true); offBorder.divide(Preferences.tiny(), 1.01); borderPolygons = offBorder.megList(); - //BooleanGrid bg; - //borderPolygons = new RrPolygonList(); - //for(int i = 0; i < offBorder.size(); i++) - //{ - // bg = new BooleanGrid(offBorder.get(i).csg()); - // borderPolygons.add(bg.allPerimiters(offBorder.get(i).getAttributes())); - //} +// BooleanGrid bg; +// borderPolygons = new RrPolygonList(); +// for(int i = 0; i < offBorder.size(); i++) +// { +// bg = new BooleanGrid(offBorder.get(i).csg()); +// borderPolygons.add(bg.allPerimiters(offBorder.get(i).getAttributes())); +// } } offHatch.divide(Preferences.tiny(), 1.01); Modified: trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java =================================================================== --- trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java 2009-12-28 16:49:32 UTC (rev 3408) +++ trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java 2009-12-30 00:37:41 UTC (rev 3409) @@ -22,6 +22,8 @@ import org.reprap.Attributes; +import java.util.ArrayList; +import java.util.List; /** * Integer 2D point @@ -88,6 +90,94 @@ } } + class iPolygon + { + private List<iPoint> points = null; + + public iPolygon() + { + points = new ArrayList<iPoint>(); + } + + public iPolygon(iPolygon a) + { + points = new ArrayList<iPoint>(); + for(int i = 0; i < a.size(); i++) + add(a.point(i)); + } + + public iPoint point(int i) + { + return points.get(i); + } + + public int size() + { + return points.size(); + } + + public void add(iPoint p) + { + points.add(p); + } + + private int nextX(int i, int x) + { + i++; + while(i < size()) + { + if(x != point(i).x) + return i; + i++; + } + return size(); + } + + private int nextY(int i, int y) + { + i++; + while(i < size()) + { + if(y != point(i).y) + return i; + i++; + } + return size(); + } + + public iPolygon rightFilter() + { + if(size() < 3) + return new iPolygon(this); + + iPolygon result = new iPolygon(); + + int last = 0; + int nextx, nexty; + while(last < size()) + { + result.add(point(last)); + nextx = nextX(last, point(last).x); + nexty = nextY(last, point(last).y); + if(nexty > nextx) + last = nexty - 1; + else + last = nextx - 1; + } + + + return result; + } + + public RrPolygon realPolygon(Attributes a, boolean closed) + { + RrPolygon result = new RrPolygon(a, closed); + for(int i = 0; i < size(); i++) + result.add(point(i).realPoint()); + return result; + } + } + //************************************************************************************************** // Constructors and administration @@ -716,9 +806,11 @@ pixel = findUnvisitedNeighbourOnEdge(pixel); } - System.err.println("Polygon size: " + p.size()); + System.err.print("Polygon before size: " + p.size()); + p = p.simplify(0.5*(xInc + yInc)); + System.err.println(", polygon after size: " + p.size()); if(p.size() >= 3) - result.add(p.simplify(1.3*Math.sqrt(xInc*xInc + yInc*yInc))); + result.add(p); pixel = findUnvisitedEdgePixel(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |