Skip to content
Snippets Groups Projects
Commit a3707ec0 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm DetectorUtils; sole fct to local namespace

parent f38f4500
No related branches found
No related tags found
1 merge request!45various cleanup
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "Core/Simulation/SpecularSimulation.h" #include "Core/Simulation/SpecularSimulation.h"
#include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintGauss.h"
#include "Device/Beam/FootprintSquare.h" #include "Device/Beam/FootprintSquare.h"
#include "Device/Detector/DetectorUtils.h"
#include "Device/Detector/RectangularDetector.h" #include "Device/Detector/RectangularDetector.h"
#include "Device/Detector/RegionOfInterest.h" #include "Device/Detector/RegionOfInterest.h"
#include "Device/Detector/SphericalDetector.h" #include "Device/Detector/SphericalDetector.h"
...@@ -42,6 +41,7 @@ ...@@ -42,6 +41,7 @@
using pyfmt::indent; using pyfmt::indent;
namespace { namespace {
//! Returns a function that converts a coordinate to a Python code snippet with appropiate unit //! Returns a function that converts a coordinate to a Python code snippet with appropiate unit
std::function<std::string(double)> printFunc(const IDetector* detector) std::function<std::string(double)> printFunc(const IDetector* detector)
{ {
...@@ -52,6 +52,17 @@ std::function<std::string(double)> printFunc(const IDetector* detector) ...@@ -52,6 +52,17 @@ std::function<std::string(double)> printFunc(const IDetector* detector)
throw std::runtime_error("SimulationToPython::defineMasks() -> Error. Unknown detector units."); throw std::runtime_error("SimulationToPython::defineMasks() -> Error. Unknown detector units.");
} }
bool isQuadraticDetector(const IDetector2D& det)
{
ASSERT(det.dimension() == 2);
if (det.axis(0).size() != det.axis(1).size())
return false;
if (std::abs(det.axis(0).span() - det.axis(1).span())
> 1e-12 * (det.axis(0).span() + det.axis(1).span()))
return false;
return true;
}
//! returns true if it is (0, -1, 0) vector //! returns true if it is (0, -1, 0) vector
bool isDefaultDirection(const kvector_t direction) bool isDefaultDirection(const kvector_t direction)
{ {
...@@ -138,7 +149,7 @@ std::string defineDetector(const ISimulation* simulation) ...@@ -138,7 +149,7 @@ std::string defineDetector(const ISimulation* simulation)
if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) { if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) {
ASSERT(det->dimension() == 2); ASSERT(det->dimension() == 2);
result << indent() << "detector = ba.SphericalDetector("; result << indent() << "detector = ba.SphericalDetector(";
if (DetectorUtils::isQuadratic(*det)) { if (isQuadraticDetector(*det)) {
result << det->axis(0).size() << ", " << pyfmt::printDegrees(det->axis(0).span()) result << det->axis(0).size() << ", " << pyfmt::printDegrees(det->axis(0).span())
<< ", " << pyfmt::printDegrees(det->axis(0).center()) << ", " << ", " << pyfmt::printDegrees(det->axis(0).center()) << ", "
<< pyfmt::printDegrees(det->axis(1).center()); << pyfmt::printDegrees(det->axis(1).center());
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Device/Detector/DetectorUtils.cpp
//! @brief Implements namespace DetectorUtils.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Device/Detector/DetectorUtils.h"
#include "Device/Detector/IDetector2D.h"
bool DetectorUtils::isQuadratic(const IDetector2D& det)
{
ASSERT(det.dimension() == 2);
if (det.axis(0).size() != det.axis(1).size())
return false;
if (std::abs(det.axis(0).span() - det.axis(1).span())
> 1e-12 * (det.axis(0).span() + det.axis(1).span()))
return false;
return true;
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Device/Detector/DetectorUtils.h
//! @brief Defines namespace DetectorUtils.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_DEVICE_DETECTOR_DETECTORUTILS_H
#define BORNAGAIN_DEVICE_DETECTOR_DETECTORUTILS_H
class IDetector2D;
namespace DetectorUtils {
bool isQuadratic(const IDetector2D& det);
} // namespace DetectorUtils
#endif // BORNAGAIN_DEVICE_DETECTOR_DETECTORUTILS_H
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