void CVolumeAdapter::get(CArray3Dd &a) { if(!src_) return; unsigned int w=a.width(), h=a.height(), d=a.depth(); ANLFloatType pi2=3.141592*2.0; for(unsigned int x=0; x<w; ++x) { for(unsigned int y=0; y<h; ++y) { for(unsigned int z=0; z<d; ++z) { ANLFloatType p=(ANLFloatType)x / (ANLFloatType)w; ANLFloatType q=(ANLFloatType)y / (ANLFloatType)h; ANLFloatType r=(ANLFloatType)z / (ANLFloatType)d; ANLFloatType nx,ny,nz,nw,nu,nv,val=0.0; ANLFloatType dx, dy, dz; switch(mode_) { case SEAMLESS_NONE: { nx=ranges_.mapx0 + p*(ranges_.mapx1-ranges_.mapx0); ny=ranges_.mapy0 + q*(ranges_.mapy1-ranges_.mapy0); nz=ranges_.mapz0 + r*(ranges_.mapz1-ranges_.mapz0); val=src_->get(nx,ny,nz); break; } case SEAMLESS_X: { dx=ranges_.loopx1-ranges_.loopx0; dy=ranges_.mapy1-ranges_.mapy0; dz=ranges_.mapz1-ranges_.mapz0; p=p*(ranges_.mapx1-ranges_.mapx0)/(ranges_.loopx1-ranges_.loopx0); nx=ranges_.loopx0 + cos(p*pi2) * dx/pi2; ny=ranges_.loopx0 + sin(p*pi2) * dx/pi2; nz=ranges_.mapy0 + q*dy; nw=ranges_.mapz0 + r*dz; val=src_->get(nx,ny,nz,nw); break; } case SEAMLESS_Y: { dx=ranges_.mapx1-ranges_.mapx0; dy=ranges_.loopy1-ranges_.loopy0; dz=ranges_.mapz1-ranges_.mapz0; q=q*(ranges_.mapy1-ranges_.mapy0)/(ranges_.loopy1-ranges_.loopy0); nx=ranges_.mapx0 + p*dx; ny=ranges_.loopy0 + cos(q*pi2) * dy/pi2; nz=ranges_.loopy0 + sin(q*pi2) * dy/pi2; nw=ranges_.mapz0 + r*dz; val=src_->get(nx,ny,nz,nw); break; } case SEAMLESS_Z: { dx=ranges_.mapx1-ranges_.mapx0; dy=ranges_.mapy1-ranges_.mapy0; dz=ranges_.loopz1-ranges_.loopz0; nx=ranges_.mapx0 + p*dx; ny=ranges_.mapy0 + p*dx; r=r*(ranges_.mapz1-ranges_.mapz0)/(ranges_.loopz1-ranges_.loopz0); nz=ranges_.loopz0 + cos(r*pi2) * dz/pi2; nw=ranges_.loopz0 + sin(r*pi2) * dz/pi2; val=src_->get(nx,ny,nz,nw); break; } case SEAMLESS_XY: { dx=ranges_.loopx1-ranges_.loopx0; dy=ranges_.loopy1-ranges_.loopy0; dz=ranges_.mapz1-ranges_.mapz0; p=p*(ranges_.mapx1-ranges_.mapx0)/(ranges_.loopx1-ranges_.loopx0); q=q*(ranges_.mapy1-ranges_.mapy0)/(ranges_.loopy1-ranges_.loopy0); nx=ranges_.loopx0 + cos(p*pi2) * dx/pi2; ny=ranges_.loopx0 + sin(p*pi2) * dx/pi2; nz=ranges_.loopy0 + cos(q*pi2) * dy/pi2; nw=ranges_.loopy0 + sin(q*pi2) * dy/pi2; nu=ranges_.mapz0 + r*dz; val=src_->get(nx,ny,nz,nw,nu,0); break; } case SEAMLESS_XZ: { dx=ranges_.loopx1-ranges_.loopx0; dy=ranges_.mapy1-ranges_.mapy0; dz=ranges_.loopz1-ranges_.loopz0; p=p*(ranges_.mapx1-ranges_.mapx0)/(ranges_.loopx1-ranges_.loopx0); r=r*(ranges_.mapz1-ranges_.mapz0)/(ranges_.loopz1-ranges_.loopz0); nx=ranges_.loopx0 + cos(p*pi2) * dx/pi2; ny=ranges_.loopx0 + sin(p*pi2) * dx/pi2; nz=ranges_.mapy0 + q*dy; nw=ranges_.loopz0 + cos(r*pi2) * dz/pi2; nu=ranges_.loopz0 + sin(r*pi2) * dz/pi2; val=src_->get(nx,ny,nz,nw,nu,0); break; } case SEAMLESS_YZ: { dx=ranges_.mapx1-ranges_.mapx0; dy=ranges_.loopy1-ranges_.loopy0; dz=ranges_.loopz1-ranges_.loopz0; q=q*(ranges_.mapy1-ranges_.mapy0)/(ranges_.loopy1-ranges_.loopy0); r=r*(ranges_.mapz1-ranges_.mapz0)/(ranges_.loopz1-ranges_.loopz0); nx=ranges_.mapx0 + p*dx; ny=ranges_.loopy0 + cos(q*pi2)*dy/pi2; nz=ranges_.loopy0 + sin(q*pi2)*dy/pi2; nw=ranges_.loopz0 + cos(r*pi2)*dz/pi2; nu=ranges_.loopz0 + sin(r*pi2)*dz/pi2; val=src_->get(nx,ny,nz,nw,nu,0); break; } default: { dx=ranges_.loopx1-ranges_.loopx0; dy=ranges_.loopy1-ranges_.loopy0; dz=ranges_.loopz1-ranges_.loopz0; p=p*(ranges_.mapx1-ranges_.mapx0)/(ranges_.loopx1-ranges_.loopx0); q=q*(ranges_.mapy1-ranges_.mapy0)/(ranges_.loopy1-ranges_.loopy0); r=r*(ranges_.mapz1-ranges_.mapz0)/(ranges_.loopz1-ranges_.loopz0); nx=ranges_.loopx0 + cos(p*pi2) * dx/pi2; ny=ranges_.loopx0 + sin(p*pi2) * dx/pi2; nz=ranges_.loopy0 + cos(q*pi2)*dy/pi2; nw=ranges_.loopy0 + sin(q*pi2)*dy/pi2; nu=ranges_.loopz0 + cos(r*pi2)*dz/pi2; nv=ranges_.loopz0 + sin(r*pi2)*dz/pi2; val=src_->get(nx,ny,nz,nw,nu,nv); break; } }; a.set(x,y,z,val); } } } }
void map3D(int seamlessmode, CArray3Dd &a, CImplicitModuleBase &m, SMappingRanges &ranges) { size_t w=a.width(); size_t h=a.height(); size_t d=a.depth(); size_t x,y,z; static double pi2=3.14159265 * 2.0; for(x=0; x<w; ++x) { for(y=0; y<h; ++y) { for(z=0; z<d; ++z) { double p=(double)x/(double)w; double q=(double)y/(double)h; double r=(double)z/(double)d; double nx,ny,nz,nw,nu,nv; double dx,dy,dz; double val=0.0; switch(seamlessmode) { case SEAMLESS_NONE: { dx=ranges.mapx1-ranges.mapx0; dy=ranges.mapy1-ranges.mapy0; dz=ranges.mapz1-ranges.mapz0; nx=ranges.mapx0 + p*dx; ny=ranges.mapy0 + q*dy; nz=ranges.mapz0 + r*dz; val=m.get(nx,ny,nz); } break; case SEAMLESS_X: { dx=ranges.loopx1-ranges.loopx0; dy=ranges.mapy1-ranges.mapy0; dz=ranges.mapz1-ranges.mapz0; p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0); nx=ranges.loopx0 + cos(p*pi2)*dx/pi2; ny=ranges.loopx0 + sin(p*pi2)*dx/pi2; nz=ranges.mapy0 + q*dy; nw=ranges.mapz0 + d*dz; val=m.get(nx,ny,nz,nw); } case SEAMLESS_Y: { dx=ranges.mapx1-ranges.mapx0; dy=ranges.loopy1-ranges.loopy0; dz=ranges.mapz1-ranges.mapz0; q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0); nx=ranges.mapx0 + p*dx; ny=ranges.loopy0 + cos(q*pi2)*dy/pi2; nz=ranges.loopy0 + sin(q*pi2)*dy/pi2; nw=ranges.mapz0 + r*dz; val=m.get(nx,ny,nz,nw); } break; case SEAMLESS_Z: { dx=ranges.mapx1-ranges.mapx0; dy=ranges.mapy1-ranges.mapy0; dz=ranges.loopz1-ranges.loopz0; r=r*(ranges.mapz1-ranges.mapz0)/(ranges.loopz1-ranges.loopz0); nx=ranges.mapx0 + p*dx; ny=ranges.mapy0 + q*dy; nz=ranges.loopz0 + cos(r*pi2)*dz/pi2; nw=ranges.loopz0 + sin(r*pi2)*dz/pi2; val=m.get(nx,ny,nz,nw); } break; case SEAMLESS_XY: { dx=ranges.loopx1-ranges.loopx0; dy=ranges.loopy1-ranges.loopy0; dz=ranges.mapz1-ranges.mapz0; p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0); q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0); nx=ranges.loopx0 + cos(p*pi2)*dx/pi2; ny=ranges.loopx0 + sin(p*pi2)*dx/pi2; nz=ranges.loopy0 + cos(q*pi2)*dy/pi2; nw=ranges.loopy0 + sin(q*pi2)*dy/pi2; nu=ranges.mapz0 + r*dz; val=m.get(nx,ny,nz,nw,nu,0); } break; case SEAMLESS_XZ: { dx=ranges.loopx1-ranges.loopx0; dy=ranges.mapy1-ranges.mapy0; dz=ranges.loopz1-ranges.loopz0; p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0); r=r*(ranges.mapz1-ranges.mapz0)/(ranges.loopz1-ranges.loopz0); nx=ranges.loopx0 + cos(p*pi2)*dx/pi2; ny=ranges.loopx0 + sin(p*pi2)*dx/pi2; nz=ranges.mapy0 + q*dy; nw=ranges.loopz0 + cos(r*pi2)*dz/pi2; nu=ranges.loopz0 + sin(r*pi2)*dz/pi2; val=m.get(nx,ny,nz,nw,nu,0); } break; case SEAMLESS_YZ: { dx=ranges.mapx1-ranges.mapx0; dy=ranges.loopy1-ranges.loopy0; dz=ranges.loopz1-ranges.loopz0; q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0); r=r*(ranges.mapz1-ranges.mapz0)/(ranges.loopz1-ranges.loopz0); nx=ranges.mapx0 + p*dx; ny=ranges.loopy0 + cos(q*pi2)*dy/pi2; nz=ranges.loopy0 + sin(q*pi2)*dy/pi2; nw=ranges.loopz0 + cos(r*pi2)*dz/pi2; nu=ranges.loopz0 + sin(r*pi2)*dz/pi2; val=m.get(nx,ny,nz,nw,nu,0); } break; case SEAMLESS_XYZ: { dx=ranges.loopx1-ranges.loopx0; dy=ranges.loopy1-ranges.loopy0; dz=ranges.loopz1-ranges.loopz0; p=p*(ranges.mapx1-ranges.mapx0)/(ranges.loopx1-ranges.loopx0); q=q*(ranges.mapy1-ranges.mapy0)/(ranges.loopy1-ranges.loopy0); r=r*(ranges.mapz1-ranges.mapz0)/(ranges.loopz1-ranges.loopz0); nx=ranges.loopx0 + cos(p*pi2)*dx/pi2; ny=ranges.loopx0 + sin(p*pi2)*dx/pi2; nz=ranges.loopy0 + cos(q*pi2)*dy/pi2; nw=ranges.loopy0 + sin(q*pi2)*dy/pi2; nu=ranges.loopz0 + cos(r*pi2)*dz/pi2; nv=ranges.loopz0 + sin(r*pi2)*dz/pi2; val=m.get(nx,ny,nz,nw,nu,nv); } break; default: break; } a.set(x,y,z,val); } } } }