writeVTK.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 "triSurface.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 void triSurface::writeVTK(const bool writeSorted, Ostream& os) const
00037 {
00038
00039 os << "# vtk DataFile Version 2.0" << nl
00040 << "triSurface" << nl
00041 << "ASCII" << nl
00042 << "DATASET POLYDATA"
00043 << nl;
00044
00045 const pointField& ps = points();
00046
00047 os << "POINTS " << ps.size() << " float" << nl;
00048
00049
00050 forAll(ps, pointi)
00051 {
00052 if (pointi > 0 && (pointi % 10) == 0)
00053 {
00054 os << nl;
00055 }
00056 else
00057 {
00058 os << ' ';
00059 }
00060 os << ps[pointi].x() << ' '
00061 << ps[pointi].y() << ' '
00062 << ps[pointi].z();
00063 }
00064 os << nl;
00065
00066 os << "POLYGONS " << size() << ' ' << 4*size() << nl;
00067
00068 labelList faceMap;
00069 surfacePatchList myPatches(calcPatches(faceMap));
00070
00071 if (writeSorted)
00072 {
00073 label faceIndex = 0;
00074
00075 forAll(myPatches, patchI)
00076 {
00077
00078
00079 for
00080 (
00081 label patchFaceI = 0;
00082 patchFaceI < myPatches[patchI].size();
00083 patchFaceI++
00084 )
00085 {
00086 if (faceIndex > 0 && (faceIndex % 10) == 0)
00087 {
00088 os << nl;
00089 }
00090 else
00091 {
00092 os << ' ';
00093 }
00094
00095 const label faceI = faceMap[faceIndex++];
00096
00097 os << "3 "
00098 << operator[](faceI)[0] << ' '
00099 << operator[](faceI)[1] << ' '
00100 << operator[](faceI)[2];
00101 }
00102 }
00103 os << nl;
00104
00105
00106
00107
00108 os << "CELL_DATA " << size() << nl;
00109 os << "FIELD attributes 1" << nl;
00110 os << "region 1 " << size() << " float" << nl;
00111
00112 faceIndex = 0;
00113
00114 forAll(myPatches, patchI)
00115 {
00116 for
00117 (
00118 label patchFaceI = 0;
00119 patchFaceI < myPatches[patchI].size();
00120 patchFaceI++
00121 )
00122 {
00123 if (faceIndex > 0 && (faceIndex % 10) == 0)
00124 {
00125 os << nl;
00126 }
00127 else
00128 {
00129 os << ' ';
00130 }
00131
00132 const label faceI = faceMap[faceIndex++];
00133
00134 os << operator[](faceI).region();
00135 }
00136 }
00137 os << nl;
00138 }
00139 else
00140 {
00141 forAll(*this, faceI)
00142 {
00143 if (faceI > 0 && (faceI % 10) == 0)
00144 {
00145 os << nl;
00146 }
00147 else
00148 {
00149 os << ' ';
00150 }
00151 os << "3 "
00152 << operator[](faceI)[0] << ' '
00153 << operator[](faceI)[1] << ' '
00154 << operator[](faceI)[2];
00155 }
00156 os << nl;
00157
00158 os << "CELL_DATA " << size() << nl;
00159 os << "FIELD attributes 1" << nl;
00160 os << "region 1 " << size() << " float" << nl;
00161
00162 forAll(*this, faceI)
00163 {
00164 if (faceI > 0 && (faceI % 10) == 0)
00165 {
00166 os << nl;
00167 }
00168 else
00169 {
00170 os << ' ';
00171 }
00172 os << operator[](faceI).region();
00173 }
00174 os << nl;
00175 }
00176 }
00177
00178
00179
00180
00181 }
00182
00183
Copyright © 2000-2009 OpenCFD Ltd