Skip to content
Snippets Groups Projects
Commit 8c0816f7 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

On removing MaterialManager...

parent 9517413a
No related branches found
No related tags found
No related merge requests found
......@@ -34,8 +34,8 @@ public:
Layer();
//! Constructs layer made of _material_ with _thickness_ in nanometers and decoration
Layer(const IMaterial* material, double thickness=0, ILayout *decoration=0);
Layer(const IMaterial* material, double thickness, const ILayout &decoration);
// Layer(const IMaterial* material, double thickness=0, ILayout *decoration=0);
Layer(const IMaterial &material, double thickness, const ILayout &decoration);
virtual ~Layer();
......@@ -54,10 +54,10 @@ public:
virtual double getThickness() const { return m_thickness; }
//! Sets _material_ of the layer.
virtual void setMaterial(const IMaterial* material);
virtual void setMaterial(const IMaterial &material);
//! Sets _material_ and _thickness_.
virtual void setMaterialAndThickness(const IMaterial* material,
virtual void setMaterialAndThickness(const IMaterial &material,
double thickness);
//! Returns layer's material.
......@@ -66,15 +66,15 @@ public:
//! Returns refractive index of the layer's material.
virtual complex_t getRefractiveIndex() const;
//! sets particle decoration
//! sets particle layout
virtual void setLayout(const ILayout &decoration);
//! returns particle decoration
virtual const ILayout* getLayout() const { return mp_decoration; }
virtual const ILayout* getLayout() const { return mp_layout; }
//! Returns true if decoration is present
virtual bool hasDWBASimulation() const {
return (mp_decoration ? true : false);
return (mp_layout ? true : false);
}
//! creates and return LayerDWBASimulation in the case of present decoration
......@@ -91,12 +91,12 @@ protected:
void print(std::ostream& ostr) const;
//! sets particle decoration (separate pointer version due to python-bindings)
virtual void setDecorationPtr(ILayout *decoration);
//! sets particle layout (separate pointer version due to python-bindings)
virtual void setLayoutPtr(ILayout *layout);
const IMaterial* mp_material; //!< pointer to the material
double m_thickness; //!< layer thickness in nanometers
ILayout *mp_decoration; //!< particle decoration
double m_thickness; //!< layer thickness in nanometers
IMaterial* mp_material; //!< pointer to the material
ILayout *mp_layout; //!< particle layout
};
......@@ -108,8 +108,8 @@ inline complex_t Layer::getRefractiveIndex() const
inline double Layer::getTotalParticleSurfaceDensity() const
{
if (mp_decoration) {
return mp_decoration->getTotalParticleSurfaceDensity();
if (mp_layout) {
return mp_layout->getTotalParticleSurfaceDensity();
}
return 0.0;
}
......
......@@ -22,30 +22,31 @@
Layer::Layer()
: mp_material(0)
, m_thickness(0)
, mp_decoration(0)
{
setName("Layer");
init_parameters();
}
Layer::Layer(const IMaterial* material, double thickness, ILayout *decoration)
: m_thickness(0)
, mp_decoration(0)
, mp_material(0)
, mp_layout(0)
{
if (thickness < 0.)
throw DomainErrorException("Layer thickness cannot be negative");
m_thickness = thickness;
setName("Layer");
setDecorationPtr(decoration);
setMaterial(material);
init_parameters();
}
Layer::Layer(const IMaterial* material, double thickness, const ILayout &decoration)
//Layer::Layer(const IMaterial* material, double thickness, ILayout *decoration)
// : m_thickness(0)
// , mp_decoration(0)
//{
// if (thickness < 0.)
// throw DomainErrorException("Layer thickness cannot be negative");
// m_thickness = thickness;
// setName("Layer");
// setDecorationPtr(decoration);
// setMaterial(material);
// init_parameters();
//}
Layer::Layer(const IMaterial &material, double thickness, const ILayout &decoration)
: m_thickness(thickness)
, mp_decoration(0)
, mp_material(0)
, mp_layout(0)
{
setName("Layer");
setLayout(decoration);
......@@ -56,9 +57,9 @@ Layer::Layer(const IMaterial* material, double thickness, const ILayout &decorat
Layer::Layer(const Layer& other) : ICompositeSample()
{
mp_material = other.mp_material;
mp_decoration = 0;
mp_layout = 0;
if(other.getLayout()) {
setDecorationPtr(other.getLayout()->clone());
setLayoutPtr(other.getLayout()->clone());
}
m_thickness = other.m_thickness;
setName(other.getName());
......@@ -67,16 +68,17 @@ Layer::Layer(const Layer& other) : ICompositeSample()
Layer::~Layer()
{
delete mp_decoration;
delete mp_material;
delete mp_layout;
}
Layer* Layer::cloneInvertB() const
{
Layer *p_clone = new Layer();
p_clone->mp_material = MaterialManager::getInvertedMaterial(this->mp_material->getName());
p_clone->mp_decoration = 0;
p_clone->mp_layout = 0;
if(this->getLayout()) {
p_clone->setDecorationPtr(this->getLayout()->cloneInvertB());
p_clone->setLayoutPtr(this->getLayout()->cloneInvertB());
}
p_clone->m_thickness = this->m_thickness;
std::string clone_name = this->getName() + "_inv";
......@@ -100,34 +102,32 @@ void Layer::setThickness(double thickness)
}
//! Sets _material_ of the layer.
void Layer::setMaterial(const IMaterial* material)
void Layer::setMaterial(const IMaterial &material)
{
if ( !material )
throw NullPointerException("The material doesn't exist");
mp_material = material;
mp_material = material.clone();
}
void Layer::setMaterialAndThickness(const IMaterial* material, double thickness)
void Layer::setMaterialAndThickness(const IMaterial &material, double thickness)
{
setMaterial(material);
setThickness(thickness);
}
void Layer::setDecorationPtr(ILayout *decoration)
void Layer::setLayoutPtr(ILayout *layout)
{
if( !decoration ) return;
if( !layout ) return;
if(mp_decoration) {
deregisterChild(mp_decoration);
delete mp_decoration;
if(mp_layout) {
deregisterChild(mp_layout);
delete mp_layout;
}
mp_decoration = decoration;
registerChild(mp_decoration);
mp_layout = layout;
registerChild(mp_layout);
}
void Layer::setLayout(const ILayout &decoration)
{
setDecorationPtr(decoration.clone());
setLayoutPtr(decoration.clone());
}
//! Prints description.
......@@ -139,7 +139,7 @@ void Layer::print(std::ostream& ostr) const
LayerDWBASimulation *Layer::createDWBASimulation() const
{
if(mp_decoration) {
if(mp_layout) {
return new DecoratedLayerDWBASimulation(this);
}
return 0;
......@@ -147,14 +147,14 @@ LayerDWBASimulation *Layer::createDWBASimulation() const
DiffuseDWBASimulation* Layer::createDiffuseDWBASimulation() const
{
if(!mp_decoration) return 0;
if(!mp_layout) return 0;
DiffuseDWBASimulation *p_sim = new DiffuseDWBASimulation;
size_t nbr_particles = mp_decoration->getNumberOfParticles();
double particle_density = mp_decoration->getTotalParticleSurfaceDensity();
size_t nbr_particles = mp_layout->getNumberOfParticles();
double particle_density = mp_layout->getTotalParticleSurfaceDensity();
const IMaterial *p_layer_material = getMaterial();
for (size_t i=0; i<nbr_particles; ++i) {
const ParticleInfo *p_info = mp_decoration->getParticleInfo(i);
const ParticleInfo *p_info = mp_layout->getParticleInfo(i);
std::vector<DiffuseParticleInfo *> *p_diffuse_nps =
p_info->getParticle()->createDiffuseParticleInfo(*p_info);
if (p_diffuse_nps) {
......
......@@ -39,9 +39,9 @@ ISample *IsGISAXS08ABuilder::buildSample() const
MaterialManager::getHomogeneousMaterial("Particle", n_particle);
Layer air_layer;
air_layer.setMaterial(p_air_material);
air_layer.setMaterial(*p_air_material);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material);
substrate_layer.setMaterial(*p_substrate_material);
InterferenceFunction2DParaCrystal *p_interference_function =
new InterferenceFunction2DParaCrystal(10.0*Units::nanometer,
......@@ -85,9 +85,9 @@ ISample *IsGISAXS08BBuilder::buildSample() const
MaterialManager::getHomogeneousMaterial("Particle", n_particle);
Layer air_layer;
air_layer.setMaterial(p_air_material);
air_layer.setMaterial(*p_air_material);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material);
substrate_layer.setMaterial(*p_substrate_material);
InterferenceFunction2DParaCrystal *p_interference_function =
new InterferenceFunction2DParaCrystal(10.0*Units::nanometer,
......
......@@ -352,4 +352,7 @@
# after implementing quick and dirty calback with mutex lock
| 2014-03-19 17:21:59 | jcnsopc126 | linuxx8664gcc | 0 | 27.394 | 2.038 | 1.776 | 1.128 | 0.668 | 5.205 | 6.787 | 0.501 | 7.711 | 1.581 |
# before removing MaterialManager
| 2014-03-25 15:08:26 | jcnsopc126 | linuxx8664gcc | 0 | 27.546 | 2.061 | 1.786 | 1.117 | 0.661 | 5.217 | 6.858 | 0.553 | 7.722 | 1.572 |
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