OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::orientedSurface
00027 
00028 Description
00029     Given point flip all faces such that normals point in same direction.
00030 
00031 SourceFiles
00032     orientedSurface.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef orientedSurface_H
00037 #define orientedSurface_H
00038 
00039 #include "triSurface.H"
00040 #include "typeInfo.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // Forward declaration of classes
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class orientedSurface Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class orientedSurface
00054 :
00055     public triSurface
00056 {
00057     // Data types
00058 
00059         //- Enumeration listing whether face needs to be flipped.
00060         enum sideStat
00061         {
00062             UNVISITED,
00063             FLIP,
00064             NOFLIP
00065         };
00066 
00067 
00068     // Private Member Functions
00069 
00070         //- Return true if face uses edge from start to end.
00071         static bool edgeOrder(const labelledTri&, const edge&);
00072 
00073         //- Return true if edge is used in opposite order in faces
00074         static bool consistentEdge
00075         (
00076             const edge& e,
00077             const labelledTri& f0,
00078             const labelledTri& f1
00079         );
00080 
00081         //- From changed faces get the changed edges
00082         static labelList faceToEdge
00083         (
00084             const triSurface&,
00085             const labelList& changedFaces
00086         );
00087 
00088         //- From changed edges check the orientation of the connected faces
00089         //  and flip them. Return changed faces.
00090         static labelList edgeToFace
00091         (
00092             const triSurface&,
00093             const labelList& changedEdges,
00094             labelList& flip
00095         );
00096 
00097         //- Walk from face across connected faces. Change orientation to be
00098         //  consistent with startFaceI.
00099         static void walkSurface
00100         (
00101             const triSurface& s,
00102             const label startFaceI,
00103             labelList& flipState
00104         );
00105 
00106         //- Given nearest point and face check orientation to nearest face
00107         //  and flip if nessecary (only marked in flipState) and propagate.
00108         static void propagateOrientation
00109         (
00110             const triSurface&,
00111             const point& outsidePoint,
00112             const bool orientOutside,
00113             const label nearestFaceI,
00114             const point& nearestPt,
00115             labelList& flipState
00116         );
00117 
00118         //- Given flipState reverse triangles of *this. Return true if
00119         //  anything flipped.
00120         static bool flipSurface(triSurface& s, const labelList& flipState);
00121 
00122 public:
00123 
00124     ClassName("orientedSurface");
00125 
00126 
00127     // Constructors
00128 
00129         //- Construct null
00130         orientedSurface();
00131 
00132         //- Construct from triSurface and sample point which is either
00133         //  outside (orientOutside = true) or inside (orientOutside = false).
00134         //  Uses linear search to find nearest.
00135         orientedSurface
00136         (
00137             const triSurface&,
00138             const point& samplePoint,
00139             const bool orientOutside = true
00140         );
00141 
00142         //- Construct from triSurface. Calculates outside point as being
00143         //  outside the bounding box of the surface.
00144         orientedSurface(const triSurface&, const bool orientOutside = true);
00145 
00146 
00147     // Member Functions
00148 
00149         //- Flip faces such that normals are consistent with point:
00150         //  orientOutside=true : point outside surface
00151         //  orientOutside=false : point inside surface
00152         static bool orient(triSurface&, const point&, const bool orientOutside);
00153 
00154 };
00155 
00156 
00157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00158 
00159 } // End namespace Foam
00160 
00161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00162 
00163 #endif
00164 
00165 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd