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

surfaceLocation.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::surfaceLocation
00027 
00028 Description
00029     Contains information about location on a triSurface:
00030 
00031     - pointIndexHit:
00032         - location
00033         - bool: hit/miss
00034         - index (of triangle/point/edge)
00035     - elementType():
00036         - what index above relates to. In triangle::proxType
00037     - triangle():
00038         - last known triangle
00039 
00040 SourceFiles
00041 
00042 \*---------------------------------------------------------------------------*/
00043 
00044 #ifndef surfaceLocation_H
00045 #define surfaceLocation_H
00046 
00047 #include "pointIndexHit.H"
00048 #include "triPointRef.H"
00049 #include "InfoProxy.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 // Forward declaration of classes
00057 class triSurface;
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class surfaceLocation Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 class surfaceLocation
00064 :
00065     public pointIndexHit
00066 {
00067     // Private data
00068 
00069         triPointRef::proxType elementType_;
00070 
00071         label triangle_;
00072 
00073 public:
00074 
00075 
00076     // Constructors
00077 
00078         //- Construct null
00079         surfaceLocation()
00080         :
00081             pointIndexHit(),
00082             elementType_(triPointRef::NONE),
00083             triangle_(-1)
00084         {}
00085 
00086         //- Construct from components
00087         surfaceLocation
00088         (   
00089             const pointIndexHit& pih,
00090             const triPointRef::proxType elementType,
00091             const label triangle
00092         )
00093         :
00094             pointIndexHit(pih),
00095             elementType_(elementType),
00096             triangle_(triangle)
00097         {}
00098 
00099         //- Construct from Istream
00100         surfaceLocation(Istream& is)
00101         :
00102             pointIndexHit(is),
00103             elementType_(triPointRef::proxType(readLabel(is))),
00104             triangle_(readLabel(is))
00105         {}
00106 
00107 
00108     // Member Functions
00109 
00110         triPointRef::proxType& elementType()
00111         {
00112             return elementType_;
00113         }
00114         
00115         triPointRef::proxType elementType() const
00116         {
00117             return elementType_;
00118         }
00119 
00120         label& triangle()
00121         {
00122             return triangle_;
00123         }
00124         
00125         label triangle() const
00126         {
00127             return triangle_;
00128         }
00129 
00130         //- Normal. Approximate for points.
00131         vector normal(const triSurface& s) const;
00132 
00133         //- Return info proxy.
00134         //  Used to print token information to a stream
00135         InfoProxy<surfaceLocation> info() const
00136         {
00137             return *this;
00138         }
00139 
00140         //- Write info to os
00141         void write(Ostream& os, const triSurface& s) const;
00142 
00143 
00144     // IOstream Operators
00145 
00146         friend Istream& operator>>(Istream& is, surfaceLocation& sl);
00147 
00148         friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
00149 
00150         friend Ostream& operator<<
00151         (
00152             Ostream&,
00153             const InfoProxy<surfaceLocation>& 
00154         );
00155 };
00156 
00157 
00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00159 
00160 } // End namespace Foam
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 #endif
00165 
00166 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd