DatasetSettings: Clarify logic for unit cell verification prior to assignment

This commit is contained in:
2026-04-15 15:46:10 +02:00
parent 1ea5de347d
commit d696d1298a
+12 -14
View File
@@ -103,20 +103,18 @@ DatasetSettings &DatasetSettings::Compression(CompressionAlgorithm input) {
}
DatasetSettings &DatasetSettings::SetUnitCell(const std::optional<UnitCell> &cell) {
if (cell
&& (cell->a > 0.0) && std::isfinite(cell->a)
&& (cell->b > 0.0) && std::isfinite(cell->b)
&& (cell->c > 0.0) && std::isfinite(cell->c)
&& (cell->alpha > 0.0) && std::isfinite(cell->alpha)
&& (cell->beta > 0.0) && std::isfinite(cell->beta)
&& (cell->gamma > 0.0) && std::isfinite(cell->gamma)) {
check_min("Angle alpha", cell->alpha, 0);
check_min("Angle beta", cell->beta, 0);
check_min("Angle gamma", cell->gamma, 0);
check_max("Angle alpha", cell->alpha, 360);
check_max("Angle beta", cell->beta, 360);
// If one or more cell parameters are zero - assume cell is not provided
// But if all parameters non-zero - throw exception for non-sense values
if (cell && (cell->a != 0) && (cell->b != 0) && (cell->c != 0)
&& (cell->alpha != 0) && (cell->beta != 0) && (cell->gamma != 0)) {
check_min("Unit cell a", cell->a, 0.1);
check_min("Unit cell b", cell->b, 0.1);
check_min("Unit cell c", cell->c, 0.1);
check_min("Angle alpha", cell->alpha, 5.0);
check_min("Angle beta", cell->beta, 5.0);
check_min("Angle gamma", cell->gamma, 5.0);
check_max("Angle alpha", cell->alpha, 355.0);
check_max("Angle beta", cell->beta, 355.0);
check_max("Angle gamma", cell->gamma, 360);
unit_cell = cell;
} else