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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2013-2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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 "DelaunayMeshTools.H"
29#include "meshTools.H"
30#include "OFstream.H"
31#include "pointConversion.H"
32
33// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
34
36(
37 const fileName& fName,
38 const List<Foam::point>& points
39)
40{
41 if (points.size())
42 {
43 OFstream str(fName);
44
45 Pout<< nl
46 << "Writing " << points.size() << " points from pointList to "
47 << str.name() << endl;
48
50 {
51 meshTools::writeOBJ(str, points[p]);
52 }
53 }
54}
55
56
58(
59 const fileName& fName,
60 const List<Vb>& points
61)
62{
63 if (points.size())
64 {
65 OFstream str(fName);
66
67 Pout<< nl
68 << "Writing " << points.size() << " points from pointList to "
69 << str.name() << endl;
70
72 {
73 meshTools::writeOBJ(str, topoint(points[p].point()));
74 }
75 }
76}
77
78
80(
81 const fileName& fName,
82 const pointField& points,
83 const faceList& faces
84)
85{
86 OFstream str(fName);
87
88 Pout<< nl
89 << "Writing points and faces to " << str.name() << endl;
90
92 {
93 meshTools::writeOBJ(str, points[p]);
94 }
95
96 forAll(faces, f)
97 {
98 str<< 'f';
99
100 const face& fP = faces[f];
101
102 forAll(fP, p)
103 {
104 str<< ' ' << fP[p] + 1;
105 }
106
107 str<< nl;
108 }
109}
110
111
112// ************************************************************************* //
volScalarField & p
const pointField & points
void writeOBJ(const fileName &fName, const List< Foam::point > &points)
Write list of points to file.
void writeObjMesh(const fileName &fName, const pointField &points, const faceList &faces)
Write an OBJ mesh consisting of points and faces.
pointFromPoint topoint(const Point &P)
vector point
Point is a vector.
Definition: point.H:43
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333