Permalink
Browse files

Found a big bad bug in the bounding box generator, which is more impo…

…rtant than it sounds.
  • Loading branch information...
1 parent da57219 commit 8524077b7eed7be63f2e1df3b1d83a347b18351a @MaskedRetriever committed Jul 30, 2010
Showing with 41 additions and 10 deletions.
  1. +12 −2 Mesh.pde
  2. +3 −2 Slice.pde
  3. +23 −6 SuperSkein.pde
  4. +3 −0 readme.txt
View
@@ -4,13 +4,14 @@ class Mesh {
ArrayList Triangles;
float bx1,by1,bz1,bx2,by2,bz2; //bounding box
-
+ float Sink;
//Mesh Loading routine
Mesh(String FileName)
{
byte b[] = loadBytes(FileName);
Triangles = new ArrayList();
+ Sink=0;
float[] Tri = new float[9];
//Skip the header
int offs = 84;
@@ -51,8 +52,15 @@ class Mesh {
void CalculateBoundingBox()
{
- for(int i = Triangles.size()-1;i>=0;i--)
+ bx1 = 10000;
+ bx2 = -10000;
+ by1 = 10000;
+ by2 = -10000;
+ bz1 = 10000;
+ bz2 = -10000;
+ for(int i = Triangles.size()-1;i>=0;i--)
{
+
Triangle tri = (Triangle) Triangles.get(i);
if(tri.x1<bx1)bx1=tri.x1;
if(tri.x2<bx1)bx1=tri.x2;
@@ -75,5 +83,7 @@ class Mesh {
}
}
+
+
}
View
@@ -42,7 +42,8 @@ class Slice {
int iNextLine;
- while(Lines.size()<FinalSize)
+ //while(Lines.size()<FinalSize)
+ while(UnsortedLines.size()>0)
{
Line2D CLine = (Line2D) Lines.get(Lines.size()-1);//Get last
iNextLine = (Lines.size()-1);
@@ -68,7 +69,7 @@ class Slice {
}
Line2D LineToMove = (Line2D) UnsortedLines.get(iNextLine);
- if(min_dflipped>min_d)LineToMove.Flip();
+ //if(min_dflipped>min_d)LineToMove.Flip();
Lines.add(LineToMove);
UnsortedLines.remove(iNextLine);
}
View
@@ -6,12 +6,22 @@
//Slicing Parameters-- someone should make
//a GUI menu at some point...
-//Obviously not as many of them now...
+//Sorted here according to units
+
+//"funny" dimensionality
float PrintHeadSpeed = 2000.0;
+
+//Measured in millimeters
float LayerThickness = 0.3;
+float Sink = 2;
+
+//Dimensionless
+float PreScale = 1;
String FileName = "sculpt_dragon.stl";
+
+
//End of "easy" modifications you can make...
//Naturally I encourage everyone to learn and
//alter the code that follows!
@@ -32,14 +42,20 @@ void setup(){
//Load the .stl
//Later we should totally make this runtime...
STLFile = new Mesh(FileName);
+
+
//Scale and locate the mesh
- //STLFile.Scale(10);
-
+ STLFile.Scale(PreScale);
//Put the mesh on the platform:
STLFile.Translate(0,0,-STLFile.bz1);
STLFile.Translate(0,0,-LayerThickness);
- print("File Loaded, Slicing:\n");
+ STLFile.Translate(0,0,-Sink);
+
+ print("File Loaded, Slicing:\n");
+print("X: " + CleanFloat(STLFile.bx1) + " - " + CleanFloat(STLFile.bx2) + " ");
+print("Y: " + CleanFloat(STLFile.by1) + " - " + CleanFloat(STLFile.by2) + " ");
+print("Z: " + CleanFloat(STLFile.bz1) + " - " + CleanFloat(STLFile.bz2) + " \n");
//Spit GCODE!
Line2D Intersection;
output = createWriter("output.gcode");
@@ -59,7 +75,7 @@ for(float ZLevel = 0;ZLevel<(STLFile.bz2-LayerThickness);ZLevel=ZLevel+LayerThic
{
ThisSlice = new Slice(STLFile,ZLevel);
print("Slicing: ");
- TextStatusBar(ZLevel/STLFile.bz2,40);
+ TextStatusBar(ZLevel/STLFile.bz2,50);
print("\n");
for(int j = ThisSlice.Lines.size()-1;j>=0;j--)
{
@@ -70,11 +86,12 @@ for(float ZLevel = 0;ZLevel<(STLFile.bz2-LayerThickness);ZLevel=ZLevel+LayerThic
output.flush();
output.close();
+
print("Finished Slicing! Bounding Box is:\n");
print("X: " + CleanFloat(STLFile.bx1) + " - " + CleanFloat(STLFile.bx2) + " ");
print("Y: " + CleanFloat(STLFile.by1) + " - " + CleanFloat(STLFile.by2) + " ");
print("Z: " + CleanFloat(STLFile.bz1) + " - " + CleanFloat(STLFile.bz2) + " ");
-
+if(STLFile.bz1<0)print("\n(Values below z=0 not exported.)");
//THEN scale to fit
if((STLFile.bx2-STLFile.bx1)>(STLFile.by2-STLFile.by1))
View
@@ -18,6 +18,9 @@ Space between the layers, obviously. This affects both where the slicer cuts an
--->String FileName = "sculpt_dragon.stl";
+**Modularity note
+I think most of the things we'll do to the file are going to be clearly divided between things we do to the whole mesh or to individual layers. I think rather than cluttering the SuperSkein.pde file we should make every effort to "push down" modifications to the objects they affect.
+
*Hacking NOTES

0 comments on commit 8524077

Please sign in to comment.