Skip to content

Commit

Permalink
Uniform lighting model handles negative cross section (sigma).
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoesmp committed Aug 29, 2023
1 parent a390993 commit 4eab409
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
30 changes: 21 additions & 9 deletions src/dataanalytics/HDA_SimStepRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,16 @@ void HDA_SimStepRecorder::recordScanner(){
scannerPositionZ->push(pos.z);
// Record scanner angles
double roll, pitch, yaw;
s.getHeadRelativeEmitterAttitude().getAngles(
&RotationOrder::XYZ, roll, pitch, yaw
);
try {
s.getHeadRelativeEmitterAttitude().getAngles(
&RotationOrder::XYZ, roll, pitch, yaw
);
}
catch(HeliosException &hex){
roll = std::numeric_limits<double>::quiet_NaN();
pitch = std::numeric_limits<double>::quiet_NaN();
yaw = std::numeric_limits<double>::quiet_NaN();
}
scannerRoll->push(roll);
scannerPitch->push(pitch);
scannerYaw->push(yaw);
Expand Down Expand Up @@ -398,15 +405,18 @@ void HDA_SimStepRecorder::recordStochastic(){

// Obtain parallel randomness generator
RandomnessGenerator<double> *rg1Par = nullptr;
size_t nthreads = 0;
WarehouseScanningPulseProcess * wspp =
dynamic_cast<WarehouseScanningPulseProcess *>(spp);
if(wspp != nullptr){
rg1Par = wspp->pool.randGens;
nthreads = wspp->pool.getPoolSize();
}
else{
BuddingScanningPulseProcess *bspp =
dynamic_cast<BuddingScanningPulseProcess *>(spp);
rg1Par = bspp->pool.randGens;
nthreads = wspp->pool.getPoolSize();
}

// Prepare fake pulse
Expand Down Expand Up @@ -434,12 +444,14 @@ void HDA_SimStepRecorder::recordStochastic(){
}

// Record parallel measurement error
for(size_t i = 0 ; i < N_SAMPLES ; ++i) {
err = ERR_BASE;
fwpr.applyMeasurementError(
*rg1Par, err, fakePulse.getOriginRef(), fakePulse.getOriginRef()
);
measErrPar->push(err-ERR_BASE);
if(nthreads > 0) { // There is no parallelism for empty thread pools
for (size_t i = 0; i < N_SAMPLES; ++i) {
err = ERR_BASE;
fwpr.applyMeasurementError(
*rg1Par, err, fakePulse.getOriginRef(), fakePulse.getOriginRef()
);
measErrPar->push(err - ERR_BASE);
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/helios_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const char * HELIOS_VERSION = "1.2.0";

const char * HELIOS_GIT_HASH = "03b19a3a";
const char * HELIOS_GIT_HASH = "a3909937";

const char * getHeliosVersion(){
return HELIOS_VERSION;
Expand Down
15 changes: 11 additions & 4 deletions src/scanner/ScanningDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,29 +323,36 @@ double ScanningDevice::calcIntensity(
double const targetArea,
double const radius
) const {
double bdrf = 0;
double bdrf = 0, sigma = 0;
if(mat.isPhong()) {
bdrf = mat.reflectance * EnergyMaths::phongBDRF(
incidenceAngle,
mat.specularity,
mat.specularExponent
);
sigma = EnergyMaths::calcCrossSection(
bdrf, targetArea, incidenceAngle
);
}
else if(mat.isLambert()){
bdrf = mat.reflectance * std::cos(incidenceAngle);
sigma = EnergyMaths::calcCrossSection(
bdrf, targetArea, incidenceAngle
);
}
else if(mat.isUniform()){
bdrf = mat.reflectance;
sigma = EnergyMaths::calcCrossSection(
bdrf, targetArea, incidenceAngle
);
if(sigma < 0) sigma = -sigma;
}
else{
std::stringstream ss;
ss << "Unexpected lighting model for material \""
<< mat.name << "\"";
logging::ERR(ss.str());
}
double const sigma = EnergyMaths::calcCrossSection(
bdrf, targetArea, incidenceAngle
);
return EnergyMaths::calcReceivedPower(
averagePower_w,
wavelength_m,
Expand Down

0 comments on commit 4eab409

Please sign in to comment.