
440 10. Modeling with polygonal datasets
BOOL CUBE GRID Init (CUBE GRID ∗g , i nt g r i d S i z e ){
in t i , j , k ;
in t curr entCube ;
in t c u rr ent Ve r te x =0;
g−>numVertices =( g r i d S i z e +1)∗( g r i d S i z e +1)∗( g r i d S i z e +1);
// assign lattic e vertex positions, this example is based on a cubic
// lattice centred on (0,0,0) and filling the cube [-10,10]
fo r ( i =0; i <g r i d S i z e +1; i ++) {
fo r ( j =0; j <g r i d S i z e +1; j ++){
fo r ( k=0; k<g r i d S i z e +1; k++){
g−>v e r t i c e s [ c ur ren tV e rt ex ] . p . x=
( i ∗20. 0 f ) / ( g r i d S i z e ) −10.0 f ;
. . // other positions
cur ren tV ert ex ++;
}
}
}
g−>numCu