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

STLsurfaceFormatCore.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::STLsurfaceFormatCore
00027 
00028 Description
00029     Internal class used by the STLsurfaceFormat
00030 
00031 SourceFiles
00032     STLsurfaceFormatCore.C
00033     STLsurfaceFormatASCII.L
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef STLsurfaceFormatCore_H
00038 #define STLsurfaceFormatCore_H
00039 
00040 #include "STLtriangle.H"
00041 #include "triFace.H"
00042 #include "IFstream.H"
00043 #include "Ostream.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 namespace fileFormats
00050 {
00051 
00052 /*---------------------------------------------------------------------------*\
00053                     Class STLsurfaceFormatCore Declaration
00054 \*---------------------------------------------------------------------------*/
00055 
00056 class STLsurfaceFormatCore
00057 {
00058     // Private Data
00059 
00060         bool sorted_;
00061 
00062         //- The points supporting the facets
00063         pointField points_;
00064 
00065         //- The zones associated with the faces
00066         List<label> zoneIds_;
00067 
00068         //- The solid names, in the order of their first appearance
00069         List<word> names_;
00070 
00071         //- The solid count, in the order of their first appearance
00072         List<label> sizes_;
00073 
00074 
00075     // Private Member Functions
00076 
00077         //- Disallow default bitwise copy construct
00078         STLsurfaceFormatCore(const STLsurfaceFormatCore&);
00079 
00080         //- Disallow default bitwise assignment
00081         void operator=(const STLsurfaceFormatCore&);
00082 
00083         //- Determine the file type
00084         static int detectBINARY(const fileName&);
00085 
00086         //- Read ASCII
00087         bool readASCII(istream&, const off_t);
00088 
00089         //- Read BINARY
00090         bool readBINARY(istream&, const off_t);
00091 
00092 
00093 public:
00094 
00095     // Static Data
00096 
00097         //- The number of bytes in the STL binary header
00098         static const unsigned int headerSize = 80;
00099 
00100 
00101     // Static Member Functions
00102 
00103         //- Write "STL binary file" and number of triangles to stream
00104         static void writeHeaderBINARY(ostream&, unsigned int);
00105 
00106 
00107     // Constructors
00108 
00109         //- Read from file, filling in the information
00110         STLsurfaceFormatCore(const fileName&);
00111 
00112 
00113     // Destructor
00114 
00115         ~STLsurfaceFormatCore();
00116 
00117 
00118     // Member Functions
00119 
00120         //- File read was already sorted
00121         bool sorted() const
00122         {
00123             return sorted_;
00124         }
00125 
00126         //- Flush all values
00127         void clear()
00128         {
00129             sorted_ = true;
00130             points_.clear();
00131             zoneIds_.clear();
00132             names_.clear();
00133             sizes_.clear();
00134         }
00135 
00136         //- Return full access to the points
00137         pointField& points()
00138         {
00139             return points_;
00140         }
00141 
00142         //- Return full access to the zoneIds
00143         List<label>& zoneIds()
00144         {
00145             return zoneIds_;
00146         }
00147 
00148         //- The list of solid names in the order of their first appearance
00149         List<word>& names()
00150         {
00151             return names_;
00152         }
00153 
00154         //- The list of solid sizes in the order of their first appearance
00155         List<label>& sizes()
00156         {
00157             return sizes_;
00158         }
00159 };
00160 
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 } // End namespace fileFormats
00165 } // End namespace Foam
00166 
00167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00168 
00169 #endif
00170 
00171 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd