00001
00011 #include "CuboidGridObjectPopulation.h"
00012
00013
00014 CuboidGridObjectPopulation::CuboidGridObjectPopulation(SimNetwork &net, GridPoint3D origin, Volume3DSize dims, SimObjectFactory & objFactory)
00015 : SpatialSimObjectPopulation(net, objFactory, dims[X] * dims[Y] * dims[Z]), origin(origin), dim(dims) {
00016
00017 }
00018
00019 CuboidGridObjectPopulation::CuboidGridObjectPopulation(SimNetwork &net, GridPoint3D origin, Volume3DSize dims, SimObject::ID::Vector vec)
00020 : SpatialSimObjectPopulation(net, vec), origin(origin), dim(dims) {
00021
00022 }
00023
00024 CuboidGridObjectPopulation CuboidGridObjectPopulation::subVolume(int origX, int origY, int origZ, int Xdim, int Ydim, int Zdim) const {
00025 SimObject::ID::Vector subvec(new vector<SimObject::ID::Packed>(Xdim * Ydim * Zdim)) ;
00026
00027 for (int i = 0; i < Xdim; ++i)
00028 for (int j = 0; j < Ydim; ++j)
00029 for (int k = 0; k < Zdim; ++k) {
00030 (*subvec)[Ydim * Zdim * i + Zdim * j + k] =
00031 (*id_vec)[ dim[Y] * dim[Z] * (origX + i) +
00032 dim[Z]* (origY + j) + (origZ + k) ];
00033 }
00034
00035 Volume3DSize size(Xdim, Ydim, Zdim);
00036 return CuboidGridObjectPopulation(*net, origin + GridPoint3D(origX, origY, origZ), size, subvec);
00037 }
00038
00039
00040 CuboidGridObjectPopulation CuboidGridObjectPopulation::subVolume(const GridPoint3D &orig, const Volume3DSize & size) const {
00041 SimObject::ID::Vector subvec(new vector<SimObject::ID::Packed>(size[X] * size[Y] * size[Z]));
00042 for (unsigned i = 0; i < size[X]; ++i)
00043 for (unsigned j = 0; j < size[Y]; ++j)
00044 for (unsigned k = 0; k < size[Z]; ++k) {
00045 (*subvec)[size[Y] * size[Z] * i + size[Z] * j + k] =
00046 (*id_vec)[ dim[Y] * dim[Z] * (orig.x() + i) +
00047 dim[Z] * (orig.y() + j) + (orig.z() + k) ];
00048 }
00049
00050 return CuboidGridObjectPopulation(*net, origin + orig, size, subvec);
00051 }
00052
00053