14#include "../../../../src/core/BaseBody.hpp"
30 template<
typename cell_t,
class plugin_t>
135 int nbCellSamePosition =
cellGrid->grid[x][y].size();
136 while(c < nbCellSamePosition && &(
cellGrid->grid[x][y][c]->getBody()) !=
this) c++;
137 if(c < nbCellSamePosition){
177 int min = std::numeric_limits<int>::max();
179 for (
int i = -range; i <= range; ++i) {
180 for (
int j = -range; j <= range; ++j) {
185 if(xi < 0) xi =
cellGrid->width - xi;
189 if(yj < 0) yj =
cellGrid->height - yj;
193 if ((xi >= 0) && (xi < cellGrid->width) && (yj >= 0) && (yj < cellGrid->height)) {
194 currentSize =
cellGrid->grid[xi][yj].size();
195 if (currentSize < min) {
201 }
else if (currentSize == min) {
210 if (posibilityX.
size() > 1) {
211 std::uniform_int_distribution<> dis(0, posibilityX.
size() - 1);
213 x = posibilityX[choice];
214 y = posibilityY[choice];
Template class for a 2D grid physics-based body.
Body2DGrid(const MecaCell::Vector3D &pos)
Constructor with position.
Vec2D get2DPosition() const
Gets the 2D position of the cell.
Body2DGrid()=default
Default constructor.
Vec2D findLowestDensityPosition(int range)
Finds one of the lowest density positions within a range. if there are multiple positions with the sa...
CellGrid< cell_t > * cellGrid
MecaCell::Vector3D position
double getBoundingBoxRadius() const
Gets the bounding box radius.
void set2DPosition(int i, int j)
Sets the 2D position of the cell.
void setRadius(double _radius)
Sets the bounding box radius.
void setPosition(const MecaCell::Vector3D &p)
Sets the 3D position of the cell.
void setNbNeighbouringCells(int n)
Sets the number of neighbouring cells.
double getDensity() const
Gets the density of the cell.
int getNbNeighbouringCells() const
Gets the number of neighbouring cells.
CellGrid< cell_t > * getCellGrid()
Gets the cell grid.
void setNbNeighbouringLocations(int n)
Sets the number of neighbouring locations.
void set2DPosition(const Vec2D &p)
Sets the 2D position of the cell.
int nbNeighbouringLocations
MecaCell::Vector3D getPosition() const
Gets the 3D position of the cell.
int getNbNeighbouringLocations() const
Gets the number of neighbouring locations.
general purpose 3D vector/point class.
A simple vector class template.
void push_back(const T &value)
Adds an element to the end of the vector.
void clear()
Clears the contents of the vector.
size_t size() const
Returns the number of elements in the vector.
Namespace for 2D grid-related structures and classes.
Template class representing a 2D grid of cell pointers.
Structure representing a 2D vector.
int x() const
Get the X-coordinate.
int y() const
Get the Y-coordinate.
static random_engine_t & globalRand()
access to the static global random engine.This pseudo - random generator is* used in random 3D vector...
static constexpr double DEFAULT_CELL_RADIUS