From: <adr...@us...> - 2011-03-30 14:23:00
|
Revision: 4071 http://reprap.svn.sourceforge.net/reprap/?rev=4071&view=rev Author: adrian-bowyer Date: 2011-03-30 14:22:52 +0000 (Wed, 30 Mar 2011) Log Message: ----------- More improved construction of unsupported bridges (experimental...). Plus an attributes class for polygons (as yet unused). Extruders have unique attributes attached, which are for an entire material. But a polygon may need internally-generated supplementary info (one day). Modified Paths: -------------- trunk/software/host/src/org/reprap/Extruder.java trunk/software/host/src/org/reprap/devices/GenericExtruder.java trunk/software/host/src/org/reprap/geometry/LayerProducer.java trunk/software/host/src/org/reprap/geometry/polygons/AllSTLsToBuild.java trunk/software/host/src/org/reprap/geometry/polygons/RrPolygon.java trunk/software/host/src/org/reprap/geometry/polygons/RrPolygonList.java Modified: trunk/software/host/src/org/reprap/Extruder.java =================================================================== --- trunk/software/host/src/org/reprap/Extruder.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/Extruder.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -587,5 +587,19 @@ * @return */ public double getOddHatchDirection(); + /** + * Get the extrude ratio + * @return + */ + public double getExtrudeRatio(); + + + /** + * Set the extrude ratio. Only to be used if you know what you + * are doing. It's a good idea to set it back when you've finished... + * @param er + */ + public void setExtrudeRatio(double er); + } Modified: trunk/software/host/src/org/reprap/devices/GenericExtruder.java =================================================================== --- trunk/software/host/src/org/reprap/devices/GenericExtruder.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/devices/GenericExtruder.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -1279,6 +1279,25 @@ return 0; return extrudeRatio*distance; } + + /** + * Get the extrude ratio + * @return + */ + public double getExtrudeRatio() + { + return extrudeRatio; + } + + /** + * Set the extrude ratio. Only to be used if you know what you + * are doing. It's a good idea to set it back when you've finished... + * @param er + */ + public void setExtrudeRatio(double er) + { + extrudeRatio = er; + } /** * Find out if we're working in 5D Modified: trunk/software/host/src/org/reprap/geometry/LayerProducer.java =================================================================== --- trunk/software/host/src/org/reprap/geometry/LayerProducer.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/geometry/LayerProducer.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -15,6 +15,7 @@ import org.reprap.geometry.polygons.Rr2Point; //import org.reprap.geometry.polygons.RrCSGPolygonList; import org.reprap.geometry.polygons.RrPolygon; +import org.reprap.geometry.polygons.PolygonAttributes; import org.reprap.geometry.polygons.RrPolygonList; import org.reprap.geometry.polygons.RrRectangle; import org.reprap.utilities.Debug; @@ -350,6 +351,7 @@ private void plot(RrPolygon p, boolean firstOneInLayer) throws Exception { Attributes att = p.getAttributes(); + PolygonAttributes pAtt = p.getPolygonAttribute(); Printer printer = layerConditions.getPrinter(); double outlineFeedrate = att.getExtruder().getOutlineFeedrate(); double infillFeedrate = att.getExtruder().getInfillFeedrate(); @@ -434,6 +436,11 @@ boolean valveOff = false; boolean oldexoff; + double oldFeedFactor = att.getExtruder().getExtrudeRatio(); + + if(pAtt != null) + att.getExtruder().setExtrudeRatio(oldFeedFactor*pAtt.getBridgeThin()); + for(int i = 1; i < p.size(); i++) { Rr2Point next = p.point((i+1)%p.size()); @@ -457,7 +464,10 @@ printer.printEndReverse(); } + // Restore sanity + att.getExtruder().setExtrudeRatio(oldFeedFactor); + if(p.isClosed()) move(p.point(0), p.point(0), false, false, true); Modified: trunk/software/host/src/org/reprap/geometry/polygons/AllSTLsToBuild.java =================================================================== --- trunk/software/host/src/org/reprap/geometry/polygons/AllSTLsToBuild.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/geometry/polygons/AllSTLsToBuild.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -3,6 +3,7 @@ import java.util.List; import java.util.ArrayList; import org.reprap.geometry.LayerRules; +import org.reprap.geometry.polygons.PolygonAttributes; import org.reprap.gui.STLObject; import org.reprap.Attributes; import org.reprap.Extruder; @@ -802,57 +803,69 @@ Rr2Point cen2 = land2.findCentroid(); if(cen2 == null) { - Debug.e("AllSTLsToBuild.bridges(): Second land found with no centroid!"); - return result; - } - - // Wipe this land from the land pattern - - land2.offset(0.5); // Slight hack... - landPattern = BooleanGrid.difference(landPattern, land2); - - // (Roughly) what direction does the bridge go in? - - Rr2Point centroidDirection = Rr2Point.sub(cen2, cen1).norm(); - Rr2Point bridgeDirection = centroidDirection; - - // Fine the edge of the bridge that is nearest parallel to that, and use that as the fill direction - - double spMax = Double.NEGATIVE_INFINITY; - double sp; - RrPolygonList bridgeOutline = bridge.allPerimiters(bridge.attribute()); - for(int pol = 0; pol < bridgeOutline.size(); pol++) + Debug.d("AllSTLsToBuild.bridges(): Second land found with no centroid!"); + + // No second land implies a ring of support - just infill it. + + result.add(bridge.hatch(layerConditions.getHatchDirection(bridge.attribute().getExtruder()), + bridge.attribute().getExtruder().getExtrusionInfillWidth(), + bridge.attribute())); + } else { - RrPolygon polygon = bridgeOutline.polygon(i); - double tooSmall = polygon.meanEdge(); - for(int vertex1 = 0; vertex1 < polygon.size(); vertex1++) + + // Wipe this land from the land pattern + + land2.offset(0.5); // Slight hack... + landPattern = BooleanGrid.difference(landPattern, land2); + + // (Roughly) what direction does the bridge go in? + + Rr2Point centroidDirection = Rr2Point.sub(cen2, cen1).norm(); + Rr2Point bridgeDirection = centroidDirection; + + // Fine the edge of the bridge that is nearest parallel to that, and use that as the fill direction + + double spMax = Double.NEGATIVE_INFINITY; + double sp; + RrPolygonList bridgeOutline = bridge.allPerimiters(bridge.attribute()); + for(int pol = 0; pol < bridgeOutline.size(); pol++) { - int vertex2 = vertex1+1; - if(vertex2 >= polygon.size()) // We know the polygon must be closed... - vertex2 = 0; - Rr2Point edge = Rr2Point.sub(polygon.point(vertex2), polygon.point(vertex1)); - if(edge.mod() > tooSmall) + RrPolygon polygon = bridgeOutline.polygon(i); + double tooSmall = polygon.meanEdge(); + for(int vertex1 = 0; vertex1 < polygon.size(); vertex1++) { - if((sp = Math.abs(Rr2Point.mul(edge, centroidDirection))) > spMax) + int vertex2 = vertex1+1; + if(vertex2 >= polygon.size()) // We know the polygon must be closed... + vertex2 = 0; + Rr2Point edge = Rr2Point.sub(polygon.point(vertex2), polygon.point(vertex1)); + if(edge.mod() > tooSmall) { - spMax = sp; - bridgeDirection = edge; + if((sp = Math.abs(Rr2Point.mul(edge, centroidDirection))) > spMax) + { + spMax = sp; + bridgeDirection = edge; + } } } } + + // Build the bridge + + result.add(bridge.hatch(new RrHalfPlane(new Rr2Point(0,0), bridgeDirection), + bridge.attribute().getExtruder().getExtrusionInfillWidth(), + bridge.attribute())); + + // We shouldn't need to remove the bridge from the bridge patterns; no other lands should + // intersect it. } - - // Build the bridge - - result.add(bridge.hatch(new RrHalfPlane(new Rr2Point(0,0), bridgeDirection), - bridge.attribute().getExtruder().getExtrusionInfillWidth(), - bridge.attribute())); - - // We shouldn't need to remove the bridge from the bridge patterns; no other lands should - // intersect it. } } +// PolygonAttributes pa = new PolygonAttributes(); +// pa.setBridgeThin(0.5); // Test value - needs to be an extruder parameter +// for(int i = 0; i < result.size(); i++) +// result.polygon(i).setPolygonAttribute(pa); + return result; } Modified: trunk/software/host/src/org/reprap/geometry/polygons/RrPolygon.java =================================================================== --- trunk/software/host/src/org/reprap/geometry/polygons/RrPolygon.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/geometry/polygons/RrPolygon.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -76,6 +76,7 @@ import org.reprap.Preferences; import org.reprap.Extruder; import org.reprap.geometry.LayerRules; +import org.reprap.geometry.polygons.PolygonAttributes; import org.reprap.machines.VelocityProfile; import org.reprap.utilities.Debug; @@ -109,6 +110,9 @@ */ private Attributes att = null; + + private PolygonAttributes pa = null; + /** * The minimum enclosing X-Y box round the polygon */ @@ -132,51 +136,39 @@ /** * Destroy me and all that I point to */ - public void destroy() - { - if(beingDestroyed) // Prevent infinite loop - return; - beingDestroyed = true; - - if(speeds != null) - { - for(int i = 0; i < size(); i++) - speeds.set(i, null); - } - speeds = null; - - if(points != null) - { - for(int i = 0; i < size(); i++) - { - points.get(i).destroy(); - points.set(i, null); - } - } - points = null; - - if(box != null) - box.destroy(); - box = null; - - // Don't destroy the attribute - that may still be needed - - //if(att != null) - // att.destroy(); - att = null; - beingDestroyed = false; - } - - /** - * Destroy just me - */ -// protected void finalize() throws Throwable +// public void destroy() // { +// if(beingDestroyed) // Prevent infinite loop +// return; +// beingDestroyed = true; +// +// if(speeds != null) +// { +// for(int i = 0; i < size(); i++) +// speeds.set(i, null); +// } +// speeds = null; +// +// if(points != null) +// { +// for(int i = 0; i < size(); i++) +// { +// points.get(i).destroy(); +// points.set(i, null); +// } +// } // points = null; -// speeds = null; +// +// if(box != null) +// box.destroy(); +// box = null; +// +// // Don't destroy the attribute - that may still be needed +// +// //if(att != null) +// // att.destroy(); // att = null; -// box = null; -// super.finalize(); +// beingDestroyed = false; // } @@ -194,6 +186,7 @@ closed = c; extrudeEnd = -1; valveEnd = -1; + pa = null; } /** @@ -208,6 +201,15 @@ } /** + * Get the polygon attribute (may be null) + * @return + */ + public PolygonAttributes getPolygonAttribute() + { + return pa; + } + + /** * Get the speed * @param i * @return i-th point object of polygon @@ -288,7 +290,8 @@ } /** - * Deep copy - NB: attributes _not_ deep copied + * Deep copy - NB: Attributes _not_ deep copied, but + * PolygonAttribute are. * @param p */ public RrPolygon(RrPolygon p) @@ -305,9 +308,22 @@ closed = p.closed; extrudeEnd = p.extrudeEnd; valveEnd = p.valveEnd; + if(p.pa != null) + pa = new PolygonAttributes(p.pa); + else + pa = null; } /** + * Set the polygon attribute + * @return + */ + public void setPolygonAttribute(PolygonAttributes p) + { + pa = p; + } + + /** * Add a new point to the polygon * @param p * @param f Modified: trunk/software/host/src/org/reprap/geometry/polygons/RrPolygonList.java =================================================================== --- trunk/software/host/src/org/reprap/geometry/polygons/RrPolygonList.java 2011-03-25 00:54:35 UTC (rev 4070) +++ trunk/software/host/src/org/reprap/geometry/polygons/RrPolygonList.java 2011-03-30 14:22:52 UTC (rev 4071) @@ -455,39 +455,31 @@ */ private boolean beingDestroyed = false; - /** - * Destroy me and all that I point to - */ - public void destroy() - { - if(beingDestroyed) // Prevent infinite loop - return; - beingDestroyed = true; - if(polygons != null) - { - for(int i = 0; i < size(); i++) - { - polygons.get(i).destroy(); - polygons.set(i,null); - } - polygons = null; - } - if(box != null) - box.destroy(); - box = null; - beingDestroyed = false; - } - - /** - * Destroy just me - */ -// protected void finalize() throws Throwable +// /** +// * Destroy me and all that I point to +// */ +// public void destroy() // { -// polygons = null; +// if(beingDestroyed) // Prevent infinite loop +// return; +// beingDestroyed = true; +// if(polygons != null) +// { +// for(int i = 0; i < size(); i++) +// { +// polygons.get(i).destroy(); +// polygons.set(i,null); +// } +// polygons = null; +// } +// if(box != null) +// box.destroy(); // box = null; -// super.finalize(); +// beingDestroyed = false; // } + + /** * Empty constructor */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |