Skip to content
Snippets Groups Projects
Verified Commit e5f0b39e authored by philippe.verley_ird.fr's avatar philippe.verley_ird.fr Committed by philippe.verley_ird.fr
Browse files

Voxelization.java: does not initialize all voxels by default for more conservative memory usage.

parent 8f8f3b7b
No related branches found
No related tags found
No related merge requests found
......@@ -53,10 +53,6 @@ public class Voxel {
* mean ray length (cumulated ray length / nbSampling)
*/
public double lMeanTotal;
/**
* approximated transmittance
*/
public double approxTransm;
/**
* numerically estimated transmittance
*/
......@@ -89,7 +85,7 @@ public class Voxel {
// variable for numerical estimation of the transmittance
public List<TrRecord> trRecords;
public boolean fallbackTransm = false;
/**
* mean distance to laser
*/
......@@ -115,9 +111,6 @@ public class Voxel {
*/
public double explorationRate;
public Voxel() {
}
public static enum MergeMode {
SUM,
......@@ -236,6 +229,21 @@ public class Voxel {
attenuationVar = new Attenuation();
}
/**
* Set some variables to NaN (zero could be ambiguous as it does not convey
* the same meaning than NaN).
*/
public void empty() {
angleMean = Double.NaN;
PadBVTotal = Double.NaN;
transmittance = Double.NaN;
distLaser = Double.NaN;
attenuation_biasCorr = Double.NaN;
attenuation = Double.NaN;
explorationRate = Double.NaN;
}
public String variablesToString(String[] names, DecimalFormat dnf) {
// voxel attributes to String
......@@ -267,7 +275,7 @@ public class Voxel {
return voxelSB.toString().trim();
}
public void addTrRecord(double bfIn, double rayLength) {
trRecords.add(new TrRecord(bfIn, rayLength));
}
......
......@@ -181,7 +181,9 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
/**
* Propagate a {@code shot} in the voxel space ignoring the vegetation in
* order to estimate a potential beam volume.
* order to estimate a potential beam volume. The method is also in charge
* of initialising the voxels since any voxel that will be crossed during
* free propagation may be crossed as well during propagation.
*
* @param shot
*/
......@@ -196,6 +198,9 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
do {
// current voxel
Point3i vcoord = context.indices;
if (null == voxels[vcoord.x][vcoord.y][vcoord.z]) {
voxels[vcoord.x][vcoord.y][vcoord.z] = initVoxel(vcoord.x, vcoord.y, vcoord.z);
}
// stop propagation if current voxel is below the ground
if (belowGround(voxels[vcoord.x][vcoord.y][vcoord.z])) {
......@@ -348,6 +353,9 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
// increment ground energy
if (groundEnergyEnabled && closeToGround(voxels[i][j][k])) {
if (null == groundEnergy[i][j]) {
groundEnergy[i][j] = new GroundEnergy();
}
groundEnergy[i][j].groundEnergyPotential++;
groundEnergy[i][j].groundEnergyActual += beamFractionIn;
}
......@@ -676,8 +684,8 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
dtm = Util.loadDTM(cfg.getVoxelParameters().getDtmFilteringParams().getDtmFile());
if (dtm != null && cfg.getVoxelParameters().getDtmFilteringParams().isUseVOPMatrix()) {
Matrix4d vop = (null == cfg.getVopMatrix())
? MatrixUtility.identity4d()
: new Matrix4d(cfg.getVopMatrix());
? MatrixUtility.identity4d()
: new Matrix4d(cfg.getVopMatrix());
dtm.setTransformationMatrix(vop);
}
}
......@@ -867,24 +875,19 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
return;
}
// empty voxel, no post-processing
if (null == voxels[i][j][k]) {
continue;
}
// unsampled voxel, no post-processing
// (may have a non zero potential beam surface though, so it
// may not be empty)
if (voxels[i][j][k].nbSampling == 0) {
voxels[i][j][k].angleMean = Double.NaN;
voxels[i][j][k].approxTransm = Double.NaN;
voxels[i][j][k].PadBVTotal = Double.NaN;
if (numEstimTransmEnabled) {
voxels[i][j][k].transmittance = Double.NaN;
}
if (wdistLaserEnabled) {
voxels[i][j][k].distLaser = Double.NaN;
}
voxels[i][j][k].attenuation_biasCorr = Double.NaN;
voxels[i][j][k].attenuation = Double.NaN;
if (subSamplingEnabled) {
voxels[i][j][k].explorationRate = Double.NaN;
}
// set to NaN some of the variables
voxels[i][j][k].empty();
continue;
}
// sampled voxel, post-processing required
Voxel voxel = voxels[i][j][k];
// mean angle
......@@ -941,13 +944,13 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
}
}
}
if (nFallback > 0) {
StringBuilder sb = new StringBuilder();
float nVoxel = parameters.infos.getSplit().x * parameters.infos.getSplit().y * parameters.infos.getSplit().z;
float fraction = 100.f * nFallback / nVoxel;
sb.append("Transmittance computation switched to fallback mode (lower precision) for ")
.append(nFallback).append("/").append((int)nVoxel).append(" voxels")
.append(nFallback).append("/").append((int) nVoxel).append(" voxels")
.append(" (~").append(String.format("%.1f", fraction)).append("%)");
LOGGER.warn(sb.toString());
}
......@@ -1055,8 +1058,6 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
voxels = new Voxel[parameters.infos.getSplit().x][parameters.infos.getSplit().y][parameters.infos.getSplit().z];
if (groundEnergyEnabled) {
// allocate
//LOGGER.info("allocate!!!!!!!!");
groundEnergy = new GroundEnergy[parameters.infos.getSplit().x][parameters.infos.getSplit().y];
for (int i = 0; i < parameters.infos.getSplit().x; i++) {
for (int j = 0; j < parameters.infos.getSplit().y; j++) {
......@@ -1065,22 +1066,13 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
}
}
// main voxel space
Scene scene = new Scene();
scene.setBoundingBox(new BoundingBox3d(parameters.infos.getMinCorner(), parameters.infos.getMaxCorner()));
voxelManager = new VoxelManager(scene, new VoxelManagerSettings(parameters.infos.getSplit(), VoxelManagerSettings.NON_TORIC_FINITE_BOX_TOPOLOGY));
// print information on main voxel space
LOGGER.info(voxelManager.getInformations());
// initialize voxel
for (int i = 0; i < parameters.infos.getSplit().x; i++) {
for (int j = 0; j < parameters.infos.getSplit().y; j++) {
for (int k = 0; k < parameters.infos.getSplit().z; k++) {
voxels[i][j][k] = initVoxel(i, j, k);
}
}
}
// sub voxel space
if (subSamplingEnabled) {
Scene subScene = new Scene();
......@@ -1121,7 +1113,14 @@ public class Voxelization extends fr.amap.commons.util.Process implements Cancel
}
public Voxel getVoxel(int i, int j, int k) {
return voxels[i][j][k];
if (null != voxels[i][j][k]) {
return voxels[i][j][k];
} else {
Voxel voxel = new Voxel(i, j, k);
voxel.empty();
return voxel;
}
}
public int getNbShotsProcessed() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment