void writePointSet ( const bool binary, const vtkMesh& vMesh, const pointSet& set, const fileName& fileName ) { std::ofstream ostr(fileName.c_str()); writeFuns::writeHeader ( ostr, binary, set.name() ); ostr<< "DATASET POLYDATA" << std::endl; //------------------------------------------------------------------ // // Write topology // //------------------------------------------------------------------ // Write points ostr<< "POINTS " << set.size() << " float" << std::endl; DynamicList<floatScalar> ptField(3*set.size()); writeFuns::insert ( UIndirectList<point>(vMesh.mesh().points(), set.toc())(), ptField ); writeFuns::write(ostr, binary, ptField); //----------------------------------------------------------------- // // Write data // //----------------------------------------------------------------- // Write faceID ostr << "POINT_DATA " << set.size() << std::endl << "FIELD attributes 1" << std::endl; // Cell ids first ostr<< "pointID 1 " << set.size() << " int" << std::endl; labelList pointIDs(set.toc()); writeFuns::write(ostr, binary, pointIDs); }
// Construct from components Foam::internalWriter::internalWriter ( const vtkMesh& vMesh, const bool binary, const fileName& fName ) : vMesh_(vMesh), binary_(binary), fName_(fName), os_(fName.c_str()) { const fvMesh& mesh = vMesh_.mesh(); const vtkTopo& topo = vMesh_.topo(); // Write header writeFuns::writeHeader(os_, binary_, mesh.time().caseName()); os_ << "DATASET UNSTRUCTURED_GRID" << std::endl; //------------------------------------------------------------------ // // Write topology // //------------------------------------------------------------------ const labelList& addPointCellLabels = topo.addPointCellLabels(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); os_ << "POINTS " << nTotPoints << " float" << std::endl; DynamicList<floatScalar> ptField(3*nTotPoints); writeFuns::insert(mesh.points(), ptField); const pointField& ctrs = mesh.cellCentres(); forAll(addPointCellLabels, api) { writeFuns::insert(ctrs[addPointCellLabels[api]], ptField); }
void writePointSet ( const bool binary, const vtkMesh& vMesh, const pointSet& set, const fileName& fileName ) { std::ofstream pStream(fileName.c_str()); pStream << "# vtk DataFile Version 2.0" << std::endl << set.name() << std::endl; if (binary) { pStream << "BINARY" << std::endl; } else { pStream << "ASCII" << std::endl; } pStream << "DATASET POLYDATA" << std::endl; //------------------------------------------------------------------ // // Write topology // //------------------------------------------------------------------ // Write points pStream << "POINTS " << set.size() << " float" << std::endl; DynamicList<floatScalar> ptField(3*set.size()); writeFuns::insert ( UIndirectList<point>(vMesh.mesh().points(), set.toc())(), ptField ); writeFuns::write(pStream, binary, ptField); //----------------------------------------------------------------- // // Write data // //----------------------------------------------------------------- // Write faceID pStream << "POINT_DATA " << set.size() << std::endl << "FIELD attributes 1" << std::endl; // Cell ids first pStream << "pointID 1 " << set.size() << " int" << std::endl; labelList pointIDs(set.toc()); writeFuns::write(pStream, binary, pointIDs); }