mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge commit 'bundle/olesenm' into home
This commit is contained in:
@ -41,6 +41,7 @@ $(surfWriters)/dx/dxSurfaceWriterRunTime.C
|
||||
$(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C
|
||||
$(surfWriters)/null/nullSurfaceWriterRunTime.C
|
||||
$(surfWriters)/raw/rawSurfaceWriterRunTime.C
|
||||
$(surfWriters)/obj/objSurfaceWriterRunTime.C
|
||||
$(surfWriters)/stl/stlSurfaceWriterRunTime.C
|
||||
$(surfWriters)/vtk/vtkSurfaceWriterRunTime.C
|
||||
|
||||
|
||||
120
src/sampling/sampledSurface/writers/obj/objSurfaceWriter.C
Normal file
120
src/sampling/sampledSurface/writers/obj/objSurfaceWriter.C
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "objSurfaceWriter.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::objSurfaceWriter<Type>::objSurfaceWriter()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::objSurfaceWriter<Type>::~objSurfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::objSurfaceWriter<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!isDir(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName fName(surfaceDir/surfaceName + ".obj");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
||||
}
|
||||
|
||||
// this is a quick hack
|
||||
OFstream os(fName);
|
||||
|
||||
os << "# Wavefront OBJ file" << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< nl
|
||||
<< "# points : " << points.size() << nl
|
||||
<< "# faces : " << faces.size() << nl
|
||||
<< "# no zones " << nl;
|
||||
|
||||
os << nl
|
||||
<< "# <points count=\"" << points.size() << "\">" << endl;
|
||||
|
||||
// Write vertex coords
|
||||
forAll(points, ptI)
|
||||
{
|
||||
os << "v " << points[ptI].x()
|
||||
<< ' ' << points[ptI].y()
|
||||
<< ' ' << points[ptI].z() << nl;
|
||||
}
|
||||
|
||||
os << "# </points>" << nl
|
||||
<< nl
|
||||
<< "# <faces count=\"" << faces.size() << "\">" << endl;
|
||||
|
||||
forAll(faces, i)
|
||||
{
|
||||
const face& f = faces[i];
|
||||
|
||||
os << 'f';
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << ' ' << f[fp] + 1;
|
||||
}
|
||||
os << nl;
|
||||
|
||||
}
|
||||
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/sampling/sampledSurface/writers/obj/objSurfaceWriter.H
Normal file
105
src/sampling/sampledSurface/writers/obj/objSurfaceWriter.H
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::objSurfaceWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
objSurfaceWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef objSurfaceWriter_H
|
||||
#define objSurfaceWriter_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class objSurfaceWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class objSurfaceWriter
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("obj");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
objSurfaceWriter();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~objSurfaceWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "objSurfaceWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "objSurfaceWriter.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeSurfaceWriters(objSurfaceWriter);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -69,7 +69,7 @@ void Foam::stlSurfaceWriter<Type>::write
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".stl");
|
||||
fileName fName(surfaceDir/surfaceName + ".stl");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user