FreeFOAM The Cross-Platform CFD Toolkit
orientedSurface.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::orientedSurface
26 
27 Description
28  Given point flip all faces such that normals point in same direction.
29 
30 SourceFiles
31  orientedSurface.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef orientedSurface_H
36 #define orientedSurface_H
37 
38 #include <triSurface/triSurface.H>
39 #include <OpenFOAM/typeInfo.H>
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 
48 /*---------------------------------------------------------------------------*\
49  Class orientedSurface Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public triSurface
55 {
56  // Data types
57 
58  //- Enumeration listing whether face needs to be flipped.
59  enum sideStat
60  {
61  UNVISITED,
62  FLIP,
63  NOFLIP
64  };
65 
66 
67  // Private Member Functions
68 
69  //- Return true if face uses edge from start to end.
70  static bool edgeOrder(const labelledTri&, const edge&);
71 
72  //- Return true if edge is used in opposite order in faces
73  static bool consistentEdge
74  (
75  const edge& e,
76  const labelledTri& f0,
77  const labelledTri& f1
78  );
79 
80  //- From changed faces get the changed edges
81  static labelList faceToEdge
82  (
83  const triSurface&,
84  const labelList& changedFaces
85  );
86 
87  //- From changed edges check the orientation of the connected faces
88  // and flip them. Return changed faces.
89  static labelList edgeToFace
90  (
91  const triSurface&,
92  const labelList& changedEdges,
93  labelList& flip
94  );
95 
96  //- Walk from face across connected faces. Change orientation to be
97  // consistent with startFaceI.
98  static void walkSurface
99  (
100  const triSurface& s,
101  const label startFaceI,
102  labelList& flipState
103  );
104 
105  //- Given nearest point and face check orientation to nearest face
106  // and flip if nessecary (only marked in flipState) and propagate.
107  static void propagateOrientation
108  (
109  const triSurface&,
110  const point& outsidePoint,
111  const bool orientOutside,
112  const label nearestFaceI,
113  const point& nearestPt,
114  labelList& flipState
115  );
116 
117  //- Given flipState reverse triangles of *this. Return true if
118  // anything flipped.
119  static bool flipSurface(triSurface& s, const labelList& flipState);
120 
121 public:
122 
123  ClassName("orientedSurface");
124 
125 
126  // Constructors
127 
128  //- Construct null
129  orientedSurface();
130 
131  //- Construct from triSurface and sample point which is either
132  // outside (orientOutside = true) or inside (orientOutside = false).
133  // Uses linear search to find nearest.
135  (
136  const triSurface&,
137  const point& samplePoint,
138  const bool orientOutside = true
139  );
140 
141  //- Construct from triSurface. Calculates outside point as being
142  // outside the bounding box of the surface.
143  orientedSurface(const triSurface&, const bool orientOutside = true);
144 
145 
146  // Member Functions
147 
148  //- Flip faces such that normals are consistent with point:
149  // orientOutside=true : point outside surface
150  // orientOutside=false : point inside surface
151  static bool orient(triSurface&, const point&, const bool orientOutside);
152 
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************ vim: set sw=4 sts=4 et: ************************ //