meshToolsTemplates.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) 2011-2013 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 template<class FaceType>
30 (
31  Ostream& os,
32  const UList<FaceType>& faces,
33  const UList<point>& points,
34  const labelList& faceLabels
35 )
36 {
37  Map<label> foamToObj(4*faceLabels.size());
38 
39  label vertI = 0;
40 
41  forAll(faceLabels, i)
42  {
43  const FaceType& f = faces[faceLabels[i]];
44 
45  forAll(f, fp)
46  {
47  if (foamToObj.insert(f[fp], vertI))
48  {
49  writeOBJ(os, points[f[fp]]);
50  vertI++;
51  }
52  }
53 
54  os << 'f';
55  forAll(f, fp)
56  {
57  os << ' ' << foamToObj[f[fp]]+1;
58  }
59  os << ' ' << foamToObj[f[0]]+1 << endl;
60  }
61 }
62 
63 
64 template<class FaceType>
66 (
67  Ostream& os,
68  const UList<FaceType>& faces,
69  const UList<point>& points
70 )
71 {
72  labelList allFaces(faces.size());
73  forAll(allFaces, i)
74  {
75  allFaces[i] = i;
76  }
77  writeOBJ(os, faces, points, allFaces);
78 }
79 
80 
81 // ************************************************************************* //
Foam::meshTools::writeOBJ
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of a point.
Definition: meshTools.C:203
Foam::Map< label >
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
f
labelList f(nPoints)
Foam::List< label >
Foam::UList
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:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56