00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::fileFormats::STLsurfaceFormat 00026 00027 Description 00028 Provide a means of reading/writing STL files (ASCII and binary). 00029 00030 Note 00031 For efficiency, the zones are sorted before creating the faces. 00032 The class is thus derived from MeshedSurface. 00033 00034 SourceFiles 00035 STLsurfaceFormat.C 00036 STLsurfaceFormatASCII.L 00037 00038 \*---------------------------------------------------------------------------*/ 00039 00040 #ifndef STLsurfaceFormat_H 00041 #define STLsurfaceFormat_H 00042 00043 #include "STLsurfaceFormatCore.H" 00044 #include <surfMesh/MeshedSurface.H> 00045 #include <surfMesh/MeshedSurfaceProxy.H> 00046 #include <surfMesh/UnsortedMeshedSurface.H> 00047 00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00049 00050 namespace Foam 00051 { 00052 namespace fileFormats 00053 { 00054 00055 /*---------------------------------------------------------------------------*\ 00056 Class STLsurfaceFormat Declaration 00057 \*---------------------------------------------------------------------------*/ 00058 00059 template<class Face> 00060 class STLsurfaceFormat 00061 : 00062 public MeshedSurface<Face> 00063 { 00064 // Private Member Functions 00065 00066 //- Write Face (ASCII) 00067 static inline void writeShell 00068 ( 00069 Ostream&, 00070 const pointField&, 00071 const Face& 00072 ); 00073 00074 //- Write Face (BINARY) 00075 static inline void writeShell 00076 ( 00077 ostream&, 00078 const pointField&, 00079 const Face&, 00080 const label zoneI 00081 ); 00082 00083 //- Disallow default bitwise copy construct 00084 STLsurfaceFormat(const STLsurfaceFormat<Face>&); 00085 00086 //- Disallow default bitwise assignment 00087 void operator=(const STLsurfaceFormat<Face>&); 00088 00089 00090 public: 00091 00092 // Constructors 00093 00094 //- Construct from file name 00095 STLsurfaceFormat(const fileName&); 00096 00097 00098 // Selectors 00099 00100 //- Read file and return surface 00101 static autoPtr<MeshedSurface<Face> > New(const fileName& name) 00102 { 00103 return autoPtr<MeshedSurface<Face> > 00104 ( 00105 new STLsurfaceFormat<Face>(name) 00106 ); 00107 } 00108 00109 00110 //- Destructor 00111 virtual ~STLsurfaceFormat() 00112 {} 00113 00114 00115 // Member Functions 00116 00117 //- Write surface mesh components by proxy (as ASCII) 00118 static void writeAscii 00119 ( 00120 const fileName&, 00121 const MeshedSurfaceProxy<Face>& 00122 ); 00123 00124 //- Write surface mesh components by proxy (as BINARY) 00125 static void writeBinary 00126 ( 00127 const fileName&, 00128 const MeshedSurfaceProxy<Face>& 00129 ); 00130 00131 //- Write surface mesh components by proxy 00132 // as ASCII or BINARY, depending on the extension 00133 static void write(const fileName&, const MeshedSurfaceProxy<Face>&); 00134 00135 //- Write UnsortedMeshedSurface (as ASCII) sorted by zone 00136 static void writeAscii 00137 ( 00138 const fileName&, 00139 const UnsortedMeshedSurface<Face>& 00140 ); 00141 00142 //- Write UnsortedMeshedSurface (as BINARY) unsorted by zone 00143 static void writeBinary 00144 ( 00145 const fileName&, 00146 const UnsortedMeshedSurface<Face>& 00147 ); 00148 00149 //- Write UnsortedMeshedSurface 00150 // as ASCII or BINARY, depending on the extension 00151 static void write(const fileName&, const UnsortedMeshedSurface<Face>&); 00152 00153 //- Read from file 00154 virtual bool read(const fileName&); 00155 00156 //- Write object 00157 virtual void write(const fileName& name) const 00158 { 00159 write(name, MeshedSurfaceProxy<Face>(*this)); 00160 } 00161 }; 00162 00163 00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00165 00166 } // End namespace fileFormats 00167 } // End namespace Foam 00168 00169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00170 00171 #ifdef NoRepository 00172 # include "STLsurfaceFormat.C" 00173 #endif 00174 00175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00176 00177 #endif 00178 00179 // ************************ vim: set sw=4 sts=4 et: ************************ //