Skip to content
Snippets Groups Projects
Commit 7cca6720 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Added check for need to use polarization analysis (based on the materials used in the sample)

parent a3558b9a
No related branches found
No related tags found
No related merge requests found
...@@ -130,6 +130,9 @@ class BA_CORE_API_ Simulation : public IParameterized, public ICloneable ...@@ -130,6 +130,9 @@ class BA_CORE_API_ Simulation : public IParameterized, public ICloneable
//! Update the sample by calling the sample builder, if present //! Update the sample by calling the sample builder, if present
void updateSample(); void updateSample();
//! Checks if the sample requires a polarized calculation
bool checkPolarizationPresent() const;
// components describing an experiment and its simulation: // components describing an experiment and its simulation:
ISample *mp_sample; ISample *mp_sample;
const ISampleBuilder *mp_sample_builder; const ISampleBuilder *mp_sample_builder;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ProgramOptions.h" #include "ProgramOptions.h"
#include "DWBASimulation.h" #include "DWBASimulation.h"
#include "MessageService.h" #include "MessageService.h"
#include "SampleMaterialVisitor.h"
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <gsl/gsl_errno.h> #include <gsl/gsl_errno.h>
...@@ -334,6 +335,24 @@ void Simulation::updateSample() ...@@ -334,6 +335,24 @@ void Simulation::updateSample()
} }
} }
bool Simulation::checkPolarizationPresent() const
{
if (!mp_sample) {
throw ClassInitializationException("Simulation::"
"checkPolarizationPresent(): sample not initialized");
}
SampleMaterialVisitor material_vis;
mp_sample->accept(&material_vis);
std::vector<const IMaterial *> materials = material_vis.getMaterials();
for (std::vector<const IMaterial *>::const_iterator it = materials.begin();
it != materials.end(); ++it) {
if (!(*it)->isScalarMaterial()) {
return true;
}
}
return false;
}
void Simulation::setDetectorParameters(const OutputData<double >& output_data) void Simulation::setDetectorParameters(const OutputData<double >& output_data)
{ {
m_instrument.matchDetectorParameters(output_data); m_instrument.matchDetectorParameters(output_data);
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
//! Indicates that the material is not scalar. This means that different //! Indicates that the material is not scalar. This means that different
//! polarization states will be diffracted differently //! polarization states will be diffracted differently
virtual bool isScalarMaterial() { return false; } virtual bool isScalarMaterial() const { return false; }
//! Get the scattering matrix from the refractive index, the //! Get the scattering matrix from the refractive index, the
//! magnetic field and a given wavevector //! magnetic field and a given wavevector
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
//! Indicates whether the interaction with the material is scalar. //! Indicates whether the interaction with the material is scalar.
//! This means that different polarization states will be diffracted //! This means that different polarization states will be diffracted
//! equally //! equally
virtual bool isScalarMaterial() { return true; } virtual bool isScalarMaterial() const { return true; }
friend std::ostream &operator<<(std::ostream &ostr, const IMaterial &m) friend std::ostream &operator<<(std::ostream &ostr, const IMaterial &m)
{ m.print(ostr); return ostr; } { m.print(ostr); return ostr; }
......
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