32 #ifndef DQPTRSENTITIES_H 33 #define DQPTRSENTITIES_H 36 #include "utility/geom/pos_vec/Pos3d.h" 37 #include "utility/geom/pos_vec/Vector3d.h" 38 #include "utility/geom/d2/Polygon3d.h" 39 #include "utility/geom/d1/Segment3d.h" 40 #include "utility/geom/d3/BND3d.h" 41 #include "boost/icl/interval_map.hpp" 42 #include "utility/utils/misc_utils/colormod.h" 55 typedef typename dq_ptr::const_iterator const_iterator;
56 typedef typename dq_ptr::iterator iterator;
78 const T *
findTag(
const size_t &)
const;
95 for(const_iterator i= this->begin();i!=this->end();i++)
96 if((*i)->getName()==nmb)
return *i;
104 for(const_iterator i= this->begin();i!=this->end();i++)
105 if((*i)->getTag()==tag)
return *i;
113 for(const_iterator i= this->begin();i!=this->end();i++)
114 if((*i)->getTag()==tag)
return *i;
125 const size_t sz= this->size();
126 const_iterator bg= this->begin();
129 const Pos3d pos= (*bg)->getCentroid();
134 const_iterator i= bg;
135 const Pos3d pos= (*i)->getCentroid();
138 for(; i != this->end(); i++)
140 const Pos3d pos= (*i)->getCentroid();
141 vpos_center_of_mass= vpos_center_of_mass + pos.
VectorPos();
143 vpos_center_of_mass= vpos_center_of_mass * (1.0/sz);
144 retval+= vpos_center_of_mass;
148 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
149 <<
"; set is empty, so it has no centroid." 150 << Color::def << std::endl;
161 const_iterator i= this->begin();
162 double d2= (*i)->getSquaredDistanceTo(p);
165 for(;i!=this->end();i++)
167 tmp= (*i)->getSquaredDistanceTo(p);
182 const T *retval=
nullptr;
185 const_iterator i= this->begin();
186 double d2= (*i)->getSquaredDistanceTo(p);
189 for(;i!=this->end();i++)
191 tmp= (*i)->getSquaredDistanceTo(p);
206 GEOM_FT retval= std::numeric_limits<GEOM_FT>::quiet_NaN();
211 retval= nearest->getDistanceTo(p);
214 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
215 <<
"; something went wrong, can't compute distance." 216 << Color::def << std::endl;
221 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
222 <<
"; this set is empty, so there is no distance." 223 << Color::def << std::endl;
237 if(!std::isnan(dist))
249 const Pos3d &p1= s.getFromPoint();
251 const Pos3d &p2= s.getToPoint();
253 return ((d1<=d) && (d2<=d));
265 if(!vertices.empty())
267 GeomObj::list_Pos3d::const_iterator i= vertices.begin();
273 for(;i!=vertices.end();i++)
305 for(const_iterator i= this->begin();i!= this->end();i++)
309 if(t->In(geomObj,tol))
324 const_iterator i= this->begin();
329 for(;i!= this->end();i++)
343 for(const_iterator i= other.begin();i!= other.end();i++)
346 iterator j= find(this->begin(),this->end(),t);
356 for(const_iterator i= other.begin();i!= other.end();i++)
359 iterator j= find(this->begin(),this->end(),t);
374 for(const_iterator i= this->begin();i!= this->end();i++)
377 const bool tmp= t->remove(ePtr);
394 for(const_iterator i= this->begin();i!= this->end();i++)
397 const bool tmp= t->remove(nPtr);
436 for(
typename DqPtrsEntities<T>::const_iterator i= a.begin();i!= a.end();i++)
439 const typename DqPtrsEntities<T>::const_iterator j= find(b.begin(),b.end(),t);
451 for(
typename DqPtrsEntities<T>::const_iterator i= a.begin();i!= a.end();i++)
454 const typename DqPtrsEntities<T>::const_iterator j= find(b.begin(),b.end(),t);
467 typedef std::set<T*> shadow_makers;
468 typedef boost::icl::interval_map<double, shadow_makers> shadow_interval_map;
469 typedef typename shadow_interval_map::iterator interval_iterator;
470 typedef typename shadow_interval_map::const_iterator interval_const_iterator;
471 typedef boost::icl::interval<double> shadow_interval;
473 shadow_interval_map x_shadows;
474 shadow_interval_map y_shadows;
475 shadow_interval_map z_shadows;
482 std::set<T *> getNeighbors(
const Pos3d &pMin,
const Pos3d &pMax)
const;
492 typedef typename DqPtrsEntities<T>::const_iterator const_iterator;
493 for(const_iterator i= entities.begin();i!= entities.end();i++)
508 const Pos3d pMin= tmp.getPMin();
509 const Pos3d pMax= tmp.getPMax();
510 auto shadow_interval_x= shadow_interval::closed(pMin.x(), pMax.x());
511 auto shadow_interval_y= shadow_interval::closed(pMin.y(), pMax.y());
512 auto shadow_interval_z= shadow_interval::closed(pMin.z(), pMax.z());
513 x_shadows.add(std::make_pair(shadow_interval_x, sm));
514 y_shadows.add(std::make_pair(shadow_interval_y, sm));
515 z_shadows.add(std::make_pair(shadow_interval_z, sm));
525 const Pos3d pMin= tmp.getPMin();
526 const Pos3d pMax= tmp.getPMax();
527 const double margin= 1.0;
528 auto shadow_interval_x= shadow_interval::closed(pMin.x()-margin, pMax.x()+margin);
529 auto shadow_interval_y= shadow_interval::closed(pMin.y()-margin, pMax.y()+margin);
530 auto shadow_interval_z= shadow_interval::closed(pMin.z()-margin, pMax.z()+margin);
531 x_shadows-= std::make_pair(shadow_interval_x, sm);
532 y_shadows-= std::make_pair(shadow_interval_y, sm);
533 z_shadows-= std::make_pair(shadow_interval_z, sm);
540 std::set<T *> retval;
541 auto x_shadow= shadow_interval::closed(pMin.x(), pMax.x());
542 shadow_interval_map x_neighbors= x_shadows & x_shadow;
543 if(!x_neighbors.empty())
545 auto y_shadow= shadow_interval::closed(pMin.y(), pMax.y());
546 shadow_interval_map y_neighbors= y_shadows & y_shadow;
547 if(!y_neighbors.empty())
549 auto z_shadow= shadow_interval::closed(pMin.z(), pMax.z());
550 shadow_interval_map z_neighbors= z_shadows & z_shadow;
551 if(!z_neighbors.empty())
554 for(interval_const_iterator k= z_neighbors.begin();k!=z_neighbors.end();k++)
555 { z_set.insert((*k).second.begin(), (*k).second.end()); }
557 for(interval_const_iterator j= y_neighbors.begin();j!=y_neighbors.end();j++)
558 { y_set.insert((*j).second.begin(), (*j).second.end()); }
560 for(interval_const_iterator i= x_neighbors.begin();i!=x_neighbors.end();i++)
561 { x_set.insert((*i).second.begin(), (*i).second.end()); }
563 std::set<T *> yz_set;
564 set_intersection(y_set.begin(), y_set.end(), z_set.begin(), z_set.end(), std::inserter(yz_set, yz_set.begin()));
565 set_intersection(x_set.begin(), x_set.end(), yz_set.begin(), yz_set.end(), std::inserter(retval, retval.begin()));
Shadows of the entities on the coordinate axis used for spatial indexing.
Definition: DqPtrsEntities.h:464
void add(T *)
Add entity to the interval map.
Definition: DqPtrsEntities.h:503
Plane polygon in a 3D space.
Definition: Polygon3d.h:35
GeomObj::list_Pos3d getVertexList(void) const
Return a Python list containing the positions of the polygon vertices.
Definition: Polygon3d.cc:73
Segment en tres dimensiones.
Definition: Segment3d.h:42
void intersect(const DqPtrsEntities< T > &other)
Removes the objects that belongs also to the given container.
Definition: DqPtrsEntities.h:354
EntitiesShadows(const DqPtrsEntities< T > &)
Constructor.
Definition: DqPtrsEntities.h:490
BND3d Bnd(void) const
Return the entities boundary.
Definition: DqPtrsEntities.h:319
Vector3d VectorPos(void) const
Return the position vector of the point.
Definition: Pos3d.cc:93
Base class for the finite elements.
Definition: Element.h:112
FiberSet operator+(const FiberSet &, const FiberSet &)
Return the union of both containers.
Definition: FiberSet.cc:65
DqPtrsEntities< T > & operator*=(const DqPtrsEntities< T > &)
*= (intersection) operator.
Definition: DqPtrsEntities.h:415
T * getNearest(const Pos3d &p)
Returns the object closest to the position being passed as parameter.
Definition: DqPtrsEntities.h:156
Container for preprocessor entities (points, lines, surfaces,...)
Definition: DqPtrsEntities.h:51
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
Objet that can execute python scripts.
Definition: CommandEntity.h:40
"boundary" en tres dimensiones.
Definition: BND3d.h:34
bool isCloserThan(const Pos3d &, const GEOM_FT &) const
Return true if the distance to the given point is smaller than the given one.
Definition: DqPtrsEntities.h:233
DqPtrsEntities< T > & operator-=(const DqPtrsEntities< T > &)
-= (difference) operator.
Definition: DqPtrsEntities.h:407
void remove(const DqPtrsEntities< T > &other)
Removes the objects that belongs also to the given container.
Definition: DqPtrsEntities.h:341
void remove(T *)
Remove entity from the interval map.
Definition: DqPtrsEntities.h:520
Posición en tres dimensiones.
Definition: Pos3d.h:44
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
FiberSet operator-(const FiberSet &, const FiberSet &)
Return the fibers in a that are not in b.
Definition: FiberSet.cc:73
Pos3d getCentroid(void) const
Returns the centroid of the entities.
Definition: DqPtrsEntities.h:120
BND3d Bnd(void) const
Return the boundary of the object.
Definition: GeomObj3d.cc:82
T * searchName(const std::string &nmb)
Returns a pointer to the object identified by the name.
Definition: DqPtrsEntities.h:93
T * findTag(const size_t &)
Returns a pointer to the object identified by the tag argument.
Definition: DqPtrsEntities.h:102
DqPtrsEntities< T > pickEntitiesInside(const GeomObj3d &, const double &tol=0.0) const
Return a container with the entities that lie inside the geometric object.
Definition: DqPtrsEntities.h:302
Mesh node.
Definition: Node.h:112
GEOM_FT getDistanceTo(const Pos3d &p) const
Return the minimum of the distances to the given point.
Definition: DqPtrsEntities.h:204
Pointer to (nodes, elements, points, lines,...) container.
Definition: DqPtrs.h:57
std::set< T * > getNeighbors(const Pos3d &pMin, const Pos3d &pMax) const
Return the objects whose "shadow" overlaps whith the interval argument.
Definition: DqPtrsEntities.h:538
Vector en tres dimensiones.
Definition: Vector3d.h:39
Clase base para los objetos en tres dimensiones.
Definition: GeomObj3d.h:43