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); }
void readFields ( const vtkMesh& vMesh, const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet<word>& selectedFields, PtrList<GeoField>& fields ) { // Search list of objects for volScalarFields IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); // Construct the vol scalar fields label nFields = fields.size(); fields.setSize(nFields + fieldObjects.size()); for ( IOobjectList::iterator iter = fieldObjects.begin(); iter != fieldObjects.end(); ++iter ) { if (selectedFields.empty() || selectedFields.found(iter()->name())) { fields.set ( nFields, vMesh.interpolate ( GeoField ( *iter(), mesh ) ) ); nFields++; } } fields.setSize(nFields); }
void Foam::writeFaceSet ( const bool binary, const vtkMesh& vMesh, const faceSet& set, const fileName& fileName ) { const faceList& faces = vMesh.mesh().faces(); std::ofstream ostr(fileName.c_str()); writeFuns::writeHeader ( ostr, binary, set.name() ); ostr<< "DATASET POLYDATA" << std::endl; //------------------------------------------------------------------ // // Write topology // //------------------------------------------------------------------ // Construct primitivePatch of faces in faceSet. faceList setFaces(set.size()); labelList setFaceLabels(set.size()); label setFacei = 0; forAllConstIter(faceSet, set, iter) { setFaceLabels[setFacei] = iter.key(); setFaces[setFacei] = faces[iter.key()]; setFacei++; }
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); }