meshToolsTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 template<class FaceType>
28 (
29  Ostream& os,
30  const UList<FaceType>& faces,
31  const pointField& points,
32  const labelList& faceLabels
33 )
34 {
35  Map<label> foamToObj(4*faceLabels.size());
36 
37  label vertI = 0;
38 
39  forAll(faceLabels, i)
40  {
41  const FaceType& f = faces[faceLabels[i]];
42 
43  forAll(f, fp)
44  {
45  if (foamToObj.insert(f[fp], vertI))
46  {
47  writeOBJ(os, points[f[fp]]);
48  vertI++;
49  }
50  }
51 
52  os << 'l';
53  forAll(f, fp)
54  {
55  os << ' ' << foamToObj[f[fp]]+1;
56  }
57  os << ' ' << foamToObj[f[0]]+1 << endl;
58  }
59 }
60 
61 
62 template<class FaceType>
64 (
65  Ostream& os,
66  const UList<FaceType>& faces,
67  const pointField& points
68 )
69 {
70  labelList allFaces(faces.size());
71  forAll(allFaces, i)
72  {
73  allFaces[i] = i;
74  }
75  writeOBJ(os, faces, points, allFaces);
76 }
77 
78 
79 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
Definition: meshTools.C:203
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
labelList f(nPoints)
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311