Skip to content
Browse files

Renamed Line2D class to SSLine (SuperSkein Line) to avoid name confli…

…ct with java.awt.geom.Line2D and made extend Line2D.Float.
  • Loading branch information...
1 parent 3ad7c29 commit a6403cb62568563020ae0fe4e1f4f863ddc67ff9 @clothbot clothbot committed Sep 6, 2010
Showing with 42 additions and 46 deletions.
  1. +17 −21 Line.pde
  2. +2 −2 Path.pde
  3. +3 −3 Poly2D.pde
  4. +4 −4 Slice.pde
  5. +11 −11 SuperSkein.pde
  6. +4 −4 Triangle.pde
  7. +1 −1 config.txt
View
38 Line.pde
@@ -1,32 +1,28 @@
// Line Class
// Once we have the slices as 2D lines,
// we never look back.
-// From this version (1.3ish?) Line2D will
+// From this version (1.3ish?) SSLine will
// have both SPEED and PLASTIC FLOW RATE.
-class Line2D {
+import java.awt.geom.Line2D;
+
+class SSLine extends Line2D.Float {
- float x1,y1,x2,y2;
+// float x1,y1,x2,y2;
float HeadSpeed;
float Flowrate;
final float epsilon = 1e-6;
- Line2D(float nx1, float ny1, float nx2, float ny2) {
- x1=nx1;
- x2=nx2;
- y1=ny1;
- y2=ny2;
+ SSLine(float nx1, float ny1, float nx2, float ny2) {
+ super(nx1,ny1,nx2,ny2);
HeadSpeed = 1000; //By default it at least does move.
Flowrate = 0; //By default the plastic does not flow.
}
- Line2D(PVector pt1, PVector pt2) {
- x1 = pt1.x;
- y1 = pt1.y;
- x2 = pt2.x;
- y2 = pt2.y;
+ SSLine(PVector pt1, PVector pt2) {
+ super(pt1.x,pt1.y,pt2.x,pt2.y);
HeadSpeed = 1000; //By default it at least does move.
Flowrate = 0; //By default the plastic does not flow.
}
@@ -168,7 +164,7 @@ class Line2D {
// Returns null if the two line segments don't intersect each other.
// Otherwise returns intersection point as a PVector.
// NOTE: coincident lines don't count as intersecting.
- PVector FindSegmentsIntersection(Line2D line2)
+ PVector FindSegmentsIntersection(SSLine line2)
{
float dx1 = x2 - x1;
float dy1 = y2 - y1;
@@ -208,7 +204,7 @@ class Line2D {
// Returns null if the two extended lines are parallel.
// Otherwise returns intersection point as a PVector.
// NOTE: coincident lines don't count as intersecting.
- PVector FindExtendedLinesIntersection(Line2D line2)
+ PVector FindExtendedLinesIntersection(SSLine line2)
{
float dx1 = x2 - x1;
float dy1 = y2 - y1;
@@ -239,17 +235,17 @@ class Line2D {
}
- // Returns a Line2D of the current segment, if it were shifted
+ // Returns a SSLine of the current segment, if it were shifted
// to the right by the given amount.
- Line2D Offset(float offsetby)
+ SSLine Offset(float offsetby)
{
float ang = this.RadianAngle();
float perpang = ang - HALF_PI;
float nux1 = x1 + offsetby * cos(perpang);
float nuy1 = y1 + offsetby * sin(perpang);
float nux2 = x2 + offsetby * cos(perpang);
float nuy2 = y2 + offsetby * sin(perpang);
- return new Line2D(nux1, nuy1, nux2, nuy2);
+ return new SSLine(nux1, nuy1, nux2, nuy2);
}
@@ -258,13 +254,13 @@ class Line2D {
// amount. The end point of the first line segment must be the
// exact same point as the start point of the second line.
// Returns null if the two lines aren't joined.
- PVector FindOffsetIntersectionByBisection(Line2D line2, float offsetby)
+ PVector FindOffsetIntersectionByBisection(SSLine line2, float offsetby)
{
if (x2 != line2.x1 || y2 != line2.y1) {
return null;
}
- Line2D offline1 = this.Offset(offsetby);
- Line2D offline2 = line2.Offset(offsetby);
+ SSLine offline1 = this.Offset(offsetby);
+ SSLine offline2 = line2.Offset(offsetby);
return offline1.FindExtendedLinesIntersection(offline2);
}
}
View
4 Path.pde
@@ -61,8 +61,8 @@ class Path2D {
return false;
}
PVector testpoint2 = new PVector(testpoint.x, testpoint.y+1e9);
- Line2D testline = new Line2D(testpoint, testpoint2);
- Line2D segment = new Line2D(0,0,0,0);
+ SSLine testline = new SSLine(testpoint, testpoint2);
+ SSLine segment = new SSLine(0,0,0,0);
int isectCount = 0;
PVector pt2 = (PVector)pathArray.get(0);
View
6 Poly2D.pde
@@ -46,11 +46,11 @@ class Poly2D extends Polygon{
ArrayList Slice2Poly2DList(Slice thisSlice) {
ArrayList nuAL=new ArrayList();
Poly2D nuP2D=new Poly2D(gridScale);
- Line2D prevLine=(Line2D) thisSlice.Lines.get(0);
+ SSLine prevLine=(SSLine) thisSlice.Lines.get(0);
PVector startPt = prevLine.getPoint1();
nuP2D.addPoint(startPt.x,startPt.y);
for(int i = 1; i<thisSlice.Lines.size(); i++ ) {
- Line2D thisLine=(Line2D) thisSlice.Lines.get(i);
+ SSLine thisLine=(SSLine) thisSlice.Lines.get(i);
PVector prevPt = prevLine.getPoint2();
PVector currPt = thisLine.getPoint1();
if(abs(prevPt.x-currPt.x)<epsilon && abs(prevPt.y-currPt.y)<epsilon) {
@@ -68,7 +68,7 @@ class Poly2D extends Polygon{
if(i<thisSlice.Lines.size()) {
nuAL.add(nuP2D);
nuP2D=new Poly2D(gridScale);
- prevLine=(Line2D) thisSlice.Lines.get(i);
+ prevLine=(SSLine) thisSlice.Lines.get(i);
startPt=prevLine.getPoint1();
nuP2D.addPoint(startPt.x,startPt.y);
} else {
View
8 Slice.pde
@@ -11,7 +11,7 @@ class Slice {
Slice(Mesh InMesh, float ZLevel) {
ArrayList UnsortedLines;
- Line2D Intersection;
+ SSLine Intersection;
UnsortedLines = new ArrayList();
for(int i = InMesh.Triangles.size()-1;i>=0;i--)
{
@@ -46,13 +46,13 @@ class Slice {
//while(Lines.size()<FinalSize)
while(UnsortedLines.size()>0)
{
- Line2D CLine = (Line2D) Lines.get(Lines.size()-1);//Get last
+ SSLine CLine = (SSLine) Lines.get(Lines.size()-1);//Get last
iNextLine = (Lines.size()-1);
mindist = 10000;
boolean doflip = false;
for(int i = UnsortedLines.size()-1;i>=0;i--)
{
- Line2D LineCandidate = (Line2D) UnsortedLines.get(i);
+ SSLine LineCandidate = (SSLine) UnsortedLines.get(i);
dist = mag(LineCandidate.x1-CLine.x2, LineCandidate.y1-CLine.y2);
dist_flipped = mag(LineCandidate.x2-CLine.x2, LineCandidate.y2-CLine.y2); // flipped
@@ -91,7 +91,7 @@ class Slice {
}
}
- Line2D LineToMove = (Line2D) UnsortedLines.get(iNextLine);
+ SSLine LineToMove = (SSLine) UnsortedLines.get(iNextLine);
if(doflip) {
LineToMove.Flip();
}
View
22 SuperSkein.pde
@@ -190,7 +190,7 @@ void draw()
fill(255);
text("MeshMRI",width/2,15);
- Line2D Intersection;
+ SSLine Intersection;
Slice = new ArrayList();
//Draw the grid
@@ -213,8 +213,8 @@ void draw()
strokeWeight(2);
for(int i = Slice.size()-1;i>=0;i--)
{
- Line2D lin = (Line2D) Slice.get(i);
- Line2D newLine = new Line2D(lin.x1,lin.y1,lin.x2,lin.y2);
+ SSLine lin = (SSLine) Slice.get(i);
+ SSLine newLine = new SSLine(lin.x1,lin.y1,lin.x2,lin.y2);
//Translate into Display Coordinates
newLine.Scale(DisplayScale);
newLine.Rotate(PI);
@@ -324,8 +324,8 @@ class FileWriteProc implements Runnable{
while(true){
while(!FileWriteTrigger)delay(300);
FileWriteTrigger=false;//Only do this once per command.
- Line2D Intersection;
- Line2D lin;
+ SSLine Intersection;
+ SSLine lin;
String GCodeFileName = selectOutput("Save G-Code to This File");
if(GCodeFileName == null) {
println("No file was selected; using STL File as G-Code file prefix.");
@@ -348,11 +348,11 @@ class FileWriteProc implements Runnable{
{
FileWriteFraction = (ZLevel/(STLFile.bz2-LayerThickness));
ThisSlice = new Slice(STLFile,ZLevel);
- lin = (Line2D) ThisSlice.Lines.get(0);
+ lin = (SSLine) ThisSlice.Lines.get(0);
output.println("G1 X" + lin.x1 + " Y" + lin.y1 + " Z" + ZLevel + " F" + PrintHeadSpeed);
for(int j = 0;j<ThisSlice.Lines.size();j++)
{
- lin = (Line2D) ThisSlice.Lines.get(j);
+ lin = (SSLine) ThisSlice.Lines.get(j);
output.println("G1 X" + lin.x2 + " Y" + lin.y2 + " Z" + ZLevel + " F" + PrintHeadSpeed);
}
}
@@ -380,8 +380,8 @@ class DXFWriteProc implements Runnable{
while(!DXFWriteTrigger)delay(300);
DXFWriteTrigger=false;//Only do this once per command.
// GUIPage=2;
- Line2D Intersection;
- Line2D lin;
+ SSLine Intersection;
+ SSLine lin;
String DXFSliceFilePrefix = selectOutput("Save Results to This File Path and Prefix");
if(DXFSliceFilePrefix == null) {
@@ -421,10 +421,10 @@ class DXFWriteProc implements Runnable{
ThisSlice = new Slice(STLFile,ZLevel);
Poly2D ThisPoly2D = new Poly2D(0.01);
PolyArray = ThisPoly2D.Slice2Poly2DList(ThisSlice);
- lin = (Line2D) ThisSlice.Lines.get(0);
+ lin = (SSLine) ThisSlice.Lines.get(0);
for(int j = 0;j<ThisSlice.Lines.size();j++)
{
- lin = (Line2D) ThisSlice.Lines.get(j);
+ lin = (SSLine) ThisSlice.Lines.get(j);
pgDxf.line(lin.x1, lin.y1, lin.x2, lin.y2);
}
output.println(" if(index>="+DXFSliceNum+"&&index<(1+"+DXFSliceNum+")) {");
View
8 Triangle.pde
@@ -111,9 +111,9 @@ class Triangle {
//out what kind of intersections the triangle
//makes with the plane, if any. Returns
//null if the triangle does not intersect.
- Line2D GetZIntersect(float ZLevel)
+ SSLine GetZIntersect(float ZLevel)
{
- Line2D Intersect;
+ SSLine Intersect;
float xa,xb,ya,yb;
if(z1<ZLevel)
{
@@ -131,7 +131,7 @@ class Triangle {
xb = x2 + (x3-x2)*(ZLevel-z2)/(z3-z2);
yb = y2 + (y3-y2)*(ZLevel-z2)/(z3-z2);
}
- Intersect = new Line2D(xa,ya,xb,yb);
+ Intersect = new SSLine(xa,ya,xb,yb);
return Intersect;
}
else
@@ -143,7 +143,7 @@ class Triangle {
xb = x2 + (x3-x2)*(ZLevel-z2)/(z3-z2);
yb = y2 + (y3-y2)*(ZLevel-z2)/(z3-z2);
- Intersect = new Line2D(xa,ya,xb,yb);
+ Intersect = new SSLine(xa,ya,xb,yb);
return Intersect;
}
else
View
2 config.txt
@@ -1,4 +1,4 @@
-CONFIG_SCALE 1.0009433
+CONFIG_SCALE 1.0
CONFIG_XROTATE 0.34
CONFIG_STLFILE sculpt_dragon.stl
MACHINE_OPTEMP 220

0 comments on commit a6403cb

Please sign in to comment.
Something went wrong with that request. Please try again.