72 fLowerCorner = TVector3(xMin,yMin,zMin);
73 fUpperCorner = TVector3(xMax,yMax,zMax);
96 TVector3 Steps = TVector3(fxSteps, fySteps, fzSteps);
105 ( GetSteps() == right.
GetSteps()) );
111 return fxSteps * fySteps * fzSteps;
117 const double xyz[3] = {p.X(), p.Y(), p.Z()};
118 return GetVoxelID(xyz);
125 int xStep = int ((Position[0]-fLowerCorner[0]) / (fUpperCorner[0]-fLowerCorner[0]) * fxSteps );
126 int yStep = int ((Position[1]-fLowerCorner[1]) / (fUpperCorner[1]-fLowerCorner[1]) * fySteps );
127 int zStep = int ((Position[2]-fLowerCorner[2]) / (fUpperCorner[2]-fLowerCorner[2]) * fzSteps );
130 if((0 <= xStep) && (xStep < fxSteps) &&
131 (0 <= yStep) && (yStep < fySteps) &&
132 (0 <= zStep) && (zStep < fzSteps) ){
136 + zStep * (fxSteps * fySteps));
153 for(
int i = 0; i < 3; ++i){
156 if(v[i] < fLowerCorner[i] || v[i] > fUpperCorner[i])
return;
158 rStepD[i] = ((v[i]-fLowerCorner[i]) / (fUpperCorner[i]-fLowerCorner[i]) * GetSteps()[i] ) - 0.5;
162 for(
int dx = 0; dx <= 1; ++dx){
163 for(
int dy = 0; dy <= 1; ++dy){
164 for(
int dz = 0; dz <= 1; ++dz){
166 const int dr[3] = {dx, dy, dz};
170 for(
int d = 0;
d < 3; ++
d){
172 rStepI[
d] = int(rStepD[
d]);
175 rStepI[
d] =
std::min(rStepI[d],
int(GetSteps()[d])-2);
181 for(
int d = 0;
d < 3; ++
d){
185 w *= 1+rStepI[
d]-rStepD[
d];
187 w *= 1-rStepI[
d]+rStepD[
d];
190 const int id = (rStepI[0] +
191 rStepI[1] * (fxSteps) +
192 rStepI[2] * (fxSteps * fySteps));
194 ret.emplace_back(
id, w);
201 for(
const NeiInfo&
n: ret) wSum +=
n.weight;
202 if(fabs(wSum-1) > 1
e-3){
203 std::cout <<
"PhotonVoxelDef::GetNeighboringVoxelIDs(): " 204 <<
"Weights sum to " << wSum <<
" (should be 1). " 206 for(
const NeiInfo&
n: ret) std::cout <<
" " <<
n.weight;
207 std::cout <<
" Aborting." << std::endl;
215 TVector3 TheSize = TVector3((GetRegionUpperCorner()[0]-GetRegionLowerCorner()[0]) / fxSteps,
216 (GetRegionUpperCorner()[1]-GetRegionLowerCorner()[1]) / fySteps,
217 (GetRegionUpperCorner()[2]-GetRegionLowerCorner()[2]) / fzSteps);
228 int xStep = ID % fxSteps ;
229 int yStep = ((ID - xStep ) / fxSteps) % fySteps ;
230 int zStep = ((ID - xStep - (yStep * fxSteps)) / (fySteps * fxSteps)) % fzSteps ;
233 TVector3 VoxelSize = GetVoxelSize();
235 double xMin = VoxelSize[0] * (xStep) + fLowerCorner[0];
236 double xMax = VoxelSize[0] * (xStep+1) + fLowerCorner[0];
237 double yMin = VoxelSize[1] * (yStep) + fLowerCorner[1];
238 double yMax = VoxelSize[1] * (yStep+1) + fLowerCorner[1];
239 double zMin = VoxelSize[2] * (zStep) + fLowerCorner[2];
240 double zMax = VoxelSize[2] * (zStep+1) + fLowerCorner[2];
244 return PhotonVoxel(xMin, xMax, yMin, yMax, zMin, zMax);
250 return (( ID > -1) && (ID<GetNVoxels()));
255 std::vector<int> ReturnVector;
256 ReturnVector.resize(3);
257 ReturnVector.at(0) = ID % fxSteps ;
258 ReturnVector.at(1) = ((ID - ReturnVector.at(0) ) / fxSteps) % fySteps ;
259 ReturnVector.at(2) = ((ID - ReturnVector.at(0) - (ReturnVector.at(1) * fxSteps)) / (fySteps * fxSteps)) % fzSteps ;
void GetNeighboringVoxelIDs(const TVector3 &v, std::vector< NeiInfo > &ret) const
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
TVector3 GetSteps() const
bool operator==(const PhotonVoxelDef &rhs) const
TVector3 GetRegionLowerCorner() const
TVector3 GetCenter() const
TVector3 GetUpperCorner() const
TVector3 GetRegionUpperCorner() const
TVector3 GetLowerCorner() const
TVector3 GetVoxelSize() const
int GetVoxelID(const TVector3 &) const
bool IsLegalVoxelID(int) const
std::vector< int > GetVoxelCoords(int ID) const
PhotonVoxel GetPhotonVoxel(int ID) const