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 "writeFaceSet.H"
00029 #include <OpenFOAM/OFstream.H>
00030 #include "writeFuns.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 void writeFaceSet
00040 (
00041 const bool binary,
00042 const vtkMesh& vMesh,
00043 const faceSet& set,
00044 const fileName& fileName
00045 )
00046 {
00047 const faceList& faces = vMesh.mesh().faces();
00048
00049 std::ofstream pStream(fileName.c_str());
00050
00051 pStream
00052 << "# vtk DataFile Version 2.0" << std::endl
00053 << set.name() << std::endl;
00054 if (binary)
00055 {
00056 pStream << "BINARY" << std::endl;
00057 }
00058 else
00059 {
00060 pStream << "ASCII" << std::endl;
00061 }
00062 pStream << "DATASET POLYDATA" << std::endl;
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 faceList setFaces(set.size());
00075 labelList setFaceLabels(set.size());
00076 label setFaceI = 0;
00077
00078 for
00079 (
00080 faceSet::const_iterator iter = set.begin();
00081 iter != set.end();
00082 ++iter
00083 )
00084 {
00085 setFaceLabels[setFaceI] = iter.key();
00086 setFaces[setFaceI] = faces[iter.key()];
00087 setFaceI++;
00088 }
00089 primitiveFacePatch fp(setFaces, vMesh.mesh().points());
00090
00091
00092
00093
00094 pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
00095
00096 DynamicList<floatScalar> ptField(3*fp.nPoints());
00097
00098 writeFuns::insert(fp.localPoints(), ptField);
00099
00100 writeFuns::write(pStream, binary, ptField);
00101
00102
00103 label nFaceVerts = 0;
00104
00105 forAll(fp.localFaces(), faceI)
00106 {
00107 nFaceVerts += fp.localFaces()[faceI].size() + 1;
00108 }
00109 pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
00110 << std::endl;
00111
00112
00113 DynamicList<label> vertLabels(nFaceVerts);
00114
00115 forAll(fp.localFaces(), faceI)
00116 {
00117 const face& f = fp.localFaces()[faceI];
00118
00119 vertLabels.append(f.size());
00120
00121 writeFuns::insert(f, vertLabels);
00122 }
00123 writeFuns::write(pStream, binary, vertLabels);
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 pStream
00135 << "CELL_DATA " << fp.size() << std::endl
00136 << "FIELD attributes 1" << std::endl;
00137
00138
00139 pStream << "faceID 1 " << fp.size() << " int" << std::endl;
00140
00141 writeFuns::write(pStream, binary, setFaceLabels);
00142 }
00143
00144
00145
00146 }
00147
00148