Skip to content
Snippets Groups Projects
Commit 9655bf78 authored by Karsten Rink's avatar Karsten Rink
Browse files

fixed epsilon calculation and default raster value assignment

parent f87eb16d
No related branches found
No related tags found
No related merge requests found
...@@ -47,14 +47,16 @@ void VtkCompositeColorByHeightFilter::init() ...@@ -47,14 +47,16 @@ void VtkCompositeColorByHeightFilter::init()
unsigned char a[4] = { 0, 0, 255, 255 }; // blue unsigned char a[4] = { 0, 0, 255, 255 }; // blue
unsigned char b[4] = { 0, 255, 0, 255 }; // green unsigned char b[4] = { 0, 255, 0, 255 }; // green
unsigned char c[4] = { 255, 255, 0, 255 }; // yellow unsigned char c[4] = { 255, 255, 0, 255 }; // yellow
unsigned char d[4] = { 255, 0, 0, 255 }; // red unsigned char d[4] = { 155, 100, 50, 255 }; // brown
unsigned char e[4] = { 255, 0, 0, 255 }; // red
VtkColorLookupTable* ColorLookupTable = heightFilter->GetColorLookupTable(); VtkColorLookupTable* ColorLookupTable = heightFilter->GetColorLookupTable();
ColorLookupTable->setInterpolationType(VtkColorLookupTable::LUTType::LINEAR); ColorLookupTable->setInterpolationType(VtkColorLookupTable::LUTType::LINEAR);
ColorLookupTable->setColor(-35, a); ColorLookupTable->setColor(-50, a);
ColorLookupTable->setColor(150, b); // green at about 150m ColorLookupTable->setColor(200, b); // green at about 20m
ColorLookupTable->setColor(450, c); // yellow at about 450m and changing to red from then on ColorLookupTable->setColor(500, c); // yellow at about 500m and changing to red from then on
ColorLookupTable->setColor(800, d); ColorLookupTable->setColor(1000, d);
ColorLookupTable->SetTableRange(-35, 800); ColorLookupTable->setColor(2000, e);
ColorLookupTable->SetTableRange(-35, 2000);
ColorLookupTable->Build(); ColorLookupTable->Build();
// This passes ownership of the ColorLookupTable to VtkVisPointSetItem // This passes ownership of the ColorLookupTable to VtkVisPointSetItem
......
...@@ -694,11 +694,10 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) ...@@ -694,11 +694,10 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName)
} }
else { else {
settings.setValue("lastOpenedTetgenFileDirectory", QFileInfo(fileName).absolutePath()); settings.setValue("lastOpenedTetgenFileDirectory", QFileInfo(fileName).absolutePath());
QString element_fname = QFileDialog::getOpenFileName(this, "Select TetGen element file", QString element_fname(fi.path() + "\\" + fi.completeBaseName() + ".ele");
settings.value("lastOpenedTetgenFileDirectory").toString(),
"TetGen element files (*.ele);;");
if (!fileName.isEmpty() && !element_fname.isEmpty()) { if (!fileName.isEmpty())
{
FileIO::TetGenInterface tetgen; FileIO::TetGenInterface tetgen;
MeshLib::Mesh* mesh (tetgen.readTetGenMesh(fileName.toStdString(), element_fname.toStdString())); MeshLib::Mesh* mesh (tetgen.readTetGenMesh(fileName.toStdString(), element_fname.toStdString()));
if (mesh) if (mesh)
......
...@@ -59,7 +59,9 @@ bool LayeredVolume::createGeoVolumes(const MeshLib::Mesh &mesh, const std::vecto ...@@ -59,7 +59,9 @@ bool LayeredVolume::createGeoVolumes(const MeshLib::Mesh &mesh, const std::vecto
if (mesh.getDimension() != 2) if (mesh.getDimension() != 2)
return false; return false;
_elevation_epsilon = calcEpsilon(*rasters.back(), *rasters[0]); _elevation_epsilon = calcEpsilon(*rasters[0], *rasters.back());
if (_elevation_epsilon <= 0)
return false;
// remove line elements, only tri + quad remain // remove line elements, only tri + quad remain
MeshLib::ElementExtraction ex(mesh); MeshLib::ElementExtraction ex(mesh);
...@@ -74,7 +76,7 @@ bool LayeredVolume::createGeoVolumes(const MeshLib::Mesh &mesh, const std::vecto ...@@ -74,7 +76,7 @@ bool LayeredVolume::createGeoVolumes(const MeshLib::Mesh &mesh, const std::vecto
for (size_t i=0; i<nRasters; ++i) for (size_t i=0; i<nRasters; ++i)
{ {
const double replacement_value = (i==0) ? noDataReplacementValue : _invalid_value; const double replacement_value = (i==0) ? noDataReplacementValue : _invalid_value;
if (!MeshLayerMapper::LayerMapping(*mesh_layer, *rasters[i], 0, 0, _invalid_value)) if (!MeshLayerMapper::LayerMapping(*mesh_layer, *rasters[i], 0, 0, replacement_value))
{ {
this->cleanUpOnError(); this->cleanUpOnError();
return false; return false;
...@@ -207,7 +209,7 @@ bool LayeredVolume::exportToGeometry(GeoLib::GEOObjects &geo_objects) const ...@@ -207,7 +209,7 @@ bool LayeredVolume::exportToGeometry(GeoLib::GEOObjects &geo_objects) const
double LayeredVolume::calcEpsilon(const GeoLib::Raster &high, const GeoLib::Raster &low) double LayeredVolume::calcEpsilon(const GeoLib::Raster &high, const GeoLib::Raster &low)
{ {
const double max (*std::max_element(high.begin(), high.end())); const double max (*std::max_element(high.begin(), high.end()));
const double min (*std::min_element(high.begin(), high.end())); const double min (*std::min_element( low.begin(), low.end()));
return ((max-min)*1e-07); return ((max-min)*1e-07);
} }
......
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