unlekker.data
Class STL

java.lang.Object
  extended by processing.core.PImage
      extended by processing.core.PGraphics
          extended by processing.core.PGraphics3D
              extended by unlekker.data.STL
All Implemented Interfaces:
java.lang.Cloneable, processing.core.PConstants

public class STL
extends processing.core.PGraphics3D

Class to export and import binary STL (stereolithography) files from Processing. STL files are typically used for rapid prototyping, and consist of simple triangle data with a face normal. See Wikipedia: STL for more info about the format.

Using Processing's beginRaw() mechanism geometry can be output through this class. STL files can also be loaded into memory.

I recommend the excellent Open Source object viewer MeshLab for checking STL models. It will show inverted normals, invalid polygons and so on. It will even attempt some limited repairs of damaged files.


Field Summary
 
Fields inherited from class processing.core.PGraphics3D
camera, cameraFar, cameraFOV, cameraNear, cameraX, cameraY, cameraZ, cameraAspect, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, lightCount, lightDiffuse, lightFalloffConstant, lightFalloffLinear, lightFalloffQuadratic, lightNormal, lightPosition, lightSpecular, lightSpotAngle, lightSpotAngleCos, lightSpotConcentration, lightType, line, MAX_LIGHTS, modelview, modelviewInv, projection, smoothTriangle, TRI_COLOR_COUNT, TRI_DIFFUSE_A, TRI_DIFFUSE_B, TRI_DIFFUSE_G, TRI_DIFFUSE_R, TRI_SPECULAR_B, TRI_SPECULAR_G, TRI_SPECULAR_R, triangle, zbuffer
 
Fields inherited from class processing.core.PGraphics
ambientB, ambientG, ambientR, backgroundColor, bezierDetail, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, curveTightness, edge, ellipseMode, emissiveB, emissiveG, emissiveR, fill, fillColor, image, imageMode, normalX, normalY, normalZ, pixelCount, rectMode, shapeMode, shininess, smooth, specularB, specularG, specularR, sphereDetailU, sphereDetailV, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, textAlign, textAlignY, textFont, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, tint, tintColor
 
Fields inherited from class processing.core.PImage
format, height, parent, pixels, width
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
STL()
          Constructor for use with beginRaw().
STL(processing.core.PApplet applet, java.lang.String path)
          Constructor for loading STL files.
 
Method Summary
 void beginDraw()
           
 void beginShape(int kind)
           
 void dispose()
           
 void endDraw()
           
 void endShape(int mode)
           
 FaceList getPolyData()
           
 void setParent(processing.core.PApplet _p)
           
 void setPath(java.lang.String path)
           
 void setSize(int w, int h)
           
 void vertex(float x, float y)
           
 void vertex(float x, float y, float z)
           
 
Methods inherited from class processing.core.PGraphics3D
ambientLight, ambientLight, applyMatrix, applyMatrix, applyMatrix, applyMatrix, beginCamera, box, camera, camera, directionalLight, endCamera, flush, frustum, getMatrix, getMatrix, hint, is2D, is3D, lightFalloff, lights, lightSpecular, modelX, modelY, modelZ, noLights, noSmooth, ortho, ortho, perspective, perspective, pointLight, popMatrix, printCamera, printMatrix, printProjection, pushMatrix, resetMatrix, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setMatrix, setMatrix, smooth, sphere, spotLight, strokeCap, strokeJoin, texture, translate, translate, vertex
 
Methods inherited from class processing.core.PGraphics
alpha, ambient, ambient, ambient, applyMatrix, arc, background, background, background, background, background, background, background, beginRaw, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, blue, box, breakShape, brightness, canDraw, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, displayable, edge, ellipse, ellipseMode, emissive, emissive, emissive, endRaw, endShape, fill, fill, fill, fill, fill, fill, getMatrix, getStyle, getStyle, green, hue, image, image, image, imageMode, lerpColor, lerpColor, line, line, noFill, normal, noStroke, noTint, point, point, popStyle, pushStyle, quad, rect, rectMode, red, saturation, setMatrix, setPrimary, shape, shape, shape, shapeMode, shininess, showException, showWarning, specular, specular, specular, sphereDetail, sphereDetail, stroke, stroke, stroke, stroke, stroke, stroke, strokeWeight, style, text, text, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, textureMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint, triangle, vertex, vertex
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, getCache, getImage, init, isModified, loadPixels, mask, mask, removeCache, resize, save, set, set, setCache, setModified, setModified, updatePixels, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

STL

public STL()
Constructor for use with beginRaw().


STL

public STL(processing.core.PApplet applet,
           java.lang.String path)
Constructor for loading STL files. Once loaded, draw() can be used to draw the geometry on the canvas.

Parameters:
filename - Name of file to open.
Method Detail

setParent

public void setParent(processing.core.PApplet _p)
Overrides:
setParent in class processing.core.PGraphics

setPath

public void setPath(java.lang.String path)
Overrides:
setPath in class processing.core.PGraphics

setSize

public void setSize(int w,
                    int h)
Overrides:
setSize in class processing.core.PGraphics3D

getPolyData

public FaceList getPolyData()

dispose

public void dispose()
Overrides:
dispose in class processing.core.PGraphics

beginDraw

public void beginDraw()
Overrides:
beginDraw in class processing.core.PGraphics3D

endDraw

public void endDraw()
Overrides:
endDraw in class processing.core.PGraphics3D

beginShape

public void beginShape(int kind)
Overrides:
beginShape in class processing.core.PGraphics3D

endShape

public void endShape(int mode)
Overrides:
endShape in class processing.core.PGraphics3D

vertex

public void vertex(float x,
                   float y)
Overrides:
vertex in class processing.core.PGraphics3D

vertex

public void vertex(float x,
                   float y,
                   float z)
Overrides:
vertex in class processing.core.PGraphics