XC Open source finite element analysis program
KDTreeElements.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 //KDTreeElements.h
28 #ifndef KDTreeElements_h
29 #define KDTreeElements_h
30 
31 #include "xc_utils/src/geom/pos_vec/KDTreePos.h"
32 #include "xc_basic/src/kdtree++/kdtree.hpp"
33 
34 class Pos3d;
35 
36 namespace XC {
37 class Element;
38 
40 //
42 class ElemPos: public KDTreePos
43  {
44  private:
45  const Element *elemPtr;
46  public:
47  ElemPos(const Element &);
48  explicit ElemPos(const Pos3d &p);
49  inline const Element *getElementPtr(void) const
50  { return elemPtr; }
51 
52  static inline double tac( ElemPos p, size_t k ) { return p[k]; }
53  };
54 
55 inline bool operator==(const ElemPos &A,const ElemPos &B)
56  { return ((A.getElementPtr()== B.getElementPtr()) && (A[0] == B[0]) && (A[1] == B[1]) && (A[2] == B[2])); }
57 
58 
59 class KDTreeElements: protected kd_tree::KDTree<3, ElemPos, std::pointer_to_binary_function<ElemPos,size_t,double> >
60  {
61  size_t pend_optimizar;
62  public:
63  typedef kd_tree::KDTree<3, ElemPos, std::pointer_to_binary_function<ElemPos,size_t,double> > tree_type;
64  KDTreeElements(void);
65 
66  void insert(const Element &);
67  void erase(const Element &);
68  void clear(void);
69 
70  const Element *getNearestElement(const Pos3d &pos) const;
71  const Element *getNearestElement(const Pos3d &pos, const double &r) const;
72  };
73 
74 } // end of XC namespace
75 
76 
77 #endif
Element position for KDTree building.
Definition: KDTreeElements.h:42
Base calass for the finite elements.
Definition: Element.h:104
Definition: KDTreeElements.h:59
ElemPos(const Element &)
Constructor.
Definition: KDTreeElements.cc:34
================================================================================
Definition: ContinuaReprComponent.h:34