![]() | (back to the list of tutorials) |
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i<=unum; i++){ for(int j=0; j<=vnum; j++){ for(int k=0; k<=wnum; k++){ // sample a point coordinates IVec pt = vol.pt(i*uinc, j*vinc, k*winc); // creating a point new IPoint(pt).clr(i*uinc, j*vinc, k*winc); } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i<=unum; i++){ for(int j=0; j<=vnum; j++){ for(int k=0; k<=wnum; k++){ IVec pt1 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt2 = vol.pt((i+1)*uinc, j*vinc, k*winc); if(i < unum){ // drawing a line new ICurve(pt1, pt2).clr(1.0,0,0); } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i<=unum; i++){ for(int j=0; j<=vnum; j++){ for(int k=0; k<=wnum; k++){ IVec pt11 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt21 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt12 = vol.pt(i*uinc, (j+1)*vinc, k*winc); if(i < unum){ // drawing a line in U direction new ICurve(pt11, pt21).clr(1.0,0,0); } if(j < vnum){ // drawing a line in V direction new ICurve(pt11, pt12).clr(0,1.0,0); } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i<=unum; i++){ for(int j=0; j<=vnum; j++){ for(int k=0; k<=wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); if(i < unum){ // drawing a line in U direction new ICurve(pt111, pt211).clr(1.0,0,0); } if(j < vnum){ // drawing a line in V direction new ICurve(pt111, pt121).clr(0,1.0,0); } if(k < wnum){ // drawing a line in W direction new ICurve(pt111, pt112).clr(0,0,1.0); } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); if(i < unum && j < vnum){ // drawing a diagonal line in UV direction new ICurve(pt111, pt221).clr(1.0,0,0); } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 8; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); if(i < unum && j < vnum){ if((i+j)%2==0){ // UV diagonal line new ICurve(pt111, pt221).clr(1.0,0,0); } else{ // UV line in another diagonal direction new ICurve(pt211, pt121).clr(0,0,1.0); } } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); //importing a Rhino file, whose file version needs to be Rhino 4. >_< IG.open("surfs.3dm"); ISurface[] surfs = IG.surfaces(); ArrayList< ISurface > surfArray = new ArrayList< ISurface >(); for(int i=0; i < surfs.length; i++){ surfArray.add(surfs[i]); } //sorting surfaces in X by the approx center points ISort.sort(surfArray, new ISurfaceXComparator()); // ISort.sort(surfArray, new ISurfaceYComparator()); // ISort.sort(surfArray, new ISurfaceZComparator()); surfs = surfArray.toArray(surfs); //number of control points in U and V needs to be all same. int ucpNum = surfs[0].ucpNum(); int vcpNum = surfs[0].vcpNum(); int wcpNum = surfs.length; //U and V degree are set to be the same with the imported surface. int udeg = surfs[0].udeg(); int vdeg = surfs[0].vdeg(); //W degree can be set as you wish. int wdeg = 3; IVec[][][] cpts = new IVec[ucpNum][vcpNum][wcpNum]; for(int i=0; i < ucpNum; i++){ for(int j=0; j < vcpNum; j++){ for(int k=0; k < wcpNum; k++){ cpts[i][j][k] = surfs[k].cp(i,j); } } } //delete the imported surfaces. //IG.del(surfs); IVolume vol = new IVolume(cpts, udeg, vdeg, wdeg).clr(1.0,1.0,0); int unum = 8; int vnum = 10; int wnum = 12; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); if(i < unum && j < vnum){ if((i+j)%2==0){ // UV diagonal line new ICurve(pt111, pt221).clr(1.0,0,0); } else{ // UV line in another diagonal direction new ICurve(pt211, pt121).clr(0,0,1.0); } } } } } }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); //importing a Rhino file, whose file version needs to be Rhino 4. >_< IG.open("surfs.3dm"); ISurface[] surfs = IG.surfaces(); ArrayList< ISurface > surfArray = new ArrayList< ISurface >(); for(int i=0; i < surfs.length; i++){ surfArray.add(surfs[i]); } //sorting surfaces in X by the approx center points ISort.sort(surfArray, new ISurfaceXComparator()); // ISort.sort(surfArray, new ISurfaceYComparator()); // ISort.sort(surfArray, new ISurfaceZComparator()); surfs = surfArray.toArray(surfs); //number of control points in U and V needs to be all same. int ucpNum = surfs[0].ucpNum(); int vcpNum = surfs[0].vcpNum(); int wcpNum = surfs.length; int udeg = surfs[0].udeg(); //U and V degree are set to be the same with the imported surface. int vdeg = surfs[0].vdeg(); int wdeg = 3; //W degree can be set as you wish. IVec[][][] cpts = new IVec[ucpNum][vcpNum][wcpNum]; for(int i=0; i < ucpNum; i++){ for(int j=0; j < vcpNum; j++){ for(int k=0; k < wcpNum; k++){ cpts[i][j][k] = surfs[k].cp(i,j); } } } IG.del(surfs); //delete the imported surfaces. IVolume vol = new IVolume(cpts, udeg, vdeg, wdeg).clr(1.0,1.0,0); int unum = 8; int vnum = 10; int wnum = 12; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); if(i < unum && j < vnum){ new ICurve(pt111, pt221).clr(1.0,1.0,0); } if(j < vnum && k < wnum){ new ICurve(pt111, pt122).clr(0,1.0,1.0); } if(k < wnum && i < unum){ new ICurve(pt111, pt212).clr(1.0,0,1.0); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); //importing a Rhino file, whose file version needs to be Rhino 4. >_< IG.open("surfs.3dm"); ISurface[] surfs = IG.surfaces(); ArrayList< ISurface > surfArray = new ArrayList< ISurface >(); for(int i=0; i < surfs.length; i++){ surfArray.add(surfs[i]); } //sorting surfaces in X by the approx center points ISort.sort(surfArray, new ISurfaceXComparator()); // ISort.sort(surfArray, new ISurfaceYComparator()); // ISort.sort(surfArray, new ISurfaceZComparator()); surfs = surfArray.toArray(surfs); //number of control points in U and V needs to be all same. int ucpNum = surfs[0].ucpNum(); int vcpNum = surfs[0].vcpNum(); int wcpNum = surfs.length; int udeg = surfs[0].udeg(); //U and V degree are set to be the same with the imported surface. int vdeg = surfs[0].vdeg(); int wdeg = 3; //W degree can be set as you wish. IVec[][][] cpts = new IVec[ucpNum][vcpNum][wcpNum]; for(int i=0; i < ucpNum; i++){ for(int j=0; j < vcpNum; j++){ for(int k=0; k < wcpNum; k++){ cpts[i][j][k] = surfs[k].cp(i,j); } } } IG.del(surfs); //delete the imported surfaces. IVolume vol = new IVolume(cpts, udeg, vdeg, wdeg).clr(1.0,1.0,0); int unum = 6; int vnum = 8; int wnum = 10; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.1; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); if(i < unum && j < vnum){ IG.meshSquareStick(pt111, pt221, radius).clr(0.7,0.7,0.7); } if(j < vnum && k < wnum){ IG.meshSquareStick(pt111, pt122, radius).clr(0.7,0.7,0.7); } if(k < wnum && i < unum){ IG.meshSquareStick(pt111, pt212, radius).clr(0.7,0.7,0.7); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ IG.meshSquareStick(pt111, pt222, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt112, pt221, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt121, pt212, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt211, pt122, radius).clr(0.7,0.7,0.7); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ if((i+j+k)%2 == 0){ IG.meshSquareStick(pt111, pt112, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt111, pt222, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt121, pt212, radius).clr(0.7,0.7,0.7); } else{ IG.meshSquareStick(pt112, pt111, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt112, pt221, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt211, pt122, radius).clr(0.5,0.5,0.5); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ if(i%2==k%2 && j%2==k%2){ IG.meshSquareStick(pt111, pt222, radius).clr(0.7,0.7,0.7); } if(i%2==k%2 && j%2!=k%2){ IG.meshSquareStick(pt121, pt212, radius).clr(0.5,0.5,0.5); } if(i%2!=k%2 && j%2==k%2){ IG.meshSquareStick(pt211, pt122, radius).clr(0.5,0,1.0); } if(i%2!=k%2 && j%2!=k%2){ IG.meshSquareStick(pt112, pt221, radius).clr(1.0,0,1.0); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum){ IG.meshSquareStick(pt111, pt211, radius).clr(0.7,0.7,0.7); } if(j < vnum){ IG.meshSquareStick(pt111, pt121, radius).clr(0.7,0.7,0.7); } if(k < wnum){ IG.meshSquareStick(pt111, pt112, radius).clr(0.7,0.7,0.7); } if(i < unum && j < vnum){ IG.meshSquareStick(pt111, pt221, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt121, pt211, radius).clr(0.5,0.5,0.5); } if(j < vnum && k < wnum){ IG.meshSquareStick(pt111, pt122, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt112, pt121, radius).clr(0.5,0.5,0.5); } if(i < unum && k < wnum){ IG.meshSquareStick(pt111, pt212, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt112, pt211, radius).clr(0.5,0.5,0.5); } if(i < unum && j < vnum && k < wnum){ IG.meshSquareStick(pt111, pt222, radius).clr(0.5,0,1.0); IG.meshSquareStick(pt121, pt212, radius).clr(0.5,0,1.0); IG.meshSquareStick(pt211, pt122, radius).clr(0.5,0,1.0); IG.meshSquareStick(pt112, pt221, radius).clr(0.5,0,1.0); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); IVec mid1 = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, k*winc); IVec mid2 = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, (k+1)*winc); IVec center = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, (k+0.5)*winc); if(i < unum && j < vnum && k < wnum){ if((i+j+k)%2 == 0){ IG.meshSquareStick(pt111, center, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt211, center, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt121, center, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(pt221, center, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(mid2, center, radius).clr(0.7,0.7,0.7); } else{ IG.meshSquareStick(mid1, center, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt112, center, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt212, center, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt122, center, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(pt222, center, radius).clr(0.5,0.5,0.5); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); IVec mid1 = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, k*winc); IVec mid2 = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, (k+1)*winc); IVec center = vol.pt((i+0.5)*uinc, (j+0.5)*vinc, (k+0.5)*winc); if(i < unum && j < vnum && k < wnum){ if(k%2 == 0){ ICurve crv1 = new ICurve(new IVec[]{ pt111, center, mid2}, 2); ICurve crv2 = new ICurve(new IVec[]{ pt211, center, mid2}, 2); ICurve crv3 = new ICurve(new IVec[]{ pt121, center, mid2}, 2); ICurve crv4 = new ICurve(new IVec[]{ pt221, center, mid2}, 2); IG.meshSquareStick(crv1, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(crv2, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(crv3, radius).clr(0.7,0.7,0.7); IG.meshSquareStick(crv4, radius).clr(0.7,0.7,0.7); } else{ ICurve crv5 = new ICurve(new IVec[]{ pt112, center, mid1}, 2); ICurve crv6 = new ICurve(new IVec[]{ pt212, center, mid1}, 2); ICurve crv7 = new ICurve(new IVec[]{ pt122, center, mid1}, 2); ICurve crv8 = new ICurve(new IVec[]{ pt222, center, mid1}, 2); IG.meshSquareStick(crv5, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(crv6, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(crv7, radius).clr(0.5,0.5,0.5); IG.meshSquareStick(crv8, radius).clr(0.5,0.5,0.5); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); //importing a Rhino file, whose file version needs to be Rhino 4. >_< IG.open("surfs.3dm"); ISurface[] surfs = IG.surfaces(); ArrayList< ISurface > surfArray = new ArrayList< ISurface >(); for(int i=0; i < surfs.length; i++){ surfArray.add(surfs[i]); } //sorting surfaces in X by the approx center points ISort.sort(surfArray, new ISurfaceXComparator()); // ISort.sort(surfArray, new ISurfaceYComparator()); // ISort.sort(surfArray, new ISurfaceZComparator()); surfs = surfArray.toArray(surfs); //number of control points in U and V needs to be all same. int ucpNum = surfs[0].ucpNum(); int vcpNum = surfs[0].vcpNum(); int wcpNum = surfs.length; int udeg = surfs[0].udeg(); //U and V degree are set to be the same with the imported surface. int vdeg = surfs[0].vdeg(); int wdeg = 3; //W degree can be set as you wish. IVec[][][] cpts = new IVec[ucpNum][vcpNum][wcpNum]; for(int i=0; i < ucpNum; i++){ for(int j=0; j < vcpNum; j++){ for(int k=0; k < wcpNum; k++){ cpts[i][j][k] = surfs[k].cp(i,j); } } } IG.del(surfs); //delete the imported surfaces. IVolume vol = new IVolume(cpts, udeg, vdeg, wdeg).clr(1.0,1.0,0); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && k < wnum ){ new ISurface(pt111,pt121,pt122,pt112).clr(1.0,0,0); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum){ new ISurface(pt111, pt211, pt221, pt121).clr(1.0,0,0); } if(j < vnum && k < wnum){ new ISurface(pt111, pt121, pt122, pt112).clr(0,1.0,0); } if(i < unum && k < wnum){ new ISurface(pt111, pt211, pt212, pt112).clr(0,0,1.0); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ new IBox(pt111, pt211, pt221, pt121, pt112, pt212, pt222, pt122).clr(1.0,0.5,0); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ if((i+j+k)%3==0){ new IBox(pt111, pt211, pt221, pt121, pt112, pt212, pt222, pt122).clr(1.0,0.5,0); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // import modules IG.open("module_surf.3dm"); ISurface moduleSrf = IG.surface(0); IG.delAll(); // clear geometries // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && k < wnum){ deform(moduleSrf.cp(), pt111, pt211, pt212, pt112).clr(1.0,0,0); } } } } vol.hide(); } // project pt in (0-1, 0-1, 0) to uv quad IVec deform(IVec pt, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ IVec upt1 = uv11.sum(uv21, pt.x); IVec upt2 = uv12.sum(uv22, pt.x); IVec uvpt = upt1.sum(upt2, pt.y); if(pt instanceof IVec4) uvpt = uvpt.to4d(((IVec4)pt).w()); return uvpt; } ICurve deform(ICurve crv, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < crv.cpNum(); i++){ crv.cps()[i].set(deform(crv.cp(i), uv11,uv21,uv22,uv12)); } crv.updateGraphic(); return crv; } ISurface deform(ISurface srf, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < srf.ucpNum(); i++){ for(int j=0; j < srf.vcpNum(); j++){ srf.cps()[i][j].set(deform(srf.cp(i,j), uv11,uv21,uv22,uv12)); } } srf.updateGraphic(); return srf; } IMesh deform(IMesh mesh, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < mesh.vertexNum(); i++){ mesh.vertex(i).set(deform(mesh.vertex(i).get(), uv11,uv21,uv22,uv12)); } mesh.updateGraphic(); return mesh; }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // import modules IG.open("module_surf2.3dm"); ISurface moduleSrf1 = IG.layer("module1").surface(0); ISurface moduleSrf2 = IG.layer("module2").surface(0); IG.delAll(); // clear geometries // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.4; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && k < wnum){ if(IRand.pct(50)){ deform(moduleSrf1.cp(), pt111, pt211, pt212, pt112).clr(1.0,0,0); } else{ deform(moduleSrf2.cp(), pt111, pt211, pt212, pt112).clr(1.0,0,0); } } if(i < unum && j < vnum){ if(IRand.pct(40)){ if(IRand.pct(50)){ deform(moduleSrf1.cp(), pt111, pt211, pt212, pt112).clr(1.0,0,0); } else{ deform(moduleSrf2.cp(), pt111, pt211, pt212, pt112).clr(1.0,0,0); } } } } } } vol.hide(); } // project pt in (0-1, 0-1, 0) to uv quad IVec deform(IVec pt, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ IVec upt1 = uv11.sum(uv21, pt.x); IVec upt2 = uv12.sum(uv22, pt.x); IVec uvpt = upt1.sum(upt2, pt.y); if(pt instanceof IVec4) uvpt = uvpt.to4d(((IVec4)pt).w()); return uvpt; } ICurve deform(ICurve crv, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < crv.cpNum(); i++){ crv.cps()[i].set(deform(crv.cp(i), uv11,uv21,uv22,uv12)); } crv.updateGraphic(); return crv; } ISurface deform(ISurface srf, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < srf.ucpNum(); i++){ for(int j=0; j < srf.vcpNum(); j++){ srf.cps()[i][j].set(deform(srf.cp(i,j), uv11,uv21,uv22,uv12)); } } srf.updateGraphic(); return srf; } IMesh deform(IMesh mesh, IVec uv11, IVec uv21, IVec uv22, IVec uv12){ for(int i=0; i < mesh.vertexNum(); i++){ mesh.vertex(i).set(deform(mesh.vertex(i).get(), uv11,uv21,uv22,uv12)); } mesh.updateGraphic(); return mesh; }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // import modules IG.open("module_brep.3dm"); IBrep moduleBrep = IG.brep(0); IG.delAll(); // clear geometries // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ deform(moduleBrep.cp(), pt111, pt211, pt221, pt121, pt112, pt212, pt222, pt122).clr(0.5,0.5,0.5); } } } } vol.hide(); } // project pt in (0-1, 0-1, 0-1) to uvw cube IVec deform(IVec pt, IVec uvw111, IVec uvw211, IVec uvw221, IVec uvw121, IVec uvw112, IVec uvw212, IVec uvw222, IVec uvw122){ IVec upt11 = uvw111.sum(uvw211, pt.x); IVec upt21 = uvw121.sum(uvw221, pt.x); IVec upt22 = uvw122.sum(uvw222, pt.x); IVec upt12 = uvw112.sum(uvw212, pt.x); IVec uvpt1 = upt11.sum(upt21, pt.y); IVec uvpt2 = upt12.sum(upt22, pt.y); IVec uvwpt = uvpt1.sum(uvpt2, pt.z); if(pt instanceof IVec4) uvwpt = uvwpt.to4d(((IVec4)pt).w()); return uvwpt; } ISurface deform(ISurface srf, IVec uvw111, IVec uvw211, IVec uvw221, IVec uvw121, IVec uvw112, IVec uvw212, IVec uvw222, IVec uvw122){ for(int i=0; i < srf.ucpNum(); i++){ for(int j=0; j < srf.vcpNum(); j++){ srf.cps()[i][j].set(deform(srf.cp(i,j), uvw111,uvw211,uvw221,uvw121,uvw112,uvw212,uvw222,uvw122)); } } srf.updateGraphic(); return srf; } IMesh deform(IMesh mesh, IVec uvw111, IVec uvw211, IVec uvw221, IVec uvw121, IVec uvw112, IVec uvw212, IVec uvw222, IVec uvw122){ for(int i=0; i < mesh.vertexNum(); i++){ mesh.vertex(i).set(deform(mesh.vertex(i).get(), uvw111,uvw211,uvw221,uvw121,uvw112,uvw212,uvw222,uvw122)); } mesh.updateGraphic(); return mesh; } IBrep deform(IBrep brep, IVec uvw111, IVec uvw211, IVec uvw221, IVec uvw121, IVec uvw112, IVec uvw212, IVec uvw222, IVec uvw122){ for(int k=0; k < brep.surfaces.length; k++){ for(int i=0; i < brep.surfaces[k].ucpNum(); i++){ for(int j=0; j < brep.surfaces[k].vcpNum(); j++){ brep.surfaces[k].cps()[i][j].set(deform(brep.surfaces[k].cp(i,j).get(), uvw111,uvw211,uvw221,uvw121,uvw112,uvw212,uvw222,uvw122)); } } } brep.updateGraphic(); return brep; }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); IVec pt232 = vol.pt((i+1)*uinc, (j+2)*vinc, (k+1)*winc); IVec pt223 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+2)*winc); IVec pt322 = vol.pt((i+2)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ if( (i+j+k)%3==0 ){ new ISurface(pt111,pt222,pt232,pt121).clr(1.,0,0); new ISurface(pt111,pt112,pt223,pt222).clr(1.,0,1.0); new ISurface(pt111,pt211,pt322,pt222).clr(0,0,1.0); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 5; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ IVec pt111 = vol.pt(i*uinc, j*vinc, k*winc); IVec pt211 = vol.pt((i+1)*uinc, j*vinc, k*winc); IVec pt121 = vol.pt(i*uinc, (j+1)*vinc, k*winc); IVec pt221 = vol.pt((i+1)*uinc, (j+1)*vinc, k*winc); IVec pt112 = vol.pt(i*uinc, j*vinc, (k+1)*winc); IVec pt212 = vol.pt((i+1)*uinc, j*vinc, (k+1)*winc); IVec pt122 = vol.pt(i*uinc, (j+1)*vinc, (k+1)*winc); IVec pt222 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+1)*winc); IVec pt232 = vol.pt((i+1)*uinc, (j+2)*vinc, (k+1)*winc); IVec pt223 = vol.pt((i+1)*uinc, (j+1)*vinc, (k+2)*winc); IVec pt322 = vol.pt((i+2)*uinc, (j+1)*vinc, (k+1)*winc); if(i < unum && j < vnum && k < wnum){ new ISurface(vol.pt((i+0.5)*uinc, j*vinc, k*winc), vol.pt((i+0.5)*uinc, (j+1)*vinc, k*winc), vol.pt((i+0.5)*uinc, (j+1)*vinc, (k+0.5)*winc),vol.pt((i+0.5)*uinc, j*vinc, (k+0.5)*winc)).clr(0,1.0,1.0); new ISurface(vol.pt((i)*uinc, (j+0.25)*vinc, (k+0.5)*winc), vol.pt((i)*uinc, (j+0.75)*vinc, (k+0.5)*winc), vol.pt((i+1)*uinc, (j+0.75)*vinc, (k+0.5)*winc),vol.pt((i+1)*uinc, (j+0.25)*vinc, (k+0.5)*winc)).clr(0,0,1.0); new ISurface(vol.pt((i+0.25)*uinc, (j+0.5)*vinc, (k)*winc), vol.pt((i+0.75)*uinc, (j+0.5)*vinc, (k+0)*winc), vol.pt((i+0.75)*uinc, (j+0.5)*vinc, (k+1)*winc),vol.pt((i+0.25)*uinc, (j+0.5)*vinc, (k+1)*winc)).clr(0.5,0,1); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 7; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ double u = i*uinc; double v = j*vinc; double w = k*winc; if(i < unum && j < vnum && k < wnum){ if(j%2==1){ u += uinc/2; } if(k%3==1){ u+=uinc/2; v-=vinc/3; } else if(k%3==2){ u+=uinc/2; v+=vinc/3; } IVec uvw111 = new IVec(u,v,w); IVec uvw112 = new IVec(u-uinc/2, v-vinc/3, w+winc); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw122 = new IVec(u, v+vinc*2/3, w+winc); IVec uvw113 = new IVec(u, v-vinc*2/3, w+winc*2); IVec uvw123 = new IVec(u-uinc/2, v+vinc/3, w+winc*2); IVec uvw223 = new IVec(u+uinc/2, v+vinc/3, w+winc*2); IVec uvw114 = new IVec(u, v, w+winc*3); new IBox(vol.pt(uvw111), vol.pt(uvw212), vol.pt(uvw113), vol.pt(uvw112), vol.pt(uvw122), vol.pt(uvw223), vol.pt(uvw114),vol.pt(uvw123)).hsb(u, v, w); } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 7; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; double radius = 0.1; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ double u = i*uinc; double v = j*vinc; double w = k*winc; if(j%2==1){ u += uinc/2; } if(k%3==1){ u+=uinc/2; v-=vinc/3; } else if(k%3==2){ u+=uinc/2; v+=vinc/3; } IVec uvw111 = new IVec(u,v,w); IVec uvw112 = new IVec(u-uinc/2, v-vinc/3, w+winc); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw122 = new IVec(u, v+vinc*2/3, w+winc); if(uvw111.x>=0 && uvw111.x<=1 && uvw111.y>=0 && uvw111.y<=1){ if(uvw112.x>=0 && uvw112.x<=1 && uvw112.y>=0 && uvw112.y<=1){ IG.pipe(vol.pt(uvw111), vol.pt(uvw112),radius).clr(0.7,0.7,0.7); } if(uvw212.x>=0 && uvw212.x<=1 && uvw212.y>=0 && uvw212.y<=1){ IG.pipe(vol.pt(uvw111), vol.pt(uvw212),radius).clr(0.7,0.7,0.7); } if(uvw122.x>=0 && uvw122.x<=1 && uvw122.y>=0 && uvw122.y<=1){ IG.pipe(vol.pt(uvw111), vol.pt(uvw122),radius).clr(0.7,0.7,0.7); } } } } } vol.hide(); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points IVec[][][] cpts = new IVec[4][3][2]; cpts[0][0][0] = new IVec(0,0,0); cpts[0][0][1] = new IVec(0,0,10); cpts[0][1][0] = new IVec(0,10,0); cpts[0][1][1] = new IVec(0,10,10); cpts[0][2][0] = new IVec(0,20,0); cpts[0][2][1] = new IVec(0,20,10); cpts[1][0][0] = new IVec(10,0,0); cpts[1][0][1] = new IVec(10,0,10); cpts[1][1][0] = new IVec(10,10,0); cpts[1][1][1] = new IVec(10,10,10); cpts[1][2][0] = new IVec(10,20,0); cpts[1][2][1] = new IVec(10,20,10); cpts[2][0][0] = new IVec(20,0,0); cpts[2][0][1] = new IVec(20,0,20); cpts[2][1][0] = new IVec(20,5,0); cpts[2][1][1] = new IVec(20,5,20); cpts[2][2][0] = new IVec(20,10,0); cpts[2][2][1] = new IVec(20,10,20); cpts[3][0][0] = new IVec(30,0,0); cpts[3][0][1] = new IVec(30,0,20); cpts[3][1][0] = new IVec(30,5,0); cpts[3][1][1] = new IVec(30,5,20); cpts[3][2][0] = new IVec(30,10,0); cpts[3][2][1] = new IVec(30,10,20); // creating NURBS IVolume IVolume vol = new IVolume(cpts, 3, 2, 1); int unum = 6; int vnum = 5; int wnum = 6; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; for(int i=0; i <= unum; i++){ for(int j=0; j <= vnum; j++){ for(int k=0; k <= wnum; k++){ double u = i*uinc; double v = j*vinc; double w = k*winc; if(j%2==1){ u += uinc/2; } if(k%3==1){ u+=uinc/2; v-=vinc/3; } else if(k%3==2){ u+=uinc/2; v+=vinc/3; } IVec uvw111 = new IVec(u,v,w); IVec uvw112 = new IVec(u-uinc/2, v-vinc/3, w+winc); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw122 = new IVec(u, v+vinc*2/3, w+winc); IVec uvw211 = new IVec(u+uinc, v, w); IVec uvw221 = new IVec(u+uinc/2, v+vinc, w); IVec uvw121 = new IVec(u-uinc/2, v+vinc, w); IVec uvw222 = new IVec(u+uinc, v+vinc*2/3, w+winc); tetra1(vol.pt(uvw122),vol.pt(uvw111),vol.pt(uvw121),vol.pt(uvw221)).clr(1.0,0,1.0).layer("1"); tetra2(vol.pt(uvw111),vol.pt(uvw212),vol.pt(uvw122),vol.pt(uvw112)).clr(0,0,1.0).layer("2"); octa(vol.pt(uvw111),vol.pt(uvw211),vol.pt(uvw221),vol.pt(uvw212),vol.pt(uvw222),vol.pt(uvw122)).clr(0,1.0,1.0).layer("3"); } } } vol.hide(); } IBrep tetra1(IVec p1, IVec p2, IVec p3, IVec p4){ ISurfaceGeo s1 = new ISurfaceGeo(p1,p2,p3); ISurfaceGeo s2 = new ISurfaceGeo(p1,p2,p4); ISurfaceGeo s3 = new ISurfaceGeo(p2,p3,p4); ISurfaceGeo s4 = new ISurfaceGeo(p3,p1,p4); return new IBrep(new ISurfaceGeo[]{ s1,s2,s3,s4 }); } IBrep tetra2(IVec p1, IVec p2, IVec p3, IVec p4){ ISurfaceGeo s1 = new ISurfaceGeo(p1,p2,p3); ISurfaceGeo s2 = new ISurfaceGeo(p1,p2,p4); ISurfaceGeo s3 = new ISurfaceGeo(p2,p3,p4); ISurfaceGeo s4 = new ISurfaceGeo(p3,p1,p4); return new IBrep(new ISurfaceGeo[]{ s1,s2,s3,s4 }); } IBrep octa(IVec p1, IVec p2, IVec p3, IVec p4, IVec p5, IVec p6){ ISurfaceGeo s1 = new ISurfaceGeo(p1,p2,p3); ISurfaceGeo s2 = new ISurfaceGeo(p1,p2,p4); ISurfaceGeo s3 = new ISurfaceGeo(p2,p3,p5); ISurfaceGeo s4 = new ISurfaceGeo(p3,p1,p6); ISurfaceGeo s5 = new ISurfaceGeo(p4,p5,p6); ISurfaceGeo s6 = new ISurfaceGeo(p4,p5,p2); ISurfaceGeo s7 = new ISurfaceGeo(p5,p6,p3); ISurfaceGeo s8 = new ISurfaceGeo(p6,p4,p1); return new IBrep(new ISurfaceGeo[]{ s1,s2,s3,s4,s5,s6,s7,s8 }); }
import processing.opengl.*; import igeo.*; void setup(){ size(960, 720, IG.GL); // control points int rnum = 10; IVec[][][] cpts3 = new IVec[rnum+1][2][2]; for(int i=0; i<=rnum; i++){ cpts3[i][0][0] = new IVec(10,0,0).rot(i*PI/rnum/2); cpts3[i][1][0] = new IVec(15,0,0).rot(i*PI/rnum/2); cpts3[i][0][1] = new IVec(10,0,5+i*0.5).rot(i*PI/rnum/2); cpts3[i][1][1] = new IVec(15,0,5+i*0.5).rot(i*PI/rnum/2); } // creating NURBS IVolume IVolume vol = new IVolume(cpts3, 2, 1, 1); int unum = 18; int vnum = 9; int wnum = 12; double uinc = 1.0/unum; double vinc = 1.0/vnum; double winc = 1.0/wnum; IVec wdir = new IVec(0,vinc*2/3,winc).mul(2); IVec wstart = new IVec(uinc, 0, 0).mul(-unum); for(int k=0; k < wnum; k++, wstart.add(wdir)){ IVec ustart = wstart.cp(); IVec udir = new IVec(uinc,0,0).mul(2); for(int i=0; i <= unum*2; i++, ustart.add(udir)){ IVec uvwdir = new IVec(uinc/2, vinc, 0); IVec uvw = ustart.cp().add(uvwdir, -unum); for(int j=0; j <= vnum*2; j++, uvw.add(uvwdir)){ double u = uvw.x; double v = uvw.y; double w = uvw.z; if(u >= 0 && v >= 0 && w >= 0 && u <= 1 && v <= 1 && w <= 1){ IVec uvw111 = new IVec(u,v,w); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw122 = new IVec(u, v+vinc*2/3, w+winc); IVec uvw221 = new IVec(u+uinc/2, v+vinc, w); IVec uvw222 = new IVec(u+uinc, v+vinc*2/3, w+winc); IVec uvw232 = new IVec(u+uinc/2, v+vinc*5/3, w+winc); triangularPrism(vol, uvw212, uvw111, uvw122, uvw222, uvw221, uvw232).clr(0,1.0,1.0); } } } } IVec udir = new IVec(uinc, 0, 0).mul(2); IVec ustart = new IVec(0,0,0).add(udir, -unum); for(int i=0; i <= unum*2; i++, ustart.add(udir)){ IVec vdir = new IVec(-uinc/2, vinc, 0).mul(2); IVec vstart = ustart.cp(); for(int j=i%2; j <= vnum; j++, vstart.add(vdir)){ IVec uvw = vstart.cp(); IVec uvwinc = new IVec(uinc/2, -vinc/3, winc); for(int k=0; k < wnum; k++){ double u = uvw.x; double v = uvw.y; double w = uvw.z; if(u >= 0 && v >= 0 && w >= 0 && u <= 1 && v <= 1 && w <= 1){ IVec uvw111 = new IVec(u,v,w); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw211 = new IVec(u+uinc, v, w); IVec uvw221 = new IVec(u+uinc/2, v+vinc, w); IVec uvw222 = new IVec(u+uinc, v+vinc*2/3, w+winc); IVec uvw210 = new IVec(u+uinc/2, v+vinc/3, w-winc); triangularPrism(vol, uvw111, uvw221, uvw210, uvw212, uvw222, uvw211).clr(0.5,0,1.); } uvw.add(uvwinc); } } } IVec udir2 = new IVec(uinc, 0, 0).mul(2); IVec ustart2 = new IVec(0,0,0).add(udir2, -unum).add(udir, 0.5); for(int i=0; i <= unum*2; i++, ustart2.add(udir2)){ IVec vdir = new IVec(-uinc/2, vinc, 0).mul(2); IVec vstart = ustart2.cp().add(vdir, -vnum); for(int j=i%2; j <= vnum*2; j++, vstart.add(vdir)){ IVec uvw = vstart.cp(); IVec uvwinc = new IVec(0, vinc*2/3, winc); for(int k=0; k < wnum; k++, uvw.add(uvwinc)){ double u = uvw.x; double v = uvw.y; double w = uvw.z; if(u >= 0 && v >= 0 && w >= 0 && u <= 1 && v <= 1 && w <= 1){ IVec uvw101 = new IVec(u+uinc/2,v-vinc,w); IVec uvw111 = new IVec(u,v,w); IVec uvw212 = new IVec(u+uinc/2, v-vinc/3, w+winc); IVec uvw122 = new IVec(u, v+vinc*2/3, w+winc); IVec uvw211 = new IVec(u+uinc, v, w); IVec uvw222 = new IVec(u+uinc, v+vinc*2/3, w+winc); triangularPrism(vol, uvw111, uvw211, uvw101, uvw122, uvw222, uvw212).clr(1.0,0,0); } } } } vol.hide(); } ISurface triangularPrism(IVolume vol, IVec uvw11, IVec uvw12, IVec uvw13, IVec uvw21, IVec uvw22, IVec uvw23){ IVec[][] cpts = new IVec[3][2]; cpts[0][0] = vol.pt(uvw11); cpts[1][0] = vol.pt(uvw12); cpts[2][0] = vol.pt(uvw13); cpts[0][1] = vol.pt(uvw21); cpts[1][1] = vol.pt(uvw22); cpts[2][1] = vol.pt(uvw23); return new ISurface(cpts, true, false); }