Skip to content
Snippets Groups Projects
Commit d2f8df57 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

PngReader added to io

parent 9878746e
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ namespace AMDiS {
/** \brief
* Copies the values of a value file to a DOF vector.
*/
void PngReader::readValue(std::string filename,
void PngReader::readValues(std::string filename,
DOFVector<double> *vec)
{
FUNCNAME("ValueReader::readValue()");
......@@ -67,6 +67,9 @@ namespace AMDiS {
const BasisFunction *basFcts = vec->getFeSpace()->getBasisFcts();
int numBasFcts = basFcts->getNumber();
DegreeOfFreedom *localIndices = new DegreeOfFreedom[numBasFcts];
double xMin = 0.0, xMax = 1.0, yMin = 0.0, yMax = 1.0;
getMeshDimension(vec->getFeSpace()->getMesh(), xMin, xMax, yMin, yMax);
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(vec->getFeSpace()->getMesh(), -1,
......@@ -78,8 +81,10 @@ namespace AMDiS {
basFcts->getLocalIndices(el, vec->getFeSpace()->getAdmin(), localIndices);
for (int i = 0; i < numBasFcts; i++) {
col = static_cast<int>(((elInfo->getCoords())[i][0])*(info_ptr->width-1));
row = static_cast<int>((1.0-(elInfo->getCoords())[i][1])*(info_ptr->height-1));
double lambdaX = ((elInfo->getCoords())[i][0] - xMin)/(xMax - xMin);
double lambdaY = ((elInfo->getCoords())[i][1] - yMin)/(yMax - yMin);
col = static_cast<int>(lambdaX*(info_ptr->width-1));
row = static_cast<int>((1.0-lambdaY)*(info_ptr->height-1));
switch (bytesPerPixel) {
case 1:
value = static_cast<double>(info_ptr->row_pointers[row][col]);
......
......@@ -36,9 +36,32 @@ namespace AMDiS {
{
public:
/// Copies the values of a value file to a DOF vector.
static void readValue(std::string filename,
static void readValues(std::string filename,
DOFVector<double> *dofVector);
};
private:
static void getMeshDimension(Mesh* mesh, double &xMin, double &xMax, double &yMin, double &yMax)
{
WorldVector<double> minDim; minDim.set(1.e10);
WorldVector<double> 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<double> &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];
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment