AC3DsurfaceFormatCore.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "AC3DsurfaceFormatCore.H"
00028 #include "clock.H"
00029 #include "IFstream.H"
00030 #include "IStringStream.H"
00031
00032
00033
00034 bool Foam::fileFormats::AC3DsurfaceFormatCore::readCmd
00035 (
00036 IFstream& is,
00037 string& cmd,
00038 string& args
00039 )
00040 {
00041 if (is.good())
00042 {
00043 string line;
00044 is.getLine(line);
00045
00046 string::size_type space = line.find(' ');
00047
00048 if (space != string::npos)
00049 {
00050 cmd = line.substr(0, space);
00051 args = line.substr(space+1);
00052
00053 return true;
00054 }
00055 }
00056 return false;
00057 }
00058
00059
00060
00061
00062 bool Foam::fileFormats::AC3DsurfaceFormatCore::cueTo
00063 (
00064 IFstream& is,
00065 const string& cmd,
00066 string& args
00067 )
00068 {
00069 while (is.good())
00070 {
00071 string line;
00072 is.getLine(line);
00073
00074 string::size_type space = line.find(' ');
00075
00076 if (space != string::npos)
00077 {
00078 if (line.substr(0, space) == cmd)
00079 {
00080 args = line.substr(space+1);
00081
00082 return true;
00083 }
00084 }
00085 }
00086 return false;
00087 }
00088
00089
00090
00091 Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
00092 (
00093 IFstream& is,
00094 const string& cmd,
00095 const string& errorMsg
00096 )
00097 {
00098 string args;
00099 if (!cueTo(is, cmd, args))
00100 {
00101 FatalErrorIn
00102 (
00103 "fileFormats::AC3DsurfaceFormat::read(const fileName&)"
00104 )
00105 << "Cannot find command " << cmd
00106 << " " << errorMsg
00107 << exit(FatalError);
00108 }
00109
00110 return args;
00111 }
00112
00113
00114 void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
00115 (
00116 Ostream& os,
00117 const UList<surfZone>& zoneLst
00118 )
00119 {
00120
00121
00122
00123
00124
00125 static scalar colourMap[] =
00126 {
00127 1, 1, 1,
00128 1, 0, 0,
00129 0, 1, 0,
00130 0, 0, 1,
00131 1, 1, 0,
00132 0, 1, 1,
00133 1, 0, 1,
00134 0.5, 0.5, 1
00135 };
00136
00137
00138 os << "AC3Db" << nl;
00139
00140 forAll(zoneLst, zoneI)
00141 {
00142 label colourI = zoneI % 8;
00143 label colourCompI = 3 * colourI;
00144
00145 os << "MATERIAL \"" << zoneLst[zoneI].name() << "Mat\" rgb "
00146 << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
00147 << ' ' << colourMap[colourCompI+2]
00148 << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
00149 << " trans 0"
00150 << nl;
00151 }
00152
00153 os << "OBJECT world" << nl
00154 << "kids " << zoneLst.size() << endl;
00155 }
00156
00157
00158
Copyright © 2000-2009 OpenCFD Ltd