OpenFOAM logo
Open Source CFD Toolkit

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-2005 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     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 // Class forward declarations
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         labelList faceToEdge(const labelList& changedFaces) const;
00083 
00084         //- From changed edges check the orientation of the connected faces
00085         //  and flip them. Return changed faces.
00086         labelList edgeToFace
00087         (
00088             const labelList& changedEdges,
00089             labelList& flip
00090         ) const;
00091 
00092 
00093         static label findEdge(const edgeList&, const labelList&, const edge&);
00094 
00095         //- Given nearest point and face check orientation to nearest face
00096         //  and flip if nessecary (only marked in flipState) and propagate.
00097         void propagateOrientation
00098         (
00099             const point& outsidePoint,
00100             const bool orientOutside,
00101             const label nearestFaceI,
00102             const point& nearestPt,
00103             labelList& flipState
00104         ) const;
00105 
00106         //- Given flipState reverse triangles of *this
00107         void flipSurface(const labelList& flipState);
00108 
00109         //- Flip faces such that normals are consistent with point
00110         void orientSurface(const point&, const bool orientOutside);
00111 
00112 public:
00113 
00114     ClassName("orientedSurface");
00115 
00116 
00117     // Constructors
00118 
00119         //- Construct null
00120         orientedSurface();
00121 
00122         //- Construct from triSurface and sample point which is either
00123         //  outside (orientOutside = true) or inside (orientOutside = false).
00124         //  Uses linear search to find nearest.
00125         orientedSurface
00126         (
00127             const triSurface&,
00128             const point& samplePoint,
00129             const bool orientOutside = true
00130         );
00131 
00132         //- Construct from triSurface. Calculates outside point as being
00133         //  outside the bounding box of the surface.
00134         orientedSurface(const triSurface&, const bool orientOutside = true);
00135 
00136 };
00137 
00138 
00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00140 
00141 } // End namespace Foam
00142 
00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00144 
00145 #endif
00146 
00147 // ************************************************************************* //
For further information go to www.openfoam.org