GimpPDBStatusType file_vtf_save_image (const gchar *fname, gint32 image, gint32 run_mode, GError **error) { SaveInfo info; info.version = 4; info.format = Vtf::FormatDXT5; info.layer = 0; info.mipmap = TRUE; info.lowres = TRUE; info.crc = TRUE; if (run_mode == GIMP_RUN_INTERACTIVE) if (!file_vtf_save_dialog (&info)) return GIMP_PDB_CANCEL; gimp_progress_init_printf ("Saving '%s'", gimp_filename_to_utf8 (fname)); std::auto_ptr<Vtf::File> vtf (new Vtf::File); try { Vtf::HiresImageResource* vres = new Vtf::HiresImageResource; // vres->setup (info.format, info.width, info.height, info); vres->check (); vtf->addResource (vres); vtf->save (fname, info.version); } catch (std::exception& e) { } gimp_progress_update (1.0); return GIMP_PDB_SUCCESS; }
void processField ( const fvMesh& mesh, const IOobjectList& objects, const word& fieldName, label& processed ) { if (processed != -1) { return; } typedef GeometricField<Type, fvPatchField, volMesh> fieldType; const word timeName(mesh.time().timeName()); IOobjectList fieldObjbjects(objects.lookupClass(fieldType::typeName)); if (fieldObjbjects.lookup(fieldName) != NULL) { fieldType vtf(*fieldObjbjects.lookup(fieldName), mesh); const typename fieldType::GeometricBoundaryField& bf = vtf.boundaryField(); forAll(bf, patchI) { if (isA<externalCoupledMixedFvPatchField<Type> >(bf[patchI])) { Info<< "Generating external coupled geometry for field " << fieldName << endl; const externalCoupledMixedFvPatchField<Type>& pf = refCast<const externalCoupledMixedFvPatchField<Type> > ( bf[patchI] ); pf.writeGeometry(); processed = 1; break; } } if (processed != 1) { processed = 0; Info<< "Field " << fieldName << " found, but does not have any " << externalCoupledMixedFvPatchField<Type>::typeName << " boundary conditions" << endl; } }
int main(int argc, char *argv[]) { timeSelector::addOptions(); # include "addRegionOption.H" # include "setRootCase.H" # include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); # include "createNamedMesh.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << nl << endl; const IOobjectList fieldObjs(mesh, runTime.timeName()); const wordList objNames = fieldObjs.names(); PtrList<volScalarField> vsf(objNames.size()); PtrList<volVectorField> vvf(objNames.size()); PtrList<volSphericalTensorField> vsptf(objNames.size()); PtrList<volSymmTensorField> vsytf(objNames.size()); PtrList<volTensorField> vtf(objNames.size()); Info<< "Valid fields:" << endl; forAll(objNames, objI) { IOobject obj ( objNames[objI], runTime.timeName(), mesh, IOobject::MUST_READ ); if (obj.headerOk()) { addToFieldList<scalar>(vsf, obj, objI, mesh); addToFieldList<vector>(vvf, obj, objI, mesh); addToFieldList<sphericalTensor>(vsptf, obj, objI, mesh); addToFieldList<symmTensor>(vsytf, obj, objI, mesh); addToFieldList<tensor>(vtf, obj, objI, mesh); } }
gint32 file_vtf_load_image (const gchar *fname, GError **error) { gimp_progress_init_printf ("Opening '%s'", gimp_filename_to_utf8 (fname)); gint32 image = -1; std::auto_ptr<Vtf::File> vtf (new Vtf::File); try { vtf->load(fname); Vtf::HiresImageResource* vres = (Vtf::HiresImageResource*) vtf->findResource (Vtf::Resource::TypeHires); if (!vres) throw Vtf::Exception ("Cound not find high-resolution image"); image = gimp_image_new (vres->width (), vres->height (), GIMP_RGB); gimp_image_set_filename (image, fname); guint16 i, frame_count = vres->frameCount (); for (i = 0; i < frame_count; i++) { if (!file_vtf_load_layer (vres, image, i)) { g_set_error (error, 0, 0, "Unsupported format %s", Vtf::formatToString (vres->format())); gimp_image_delete (image); image = -1; break; } } gimp_progress_update (1.0); } catch (std::exception& e) { g_set_error (error, 0, 0, e.what ()); } return image; }