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