labelledPoint.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  labelledPoint
26 
27 Description
28  A class containing point label and its coordinates. It is used for
29  exchanging data over processors
30 
31 SourceFiles
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef labelledPoint_H
36 #define labelledPoint_H
37 
38 #include "label.H"
39 #include "point.H"
40 #include "contiguous.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class labelledPoint Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class labelledPoint
52 {
53  // Private data
54  //- point label
55  label pLabel_;
56 
57  //- point coordinates
58  point coords_;
59 
60  public:
61 
62  // Constructors
63  //- Null construct
65  :
66  pLabel_(-1),
68  {}
69 
70  //- Construct from point and label
71  labelledPoint(const label pl, const point& p)
72  :
73  pLabel_(pl),
74  coords_(p)
75  {}
76 
77  // Destructor
79  {}
80 
81  // Member functions
82  //- return point label
83  inline label pointLabel() const
84  {
85  return pLabel_;
86  }
87 
88  inline label& pointLabel()
89  {
90  return pLabel_;
91  }
92 
93  //- return point coordinates
94  inline const point& coordinates() const
95  {
96  return coords_;
97  }
98 
99  inline point& coordinates()
100  {
101  return coords_;
102  }
103 
104  // Member operators
105 
106  inline void operator=(const labelledPoint& lp)
107  {
108  pLabel_ = lp.pLabel_;
109  coords_ = lp.coords_;
110  }
111 
112  inline bool operator==(const labelledPoint& lp) const
113  {
114  if( pLabel_ == lp.pLabel_ )
115  return true;
116 
117  return false;
118  }
119 
120  inline bool operator!=(const labelledPoint& lp) const
121  {
122  return !this->operator==(lp);
123  }
124 
125  // Friend operators
126  friend Ostream& operator<<(Ostream& os, const labelledPoint& lp)
127  {
128  os << token::BEGIN_LIST;
129  os << lp.pLabel_ << token::SPACE;
130  os << lp.coords_ << token::END_LIST;
131 
132  // Check state of Ostream
133  os.check("operator<<(Ostream&, const labelledPoint&");
134 
135  return os;
136  }
137 
138  friend Istream& operator>>(Istream& is, labelledPoint& lp)
139  {
140  // Read beginning of labelledPoint
141  is.readBegin("labelledPoint");
142 
143  is >> lp.pLabel_;
144  is >> lp.coords_;
145 
146  // Read end of labelledPoint
147  is.readEnd("labelledPoint");
148 
149  // Check state of Istream
150  is.check("operator>>(Istream&, labelledPoint");
151 
152  return is;
153  }
154 };
155 
156 //- Specify data associated with labelledPoint type is contiguous
157 template<>
158 inline bool contiguous<labelledPoint>() {return true;}
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
Foam::labelledPoint::coordinates
point & coordinates()
Definition: labelledPoint.H:98
Foam::labelledPoint::coordinates
const point & coordinates() const
return point coordinates
Definition: labelledPoint.H:93
p
p
Definition: pEqn.H:62
point.H
Foam::labelledPoint::labelledPoint
labelledPoint(const label pl, const point &p)
Construct from point and label.
Definition: labelledPoint.H:70
Foam::labelledPoint::~labelledPoint
~labelledPoint()
Definition: labelledPoint.H:77
Foam::contiguous< labelledPoint >
bool contiguous< labelledPoint >()
Specify data associated with labelledPoint type is contiguous.
Definition: labelledPoint.H:157
Foam::labelledPoint::pointLabel
label & pointLabel()
Definition: labelledPoint.H:87
Foam::labelledPoint::operator<<
friend Ostream & operator<<(Ostream &os, const labelledPoint &lp)
Definition: labelledPoint.H:125
Foam::labelledPoint::operator==
bool operator==(const labelledPoint &lp) const
Definition: labelledPoint.H:111
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::labelledPoint::labelledPoint
labelledPoint()
Null construct.
Definition: labelledPoint.H:63
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::labelledPoint::pLabel_
label pLabel_
point label
Definition: labelledPoint.H:54
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::labelledPoint::coords_
point coords_
point coordinates
Definition: labelledPoint.H:57
Foam::labelledPoint::operator=
void operator=(const labelledPoint &lp)
Definition: labelledPoint.H:105
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::labelledPoint
Definition: labelledPoint.H:50
Foam::Vector< scalar >
label.H
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::labelledPoint::operator>>
friend Istream & operator>>(Istream &is, labelledPoint &lp)
Definition: labelledPoint.H:137
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Istream::readBegin
Istream & readBegin(const char *funcName)
Definition: Istream.C:88
Foam::labelledPoint::operator!=
bool operator!=(const labelledPoint &lp) const
Definition: labelledPoint.H:119
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::labelledPoint::pointLabel
label pointLabel() const
return point label
Definition: labelledPoint.H:82
Foam::token::SPACE
@ SPACE
Definition: token.H:95
Foam::zero
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47