GetFEM  5.4.3
bgeot_node_tab.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2007-2020 Yves Renard
5 
6  This file is a part of GetFEM
7 
8  GetFEM is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, you may use this file as it is a part of a free
22  software library without restriction. Specifically, if other files
23  instantiate templates or use macros or inline functions from this file,
24  or you compile this file and link it with other files to produce an
25  executable, this file does not by itself cause the resulting executable
26  to be covered by the GNU Lesser General Public License. This exception
27  does not however invalidate any other reasons why the executable file
28  might be covered by the GNU Lesser General Public License.
29 
30 ===========================================================================*/
31 
32 #ifndef BGEOT_NODE_TAB_H
33 #define BGEOT_NODE_TAB_H
34 
35 /** @file bgeot_node_tab.h
36  @author Yves Renard <[email protected]>
37  @date January 2004.
38  @brief Structure which dynamically collects points identifying points
39  that are nearer than a certain very small distance.
40 
41 */
42 #include "bgeot_small_vector.h"
43 #include "dal_tree_sorted.h"
44 #include "set"
45 
46 namespace bgeot {
47 
48 
49  /** Store a set of points, identifying points
50  that are nearer than a certain very small distance.
51  */
52  class APIDECL node_tab : public dal::dynamic_tas<base_node> {
53 
54  protected :
55 
56  struct component_comp {
57  const dal::dynamic_tas<base_node> *vbn;
58  const base_node *c;
60  bool operator()(size_type i1, size_type i2) const;
61  component_comp(const dal::dynamic_tas<base_node> &vbn_,
62  const base_node &c_, unsigned dim);
63  component_comp() : vbn(0), c(0) {}
64  };
65  typedef std::set<size_type, component_comp> sorter;
66 
67  mutable std::vector<sorter> sorters;
68  mutable base_node c;
69  scalar_type eps, prec_factor, max_radius;
70  unsigned dim_;
71 
72  void add_sorter(void) const;
73 
74  public :
75 
76  /// reset the array, remove all points
77  void clear(void);
78 
79  /** Search a node in the array. return its index if it exists
80  or size_type(-1) otherwise.
81  */
82  size_type search_node(const base_node &pt, const scalar_type radius=0) const;
83  /** Add a point to the array or use an existing point, located within
84  a distance smaller than radius. If radius is negative, the detection
85  of proximate existing points will be skipped and the point will simply
86  be added to the array.
87  The optional argument remove_duplicated_nodes is deprecated. Setting it
88  to false has the same effect as passing a negative value to radius.
89  */
90  size_type add_node(const base_node &pt, const scalar_type radius=0,
91  bool remove_duplicated_nodes = true);
92  size_type add(const base_node &pt) { return add_node(pt); }
93  void sup_node(size_type i);
94  void sup(size_type i) { sup_node(i); }
95  void resort(void) { sorters = std::vector<sorter>(); }
96  dim_type dim(void) const { return dim_type(dim_); }
97  void translation(const base_small_vector &V);
98  void transformation(const base_matrix &M);
99 
100  void swap_points(size_type i, size_type j);
101  void swap(size_type i, size_type j) { swap_points(i,j); }
102 
103  node_tab(scalar_type prec_loose = scalar_type(10000));
104  node_tab(const node_tab &t);
105  node_tab &operator =(const node_tab &t);
106  };
107 
108 
109 
110 }
111 #endif
Small (dim < 8) vectors.
Store a set of points, identifying points that are nearer than a certain very small distance.
a balanced tree stored in a dal::dynamic_array
Basic Geometric Tools.