DelaunayMeshTools.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) 2013-2015 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 "DelaunayMeshTools.H"
27 #include "meshTools.H"
28 #include "OFstream.H"
29 #include "pointConversion.H"
30 
31 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
32 
34 (
35  const fileName& fName,
36  const List<Foam::point>& points
37 )
38 {
39  if (points.size())
40  {
41  OFstream str(fName);
42 
43  Pout<< nl
44  << "Writing " << points.size() << " points from pointList to "
45  << str.name() << endl;
46 
47  forAll(points, p)
48  {
49  meshTools::writeOBJ(str, points[p]);
50  }
51  }
52 }
53 
54 
56 (
57  const fileName& fName,
58  const List<Vb>& points
59 )
60 {
61  if (points.size())
62  {
63  OFstream str(fName);
64 
65  Pout<< nl
66  << "Writing " << points.size() << " points from pointList to "
67  << str.name() << endl;
68 
69  forAll(points, p)
70  {
71  meshTools::writeOBJ(str, topoint(points[p].point()));
72  }
73  }
74 }
75 
76 
78 (
79  const fileName& fName,
80  const pointField& points,
81  const faceList& faces
82 )
83 {
84  OFstream str(fName);
85 
86  Pout<< nl
87  << "Writing points and faces to " << str.name() << endl;
88 
89  forAll(points, p)
90  {
91  meshTools::writeOBJ(str, points[p]);
92  }
93 
94  forAll(faces, f)
95  {
96  str<< 'f';
97 
98  const face& fP = faces[f];
99 
100  forAll(fP, p)
101  {
102  str<< ' ' << fP[p] + 1;
103  }
104 
105  str<< nl;
106  }
107 }
108 
109 
110 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
pointFromPoint topoint(const Point &P)
void writeOBJ(const fileName &fName, const List< Foam::point > &points)
Write list of points to file.
List< face > faceList
Definition: faceListFwd.H:43
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
Definition: meshTools.C:203
void writeObjMesh(const fileName &fName, const pointField &points, const faceList &faces)
Write an OBJ mesh consisting of points and faces.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
static const char nl
Definition: Ostream.H:262
labelList f(nPoints)
vector point
Point is a vector.
Definition: point.H:41
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
volScalarField & p