xc
KDTreeElements.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //KDTreeElements.h
29 #ifndef KDTreeElements_h
30 #define KDTreeElements_h
31 
32 #include "utility/geom/pos_vec/KDTreePos.h"
34 
35 class Pos3d;
36 
37 namespace XC {
38 class Element;
39 
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 
63 class KDTreeElements: protected kd_tree::KDTree<3, ElemPos, std::pointer_to_binary_function<ElemPos,size_t,double> >
64  {
65  size_t pend_optimizar;
66  public:
68  KDTreeElements(void);
69 
70  void insert(const Element &);
71  void erase(const Element &);
72  void clear(void);
73 
74  const Element *getNearest(const Pos3d &pos) const;
75  const Element *getNearest(const Pos3d &pos, const double &r) const;
76  };
77 
78 } // end of XC namespace
79 
80 
81 #endif
ElemPos(const Element &)
Constructor.
Definition: KDTreeElements.cc:34
Element position for KDTree building.
Definition: KDTreeElements.h:42
Defines the interface for the KDTree class.
Base class for the finite elements.
Definition: Element.h:112
Definition: kdtree.hpp:99
Posición en tres dimensiones.
Definition: Pos3d.h:44
k-d tree for searching the nearest element to a given position.
Definition: KDTreeElements.h:63
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Base class for KDTree positions.
Definition: KDTreePos.h:31