indexedVertex.C
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) 2012-2016 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "indexedVertex.H"
27 #include "point.H"
28 #include "Istream.H"
29 #include "Ostream.H"
30 #include "OStringStream.H"
31 #include "IStringStream.H"
32 
33 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
34 
35 Foam::Istream& Foam::operator>>
36 (
37  Istream& is,
38  CGAL::Point_3<baseK>& p
39 )
40 {
41 // string data(is);
42 //
43 // std::istringstream stdIs;
44 //
45 // CGAL::set_ascii_mode(stdIs);
46 //
47 // stdIs.str(data);
48 //
49 // CGAL::Gmpz xNumer, xDenom;
50 // CGAL::Gmpz yNumer, yDenom;
51 // CGAL::Gmpz zNumer, zDenom;
52 //
53 // stdIs >> xNumer >> xDenom >> yNumer >> yDenom >> zNumer >> zDenom;
54 //
55 // CGAL::Gmpq x(xNumer, xDenom);
56 // CGAL::Gmpq y(yNumer, yDenom);
57 // CGAL::Gmpq z(zNumer, zDenom);
58 //
59 // p = CGAL::Point_3<baseK>
60 // (
61 // CGAL::to_double(x),
62 // CGAL::to_double(y),
63 // CGAL::to_double(z)
64 // );
65 
66  Foam::point pt;
67 
68  is >> pt.x() >> pt.y() >> pt.z();
69 
70  p = CGAL::Point_3<baseK>
71  (
72  pt.x(),
73  pt.y(),
74  pt.z()
75  );
76 
77  return is;
78 }
79 
80 
81 Foam::Ostream& Foam::operator<<
82 (
83  Ostream& os,
84  const CGAL::Point_3<baseK>& p
85 )
86 {
87 // CGAL::Gmpq x(CGAL::to_double(p.x()));
88 // CGAL::Gmpq y(CGAL::to_double(p.y()));
89 // CGAL::Gmpq z(CGAL::to_double(p.z()));
90 //
91 // std::ostringstream stdOs;
92 //
93 // CGAL::set_ascii_mode(stdOs);
94 //
95 // stdOs<< x.numerator() << ' ' << x.denominator() << ' '
96 // << y.numerator() << ' ' << y.denominator() << ' '
97 // << z.numerator() << ' ' << z.denominator();
98 //
99 // os << stdOs.str();
100 
101  os << CGAL::to_double(p.x()) << ' '
102  << CGAL::to_double(p.y()) << ' '
103  << CGAL::to_double(p.z());
104 
105  return os;
106 }
107 
108 
109 template<class Gt, class Vb>
110 Foam::Ostream& Foam::operator<<
111 (
112  Ostream& os,
114 )
115 {
116  os << p.point() << ' '
117  << p.index() << ' '
118  << static_cast<int>(p.type()) << ' '
119  << p.procIndex() << ' '
120  << p.alignment() << ' '
121  << p.targetCellSize() << ' '
122  << static_cast<int>(p.fixed());
123 
124  return os;
125 }
126 
127 
128 template<class Gt, class Vb>
129 Foam::Istream& Foam::operator>>
130 (
131  Istream& is,
133 )
134 {
135  is >> p.point()
136  >> p.index();
137 
138  int type;
139  is >> type;
140  p.type() = static_cast<Foam::indexedVertexEnum::vertexType>(type);
141 
142  is >> p.procIndex()
143  >> p.alignment()
144  >> p.targetCellSize();
145 
146  int fixed;
147  is >> fixed;
148  p.fixed() = static_cast<bool>(fixed);
149 
150  return is;
151 }
152 
153 
154 template<class Gt, class Vb>
155 Foam::Ostream& Foam::operator<<
156 (
157  Ostream& os,
158  const InfoProxy<CGAL::indexedVertex<Gt, Vb>>& p
159 )
160 {
161  const CGAL::indexedVertex<Gt, Vb>& iv = p.t_;
162 
163  const Foam::point pt
164  (
165  CGAL::to_double(iv.point().x()),
166  CGAL::to_double(iv.point().y()),
167  CGAL::to_double(iv.point().z())
168  );
169 
170  string fixed
171  (
172  iv.vertexFixed_
173  ? string(" fixed, ")
174  : string(" free, ")
175  );
176 
177  string referred
178  (
179  Pstream::myProcNo() == iv.processor_
180  ? string(" (local)")
181  : string(" (from " + name(iv.processor_) + ")")
182  );
183 
184  os << iv.index_ << " "
186  << " at:" << pt
187  << " size:" << iv.targetCellSize_
188  << " alignment:" << iv.alignment_
189  << fixed
190  << referred.c_str()
191  << endl;
192 
193  return os;
194 }
195 
196 
197 // ************************************************************************* //
type
Types of root.
Definition: Roots.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
const Cmpt & z() const
Definition: VectorI.H:87
IOstream & fixed(IOstream &io)
Definition: IOstream.H:576
const Cmpt & y() const
Definition: VectorI.H:81
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Definition: indexedVertex.H:51
const Cmpt & x() const
Definition: VectorI.H:75
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
volScalarField & p