edgeIntersections.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::edgeIntersections
28 
29 Description
30  Holder of intersections of edges of a surface with another surface.
31  Optionally shuffles around points on surface to resolve any 'conflicts'
32  (edge hitting triangle edge, edge hitting point etc.).
33 
34 SourceFiles
35  edgeIntersections.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef edgeIntersections_H
40 #define edgeIntersections_H
41 
42 #include "pointIndexHit.H"
43 #include "scalarField.H"
44 #include "pointField.H"
45 #include "typeInfo.H"
46 #include "boolList.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class triSurface;
55 class triSurfaceSearch;
56 class Random;
57 class edge;
58 
59 /*---------------------------------------------------------------------------*\
60  Class edgeIntersections Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 :
65  public List<List<pointIndexHit>>
66 {
67  // Private data
68 
69  //- For every entry in *this gives the edge classification result.
70  // -1 : intersection not close to edge
71  // 0 : intersection close to e[0]
72  // 1 : intersection close to e[1]
73  // 2 : edge aligned with intersection face
74  labelListList classification_;
75 
76 
77  // Private Member Functions
78 
79  //- Check for too small edges
80  static void checkEdges(const triSurface& surf);
81 
82  //- Intersect selected surface edges (edgeLabels) with surface2.
83  // Updates *this with pointHits and classification_ with status
84  // of hitPoint compared to edge end points.
85  void intersectEdges
86  (
87  const triSurface& surf1,
88  const pointField& points1, // surf1 meshPoints
89  const triSurfaceSearch& querySurf2,
90  const scalarField& surf1PointTol, // surf1 tolerance per point
91  const labelList& edgeLabels
92  );
93 
94  //- Perturb endpoints of edge if they are close to the intersection.
95  // Move point (in points1) by factor*surf1PointTol in direction of
96  // edge. Mark pointEdges of moved point in affectedEdges.
97  // Return true if anything changed.
98  bool inlinePerturb
99  (
100  const triSurface& surf1,
101  const scalarField& surf1PointTol,
102  const label edgeI,
103  Random& rndGen,
104  pointField& points1,
105  boolList& affectedEdges
106  ) const;
107 
108  //- Perturb single endpoint of edge if edge is aligned with face.
109  // See inlinePerturb. Return true if anything changed.
110  bool rotatePerturb
111  (
112  const triSurface& surf1,
113  const scalarField& surf1PointTol,
114  const label edgeI,
115  Random& rndGen,
116  pointField& points1,
117  boolList& affectedEdges
118  ) const;
119 
120 
121  //- Perturb edge by shifting in direction trianglecentre - intersection
122  // when hits close to face. Update points, mark affected edges and
123  // return true if anything changed.
124  bool offsetPerturb
125  (
126  const triSurface& surf1,
127  const triSurface& surf2,
128  const label edgeI,
129 
130  Random& rndGen,
131  pointField& points1,
132  boolList& affectedEdges
133  ) const;
134 
135 
136 public:
137 
138  ClassName("edgeIntersections");
139 
140 
141  // Static data members
142 
143  //- Cosine between edge and face normal when considered parallel
144  // (note: should be private and make access- and set- function)
145  static scalar alignedCos_;
146 
147 
148  // Static Functions
149 
150  //- Calculate min edge length for every surface point
151  static scalarField minEdgeLength(const triSurface& surf);
152 
153 
154  // Constructors
155 
156  //- Construct null
158 
159  //- Construct from surface and tolerance
161  (
162  const triSurface& surf1,
163  const triSurfaceSearch& query2,
164  const scalarField& surf1PointTol
165  );
166 
167  //- Construct from components
169  (
170  const List<List<pointIndexHit>>&,
171  const labelListList&
172  );
173 
174 
175  // Member Functions
176 
177 
178  // Access
179 
180  //- For every intersection the classification status.
181  const labelListList& classification() const
182  {
183  return classification_;
184  }
185 
186 
187  // Edit
188 
189  //- Resolve ties. Shuffles points so all edge - face intersections
190  // will be on the face interior.
191  // Points will be the new surface points.
192  // Returns number of iterations needed. (= nIters if still
193  // has degenerate cuts)
194  label removeDegenerates
195  (
196  const label nIters,
197  const triSurface& surf1,
198  const triSurfaceSearch& query2,
199  const scalarField& surf1PointTol,
200  pointField& points1
201  );
202 
203  //- Merge (or override) edge intersection for a subset
204  // (given as edge map and face map - for face indices stored in
205  // pointIndexHit.index())
206  void merge
207  (
208  const edgeIntersections&,
209  const labelList& edgeMap,
210  const labelList& faceMap,
211  const bool merge = true
212  );
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
Foam::edgeIntersections::classification
const labelListList & classification() const
For every intersection the classification status.
Definition: edgeIntersections.H:180
Foam::Random
Random number generator.
Definition: Random.H:59
pointIndexHit.H
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
boolList.H
typeInfo.H
scalarField.H
Foam::triSurfaceSearch
Helper class to search on triSurface.
Definition: triSurfaceSearch.H:58
Foam::edgeIntersections::alignedCos_
static scalar alignedCos_
Cosine between edge and face normal when considered parallel.
Definition: edgeIntersections.H:144
Foam::edgeIntersections::removeDegenerates
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.
Definition: edgeIntersections.C:516
Foam::Field< vector >
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:76
Foam::edgeIntersections::ClassName
ClassName("edgeIntersections")
Foam::edgeIntersections::minEdgeLength
static scalarField minEdgeLength(const triSurface &surf)
Calculate min edge length for every surface point.
Definition: edgeIntersections.C:488
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::edgeIntersections::edgeIntersections
edgeIntersections()
Construct null.
Definition: edgeIntersections.C:441
pointField.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
rndGen
Random rndGen
Definition: createFields.H:23
Foam::edgeIntersections::merge
void merge(const edgeIntersections &, const labelList &edgeMap, const labelList &faceMap, const bool merge=true)
Merge (or override) edge intersection for a subset.
Definition: edgeIntersections.C:674
Foam::edgeIntersections
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
Definition: edgeIntersections.H:62