All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polygonTriangulateI.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) 2021 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 \*---------------------------------------------------------------------------*/
25 
26 #include "polygonTriangulate.H"
27 
28 // * * * * * * * * * * * Private Static Member Functions * * * * * * * * * * //
29 
30 inline Foam::label Foam::polygonTriangulate::renumberPolyToGlobal
31 (
32  const label triPoly,
33  const UList<label>& polyToGlobal
34 )
35 {
36  return triPoly < polyToGlobal.size() ? polyToGlobal[triPoly] : -1;
37 }
38 
39 template<class Type>
40 inline Type Foam::polygonTriangulate::renumberPolyToGlobal
41 (
42  const Type& triPoly,
43  const UList<label>& polyToGlobal
44 )
45 {
46  Type result;
47  result.resize(triPoly.size());
48  forAll(triPoly, i)
49  {
50  result[i] = renumberPolyToGlobal(triPoly[i], polyToGlobal);
51  }
52  return result;
53 }
54 
55 
56 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
57 
58 inline const Foam::UList<Foam::triFace>&
60 {
61  return triPoints_;
62 }
63 
64 
66 (
67  const UList<label>& polyPoints
68 ) const
69 {
70  return renumberPolyToGlobal(triPoints_, polyPoints);
71 }
72 
73 
75 (
76  const label trii,
77  const UList<label>& polyPoints
78 ) const
79 {
80  return renumberPolyToGlobal(triPoints_[trii], polyPoints);
81 }
82 
83 
86 {
87  return triEdges_;
88 }
89 
90 
93 (
94  const UList<label>& polyEdges
95 ) const
96 {
97  return renumberPolyToGlobal(triEdges_, polyEdges);
98 }
99 
100 
102 (
103  const label trii,
104  const UList<label>& polyEdges
105 ) const
106 {
107  return renumberPolyToGlobal(triEdges_[trii], polyEdges);
108 }
109 
110 
111 inline const Foam::UList<Foam::triFace>& Foam::polygonTriangulate::triangulate
112 (
113  const UIndirectList<point>& points,
114  const vector& normal,
115  const bool simple,
116  const bool optimal
117 )
118 {
119  points_ = points;
120 
121  return triangulate(points_, normal, simple, optimal);
122 }
123 
124 
125 inline const Foam::UList<Foam::triFace>& Foam::polygonTriangulate::triangulate
126 (
127  const UIndirectList<point>& points,
128  const bool simple,
129  const bool optimal
130 )
131 {
132  points_ = points;
133 
134  return triangulate(points_, simple, optimal);
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:54
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
const UList< FixedList< label, 3 > > & triEdges() const
Get the triangles&#39; edges.
const pointField & points
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:68
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
A List with indirect addressing.
Definition: fvMatrix.H:106
const UList< triFace > & triPoints() const
Get the triangles&#39; points.