12 #ifndef CD_KDNodeImplem_H
13 #define CD_KDNodeImplem_H
17 #include <type_traits>
21 #include <CD_NamespaceHeader.H>
29 : m_left(nullptr), m_right(nullptr), m_weight(0.0), m_particles(std::move(a_particles))
68 return (m_left ==
nullptr) && (m_right ==
nullptr);
75 return !(this->isLeafNode());
84 this->gatherParticles(primitives);
93 if (this->isLeafNode()) {
94 a_particles.reserve(a_particles.size() + m_particles.size());
95 a_particles.insert(a_particles.end(), m_particles.begin(), m_particles.end());
98 m_left->gatherParticles(a_particles);
99 m_right->gatherParticles(a_particles);
109 this->moveParticles(primitives);
118 if (this->isLeafNode()) {
119 a_particles.reserve(a_particles.size() + m_particles.size());
121 std::move(m_particles.begin(), m_particles.end(), std::back_inserter(a_particles));
124 m_left->moveParticles(a_particles);
125 m_right->moveParticles(a_particles);
130 inline std::shared_ptr<KDNode<P>>&
137 inline std::shared_ptr<KDNode<P>>&
143 #include <CD_NamespaceFooter.H>
Namespace containing various particle management utilities.
ParticleList moveParticles() noexcept
Move the particles list further down in the subtree into this vector.
Definition: CD_KDNodeImplem.H:105
const Real & weight() const noexcept
Get the node weight.
Definition: CD_KDNodeImplem.H:52
const ParticleList & getParticles() const noexcept
Get particles in this node.
Definition: CD_KDNodeImplem.H:38
KDNode()
Default constructor.
Definition: CD_KDNodeImplem.H:24
std::shared_ptr< KDNode< P > > & getRight() noexcept
Get the right node.
Definition: CD_KDNodeImplem.H:138
ParticleList gatherParticles() const noexcept
Gather particles further down in the subtree and return all particles (in the leaf nodes)
Definition: CD_KDNodeImplem.H:80
virtual ~KDNode()
Destructor. Does nothing.
Definition: CD_KDNodeImplem.H:33
std::shared_ptr< KDNode< P > > & getLeft() noexcept
Get the left node.
Definition: CD_KDNodeImplem.H:131
std::vector< P > ParticleList
List of particles. This is aliased because the KD-tree construction may require both random access an...
Definition: CD_KDNode.H:39
bool isLeafNode() const noexcept
Is leaf node or not.
Definition: CD_KDNodeImplem.H:66
bool isInteriorNode() const noexcept
Is leaf node or not.
Definition: CD_KDNodeImplem.H:73