32 template <
typename CT>
83 for (
auto i : entities.
asVector(std::numeric_limits<short>::max())) {
92 void remove(CT entity) {
103 std::vector<CT>
asVector(
short maxLevel = std::numeric_limits<short>::max())
const {
125 for (
auto i :
asVector(std::numeric_limits<short>::max())) {
126 if (i->layer() == layer) {
144 for (
auto i :
asVector(std::numeric_limits<short>::max())) {
162 const short maxLevel = std::numeric_limits<short>::max())
const {
166 for (
auto i : entities) {
168 if (i->boundingBox().inArea(area)) {
182 if (entities.size() > 0) {
183 extends = entities[0]->boundingBox();
184 for (
const auto &i : entities) {
185 extends = extends.
merge(i->boundingBox());
204 const short maxLevel = std::numeric_limits<short>::max())
const {
208 for (
auto i : entities) {
211 if (i->boundingBox().inArea(area)) {
220 auto c = i->boundingBox().numCornersInside(area);
230 auto &&v = area.
top();
231 visitorDispatcher<bool, lc::GeoEntityVisitor>(intersect, v, *i.get());
232 if (!intersect.result().empty()) {
238 visitorDispatcher<bool, GeoEntityVisitor>(intersect, v, *i.get());
239 if (!intersect.result().empty()) {
245 visitorDispatcher<bool, GeoEntityVisitor>(intersect, v, *i.get());
246 if (!intersect.result().empty()) {
252 visitorDispatcher<bool, GeoEntityVisitor>(intersect, v, *i.get());
253 if (!intersect.result().empty()) {
273 const short maxLevel = std::numeric_limits<short>::max())
const {
276 std::vector<CT> &&entities =
_tree->
retrieve(area, maxLevel);
278 for (
auto &i : entities) {
280 if (i->boundingBox().overlaps(area)) {
295 double distance)
const {
302 std::vector<lc::EntityDistance> entities;
303 for (
auto item : ent) {
304 Snapable_CSPtr entity = std::dynamic_pointer_cast<
const lc::Snapable>(item);
306 if (entity !=
nullptr) {
308 if (eCoordinate.
distanceTo(point) < distance) {
309 entities.emplace_back(item, eCoordinate);
346 template<
typename U,
typename T>
void each(T func) {
347 _tree->template each<U>(func);
350 template<
typename U,
typename T>
void each(T func)
const {
351 _tree->template each<const U>(func);
The EntityContainer class manages a set of entities. This call will allow to select (but not manipula...
bool erase(const E entity)
remove Remove entity from quad tree
virtual ~EntityContainer()
double x() const
Returns x of Coordinate.
Vector right() const
right vector of this area
const E entityByID(ID_DATATYPE id) const
lc::geo::Area bounds() const
bound returns the size of the document
calculate the intersection pojnts of 2 entities
EntityContainer entitiesByLayer(const Layer_CSPtr layer) const
findEntitiesByLayer Return a entities container with all entities from a specific layer ...
EntityContainer(const EntityContainer &other)
EntityContainer Copy Constructor.
double y() const
Returns y of Coordinate.
bool optimise()
optimise Optmise this tree. Current implementation will remove empty nodes up till the root node ...
void optimise()
optimise this container
Area merge(const Area &other) const
merge two area's and expand if required to largest containing area
EntityContainer & operator=(const EntityContainer &ec)
EntityContainer entitiesWithinAndCrossingAreaFast(const geo::Area &area, const short maxLevel=std::numeric_limits< short >::max()) const
entitiesWithinAndCrossingAreaFast Find all entities within a selected area. Unlike entitiesWithinAndC...
geo::Area bounds() const
bounds of the root portion of the tree
geo::Area boundingBox() const
Vector top() const
top vector of this area
std::vector< E > retrieve(const geo::Area &area, const short maxLevel=SHRT_MAX) const
retrieve all object's that are located within a given area
EntityContainer entitiesByMetaType(const std::string &metaName) const
entitiesByMetaType Return all entities that contain's a specific metaInfo
Vector bottom() const
bottom vector of this area
void insert(const E entity)
insert Insert entity into the quad tree
std::vector< lc::EntityDistance > getEntityPathsNearCoordinate(const lc::geo::Coordinate &point, double distance) const
getEntityPathsNearCoordinate
EntityContainer()
EntityContainer Default constructor. Usually you would retrieve a EntityContainer from the document...
double distanceTo(const geo::Coordinate &c) const
std::vector< CT > asVector(short maxLevel=std::numeric_limits< short >::max()) const
asVector return all entities as std::vector optionally up until a given level This is useful to retur...
Vector left() const
left vector for this area
EntityContainer entitiesFullWithinArea(const geo::Area &area, const short maxLevel=std::numeric_limits< short >::max()) const
entitiesByArea Find all entities within a selected area based on boundingbox of the entities ...
void combine(const EntityContainer &entities)
Add all entities to this container Any entity that already exists will get replaced.
void insert(CT entity)
add an entity to the EntityContainer If the entity already exists, it will be replaced ...
EntityContainer entitiesWithinAndCrossingArea(const geo::Area &area, const short maxLevel=std::numeric_limits< short >::max()) const
entitiesWithinAndCrossingArea Find all entities within a selected area or where the path is crossing ...
CT entityByID(ID_DATATYPE id) const
entityByID return a entity by it's id, return's a empty shared ptr when not found ...