bool CTileset::ReadTileTypeFile(char * szFile) { //Detect if the tiletype file already exists, if not create it if (File_Exists(szFile)) { BinaryFile tsf(szFile, "rb"); if (!tsf.is_open()) { printf("ERROR: couldn't open tileset file: %s\n", szFile); return false; } iTileTypeSize = tsf.read_i32(); if (iTileTypeSize <= 0 || iTileTypeSize > 1024) { return false; } tiletypes = new TileType[iTileTypeSize]; for (short i = 0; i < iTileTypeSize; i++) { tiletypes[i] = (TileType)tsf.read_i32(); } } else { iTileTypeSize = iWidth * iHeight; tiletypes = new TileType[iTileTypeSize]; for (short i = 0; i < iTileTypeSize; i++) { tiletypes[i] = tile_nonsolid; } } return true; }
void CTileset::SaveTileset() { BinaryFile tsf(szTilesetPath, "wb"); if (!tsf.is_open()) { printf("ERROR: couldn't open tileset file to save tile types: %s\n", szTilesetPath); return; } tsf.write_i32(iTileTypeSize); for (short i = 0; i < iTileTypeSize; i++) { tsf.write_i32(tiletypes[i]); } #if defined(__MACOSX__) chmod(szTilesetPath, S_IRWXU | S_IRWXG | S_IROTH); #endif }
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> snGradScheme<Type>::snGrad ( const GeometricField<Type, fvPatchField, volMesh>& vf, const tmp<surfaceScalarField>& tdeltaCoeffs, const word& snGradName ) { const fvMesh& mesh = vf.mesh(); // construct GeometricField<Type, fvsPatchField, surfaceMesh> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tsf ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( snGradName + "("+vf.name()+')', vf.instance(), vf.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*tdeltaCoeffs().dimensions() ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref(); // set reference to difference factors array const scalarField& deltaCoeffs = tdeltaCoeffs().internalField(); // owner/neighbour addressing const labelUList& owner = mesh.owner(); const labelUList& neighbour = mesh.neighbour(); forAll(owner, facei) { ssf[facei] = deltaCoeffs[facei]*(vf[neighbour[facei]] - vf[owner[facei]]); }