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

Implemented comparison of magnetic materials

parent 4359ae5d
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
private: private:
bool definesSameMaterial(IMaterial *left, IMaterial *right) const; bool definesSameMaterial(const IMaterial *left, const IMaterial *right) const;
std::map<const IFormFactor *,std::string> m_formFactorLabel; std::map<const IFormFactor *,std::string> m_formFactorLabel;
std::map<const IInterferenceFunction *, std::string> m_interferenceFunctionLabel; std::map<const IInterferenceFunction *, std::string> m_interferenceFunctionLabel;
std::map<const Layer *,std::string> m_layerLabel; std::map<const Layer *,std::string> m_layerLabel;
......
...@@ -132,8 +132,7 @@ void LabelSample::insertMaterial(const IMaterial *sample) ...@@ -132,8 +132,7 @@ void LabelSample::insertMaterial(const IMaterial *sample)
std::map<const IMaterial *,std::string>::const_iterator iEnd = m_materialLabel.end(); std::map<const IMaterial *,std::string>::const_iterator iEnd = m_materialLabel.end();
while (it != iEnd) while (it != iEnd)
{ {
if(it->first->getName() == sample->getName() && if(definesSameMaterial(it->first, sample) )
it->first->getRefractiveIndex() == sample->getRefractiveIndex() )
{ {
m_materialLabel[sample] = it->second; m_materialLabel[sample] = it->second;
break; break;
...@@ -142,9 +141,9 @@ void LabelSample::insertMaterial(const IMaterial *sample) ...@@ -142,9 +141,9 @@ void LabelSample::insertMaterial(const IMaterial *sample)
} }
if(it == iEnd) if(it == iEnd)
{ {
std::ostringstream inter; std::ostringstream label_stream;
inter << "Material_" << m_materialLabel.size()+1; label_stream << "Material_" << m_materialLabel.size()+1;
m_materialLabel[sample] = inter.str(); m_materialLabel[sample] = label_stream.str();
} }
} }
...@@ -169,7 +168,6 @@ void LabelSample::setLabel(const ILayout *sample) ...@@ -169,7 +168,6 @@ void LabelSample::setLabel(const ILayout *sample)
m_ILayoutLabel[sample] = inter.str();; m_ILayoutLabel[sample] = inter.str();;
} }
void LabelSample::setLabel(const Layer *sample) void LabelSample::setLabel(const Layer *sample)
{ {
std::ostringstream inter; std::ostringstream inter;
...@@ -216,7 +214,7 @@ void LabelSample::setLabel(const ParticleInfo *sample) ...@@ -216,7 +214,7 @@ void LabelSample::setLabel(const ParticleInfo *sample)
m_particleInfoLabel[sample] = inter.str();; m_particleInfoLabel[sample] = inter.str();;
} }
bool LabelSample::definesSameMaterial(IMaterial *left, IMaterial *right) const bool LabelSample::definesSameMaterial(const IMaterial *left, const IMaterial *right) const
{ {
// Non-magnetic materials // Non-magnetic materials
if (left->isScalarMaterial() && right->isScalarMaterial()) { if (left->isScalarMaterial() && right->isScalarMaterial()) {
...@@ -228,8 +226,18 @@ bool LabelSample::definesSameMaterial(IMaterial *left, IMaterial *right) const ...@@ -228,8 +226,18 @@ bool LabelSample::definesSameMaterial(IMaterial *left, IMaterial *right) const
} }
// Magnetic materials TODO // Magnetic materials TODO
else if (!left->isScalarMaterial() && !right->isScalarMaterial()) { else if (!left->isScalarMaterial() && !right->isScalarMaterial()) {
if (left->getName() == right->getName() && const HomogeneousMagneticMaterial *p_left =
left->getRefractiveIndex() == right->getRefractiveIndex() ) { dynamic_cast<const HomogeneousMagneticMaterial *>(left);
const HomogeneousMagneticMaterial *p_right =
dynamic_cast<const HomogeneousMagneticMaterial *>(right);
if (!p_left || !p_right) {
throw Exceptions::RuntimeErrorException("LabelSample::definesSameMaterial: "
"non-scalar materials should be of type "
"HomogeneousMagneticMaterial");
}
if (p_left->getName() == p_right->getName() &&
p_left->getRefractiveIndex() == p_right->getRefractiveIndex() &&
p_left->getMagneticField() == p_right->getMagneticField() ) {
return true; return true;
} }
return false; return false;
......
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