FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 
41 #include <OpenFOAM/scalarField.H>
42 #include <OpenFOAM/pointField.H>
43 #include <OpenFOAM/typeInfo.H>
44 #include <OpenFOAM/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 public:
134 
135  ClassName("edgeIntersections");
136 
137 
138  // Static data members
139 
140  //- cosine between edge and face normal when considered parallel
141  // (note: should be private and make access- and set- function)
142  static scalar alignedCos_;
143 
144 
145  // Static Functions
146 
147  //- Calculate min edge length for every surface point
148  static scalarField minEdgeLength(const triSurface& surf);
149 
150 
151  // Constructors
152 
153  //- Construct null
155 
156  //- Construct from surface and tolerance
158  (
159  const triSurface& surf1,
160  const triSurfaceSearch& query2,
161  const scalarField& surf1PointTol
162  );
163 
164  //- Construct from components
166  (
167  const List<List<pointIndexHit> >&,
168  const labelListList&
169  );
170 
171 
172  // Member Functions
173 
174 
175  // Access
176 
177  //- For every intersection the classification status.
179  {
180  return classification_;
181  }
182 
183 
184  // Edit
185 
186  //- Resolve ties. Shuffles points so all edge - face intersections
187  // will be on the face interior.
188  // Points will be the new surface points.
189  // Returns number of iterations needed. (= nIters if still
190  // has degenerate cuts)
191  label removeDegenerates
192  (
193  const label nIters,
194  const triSurface& surf1,
195  const triSurfaceSearch& query2,
196  const scalarField& surf1PointTol,
197  pointField& points1
198  );
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************ vim: set sw=4 sts=4 et: ************************ //