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

Panelization Examples

     Panelization Example8

The following is an example of taking 2 input surfaces and building geometries between those surfaces. To use two surfaces at the same time, you assign two different variables to those surfaces, take points out of each surfaces. Note that the code below would crash if the input file doesn't contain 2 surfaces.

surface9.3dm

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

size(480, 360, IG.GL);

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

ISurface surfA = surfaces[0];
ISurface surfB = surfaces[1];

int unum = 10, vnum = 10;
double uinc = 1.0/unum, vinc = 1.0/vnum;

for (int i=0; i < unum; i++) {
  for (int j=0; j < vnum; j++) {
    IVec ptA = surfA.pt( i*uinc, j*vinc );
    IVec ptB = surfB.pt( i*uinc, j*vinc );
    new ICurve(ptA, ptB).clr(1.0,0,0);
  }
}

Then multiple points on each surface are sampled in the for-loop body and used to build more connections.

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

size(480, 360, IG.GL);

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

ISurface surfA = surfaces[0];
ISurface surfB = surfaces[1];

int unum = 10, vnum = 10;
double uinc = 1.0/unum, vinc = 1.0/vnum;

for (int i=0; i < unum; i++) {
  for (int j=0; j < vnum; j++) {
    IVec ptA11 = surfA.pt( i*uinc, j*vinc );
    IVec ptA21 = surfA.pt( (i + 1)*uinc, j*vinc );
    IVec ptA12 = surfA.pt( i*uinc, (j + 1)*vinc);
    IVec ptA22 = surfA.pt( (i + 1)*uinc, (j + 1)*vinc );

    IVec ptB11 = surfB.pt( i*uinc, j*vinc );
    IVec ptB21 = surfB.pt( (i + 1)*uinc, j*vinc );
    IVec ptB12 = surfB.pt( i*uinc, (j + 1)*vinc);
    IVec ptB22 = surfB.pt( (i + 1)*uinc, (j + 1)*vinc );

    new ICurve(ptA11, ptB11).clr(1.,0,0);
    new ICurve(ptA11, ptB22).clr(0,0,0.5);
    new ICurve(ptA12, ptB12).clr(1.0,0,1.0);
    new ICurve(ptA12, ptB21).clr(0.5,0,0.5);
    new ICurve(ptA21, ptB11).clr(0);
  }
}
surfA.del();
surfB.del();

Then those lines are piped with cylinders and triangular panels are added on the both sides.

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

size(480, 360, IG.GL);

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

ISurface surfA = surfaces[0];
ISurface surfB = surfaces[1];

int unum = 10, vnum = 10;
double uinc = 1.0/unum, vinc = 1.0/vnum;

for (int i=0; i < unum; i++) {
  for (int j=0; j < vnum; j++) {
    IVec ptA11 = surfA.pt( i*uinc, j*vinc );
    IVec ptA21 = surfA.pt( (i + 1)*uinc, j*vinc );
    IVec ptA12 = surfA.pt( i*uinc, (j + 1)*vinc);
    IVec ptA22 = surfA.pt( (i + 1)*uinc, (j + 1)*vinc );

    IVec ptB11 = surfB.pt( i*uinc, j*vinc );
    IVec ptB21 = surfB.pt( (i + 1)*uinc, j*vinc );
    IVec ptB12 = surfB.pt( i*uinc, (j + 1)*vinc);
    IVec ptB22 = surfB.pt( (i + 1)*uinc, (j + 1)*vinc );

    // triangular panels
    new ISurface(ptA11,ptA21,ptA22).clr(i*uinc,j*vinc,0,0.5);
    new ISurface(ptA22,ptA12,ptA11).clr(i*uinc,j*vinc,0,0.5);
    new ISurface(ptB11,ptB21,ptB12).clr(0,i*uinc,j*vinc,0.5);
    new ISurface(ptB21,ptB22,ptB12).clr(0,i*uinc,j*vinc,0.5);

    // frame of panels (square-piping with degree 1, closed)
    double size = 0.2;
    IG.squarePipe(new IVec[]{ptA11,ptA21,ptA22},1,true,size).clr(.2);
    IG.squarePipe(new IVec[]{ptA22,ptA12,ptA11},1,true,size).clr(0.2);
    IG.squarePipe(new IVec[]{ptB11,ptB21,ptB12},1,true,size).clr(0.2);
    IG.squarePipe(new IVec[]{ptB21,ptB22,ptB12},1,true,size).clr(0.2);

    // pipe between two surfaces
    double radius = 0.1;
    new ICylinder(ptA11, ptB11, radius).clr(1.,0,0);
    new ICylinder(ptA11, ptB22, radius).clr(0,0,0.5);
    new ICylinder(ptA12, ptB12, radius).clr(1.0,0,1.0);
    new ICylinder(ptA12, ptB21, radius).clr(0.5,0,0.5);
    new ICylinder(ptA21, ptB11, radius).clr(0);
  }
}
surfA.del();
surfB.del();


(back to the list of tutorials)

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