diff --git a/GUI/Model/Sample/LayerItem.cpp b/GUI/Model/Sample/LayerItem.cpp index c866ab5072ce8f9a8f29757ce9ec58f174cced0d..ce38bb0d32086bb767399f960aba28d413e0e8df 100644 --- a/GUI/Model/Sample/LayerItem.cpp +++ b/GUI/Model/Sample/LayerItem.cpp @@ -45,21 +45,19 @@ QVector<ItemWithMaterial*> layoutItemsWithMaterial(ParticleLayoutItem* item) if (!item) continue; - if (item->hasModelType<ParticleCompositionItem>()) - itemsWithParticles << polymorphic_cast<ParticleCompositionItem*>(item)->particles(); - else if (item->hasModelType<MesoCrystalItem>()) - itemsWithParticles << polymorphic_cast<MesoCrystalItem*>(item)->basisParticle(); - else if (item->hasModelType<ParticleItem>()) - ret << dynamic_cast<ParticleItem*>(item); - else if (item->hasModelType<ParticleCoreShellItem>()) { - if (auto* core = dynamic_cast<ParticleCoreShellItem*>(item)->core()) - ret << core; - if (auto* shell = dynamic_cast<ParticleCoreShellItem*>(item)->shell()) - ret << shell; + if (auto* p = dynamic_cast<ParticleCompositionItem*>(item)) + itemsWithParticles << p->particles(); + else if (auto* p = dynamic_cast<MesoCrystalItem*>(item)) + itemsWithParticles << p->basisParticle(); + else if (auto* p = dynamic_cast<ParticleItem*>(item)) + ret << p; + else if (auto* p = dynamic_cast<ParticleCoreShellItem*>(item)) { + if (p->core()) + ret << p->core(); + if (p->shell()) + ret << p->shell(); } else - throw Error("Error in GUI::MaterialUtil::materialProperties: cannot handle " - "passed model type '" - + item->modelType() + "'"); + ASSERT(false); } return ret; }