All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sortLabelledTri.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sortLabelledTri
26 
27 Description
28  Helper class which when constructed with a triSurface
29  sorts the faces according to region number (or rather constructs a
30  mapping).
31 
32 SourceFiles
33  sortLabelledTri.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sortLabelledTri_H
38 #define sortLabelledTri_H
39 
40 #include "labelList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class sortLabelledTri;
48 class triSurface;
49 
50 /*---------------------------------------------------------------------------*\
51  Class surfAndLabel Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 //- Hold surface and label
55 class surfAndLabel
56 {
57  const triSurface* surfPtr_;
58 
59  label index_;
60 
61  // Private Classes
62 
63  //- Scalar comparison function used for sorting
64  class less
65  {
66  public:
67 
68  inline bool operator()
69  (
70  const surfAndLabel& one,
71  const surfAndLabel& two
72  ) const;
73  };
74 
75 
76 public:
77 
78  friend class sortLabelledTri;
79 
80  // Constructors
81 
82  //- Construct null
83  surfAndLabel()
84  :
85  surfPtr_(nullptr),
86  index_(-1)
87  {}
88 
89  //- Construct from surface and index
90  surfAndLabel(const triSurface& surf, const label index)
91  :
92  surfPtr_(&surf),
93  index_(index)
94  {}
95 };
96 
97 
98 /*---------------------------------------------------------------------------*\
99  Class sortLabelledTri Declaration
100 \*---------------------------------------------------------------------------*/
101 
102 class sortLabelledTri
103 :
104  public List<surfAndLabel>
105 {
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct from surface, sorting the faces according to patch
112  sortLabelledTri(const triSurface&);
113 
114 
115  // Member Functions
116 
117  // Access
118 
119  //- Set the labelList to those of sorted point indices
120  void indices(labelList&) const;
121 
122  //- Return the list of sorted point indices
123  labelList indices() const;
124 };
125 
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace Foam
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:51
Helper class which when constructed with a triSurface sorts the faces according to region number (or ...
sortLabelledTri(const triSurface &)
Construct from surface, sorting the faces according to patch.
labelList indices() const
Return the list of sorted point indices.
Hold surface and label.
surfAndLabel()
Construct null.
Triangulated surface description with patch information.
Definition: triSurface.H:69
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static bool less(const vector &x, const vector &y)
To compare normals.