All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edgeIntersections.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-2019 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::edgeIntersections
26 
27 Description
28  Holder of intersections of edges of a surface with another surface.
29  Optionally shuffles around points on surface to resolve any 'conflicts'
30  (edge hitting triangle edge, edge hitting point etc.).
31 
32 SourceFiles
33  edgeIntersections.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef edgeIntersections_H
38 #define edgeIntersections_H
39 
40 #include "pointIndexHit.H"
41 #include "scalarField.H"
42 #include "pointField.H"
43 #include "typeInfo.H"
44 #include "boolList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class triSurface;
53 class triSurfaceSearch;
54 class Random;
55 class edge;
56 
57 /*---------------------------------------------------------------------------*\
58  Class edgeIntersections Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 :
63  public List<List<pointIndexHit>>
64 {
65  // Private Data
66 
67  //- For every entry in *this gives the edge classification result.
68  // -1 : intersection not close to edge
69  // 0 : intersection close to e[0]
70  // 1 : intersection close to e[1]
71  // 2 : edge aligned with intersection face
72  labelListList classification_;
73 
74 
75  // Private Member Functions
76 
77  //- Check for too small edges
78  static void checkEdges(const triSurface& surf);
79 
80  //- Intersect selected surface edges (edgeLabels) with surface2.
81  // Updates *this with pointHits and classification_ with status
82  // of hitPoint compared to edge end points.
83  void intersectEdges
84  (
85  const triSurface& surf1,
86  const pointField& points1, // surf1 meshPoints
87  const triSurfaceSearch& querySurf2,
88  const scalarField& surf1PointTol, // surf1 tolerance per point
89  const labelList& edgeLabels
90  );
91 
92  //- Perturb endpoints of edge if they are close to the intersection.
93  // Move point (in points1) by factor*surf1PointTol in direction of
94  // edge. Mark pointEdges of moved point in affectedEdges.
95  // Return true if anything changed.
96  bool inlinePerturb
97  (
98  const triSurface& surf1,
99  const scalarField& surf1PointTol,
100  const label edgeI,
101  Random& rndGen,
102  pointField& points1,
103  boolList& affectedEdges
104  ) const;
105 
106  //- Perturb single endpoint of edge if edge is algigned with face.
107  // See inlinePerturb. Return true if anything changed.
108  bool rotatePerturb
109  (
110  const triSurface& surf1,
111  const scalarField& surf1PointTol,
112  const label edgeI,
113  Random& rndGen,
114  pointField& points1,
115  boolList& affectedEdges
116  ) const;
117 
118 
119  //- Perturb edge by shifting in direction trianglecentre - intersection
120  // when hits close to face. Update points, mark affected edges and
121  // return true if anything changed.
122  bool offsetPerturb
123  (
124  const triSurface& surf1,
125  const triSurface& surf2,
126  const label edgeI,
127 
128  Random& rndGen,
129  pointField& points1,
130  boolList& affectedEdges
131  ) const;
132 
133 
134 public:
135 
136  ClassName("edgeIntersections");
137 
138 
139  // Static Data Members
140 
141  //- Cosine between edge and face normal when considered parallel
142  // (note: should be private and make access- and set- function)
143  static scalar alignedCos_;
144 
145 
146  // Static Functions
147 
148  //- Calculate min edge length for every surface point
149  static scalarField minEdgeLength(const triSurface& surf);
150 
151 
152  // Constructors
153 
154  //- Construct null
156 
157  //- Construct from surface and tolerance
159  (
160  const triSurface& surf1,
161  const triSurfaceSearch& query2,
162  const scalarField& surf1PointTol
163  );
164 
165  //- Construct from components
167  (
168  const List<List<pointIndexHit>>&,
169  const labelListList&
170  );
171 
172 
173  // Member Functions
174 
175 
176  // Access
177 
178  //- For every intersection the classification status.
179  const labelListList& classification() const
180  {
181  return classification_;
182  }
183 
184 
185  // Edit
186 
187  //- Resolve ties. Shuffles points so all edge - face intersections
188  // will be on the face interior.
189  // Points will be the new surface points.
190  // Returns number of iterations needed. (= nIters if still
191  // has degenerate cuts)
193  (
194  const label nIters,
195  const triSurface& surf1,
196  const triSurfaceSearch& query2,
197  const scalarField& surf1PointTol,
198  pointField& points1
199  );
200 
201  //- Merge (or override) edge intersection for a subset
202  // (given as edge map and face map - for face indices stored in
203  // pointIndexHit.index())
204  void merge
205  (
206  const edgeIntersections&,
207  const labelList& edgeMap,
208  const labelList& faceMap,
209  const bool merge = true
210  );
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
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 array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void merge(const edgeIntersections &, const labelList &edgeMap, const labelList &faceMap, const bool merge=true)
Merge (or override) edge intersection for a subset.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
static scalar alignedCos_
Cosine between edge and face normal when considered parallel.
Random rndGen(label(0))
Helper class to search on triSurface.
static scalarField minEdgeLength(const triSurface &surf)
Calculate min edge length for every surface point.
const labelListList & classification() const
For every intersection the classification status.
Random number generator.
Definition: Random.H:57
label removeDegenerates(const label nIters, const triSurface &surf1, const triSurfaceSearch &query2, const scalarField &surf1PointTol, pointField &points1)
Resolve ties. Shuffles points so all edge - face intersections.
Triangulated surface description with patch information.
Definition: triSurface.H:66
ClassName("edgeIntersections")
edgeIntersections()
Construct null.
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
Namespace for OpenFOAM.