Skip to content
Snippets Groups Projects
Commit 5fe0d98f authored by Tom Fischer's avatar Tom Fischer
Browse files

Using GeoLib::Raster instead of VtkRaster in DirectConditionGenerator.

parent c92dd17a
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,14 @@
* Created on 2012-01-04 by Karsten Rink
*/
#include <fstream>
// ThirdParty/logog
#include "logog/include/logog.hpp"
#include "DirectConditionGenerator.h"
#include "VtkRaster.h"
#include "Raster.h"
#include "MshEditor.h"
#include "PointWithID.h"
#include "Mesh.h"
......@@ -23,18 +28,21 @@ const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directT
{
if (_direct_values.empty())
{
double origin_x(0), origin_y(0), delta(0), no_data(-9999);
unsigned imgwidth(0), imgheight(0);
double* img = VtkRaster::loadDataFromASC(filename, origin_x, origin_y, imgwidth, imgheight, delta, no_data);
if (img == 0)
{
std::cout << "Error in DirectConditionGenerator::directWithSurfaceIntegration() - could not load vtk raster." << std::endl;
GeoLib::Raster* raster(GeoLib::Raster::getRasterFromASCFile(filename));
if (! raster) {
ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration() - could not load vtk raster.");
return _direct_values;
}
}
double origin_x(raster->getOrigin()[0]);
double origin_y(raster->getOrigin()[1]);
double delta(raster->getRasterPixelDistance());
double no_data(raster->getNoDataValue());
unsigned imgwidth(raster->getNCols()), imgheight(raster->getNRows());
double const*const img(raster->begin());
const double dir[3] = {0,0,1};
const std::vector<GeoLib::PointWithID*> surface_nodes ( MeshLib::MshEditor::getSurfaceNodes(mesh, dir) );
const std::vector<GeoLib::PointWithID*> surface_nodes(MeshLib::MshEditor::getSurfaceNodes(mesh, dir) );
//std::vector<MeshLib::CNode*> nodes = mesh.nod_vector;
const size_t nNodes(surface_nodes.size());
_direct_values.reserve(nNodes);
......@@ -57,11 +65,10 @@ const std::vector< std::pair<size_t,double> >& DirectConditionGenerator::directT
}
}
delete[] img;
delete raster;
}
else
std::cout << "Error in DirectConditionGenerator::directToSurfaceNodes() - Data vector contains outdated values..." << std::endl;
ERR("Error in DirectConditionGenerator::directToSurfaceNodes() - Data vector contains outdated values.");
return _direct_values;
}
......
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