ENH: Template writeOBJ functions on the face type

This commit is contained in:
laurence
2013-03-21 09:45:05 +00:00
parent 15ff97d947
commit 0ba0ff841c
3 changed files with 115 additions and 55 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -215,6 +215,20 @@ void Foam::meshTools::writeOBJ
} }
void Foam::meshTools::writeOBJ
(
Ostream& os,
const triad& t,
const point& pt
)
{
forAll(t, dirI)
{
writeOBJ(os, pt, pt + t[dirI]);
}
}
void Foam::meshTools::writeOBJ void Foam::meshTools::writeOBJ
( (
Ostream& os, Ostream& os,
@ -248,57 +262,6 @@ void Foam::meshTools::writeOBJ
} }
void Foam::meshTools::writeOBJ
(
Ostream& os,
const faceList& faces,
const pointField& points,
const labelList& faceLabels
)
{
Map<label> foamToObj(4*faceLabels.size());
label vertI = 0;
forAll(faceLabels, i)
{
const face& f = faces[faceLabels[i]];
forAll(f, fp)
{
if (foamToObj.insert(f[fp], vertI))
{
writeOBJ(os, points[f[fp]]);
vertI++;
}
}
os << 'l';
forAll(f, fp)
{
os << ' ' << foamToObj[f[fp]]+1;
}
os << ' ' << foamToObj[f[0]]+1 << endl;
}
}
void Foam::meshTools::writeOBJ
(
Ostream& os,
const faceList& faces,
const pointField& points
)
{
labelList allFaces(faces.size());
forAll(allFaces, i)
{
allFaces[i] = i;
}
writeOBJ(os, faces, points, allFaces);
}
void Foam::meshTools::writeOBJ void Foam::meshTools::writeOBJ
( (
Ostream& os, Ostream& os,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,6 +37,7 @@ SourceFiles
#include "label.H" #include "label.H"
#include "vector.H" #include "vector.H"
#include "triad.H"
#include "labelList.H" #include "labelList.H"
#include "pointField.H" #include "pointField.H"
#include "faceList.H" #include "faceList.H"
@ -107,6 +108,15 @@ namespace meshTools
const point& pt const point& pt
); );
//- Write obj representation of a triad. Requires the location of the
// triad to be supplied
void writeOBJ
(
Ostream& os,
const triad& t,
const point& pt
);
//- Write obj representation of a line connecting two points //- Write obj representation of a line connecting two points
// Need to keep track of points that have been added. count starts at 0 // Need to keep track of points that have been added. count starts at 0
void writeOBJ void writeOBJ
@ -126,19 +136,21 @@ namespace meshTools
); );
//- Write obj representation of faces subset //- Write obj representation of faces subset
template <class FaceType>
void writeOBJ void writeOBJ
( (
Ostream& os, Ostream& os,
const faceList&, const List<FaceType>&,
const pointField&, const pointField&,
const labelList& faceLabels const labelList& faceLabels
); );
//- Write obj representation of faces //- Write obj representation of faces
template <class FaceType>
void writeOBJ void writeOBJ
( (
Ostream& os, Ostream& os,
const faceList&, const List<FaceType>&,
const pointField& const pointField&
); );
@ -332,6 +344,12 @@ namespace meshTools
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "meshToolsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template <class FaceType>
void Foam::meshTools::writeOBJ
(
Ostream& os,
const List<FaceType>& faces,
const pointField& points,
const labelList& faceLabels
)
{
Map<label> foamToObj(4*faceLabels.size());
label vertI = 0;
forAll(faceLabels, i)
{
const FaceType& f = faces[faceLabels[i]];
forAll(f, fp)
{
if (foamToObj.insert(f[fp], vertI))
{
writeOBJ(os, points[f[fp]]);
vertI++;
}
}
os << 'l';
forAll(f, fp)
{
os << ' ' << foamToObj[f[fp]]+1;
}
os << ' ' << foamToObj[f[0]]+1 << endl;
}
}
template <class FaceType>
void Foam::meshTools::writeOBJ
(
Ostream& os,
const List<FaceType>& faces,
const pointField& points
)
{
labelList allFaces(faces.size());
forAll(allFaces, i)
{
allFaces[i] = i;
}
writeOBJ(os, faces, points, allFaces);
}
// ************************************************************************* //