xc
KDTreeNodes.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 //KDTreeNodes.h
29 #ifndef KDTreeNodes_h
30 #define KDTreeNodes_h
31 
32 #include "utility/geom/pos_vec/KDTreePos.h"
34 
35 class Pos3d;
36 
37 namespace XC {
38 class Node;
39 
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 
62 class KDTreeNodes: protected kd_tree::KDTree<3, NodePos, std::pointer_to_binary_function<NodePos,size_t,double> >
63  {
64  size_t pend_optimizar;
65  public:
67  KDTreeNodes(void);
68 
69  void insert(const Node &);
70  void erase(const Node &);
71  void clear(void);
72 
73  const Node *getNearest(const Pos3d &pos) const;
74  const Node *getNearest(const Pos3d &pos, const double &r) const;
75  };
76 
77 } // end of XC namespace
78 
79 
80 #endif
Defines the interface for the KDTree class.
NodePos(const Node &)
Constructor.
Definition: KDTreeNodes.cc:34
Definition: kdtree.hpp:99
Posición en tres dimensiones.
Definition: Pos3d.h:44
Node position for its use in the KDTree.
Definition: KDTreeNodes.h:42
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Mesh node.
Definition: Node.h:111
Base class for KDTree positions.
Definition: KDTreePos.h:31
k-d tree for searching the nearest node to a given position.
Definition: KDTreeNodes.h:62