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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "indexedVertex.H"
29 #include "point.H"
30 #include "Istream.H"
31 #include "Ostream.H"
32 #include "StringStream.H"
33 
34 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
35 
36 Foam::Istream& Foam::operator>>
37 (
38  Istream& is,
39  CGAL::Point_3<baseK>& p
40 )
41 {
42 // string data(is);
43 //
44 // std::istringstream stdIs;
45 //
46 // CGAL::set_ascii_mode(stdIs);
47 //
48 // stdIs.str(data);
49 //
50 // CGAL::Gmpz xNumer, xDenom;
51 // CGAL::Gmpz yNumer, yDenom;
52 // CGAL::Gmpz zNumer, zDenom;
53 //
54 // stdIs >> xNumer >> xDenom >> yNumer >> yDenom >> zNumer >> zDenom;
55 //
56 // CGAL::Gmpq x(xNumer, xDenom);
57 // CGAL::Gmpq y(yNumer, yDenom);
58 // CGAL::Gmpq z(zNumer, zDenom);
59 //
60 // p = CGAL::Point_3<baseK>
61 // (
62 // CGAL::to_double(x),
63 // CGAL::to_double(y),
64 // CGAL::to_double(z)
65 // );
66 
67  Foam::point pt;
68 
69  is >> pt.x() >> pt.y() >> pt.z();
70 
71  p = CGAL::Point_3<baseK>
72  (
73  pt.x(),
74  pt.y(),
75  pt.z()
76  );
77 
78  return is;
79 }
80 
81 
82 Foam::Ostream& Foam::operator<<
83 (
84  Ostream& os,
85  const CGAL::Point_3<baseK>& p
86 )
87 {
88 // CGAL::Gmpq x(CGAL::to_double(p.x()));
89 // CGAL::Gmpq y(CGAL::to_double(p.y()));
90 // CGAL::Gmpq z(CGAL::to_double(p.z()));
91 //
92 // std::ostringstream stdOs;
93 //
94 // CGAL::set_ascii_mode(stdOs);
95 //
96 // stdOs<< x.numerator() << ' ' << x.denominator() << ' '
97 // << y.numerator() << ' ' << y.denominator() << ' '
98 // << z.numerator() << ' ' << z.denominator();
99 //
100 // os << stdOs.str();
101 
102  os << CGAL::to_double(p.x()) << ' '
103  << CGAL::to_double(p.y()) << ' '
104  << CGAL::to_double(p.z());
105 
106  return os;
107 }
108 
109 
110 template<class Gt, class Vb>
111 Foam::Ostream& Foam::operator<<
112 (
113  Ostream& os,
115 )
116 {
117  os << p.point() << ' '
118  << p.index() << ' '
119  << static_cast<int>(p.type()) << ' '
120  << p.procIndex() << ' '
121  << p.alignment() << ' '
122  << p.targetCellSize() << ' '
123  << static_cast<int>(p.fixed());
124 
125  return os;
126 }
127 
128 
129 template<class Gt, class Vb>
130 Foam::Istream& Foam::operator>>
131 (
132  Istream& is,
134 )
135 {
136  is >> p.point()
137  >> p.index();
138 
139  int type;
140  is >> type;
141  p.type() = static_cast<Foam::indexedVertexEnum::vertexType>(type);
142 
143  is >> p.procIndex()
144  >> p.alignment()
145  >> p.targetCellSize();
146 
147  int fixed;
148  is >> fixed;
149  p.fixed() = static_cast<bool>(fixed);
150 
151  return is;
152 }
153 
154 
155 template<class Gt, class Vb>
156 Foam::Ostream& Foam::operator<<
157 (
158  Ostream& os,
159  const InfoProxy<CGAL::indexedVertex<Gt, Vb>>& p
160 )
161 {
162  const CGAL::indexedVertex<Gt, Vb>& iv = p.t_;
163 
164  const Foam::point pt
165  (
166  CGAL::to_double(iv.point().x()),
167  CGAL::to_double(iv.point().y()),
168  CGAL::to_double(iv.point().z())
169  );
170 
171  string fixed
172  (
173  iv.vertexFixed_
174  ? string(" fixed, ")
175  : string(" free, ")
176  );
177 
178  string referred
179  (
180  Pstream::myProcNo() == iv.processor_
181  ? string(" (local)")
182  : string(" (from " + name(iv.processor_) + ")")
183  );
184 
185  os << iv.index_ << " "
187  << " at:" << pt
188  << " size:" << iv.targetCellSize_
189  << " alignment:" << iv.alignment_
190  << fixed
191  << referred.c_str()
192  << endl;
193 
194  return os;
195 }
196 
197 
198 // ************************************************************************* //
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
p
volScalarField & p
Definition: createFieldRefs.H:8
point.H
CGAL::indexedVertex
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Definition: indexedVertex.H:54
StringStream.H
Input/output from string buffers.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::indexedVertexEnum::vertexType
vertexType
Definition: indexedVertexEnum.H:52
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Istream.H
Foam::fixed
IOstream & fixed(IOstream &io)
Definition: IOstream.H:458
os
OBJstream os(runTime.globalPath()/outputName)
Ostream.H
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56