Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Digital Fabrication
Results will update as you type.
  • Digital Fabrication HS 2018
  • Digital Fabrication HS 2017
    • Lectures
    • ZHdK Zoetrope
    • Processing and Laser cutting
    • Project Briefs
    • Readings
    • Tools
    • Timetable
    • Software
  • Digital Fabrication HS 2019
  • Digital Fabrication HS 2020
  • Digital Fabrication HS 2021
  • Digital Fabrication HS 2022/23

    Two hearts overlapped with each other
    Welcome back
    Catch up on the top discussions and highlights from your team.
    /
    Processing and Laser cutting
    Updated Jan 05, 2017

    Processing and Laser cutting

    Jan 05, 2017

    Analytics

    Loading data...

    This example produces a pseudo 3d form from a depth map image. It produces a pdf file suitable for Laser cutting based on this slicing method.  

    import processing.pdf.*; PGraphicsPDF pdf; int gridWidth = 100; int gridHeight = 100; int cutHeight = 50; float pointDistX = 5; float pointDistY = 5; ArrayList<Float> imageGreyScaleList = new ArrayList<Float>(); ArrayList<Integer> MaxHeight = new ArrayList<Integer>(); float waveHeight = 20; PImage baseImage; void setup() { size(700, 700); smooth(); baseImage = loadImage("data/image.jpg"); baseImage.loadPixels(); int loc; float combinedHeight = 0; for (int i = 0; i < baseImage.width; i++) { MaxHeight.add(0); for (int j = 0; j < baseImage.height; j++) { loc = i + j*baseImage.width; //println(baseImage.pixels[loc]); color pixel = baseImage.pixels[loc]; int greyScale = floor(red(pixel)); float heightConverted = map(greyScale, 0, 255, 0, -waveHeight); imageGreyScaleList.add(heightConverted); } combinedHeight += waveHeight+cutHeight; } // create a pdf the lenght of the total graphic pdf = (PGraphicsPDF) createGraphics(width, int(combinedHeight), PDF, "export.pdf"); } void draw() { background(255); beginRecord(pdf); exportSlices(); endRecord(); background(255); draw2D(); noLoop(); }; void draw2D() { fill(255); background(255); pushMatrix(); //translate graphic to the center of the screen translate((width-(pointDistX*gridWidth))/2, (height-(pointDistY*gridHeight))/2); int loc; for (int i = 0; i<gridHeight; i++ ) { beginShape(); for (int j = 0; j<gridWidth; j++) { loc = i + j*baseImage.width; float posX = j*pointDistX; float posY = i*pointDistY+imageGreyScaleList.get(loc); // offset y coordinate based on the pixels colour curveVertex(posX, posY); }; endShape(); }; popMatrix(); }; void exportSlices() { noFill(); background(255); pushMatrix(); //translate graphic to the center of the screen //translate((width-(pointDistX*gridWidth))/2, (height-(pointDistY*gridHeight))/2); int loc; for (int i = 0; i<gridHeight; i++ ) { float y = i*(pointDistY+cutHeight+waveHeight); beginShape(); curveVertex(0, y); for (int j = 0; j<gridWidth; j++) { loc = i + j*baseImage.width; float posX = j*pointDistX; float posY = y+imageGreyScaleList.get(loc); // offset y coordinate based on the pixels colour curveVertex(posX, posY); }; vertex(gridWidth*pointDistX, y); vertex(gridWidth*pointDistX, y+cutHeight); vertex(0, y+cutHeight); vertex(0, y); pushStyle(); fill(0); text("no_ "+i, 5, y+cutHeight-5); popStyle(); endShape(); }; popMatrix(); };

     

     

    {"serverDuration": 16, "requestCorrelationId": "85df3fa8febd456d915c40b421677978"}