summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrian-bowyer <adrian-bowyer@cb376a5e-1013-0410-a455-b6b1f9ac8223>2010-08-26 15:10:06 +0000
committeradrian-bowyer <adrian-bowyer@cb376a5e-1013-0410-a455-b6b1f9ac8223>2010-08-26 15:10:06 +0000
commit86360f70671cbd6e49dac7f746596e7bf9791cba (patch)
tree3382a506ace5b8637ea002c01fbc2db6059d649e
parent4ee79caf2ab17525b372e479155af3e2fb106ce9 (diff)
downloadreprap-backup-86360f70671cbd6e49dac7f746596e7bf9791cba.tar.gz
reprap-backup-86360f70671cbd6e49dac7f746596e7bf9791cba.zip
More messing around with the PCB code.
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@3731 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rw-r--r--trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java4
-rw-r--r--trunk/reprap/host/src/org/reprap/pcb/GerberGCode.java82
-rw-r--r--trunk/reprap/host/src/org/reprap/pcb/PCB.java62
-rw-r--r--trunk/reprap/host/src/org/reprap/utilities/RrGraphics.java2
4 files changed, 97 insertions, 53 deletions
diff --git a/trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java b/trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java
index 3f717cf0..707e66ae 100644
--- a/trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java
+++ b/trunk/reprap/host/src/org/reprap/geometry/polygons/BooleanGrid.java
@@ -2057,6 +2057,8 @@ public class BooleanGrid
private iPolygonList marchAll()
{
iPolygonList result = new iPolygonList();
+ if(isEmpty())
+ return result;
iPoint start;
iPolygon p;
int m;
@@ -2562,6 +2564,8 @@ public class BooleanGrid
result.disc(p1, Math.abs(r), r > 0);
}
}
+ if(result.isEmpty())
+ return nothingThere;
//if(dist < 0)
result.deWhisker();
return result;
diff --git a/trunk/reprap/host/src/org/reprap/pcb/GerberGCode.java b/trunk/reprap/host/src/org/reprap/pcb/GerberGCode.java
index 2729b9a5..25833457 100644
--- a/trunk/reprap/host/src/org/reprap/pcb/GerberGCode.java
+++ b/trunk/reprap/host/src/org/reprap/pcb/GerberGCode.java
@@ -8,7 +8,7 @@ import org.reprap.geometry.polygons.*;
//import org.reprap.Attributes;
import org.reprap.utilities.RrGraphics;
import org.reprap.Preferences;
-
+import org.reprap.Extruder;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
@@ -43,27 +43,29 @@ public class GerberGCode {
boolean dawingOn = false;
LinkedList <Aperture> apertures = new LinkedList<Aperture>();
- double penWidth;
+ //double penWidth;
Aperture curAperture = null;
boolean absolute = true;
+ Extruder pcbPen;
BooleanGrid pcb;
Rr2Point lastCoords = null;
- RrPolygonList thePattern = new RrPolygonList();
+// RrPolygonList thePattern = new RrPolygonList();
boolean colour = true;
// RrPolygon currentPolygon = null;
- Appearance looksLike;
+ //Appearance looksLike;
- public GerberGCode(double penWidth, BooleanGrid p, boolean c) //, double drawingHeight, double freemoveHeight, int XYFeedrate, int ZFeedrate)
+ public GerberGCode(Extruder pp, BooleanGrid p, boolean c) //, double drawingHeight, double freemoveHeight, int XYFeedrate, int ZFeedrate)
{
- this.penWidth = penWidth;
+ pcbPen = pp;
+ //this.penWidth = penWidth;
enableAbsolute();
disableDrawing();
pcb = p;
colour = c;
lastCoords = new Rr2Point(0, 0);
- looksLike = new Appearance();
- looksLike.setMaterial(new Material(new Color3f(0.5f, 0.5f, 0.5f), new Color3f(0f, 0f, 0f), new Color3f(0.5f, 0.5f, 0.5f), new Color3f(0f, 0f, 0f), 0f));
+ //looksLike = new Appearance();
+ //looksLike.setMaterial(new Material(new Color3f(0.5f, 0.5f, 0.5f), new Color3f(0f, 0f, 0f), new Color3f(0.5f, 0.5f, 0.5f), new Color3f(0f, 0f, 0f), 0f));
}
public RrRectangle drawLine(Rr2Point c)
@@ -147,26 +149,7 @@ public class GerberGCode {
return result;
}
- public RrPolygonList getPolygons()
- {
- try
- {
- if(Preferences.loadGlobalBool("DisplaySimulation"))
- {
- RrGraphics simulationPlot = new RrGraphics("PCB simulation");
-// if(currentPolygon != null)
-// thePattern.add(new RrPolygon(currentPolygon));
- simulationPlot.init(pcb.box(), false, 0);
- simulationPlot.add(pcb);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return thePattern;
- }
-
// private void addPointToPolygons(Rr2Point c)
// {
// if(currentPolygon == null && dawingOn)
@@ -248,5 +231,50 @@ public class GerberGCode {
}
return c;
}
+
+ public RrPolygonList getPolygons()
+ {
+ try
+ {
+ if(Preferences.loadGlobalBool("DisplaySimulation"))
+ {
+ RrGraphics simulationPlot1 = new RrGraphics("PCB pattern");
+// if(currentPolygon != null)
+// thePattern.add(new RrPolygon(currentPolygon));
+ simulationPlot1.init(pcb.box(), false, 0);
+ simulationPlot1.add(pcb);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ RrPolygonList result = new RrPolygonList();
+ double penWidth = pcbPen.getExtrusionSize();
+ pcb = pcb.offset(-0.5*penWidth);
+ RrPolygonList pol = pcb.allPerimiters(pcb.attribute());
+
+ while( pol.size() > 0 )
+ {
+ result.add(pol);
+ pcb = pcb.offset(-penWidth);
+ pol = pcb.allPerimiters(pcb.attribute());
+ }
+ try
+ {
+ if(Preferences.loadGlobalBool("DisplaySimulation"))
+ {
+ RrGraphics simulationPlot2 = new RrGraphics("PCB plotlines");
+// if(currentPolygon != null)
+// thePattern.add(new RrPolygon(currentPolygon));
+ simulationPlot2.init(result.getBox(), false, 0);
+ simulationPlot2.add(result);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return result;
+ }
+
}
diff --git a/trunk/reprap/host/src/org/reprap/pcb/PCB.java b/trunk/reprap/host/src/org/reprap/pcb/PCB.java
index fb878ce3..34f37097 100644
--- a/trunk/reprap/host/src/org/reprap/pcb/PCB.java
+++ b/trunk/reprap/host/src/org/reprap/pcb/PCB.java
@@ -15,7 +15,7 @@ public class PCB {
GerberGCode gerberGcode;
String[] splitline;
- boolean debug = true;
+ boolean debug = false;
BufferedReader in;
String line;
@@ -28,10 +28,10 @@ public class PCB {
double penWidth = 0.7f;
double offsetX=40;
double offsetY=40;
- int XYFeedrate = 1000;
- int ZFeedrate = 70;
- double drawingHeight = 1.8f;
- double freemoveHeight = 3.8f;//1.7f;
+// int XYFeedrate = 1000;
+// int ZFeedrate = 70;
+// double drawingHeight = 1.8f;
+// double freemoveHeight = 3.8f;//1.7f;
/**
* @param args
*/
@@ -49,10 +49,10 @@ public class PCB {
System.out.println("Pen Width: " + penWidth + " mm");
System.out.println("Offset X: " + offsetX + " mm");
System.out.println("Offset Y: " + offsetY + " mm");
- System.out.println("Drawing Height: " + drawingHeight + " mm");
- System.out.println("Freemove Height: " + freemoveHeight + " mm\n");
+// System.out.println("Drawing Height: " + drawingHeight + " mm");
+// System.out.println("Freemove Height: " + freemoveHeight + " mm\n");
- gerberGcode = new GerberGCode(penWidth, null, true); //, drawingHeight, freemoveHeight, XYFeedrate, ZFeedrate);
+ gerberGcode = new GerberGCode(pcbPen, null, true); //, drawingHeight, freemoveHeight, XYFeedrate, ZFeedrate);
RrRectangle box = new RrRectangle();
@@ -74,7 +74,7 @@ public class PCB {
BooleanGrid pattern = new BooleanGrid(RrCSG.nothing(), box, new Attributes(null, null, null, pcbPen.getAppearance()));
- gerberGcode = new GerberGCode(penWidth, pattern, true);
+ gerberGcode = new GerberGCode(pcbPen, pattern, true);
while((line = in.readLine()) != null)
{
@@ -84,7 +84,8 @@ public class PCB {
if(inputDrill != null)
{
in = new BufferedReader(new FileReader(inputDrill));
- gerberGcode = new GerberGCode(penWidth, pattern, false);
+ gerberGcode = new GerberGCode(pcbPen, pattern, false);
+ gerberGcode.addCircleAperture(-1, 0.3);
while((line = in.readLine()) != null)
{
processLine(line, true);
@@ -238,12 +239,20 @@ public class PCB {
else
if(line.startsWith("G54"))
{
- int aperture;
+ if(drill)
+ {
+ gerberGcode.selectAperture(-1);
+ if(debug)
+ System.out.println("Drill centre selected.");
+ } else
+ {
+ int aperture;
- aperture = Integer.valueOf(line.substring(4, line.length()-1).trim());
- gerberGcode.selectAperture(aperture);
- if(debug)
- System.out.println("Apature: " + aperture + " selected.");
+ aperture = Integer.valueOf(line.substring(4, line.length()-1).trim());
+ gerberGcode.selectAperture(aperture);
+ if(debug)
+ System.out.println("Apature: " + aperture + " selected.");
+ }
}
else
@@ -297,17 +306,20 @@ public class PCB {
else
if(line.startsWith("D") || (line.startsWith("T") && drill && !drillDef))
{
- int aperture;
-
- aperture = Integer.valueOf(line.substring(1, 3));
- gerberGcode.selectAperture(aperture);
- if(debug)
+ if(drill)
+ {
+ gerberGcode.selectAperture(-1);
+ if(debug)
+ System.out.println("Drill centre selected.");
+ } else
{
- if(drill)
- System.out.print("Drill: ");
- else
- System.out.print("Apature: ");
- System.out.print(aperture + " selected.");
+ int aperture;
+
+ aperture = Integer.valueOf(line.substring(1, 3));
+ gerberGcode.selectAperture(aperture);
+
+ if(debug)
+ System.out.print("Apature: " + aperture + " selected.");
}
}
return result;
diff --git a/trunk/reprap/host/src/org/reprap/utilities/RrGraphics.java b/trunk/reprap/host/src/org/reprap/utilities/RrGraphics.java
index f6e945cf..2d349daf 100644
--- a/trunk/reprap/host/src/org/reprap/utilities/RrGraphics.java
+++ b/trunk/reprap/host/src/org/reprap/utilities/RrGraphics.java
@@ -102,7 +102,7 @@ public class RrGraphics
/**
* Pixels
*/
- private final int frame = 600;
+ private final int frame = 1200;
/**
*