GetFEM  5.5
bgeot_node_tab.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2007-2026 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, see https://www.gnu.org/licenses/.
19 
20  As a special exception, you may use this file as it is a part of a free
21  software library without restriction. Specifically, if other files
22  instantiate templates or use macros or inline functions from this file,
23  or you compile this file and link it with other files to produce an
24  executable, this file does not by itself cause the resulting executable
25  to be covered by the GNU Lesser General Public License. This exception
26  does not however invalidate any other reasons why the executable file
27  might be covered by the GNU Lesser General Public License.
28 
29 ===========================================================================*/
30 
31 #ifndef BGEOT_NODE_TAB_H
32 #define BGEOT_NODE_TAB_H
33 
34 /** @file bgeot_node_tab.h
35  @author Yves Renard <Yves.Renard@insa-lyon.fr>
36  @date January 2004.
37  @brief Structure which dynamically collects points identifying points
38  that are nearer than a certain very small distance.
39 
40 */
41 #include "bgeot_small_vector.h"
42 #include "dal_tree_sorted.h"
43 #include "set"
44 
45 namespace bgeot {
46 
47 
48  /** Store a set of points, identifying points
49  that are nearer than a certain very small distance.
50  */
51  class APIDECL node_tab : public dal::dynamic_tas<base_node> {
52 
53  protected :
54 
55  struct component_comp {
56  const dal::dynamic_tas<base_node> *vbn;
57  const base_node *c;
59  bool operator()(size_type i1, size_type i2) const;
60  component_comp(const dal::dynamic_tas<base_node> &vbn_,
61  const base_node &c_, unsigned dim);
62  component_comp() : vbn(0), c(0) {}
63  };
64  typedef std::set<size_type, component_comp> sorter;
65 
66  mutable std::vector<sorter> sorters;
67  mutable base_node c;
68  scalar_type eps, prec_factor, max_radius;
69  unsigned dim_;
70 
71  void add_sorter() const;
72 
73  public :
74 
75  /// reset the array, remove all points
76  void clear();
77 
78  /** Search a node in the array. return its index if it exists
79  or size_type(-1) otherwise.
80  */
81  size_type search_node(const base_node &pt, const scalar_type radius=0) const;
82  /** Add a point to the array or use an existing point, located within
83  a distance smaller than radius. If radius is negative, the detection
84  of proximate existing points will be skipped and the point will simply
85  be added to the array.
86  The optional argument remove_duplicated_nodes is deprecated. Setting it
87  to false has the same effect as passing a negative value to radius.
88  */
89  size_type add_node(const base_node &pt, const scalar_type radius=0,
90  bool remove_duplicated_nodes = true);
91  size_type add(const base_node &pt) { return add_node(pt); }
92  void sup_node(size_type i);
93  void sup(size_type i) { sup_node(i); }
94  void resort() { sorters = std::vector<sorter>(); }
95  dim_type dim() const { return dim_type(dim_); }
96  void translation(const base_small_vector &V);
97  void transformation(const base_matrix &M);
98 
99  void swap_points(size_type i, size_type j);
100  void swap(size_type i, size_type j) { swap_points(i,j); }
101 
102  node_tab(scalar_type prec_loose = scalar_type(10000));
103  node_tab(const node_tab &t);
104  node_tab &operator =(const node_tab &t);
105  };
106 
107 
108 
109 }
110 #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.