FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

orientedSurface.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::orientedSurface
00026 
00027 Description
00028     Given point flip all faces such that normals point in same direction.
00029 
00030 SourceFiles
00031     orientedSurface.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef orientedSurface_H
00036 #define orientedSurface_H
00037 
00038 #include <triSurface/triSurface.H>
00039 #include <OpenFOAM/typeInfo.H>
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 // Forward declaration of classes
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class orientedSurface Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class orientedSurface
00053 :
00054     public triSurface
00055 {
00056     // Data types
00057 
00058         //- Enumeration listing whether face needs to be flipped.
00059         enum sideStat
00060         {
00061             UNVISITED,
00062             FLIP,
00063             NOFLIP
00064         };
00065 
00066 
00067     // Private Member Functions
00068 
00069         //- Return true if face uses edge from start to end.
00070         static bool edgeOrder(const labelledTri&, const edge&);
00071 
00072         //- Return true if edge is used in opposite order in faces
00073         static bool consistentEdge
00074         (
00075             const edge& e,
00076             const labelledTri& f0,
00077             const labelledTri& f1
00078         );
00079 
00080         //- From changed faces get the changed edges
00081         static labelList faceToEdge
00082         (
00083             const triSurface&,
00084             const labelList& changedFaces
00085         );
00086 
00087         //- From changed edges check the orientation of the connected faces
00088         //  and flip them. Return changed faces.
00089         static labelList edgeToFace
00090         (
00091             const triSurface&,
00092             const labelList& changedEdges,
00093             labelList& flip
00094         );
00095 
00096         //- Walk from face across connected faces. Change orientation to be
00097         //  consistent with startFaceI.
00098         static void walkSurface
00099         (
00100             const triSurface& s,
00101             const label startFaceI,
00102             labelList& flipState
00103         );
00104 
00105         //- Given nearest point and face check orientation to nearest face
00106         //  and flip if nessecary (only marked in flipState) and propagate.
00107         static void propagateOrientation
00108         (
00109             const triSurface&,
00110             const point& outsidePoint,
00111             const bool orientOutside,
00112             const label nearestFaceI,
00113             const point& nearestPt,
00114             labelList& flipState
00115         );
00116 
00117         //- Given flipState reverse triangles of *this. Return true if
00118         //  anything flipped.
00119         static bool flipSurface(triSurface& s, const labelList& flipState);
00120 
00121 public:
00122 
00123     ClassName("orientedSurface");
00124 
00125 
00126     // Constructors
00127 
00128         //- Construct null
00129         orientedSurface();
00130 
00131         //- Construct from triSurface and sample point which is either
00132         //  outside (orientOutside = true) or inside (orientOutside = false).
00133         //  Uses linear search to find nearest.
00134         orientedSurface
00135         (
00136             const triSurface&,
00137             const point& samplePoint,
00138             const bool orientOutside = true
00139         );
00140 
00141         //- Construct from triSurface. Calculates outside point as being
00142         //  outside the bounding box of the surface.
00143         orientedSurface(const triSurface&, const bool orientOutside = true);
00144 
00145 
00146     // Member Functions
00147 
00148         //- Flip faces such that normals are consistent with point:
00149         //  orientOutside=true : point outside surface
00150         //  orientOutside=false : point inside surface
00151         static bool orient(triSurface&, const point&, const bool orientOutside);
00152 
00153 };
00154 
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 } // End namespace Foam
00159 
00160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00161 
00162 #endif
00163 
00164 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines