XC Open source finite element analysis program
KDTreeNodes.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 //KDTreeNodes.h
28 #ifndef KDTreeNodes_h
29 #define KDTreeNodes_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 Node;
38 
40 //
42 class NodePos: public KDTreePos
43  {
44  private:
45  const Node *nodPtr;
46  public:
47  NodePos(const Node &);
48  explicit NodePos(const Pos3d &p);
49  inline const Node *getNodePtr(void) const
50  { return nodPtr; }
51  static inline double tac( NodePos p, size_t k ) { return p[k]; }
52  };
53 
54 inline bool operator==(const NodePos &A,const NodePos &B)
55  { return ((A.getNodePtr()== B.getNodePtr()) && (A[0] == B[0]) && (A[1] == B[1]) && (A[2] == B[2])); }
56 
57 
58 class KDTreeNodes: protected kd_tree::KDTree<3, NodePos, std::pointer_to_binary_function<NodePos,size_t,double> >
59  {
60  size_t pend_optimizar;
61  public:
62  typedef kd_tree::KDTree<3, NodePos, std::pointer_to_binary_function<NodePos,size_t,double> > tree_type;
63  KDTreeNodes(void);
64 
65  void insert(const Node &);
66  void erase(const Node &);
67  void clear(void);
68 
69  const Node *getNearestNode(const Pos3d &pos) const;
70  const Node *getNearestNode(const Pos3d &pos, const double &r) const;
71  };
72 
73 } // end of XC namespace
74 
75 
76 #endif
Mesh node.
Definition: Node.h:99
Definition: KDTreeNodes.h:58
NodePos(const Node &)
Constructor.
Definition: KDTreeNodes.cc:34
Node position for its use in the KDTree.
Definition: KDTreeNodes.h:42
================================================================================
Definition: ContinuaReprComponent.h:34