31 #include "Sample/Aggregate/Interferences.h"
32 #include "Sample/Particle/Particle.h"
33 #include "Sample/Particle/ParticleCoreShell.h"
37 std::vector<std::vector<double>> generatePositions(
const ParticleLayoutItem& layoutItem,
38 double layerSize,
double density)
40 auto* interferenceItem = layoutItem.
interference().currentItem();
41 if (interferenceItem) {
42 auto interference = interferenceItem->createInterference();
44 if (
auto* p =
dynamic_cast<Interference1DLattice*
>(interference.get()))
47 if (
auto* p =
dynamic_cast<Interference2DLattice*
>(interference.get()))
50 if (
auto* p =
dynamic_cast<Interference2DParaCrystal*
>(interference.get()))
53 if (
auto* p =
dynamic_cast<InterferenceFinite2DLattice*
>(interference.get()))
56 if (
auto* p =
dynamic_cast<InterferenceRadialParaCrystal*
>(interference.get()))
68 m_builderUtils = std::make_unique<RealSpace::BuilderUtils>(fnColorFromMaterialName);
78 if (
const auto* p = std::get_if<MultiLayerItem*>(&item))
80 else if (
const auto* p = std::get_if<LayerItem*>(&item))
82 else if (
const auto* p = std::get_if<ParticleLayoutItem*>(&item))
84 else if (
const auto* p = std::get_if<ItemWithParticles*>(&item))
91 const QVector3D&)
const
93 double total_height(0.0);
96 bool isTopLayer = index == 0;
98 QVector3D(0, 0,
static_cast<float>(-total_height)), isTopLayer);
109 const bool isTopLayer)
const
112 if (layer && !isTopLayer)
122 const QVector3D& origin)
const
128 double layer_size = sceneGeometry.
layerSize;
131 auto particle3DContainer_vector =
m_builderUtils->particle3DContainerVector(layoutItem, origin);
133 const auto latticePositions = generatePositions(layoutItem, layer_size, total_density);
142 if (
const auto* pItem =
dynamic_cast<const ParticleItem*
>(&particleItem)) {
144 particle3DContainer =
m_builderUtils->singleParticle3DContainer(*particle);
145 }
else if (
const auto* particleCoreShellItem =
148 if (!particleCoreShellItem->core() || !particleCoreShellItem->shell())
150 auto particleCoreShell = particleCoreShellItem->createParticleCoreShell();
151 particle3DContainer =
m_builderUtils->particleCoreShell3DContainer(*particleCoreShell);
152 }
else if (
const auto* particleCompositionItem =
155 if (!particleCompositionItem->particles().empty())
157 auto particleComposition = particleCompositionItem->createParticleComposition();
158 particle3DContainer =
m_builderUtils->particleComposition3DContainer(*particleComposition);
159 }
else if (
const auto* mesoCrystalItem =
dynamic_cast<const MesoCrystalItem*
>(&particleItem)) {
161 if (!mesoCrystalItem->basisParticle())
163 particle3DContainer =
m_builderUtils->mesoCrystal3DContainer(*mesoCrystalItem);
171 const QVector3D& lattice_position)
const
174 for (
size_t i = 0; i < particle3DContainer.
containerSize(); ++i) {
176 particle3D->addTranslation(lattice_position);
179 model->
add(particle3D.release());
181 model->
addBlend(particle3D.release());
Defines class DoubleDescriptor.
Declares interface IPositionBuilder and subclasses.
Defines InterferenceItems's classes.
Defines class MesoCrystalItem.
Defines class MultiLayerItem.
Implements namespace GUI::View::TransformTo3D.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellItem.
Defines class ParticleItem.
Defines class ParticleLayoutItem.
Defines GUI::RealSpace::BuilderUtils namespace.
Defines class RealSpaceBuilder.
Defines class RealSpaceCanvas.
void addBlend(Object *)
add a transparent object, the model takes ownership
void add(Object *)
add an opaque object, the model takes ownership
Camera::Position defCamPos
default camera params
std::vector< std::vector< double > > generatePositions(double layer_size, double density=0.0) const
QVector< ParticleLayoutItem * > layouts() const
QVector< LayerItem * > layers() const
std::unique_ptr< GUI::RealSpace::Particles::Particle > createParticle(const size_t &index) const
size_t containerSize() const
bool particle3DBlend(const size_t &index) const
DoubleDescriptor totalDensity() const
The real density.
QVector< ItemWithParticles * > particles() const
The particles this layout contains.
SelectionDescriptor< InterferenceItem * > interference() const
RealSpaceBuilder(std::function< QColor(const QString &)> fnColorFromMaterialName)
std::variant< MultiLayerItem *, LayerItem *, ParticleLayoutItem *, ItemWithParticles * > ItemForRealSpace
Defines the item types this class can handle.
void populateParticleFromParticle3DContainer(RealSpace::Model *model, const Particle3DContainer &particle3DContainer, const QVector3D &lattice_position={}) const
void populateLayer(RealSpace::Model *model, const LayerItem &layerItem, const SceneGeometry &sceneGeometry, const QVector3D &origin={}, bool isTopLayer=false) const
void populateParticleFromParticleItem(RealSpace::Model *model, const ItemWithParticles &particleItem) const
std::unique_ptr< RealSpace::BuilderUtils > m_builderUtils
void populateMultiLayer(RealSpace::Model *model, const MultiLayerItem &mlayerItem, const SceneGeometry &sceneGeometry, const QVector3D &origin={}) const
void populateLayout(RealSpace::Model *model, const ParticleLayoutItem &layoutItem, const SceneGeometry &sceneGeometry, const QVector3D &origin={}) const
void populate(RealSpace::Model *model, ItemForRealSpace item, const SceneGeometry &sceneGeometry, const RealSpace::Camera::Position &cameraPosition=RealSpace::Camera::Position(RealSpace::Vector3D(0, -200, 120), RealSpace::Vector3D(0, 0, 0), RealSpace::Vector3D::_z)) const
std::vector< std::vector< double > > latticePositions(const Interference2DParaCrystal *, double layer_size)
Size and thickness information of layers.