1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "objectRegistry.H"
27 #include "AC3DsurfaceFormatCore.H"
30 #include "IStringStream.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 bool Foam::fileFormats::AC3DsurfaceFormatCore::readCmd
46 string::size_type space = line.find(' ');
48 if (space != string::npos)
50 cmd = line.substr(0, space);
51 args = line.substr(space+1);
60 // Read up to line starting with cmd. Sets args to rest of line.
61 // Returns true if found, false if stream is not good anymore.
62 bool Foam::fileFormats::AC3DsurfaceFormatCore::cueTo
74 string::size_type space = line.find(' ');
76 if (space != string::npos)
78 if (line.substr(0, space) == cmd)
80 args = line.substr(space+1);
90 // Similar to cueTo(), but throws error if cmd not found
91 Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
95 const string& errorMsg
99 if (!cueTo(is, cmd, args))
103 "fileFormats::AC3DsurfaceFormat::read(const fileName&)"
105 << "Cannot find command " << cmd
114 void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
117 const UList<surfZone>& zoneLst
120 // Write with zones as separate objects under "world" object.
121 // Header is taken over from sample file.
122 // Defines separate materials for all zones. Recycle colours.
124 // Define 8 standard colours as r,g,b components
125 static scalar colourMap[] =
137 // Write header. Define materials.
140 forAll(zoneLst, zoneI)
142 label colourI = zoneI % 8;
143 label colourCompI = 3 * colourI;
145 os << "MATERIAL \"" << zoneLst[zoneI].name() << "Mat\" rgb "
146 << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
147 << ' ' << colourMap[colourCompI+2]
148 << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
153 os << "OBJECT world" << nl
154 << "kids " << zoneLst.size() << endl;
158 // ************************************************************************* //