home processing download documents tutorial python tutorial gallery source about
 Tutorials (back to the list of tutorials)

Panelization Examples

     Panelization Example5

The following example shows panelization with random length panels. Each of the panel length is defined by vlen .
The sample input file used in the example is below.

surface5.3dm

import processing.opengl.*;
import igeo.*;

size(480, 360, IG.GL);

IG.open("surface5.3dm");
ISurface[] surfaces = IG.surfaces();

for (ISurface surf : surfaces) {

  int unum = 30, vnum=40;
  double uinc = 1.0/unum, vinc = 1.0/vnum;
  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      int vlen = IRandom.getInt(1, 10);
      if (j+vlen > vnum) vlen = vnum-j;
      IVec[][] cpts = new IVec[2][vlen+1];
      
      for (int k=0; k <= vlen; k++) {
        cpts[0][k] = surf.pt(i*uinc, (j + k)*vinc);
        cpts[1][k] = surf.pt((i+1)*uinc, (j + k)*vinc);
      }
      new ISurface(cpts).clr(IRandom.clr());
      
      j+=vlen-1;
    }
  }
  surf.del();
}

And then the offset distance of the panel from the orignal input surface is randomized by the parameter depth.

import processing.opengl.*;
import igeo.*;

size(480, 360, IG.GL);

IG.open("surface5.3dm");
ISurface[] surfaces = IG.surfaces();

for (ISurface surf : surfaces) {

  int unum = 30, vnum=40;
  double uinc = 1.0/unum, vinc = 1.0/vnum;
  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      int vlen = IRandom.getInt(1, 10);
      if (j+vlen > vnum) vlen = vnum-j;
      IVec[][] cpts = new IVec[2][vlen+1];

      double depth = IRandom.get(0, 1);
      for (int k=0; k <= vlen; k++) {
        cpts[0][k] = surf.pt(i*uinc, (j+k)*vinc, depth);
        cpts[1][k] = surf.pt((i+1)*uinc, (j+k)*vinc, depth);
      }
      new ISurface(cpts).clr(IRandom.gray());
      
      j+=vlen-1;
    }
  }
  surf.del();
}


(back to the list of tutorials)

HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java / Python)
GALLERY
SOURCE CODE(GitHub)
PRIVACY POLICY
ABOUT/CONTACT