OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

STLsurfaceFormat.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::fileFormats::STLsurfaceFormat
00027 
00028 Description
00029     Provide a means of reading/writing STL files (ASCII and binary).
00030 
00031 Note
00032     For efficiency, the zones are sorted before creating the faces.
00033     The class is thus derived from MeshedSurface.
00034 
00035 SourceFiles
00036     STLsurfaceFormat.C
00037     STLsurfaceFormatASCII.L
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef STLsurfaceFormat_H
00042 #define STLsurfaceFormat_H
00043 
00044 #include "STLsurfaceFormatCore.H"
00045 #include "MeshedSurface.H"
00046 #include "MeshedSurfaceProxy.H"
00047 #include "UnsortedMeshedSurface.H"
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 namespace fileFormats
00054 {
00055 
00056 /*---------------------------------------------------------------------------*\
00057                      Class STLsurfaceFormat Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 template<class Face>
00061 class STLsurfaceFormat
00062 :
00063     public MeshedSurface<Face>
00064 {
00065     // Private Member Functions
00066 
00067         //- Write Face (ASCII)
00068         static inline void writeShell
00069         (
00070             Ostream&,
00071             const pointField&,
00072             const Face&
00073         );
00074 
00075         //- Write Face (BINARY)
00076         static inline void writeShell
00077         (
00078             ostream&,
00079             const pointField&,
00080             const Face&,
00081             const label zoneI
00082         );
00083 
00084         //- Disallow default bitwise copy construct
00085         STLsurfaceFormat(const STLsurfaceFormat<Face>&);
00086 
00087         //- Disallow default bitwise assignment
00088         void operator=(const STLsurfaceFormat<Face>&);
00089 
00090 
00091 public:
00092 
00093     // Constructors
00094 
00095         //- Construct from file name
00096         STLsurfaceFormat(const fileName&);
00097 
00098 
00099     // Selectors
00100 
00101         //- Read file and return surface
00102         static autoPtr<MeshedSurface<Face> > New(const fileName& name)
00103         {
00104             return autoPtr<MeshedSurface<Face> >
00105             (
00106                 new STLsurfaceFormat<Face>(name)
00107             );
00108         }
00109 
00110 
00111     //- Destructor
00112     virtual ~STLsurfaceFormat()
00113     {}
00114 
00115 
00116     // Member Functions
00117 
00118         //- Write surface mesh components by proxy (as ASCII)
00119         static void writeAscii
00120         (
00121             const fileName&,
00122             const MeshedSurfaceProxy<Face>&
00123         );
00124 
00125         //- Write surface mesh components by proxy (as BINARY)
00126         static void writeBinary
00127         (
00128             const fileName&,
00129             const MeshedSurfaceProxy<Face>&
00130         );
00131 
00132         //- Write surface mesh components by proxy
00133         //  as ASCII or BINARY, depending on the extension
00134         static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
00135 
00136         //- Write UnsortedMeshedSurface (as ASCII) sorted by zone
00137         static void writeAscii
00138         (
00139             const fileName&,
00140             const UnsortedMeshedSurface<Face>&
00141         );
00142 
00143         //- Write UnsortedMeshedSurface (as BINARY) unsorted by zone
00144         static void writeBinary
00145         (
00146             const fileName&,
00147             const UnsortedMeshedSurface<Face>&
00148         );
00149 
00150         //- Write UnsortedMeshedSurface
00151         //  as ASCII or BINARY, depending on the extension
00152         static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
00153 
00154         //- Read from file
00155         virtual bool read(const fileName&);
00156 
00157         //- Write object
00158         virtual void write(const fileName& name) const
00159         {
00160             write(name, MeshedSurfaceProxy<Face>(*this));
00161         }
00162 };
00163 
00164 
00165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00166 
00167 } // End namespace fileFormats
00168 } // End namespace Foam
00169 
00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00171 
00172 #ifdef NoRepository
00173 #   include "STLsurfaceFormat.C"
00174 #endif
00175 
00176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00177 
00178 #endif
00179 
00180 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd