writeAC.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
00028
00029 #include "triSurface.H"
00030 #include "IOmanip.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 void triSurface::writeAC(Ostream& os) const
00040 {
00041
00042
00043
00044
00045
00046 static scalar colourMap[] =
00047 {
00048 1, 1, 1,
00049 1, 0, 0,
00050 0, 1, 0,
00051 0, 0, 1,
00052 1, 1, 0,
00053 0, 1, 1,
00054 1, 0, 1,
00055 0.5, 0.5, 1
00056 };
00057
00058
00059
00060 labelList faceMap;
00061
00062 surfacePatchList myPatches(calcPatches(faceMap));
00063
00064
00065
00066
00067 os << "AC3Db" << endl;
00068
00069 forAll(myPatches, patchI)
00070 {
00071 const word& pName = myPatches[patchI].name();
00072
00073 label colourI = patchI % 8;
00074 label colourCompI = 3 * colourI;
00075
00076 os << "MATERIAL \"" << pName << "Mat\" rgb "
00077 << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
00078 << ' ' << colourMap[colourCompI+2]
00079 << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
00080 << " trans 0"
00081 << endl;
00082 }
00083
00084 os << "OBJECT world" << endl
00085 << "kids " << myPatches.size() << endl;
00086
00087
00088
00089
00090 label faceIndex = 0;
00091
00092 forAll(myPatches, patchI)
00093 {
00094 const surfacePatch& sp = myPatches[patchI];
00095
00096 os << "OBJECT poly" << endl
00097 << "name \"" << sp.name() << '"' << endl;
00098
00099
00100
00101 boolList include(size(), false);
00102
00103 forAll(sp, patchFaceI)
00104 {
00105 const label faceI = faceMap[faceIndex++];
00106
00107 include[faceI] = true;
00108 }
00109
00110 labelList pointMap;
00111 labelList faceMap;
00112
00113 triSurface patch = subsetMesh(include, pointMap, faceMap);
00114
00115
00116
00117 os << "numvert " << patch.nPoints() << endl;
00118
00119 forAll(patch.localPoints(), ptI)
00120 {
00121 const point& pt = patch.localPoints()[ptI];
00122
00123 os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
00124 }
00125
00126 os << "numsurf " << patch.localFaces().size() << endl;
00127
00128 forAll(patch.localFaces(), faceI)
00129 {
00130 const labelledTri& f = patch.localFaces()[faceI];
00131
00132 os << "SURF 0x20" << endl
00133 << "mat " << patchI << endl
00134 << "refs " << f.size() << endl;
00135
00136 os << f[0] << " 0 0" << endl;
00137 os << f[1] << " 0 0" << endl;
00138 os << f[2] << " 0 0" << endl;
00139 }
00140
00141 os << "kids 0" << endl;
00142 }
00143 }
00144
00145
00146
00147
00148 }
00149
00150
Copyright © 2000-2009 OpenCFD Ltd