initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / triSurface / surfaceLocation / surfaceLocation.H
blob9994744a190b979bd447c9d77fbea6ade9332665
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::surfaceLocation
28 Description
29     Contains information about location on a triSurface:
31     - pointIndexHit:
32         - location
33         - bool: hit/miss
34         - index (of triangle/point/edge)
35     - elementType():
36         - what index above relates to. In triangle::proxType
37     - triangle():
38         - last known triangle
40 SourceFiles
42 \*---------------------------------------------------------------------------*/
44 #ifndef surfaceLocation_H
45 #define surfaceLocation_H
47 #include "pointIndexHit.H"
48 #include "triPointRef.H"
49 #include "InfoProxy.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 namespace Foam
56 // Forward declaration of classes
57 class triSurface;
59 /*---------------------------------------------------------------------------*\
60                            Class surfaceLocation Declaration
61 \*---------------------------------------------------------------------------*/
63 class surfaceLocation
65     public pointIndexHit
67     // Private data
69         triPointRef::proxType elementType_;
71         label triangle_;
73 public:
76     // Constructors
78         //- Construct null
79         surfaceLocation()
80         :
81             pointIndexHit(),
82             elementType_(triPointRef::NONE),
83             triangle_(-1)
84         {}
86         //- Construct from components
87         surfaceLocation
88         (   
89             const pointIndexHit& pih,
90             const triPointRef::proxType elementType,
91             const label triangle
92         )
93         :
94             pointIndexHit(pih),
95             elementType_(elementType),
96             triangle_(triangle)
97         {}
99         //- Construct from Istream
100         surfaceLocation(Istream& is)
101         :
102             pointIndexHit(is),
103             elementType_(triPointRef::proxType(readLabel(is))),
104             triangle_(readLabel(is))
105         {}
108     // Member Functions
110         triPointRef::proxType& elementType()
111         {
112             return elementType_;
113         }
114         
115         triPointRef::proxType elementType() const
116         {
117             return elementType_;
118         }
120         label& triangle()
121         {
122             return triangle_;
123         }
124         
125         label triangle() const
126         {
127             return triangle_;
128         }
130         //- Normal. Approximate for points.
131         vector normal(const triSurface& s) const;
133         //- Return info proxy.
134         //  Used to print token information to a stream
135         InfoProxy<surfaceLocation> info() const
136         {
137             return *this;
138         }
140         //- Write info to os
141         void write(Ostream& os, const triSurface& s) const;
144     // IOstream Operators
146         friend Istream& operator>>(Istream& is, surfaceLocation& sl);
148         friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
150         friend Ostream& operator<<
151         (
152             Ostream&,
153             const InfoProxy<surfaceLocation>& 
154         );
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 } // End namespace Foam
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 #endif
166 // ************************************************************************* //