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