GetFEM++  5.3
bgeot_node_tab.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2007-2017 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 <Yves.Renard@insa-lyon.fr>
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 identify it with a very close existing
84  point. If remove_duplicated_nodes = false, the identification of close existing points will be
85  omitted and the point simply added to the array.
86  */
87  size_type add_node(const base_node &pt, const scalar_type radius=0,
88  bool remove_duplicated_nodes = true);
89  size_type add(const base_node &pt) { return add_node(pt); }
90  void sup_node(size_type i);
91  void sup(size_type i) { sup_node(i); }
92  void resort(void) { sorters = std::vector<sorter>(); }
93  dim_type dim(void) const { return dim_type(dim_); }
94  void translation(const base_small_vector &V);
95  void transformation(const base_matrix &M);
96 
97  void swap_points(size_type i, size_type j);
98  void swap(size_type i, size_type j) { swap_points(i,j); }
99 
100  node_tab(scalar_type prec_loose = scalar_type(10000));
101  node_tab(const node_tab &t);
102  node_tab &operator =(const node_tab &t);
103  };
104 
105 
106 
107 }
108 #endif
Small (dim < 8) vectors.
a balanced tree stored in a dal::dynamic_array
Store a set of points, identifying points that are nearer than a certain very small distance...
Basic Geometric Tools.