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;
94 for(const_iterator i= this->begin();i!=this->end();i++)
95 if((*i)->getName()==nmb)
return *i;
103 for(const_iterator i= this->begin();i!=this->end();i++)
104 if((*i)->getTag()==tag)
return *i;
115 const size_t sz= this->size();
116 const_iterator bg= this->begin();
119 const Pos3d pos= (*bg)->getCentroid();
124 const_iterator i= bg;
125 const Pos3d pos= (*i)->getCentroid();
128 for(; i != this->end(); i++)
130 const Pos3d pos= (*i)->getCentroid();
131 vpos_center_of_mass= vpos_center_of_mass + pos.
VectorPos();
133 vpos_center_of_mass= vpos_center_of_mass * (1.0/sz);
134 retval+= vpos_center_of_mass;
138 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
139 <<
"; set is empty, so it has no centroid." 140 << Color::def << std::endl;
151 const_iterator i= this->begin();
152 double d2= (*i)->getSquaredDistanceTo(p);
155 for(;i!=this->end();i++)
157 tmp= (*i)->getSquaredDistanceTo(p);
172 const T *retval=
nullptr;
175 const_iterator i= this->begin();
176 double d2= (*i)->getSquaredDistanceTo(p);
179 for(;i!=this->end();i++)
181 tmp= (*i)->getSquaredDistanceTo(p);
196 GEOM_FT retval= std::numeric_limits<GEOM_FT>::quiet_NaN();
201 retval= nearest->getDistanceTo(p);
204 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
205 <<
"; something went wrong, can't compute distance." 206 << Color::def << std::endl;
211 std::cerr << Color::red << this->
getClassName() <<
"::" << __FUNCTION__
212 <<
"; this set is empty, so there is no distance." 213 << Color::def << std::endl;
227 if(!std::isnan(dist))
239 const Pos3d &p1= s.getFromPoint();
241 const Pos3d &p2= s.getToPoint();
243 return ((d1<=d) && (d2<=d));
255 if(!vertices.empty())
257 GeomObj::list_Pos3d::const_iterator i= vertices.begin();
263 for(;i!=vertices.end();i++)
295 for(const_iterator i= this->begin();i!= this->end();i++)
299 if(t->In(geomObj,tol))
314 const_iterator i= this->begin();
319 for(;i!= this->end();i++)
333 for(const_iterator i= other.begin();i!= other.end();i++)
336 iterator j= find(this->begin(),this->end(),t);
346 for(const_iterator i= other.begin();i!= other.end();i++)
349 iterator j= find(this->begin(),this->end(),t);
364 for(const_iterator i= this->begin();i!= this->end();i++)
367 const bool tmp= t->remove(ePtr);
384 for(const_iterator i= this->begin();i!= this->end();i++)
387 const bool tmp= t->remove(nPtr);
426 for(
typename DqPtrsEntities<T>::const_iterator i= a.begin();i!= a.end();i++)
429 const typename DqPtrsEntities<T>::const_iterator j= find(b.begin(),b.end(),t);
441 for(
typename DqPtrsEntities<T>::const_iterator i= a.begin();i!= a.end();i++)
444 const typename DqPtrsEntities<T>::const_iterator j= find(b.begin(),b.end(),t);
457 typedef std::set<T*> shadow_makers;
458 typedef boost::icl::interval_map<double, shadow_makers> shadow_interval_map;
459 typedef typename shadow_interval_map::iterator interval_iterator;
460 typedef typename shadow_interval_map::const_iterator interval_const_iterator;
461 typedef boost::icl::interval<double> shadow_interval;
463 shadow_interval_map x_shadows;
464 shadow_interval_map y_shadows;
465 shadow_interval_map z_shadows;
472 std::set<T *> getNeighbors(
const Pos3d &pMin,
const Pos3d &pMax)
const;
482 typedef typename DqPtrsEntities<T>::const_iterator const_iterator;
483 for(const_iterator i= entities.begin();i!= entities.end();i++)
498 const Pos3d pMin= tmp.getPMin();
499 const Pos3d pMax= tmp.getPMax();
500 auto shadow_interval_x= shadow_interval::closed(pMin.x(), pMax.x());
501 auto shadow_interval_y= shadow_interval::closed(pMin.y(), pMax.y());
502 auto shadow_interval_z= shadow_interval::closed(pMin.z(), pMax.z());
503 x_shadows.add(std::make_pair(shadow_interval_x, sm));
504 y_shadows.add(std::make_pair(shadow_interval_y, sm));
505 z_shadows.add(std::make_pair(shadow_interval_z, sm));
515 const Pos3d pMin= tmp.getPMin();
516 const Pos3d pMax= tmp.getPMax();
517 const double margin= 1.0;
518 auto shadow_interval_x= shadow_interval::closed(pMin.x()-margin, pMax.x()+margin);
519 auto shadow_interval_y= shadow_interval::closed(pMin.y()-margin, pMax.y()+margin);
520 auto shadow_interval_z= shadow_interval::closed(pMin.z()-margin, pMax.z()+margin);
521 x_shadows-= std::make_pair(shadow_interval_x, sm);
522 y_shadows-= std::make_pair(shadow_interval_y, sm);
523 z_shadows-= std::make_pair(shadow_interval_z, sm);
530 std::set<T *> retval;
531 auto x_shadow= shadow_interval::closed(pMin.x(), pMax.x());
532 shadow_interval_map x_neighbors= x_shadows & x_shadow;
533 if(!x_neighbors.empty())
535 auto y_shadow= shadow_interval::closed(pMin.y(), pMax.y());
536 shadow_interval_map y_neighbors= y_shadows & y_shadow;
537 if(!y_neighbors.empty())
539 auto z_shadow= shadow_interval::closed(pMin.z(), pMax.z());
540 shadow_interval_map z_neighbors= z_shadows & z_shadow;
541 if(!z_neighbors.empty())
544 for(interval_const_iterator k= z_neighbors.begin();k!=z_neighbors.end();k++)
545 { z_set.insert((*k).second.begin(), (*k).second.end()); }
547 for(interval_const_iterator j= y_neighbors.begin();j!=y_neighbors.end();j++)
548 { y_set.insert((*j).second.begin(), (*j).second.end()); }
550 for(interval_const_iterator i= x_neighbors.begin();i!=x_neighbors.end();i++)
551 { x_set.insert((*i).second.begin(), (*i).second.end()); }
553 std::set<T *> yz_set;
554 set_intersection(y_set.begin(), y_set.end(), z_set.begin(), z_set.end(), std::inserter(yz_set, yz_set.begin()));
555 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:454
void add(T *)
Add entity to the interval map.
Definition: DqPtrsEntities.h:493
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:41
Base class for position lists.
Definition: PolyPos.h:35
void intersect(const DqPtrsEntities< T > &other)
Removes the objects that belongs also to the given container.
Definition: DqPtrsEntities.h:344
EntitiesShadows(const DqPtrsEntities< T > &)
Constructor.
Definition: DqPtrsEntities.h:480
BND3d Bnd(void) const
Return the entities boundary.
Definition: DqPtrsEntities.h:309
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:405
T * getNearest(const Pos3d &p)
Returns the object closest to the position being passed as parameter.
Definition: DqPtrsEntities.h:146
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:223
DqPtrsEntities< T > & operator-=(const DqPtrsEntities< T > &)
-= (difference) operator.
Definition: DqPtrsEntities.h:397
void remove(const DqPtrsEntities< T > &other)
Removes the objects that belongs also to the given container.
Definition: DqPtrsEntities.h:331
void remove(T *)
Remove entity from the interval map.
Definition: DqPtrsEntities.h:510
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:110
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:92
T * findTag(const size_t &)
Returns a pointer to the object identified by the tag argument.
Definition: DqPtrsEntities.h:101
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:292
Mesh node.
Definition: Node.h:111
GEOM_FT getDistanceTo(const Pos3d &p) const
Return the minimum of the distances to the given point.
Definition: DqPtrsEntities.h:194
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:528
Vector en tres dimensiones.
Definition: Vector3d.h:39
Clase base para los objetos en tres dimensiones.
Definition: GeomObj3d.h:43