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

Panelization Examples

     Panelization Example9

The following is an example of deformed diamond panelization with diagrid structure. It starts with the example code of diamond panelization in the section of simple panelization.

The sample input file used in the example is this.

surface10.3dm

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

size(480, 360, IG.GL);

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

for (ISurface surf : surfaces) {
  int unum = 36, vnum = 24;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      if( (i+j)%2==0 ){
        IVec pt1 = surf.pt( (i-1)*uinc, j*vinc );
        IVec pt2 = surf.pt( i*uinc, (j+1)*vinc );
        IVec pt3 = surf.pt( (i+1)*uinc, j*vinc );
        IVec pt4 = surf.pt( i*uinc, (j-1)*vinc );
        
        new ISurface(pt1,pt2,pt3,pt4).clr(0.3,0.4*j*vinc,i*uinc*0.8);
      }
    }
  }
  surf.del();
}

To deform the diamond panel, a surface is created by an array of 3 by 3 control points instead of 4 corner points. The corners of matrix of 3 by 3 control points array have same corner points with the previous code. Other points are mid points of each edge and the center of the panel region. The degree of the surface is changed to 2 to have curved shape.

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

size(480, 360, IG.GL);

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

for (ISurface surf : surfaces) {
  int unum = 36, vnum = 24;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      if ( (i+j)%2==0 ) {
        IVec[][]cpts = new IVec[3][3];
        // corner 1
        cpts[0][0] = surf.pt( (i-1)*uinc, j*vinc );
        cpts[1][0] = surf.pt( (i-0.5)*uinc, (j+0.5)*vinc );
        // corner 2
        cpts[2][0] = surf.pt( i*uinc, (j+1)*vinc );
        cpts[2][1] = surf.pt( (i+0.5)*uinc, (j+0.5)*vinc );
        // corner 3
        cpts[2][2] = surf.pt( (i+1)*uinc, j*vinc );
        cpts[1][2] = surf.pt( (i+0.5)*uinc, (j-0.5)*vinc );
        // corner 4
        cpts[0][2] = surf.pt( i*uinc, (j-1)*vinc );
        cpts[0][1] = surf.pt( (i-0.5)*uinc, (j-0.5)*vinc );
        // center
        cpts[1][1] = surf.pt( i*uinc, j*vinc, -1 );

        new ISurface( cpts, 2, 2 ).clr(0.3, 0.4*j*vinc, i*uinc*0.8);
      }
    }
  }
  surf.del();
}

Then the front corner of a diamond panel is shifted up. Now depth of center point and the depth of the front shift is controlled by the variable centerDepth and frontDepth.

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

size(480, 360, IG.GL);

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

for (ISurface surf : surfaces) {
  int unum = 36, vnum = 24;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {
      if ( (i+j)%2==0 ) {
        double centerDepth = -1.5;
        double frontDepth = -1;

        IVec[][]cpts = new IVec[3][3];
        // corner 1
        cpts[0][0] = surf.pt( (i-1)*uinc, j*vinc );
        cpts[1][0] = surf.pt( (i-0.5)*uinc, (j+0.5)*vinc );
        // corner 2
        cpts[2][0] = surf.pt( i*uinc, (j+1)*vinc );
        cpts[2][1] = surf.pt( (i+0.5)*uinc, (j+0.5)*vinc,
                              frontDepth/2 );
        // corner 3
        cpts[2][2] = surf.pt( (i+1)*uinc, j*vinc,
                              frontDepth );
        cpts[1][2] = surf.pt( (i+0.5)*uinc, (j-0.5)*vinc,
                              frontDepth/2 );
        // corner 4
        cpts[0][2] = surf.pt( i*uinc, (j-1)*vinc );
        cpts[0][1] = surf.pt( (i-0.5)*uinc, (j-0.5)*vinc );
        // center
        cpts[1][1] = surf.pt( i*uinc, j*vinc, centerDepth );

        new ISurface( cpts, 2, 2 ).clr(0.3, 0.4*j*vinc, i*uinc*0.8);
      }
    }
  }
  surf.del();
}

Finally, the diagrid structure is added underneath the diamond panels. The image map is also introduced and the input bitmap is controlling the depths of panels.

The input bitmap used in the example is this.


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

size(480, 360, IG.GL);

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

IImageMap map = new IImageMap("map4.jpg");

for (ISurface surf : surfaces) {
  int unum = 36, vnum = 24;
  double uinc = 1.0/unum, vinc = 1.0/vnum;

  for (int i=0; i < unum; i++) {
    for (int j=0; j < vnum; j++) {

      if ( (i+j)%2==0 ) {
        double val = map.get(i*uinc, j*vinc);
        
        double centerDepth = -2*val;
        double frontDepth = -1.5*val;
        
        IVec[][]cpts = new IVec[3][3];
        // corner 1
        cpts[0][0] = surf.pt( (i-1)*uinc, j*vinc );
        cpts[1][0] = surf.pt( (i-0.5)*uinc, (j+0.5)*vinc );
        // corner 2
        cpts[2][0] = surf.pt( i*uinc, (j+1)*vinc );
        cpts[2][1] = surf.pt( (i+0.5)*uinc, (j+0.5)*vinc,
                              frontDepth/2 );
        // corner 3
        cpts[2][2] = surf.pt( (i+1)*uinc, j*vinc,
                              frontDepth );
        cpts[1][2] = surf.pt( (i+0.5)*uinc, (j-0.5)*vinc,
                              frontDepth/2 );
        // corner 4
        cpts[0][2] = surf.pt( i*uinc, (j-1)*vinc );
        cpts[0][1] = surf.pt( (i-0.5)*uinc, (j-0.5)*vinc );
        // center
        cpts[1][1] = surf.pt( i*uinc, j*vinc, centerDepth );

        new ISurface(cpts, 2, 2).clr(0.3, 0.4*j*vinc, i*uinc*0.8);
        
        double structureDepth = 0.1;
        double structureRadius = 0.05;
        IVec pt1 = surf.pt( (i-1)*uinc, j*vinc,
                            structureDepth);
        IVec pt2 = surf.pt( i*uinc, (j+1)*vinc,
                            structureDepth);
        IVec pt3 = surf.pt( (i+1)*uinc, j*vinc,
                            structureDepth);
        IVec pt4 = surf.pt( i*uinc, (j-1)*vinc,
                            structureDepth);
        new ICylinder(pt1,pt2,structureRadius).clr(0.2);
        new ICylinder(pt1,pt4,structureRadius).clr(0.2);
        if(j == 0 && i < unum-1){
          new ICylinder(pt3,pt4,structureRadius).clr(0.2);
        }      
        if(j == vnum-1 && i < unum-1){
          new ICylinder(pt2,pt3,structureRadius).clr(0.2);
        }
      }
    }
  }
  surf.del();
}


(back to the list of tutorials)

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