1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "AC3DsurfaceFormatCore.H"
29 #include "IStringStream.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 bool Foam::fileFormats::AC3DsurfaceFormatCore::readCmd
45 string::size_type space = line.find(' ');
47 if (space != string::npos)
49 cmd = line.substr(0, space);
50 args = line.substr(space+1);
59 // Read up to line starting with cmd. Sets args to rest of line.
60 // Returns true if found, false if stream is not good anymore.
61 bool Foam::fileFormats::AC3DsurfaceFormatCore::cueTo
73 string::size_type space = line.find(' ');
75 if (space != string::npos)
77 if (line.substr(0, space) == cmd)
79 args = line.substr(space+1);
89 // Similar to cueTo(), but throws error if cmd not found
90 Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
94 const string& errorMsg
98 if (!cueTo(is, cmd, args))
102 "fileFormats::AC3DsurfaceFormat::read(const fileName&)"
104 << "Cannot find command " << cmd
113 void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
116 const UList<surfZone>& zoneLst
119 // Write with zones as separate objects under "world" object.
120 // Header is taken over from sample file.
121 // Defines separate materials for all zones. Recycle colours.
123 // Define 8 standard colours as r,g,b components
124 static scalar colourMap[] =
136 // Write header. Define materials.
139 forAll(zoneLst, zoneI)
141 label colourI = zoneI % 8;
142 label colourCompI = 3 * colourI;
144 os << "MATERIAL \"" << zoneLst[zoneI].name() << "Mat\" rgb "
145 << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
146 << ' ' << colourMap[colourCompI+2]
147 << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
152 os << "OBJECT world" << nl
153 << "kids " << zoneLst.size() << endl;
157 // ************************************************************************* //