writePatch.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 "writePatch.H"
00030 #include "OFstream.H"
00031 #include "writeFuns.H"
00032 #include "primitiveFacePatch.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038
00039
00040
00041 void writePatch
00042 (
00043 const bool binary,
00044 const word& setName,
00045 const primitiveFacePatch& fp,
00046 const word& fieldName,
00047 labelList& fieldValues,
00048 const fileName& fileName
00049 )
00050 {
00051 std::ofstream pStream(fileName.c_str());
00052
00053 pStream
00054 << "# vtk DataFile Version 2.0" << std::endl
00055 << setName << std::endl;
00056 if (binary)
00057 {
00058 pStream << "BINARY" << std::endl;
00059 }
00060 else
00061 {
00062 pStream << "ASCII" << std::endl;
00063 }
00064 pStream << "DATASET POLYDATA" << std::endl;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
00077
00078 DynamicList<floatScalar> ptField(3*fp.nPoints());
00079
00080 writeFuns::insert(fp.localPoints(), ptField);
00081
00082 writeFuns::write(pStream, binary, ptField);
00083
00084
00085 label nFaceVerts = 0;
00086
00087 forAll(fp.localFaces(), faceI)
00088 {
00089 nFaceVerts += fp.localFaces()[faceI].size() + 1;
00090 }
00091 pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
00092 << std::endl;
00093
00094
00095 DynamicList<label> vertLabels(nFaceVerts);
00096
00097 forAll(fp.localFaces(), faceI)
00098 {
00099 const face& f = fp.localFaces()[faceI];
00100
00101 vertLabels.append(f.size());
00102
00103 writeFuns::insert(f, vertLabels);
00104 }
00105 writeFuns::write(pStream, binary, vertLabels);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 pStream
00117 << "CELL_DATA " << fp.size() << std::endl
00118 << "FIELD attributes 1" << std::endl;
00119
00120
00121 pStream << fieldName << " 1 " << fp.size() << " int" << std::endl;
00122
00123 writeFuns::write(pStream, binary, fieldValues);
00124 }
00125
00126
00127
00128 }
00129
00130
Copyright © 2000-2009 OpenCFD Ltd