FreeFOAM The Cross-Platform CFD Toolkit
surfaceLocation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::surfaceLocation
26 
27 Description
28  Contains information about location on a triSurface:
29 
30  - pointIndexHit:
31  - location
32  - bool: hit/miss
33  - index (of triangle/point/edge)
34  - elementType():
35  - what index above relates to. In triangle::proxType
36  - triangle():
37  - last known triangle
38 
39 SourceFiles
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef surfaceLocation_H
44 #define surfaceLocation_H
45 
47 #include <OpenFOAM/triPointRef.H>
48 #include <OpenFOAM/InfoProxy.H>
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class triSurface;
57 
58 /*---------------------------------------------------------------------------*\
59  Class surfaceLocation Declaration
60 \*---------------------------------------------------------------------------*/
61 
63 :
64  public pointIndexHit
65 {
66  // Private data
67 
68  triPointRef::proxType elementType_;
69 
70  label triangle_;
71 
72 public:
73 
74 
75  // Constructors
76 
77  //- Construct null
79  :
80  pointIndexHit(),
81  elementType_(triPointRef::NONE),
82  triangle_(-1)
83  {}
84 
85  //- Construct from components
87  (
88  const pointIndexHit& pih,
90  const label triangle
91  )
92  :
93  pointIndexHit(pih),
94  elementType_(elementType),
95  triangle_(triangle)
96  {}
97 
98  //- Construct from Istream
100  :
101  pointIndexHit(is),
102  elementType_(triPointRef::proxType(readLabel(is))),
103  triangle_(readLabel(is))
104  {}
105 
106 
107  // Member Functions
108 
110  {
111  return elementType_;
112  }
113 
115  {
116  return elementType_;
117  }
118 
119  label& triangle()
120  {
121  return triangle_;
122  }
123 
124  label triangle() const
125  {
126  return triangle_;
127  }
128 
129  //- Normal. Approximate for points.
130  vector normal(const triSurface& s) const;
131 
132  //- Return info proxy.
133  // Used to print token information to a stream
135  {
136  return *this;
137  }
138 
139  //- Write info to os
140  void write(Ostream& os, const triSurface& s) const;
141 
142 
143  // IOstream Operators
144 
145  friend Istream& operator>>(Istream& is, surfaceLocation& sl);
146 
147  friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
148 
149  friend Ostream& operator<<
150  (
151  Ostream&,
153  );
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************ vim: set sw=4 sts=4 et: ************************ //