// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. /** \file ValueReader.h */ #ifndef AMDIS_VALUEREADER_H #define AMDIS_VALUEREADER_H #include "AMDiS.h" namespace AMDiS { /** \ingroup Input * * \brief * Static class which reads a png file and gets values for each pixel */ class PngReader { public: /// Copies the values of a value file to a DOF vector. static void readValues(std::string filename, DOFVector *dofVector); private: static void getMeshDimension(Mesh* mesh, double &xMin, double &xMax, double &yMin, double &yMax) { WorldVector minDim; minDim.set(1.e10); WorldVector maxDim; maxDim.set(-1.e10); TraverseStack stack; ElInfo *elInfo = stack.traverseFirst(mesh, 0, Mesh::CALL_EL_LEVEL | Mesh::FILL_COORDS); while (elInfo) { for (int i = 0; i <= mesh->getDim(); i++) { WorldVector &coords = elInfo->getMacroElement()->getCoord(i); for (int j = 0; j < coords.getSize(); ++j) { minDim[j] = std::min(minDim[j], coords[j]); maxDim[j] = std::max(maxDim[j], coords[j]); } } elInfo = stack.traverseNext(elInfo); } xMin = minDim[0]; xMax = maxDim[0]; yMin = minDim[1]; yMax = maxDim[1]; }; } #endif