From 74e4544a5533c76479c26ab42e64bc26c8ddc458 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 8 Apr 2020 15:09:20 +0200 Subject: [PATCH] Correct computation of H/W ratio in Bora (Igor Zivanovic). * Bug: In Bora/SlicingDataModel, the division was done with integers, leading so there was a rounding *before* we casted to double. Now, use the BoxSet::getRatio() method and cast to double *before* dividing. --- bora/src/SlicingDataModel.cpp | 11 +++++------ bora/src/bora/BoxSet.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bora/src/SlicingDataModel.cpp b/bora/src/SlicingDataModel.cpp index bf3f14f4..cc9728ce 100644 --- a/bora/src/SlicingDataModel.cpp +++ b/bora/src/SlicingDataModel.cpp @@ -77,12 +77,11 @@ namespace Bora { NodeSets nodeSets = slicingtree->getNodeSets(); switch ( index.column() ) { case 0: return QVariant( row ); - case 1: return QVariant( DbU::toPhysical(nodeSets[row]->getHeight() , DbU::Micro) ); - case 2: return QVariant( DbU::toPhysical(nodeSets[row]->getWidth() , DbU::Micro) ); - case 3: return QVariant( nodeSets[row]->getOccupationArea() ); - case 4: return QVariant( nodeSets[row]->getCpt() ); - case 5: return QVariant( (double) ( nodeSets[row]->getWidth() - / nodeSets[row]->getHeight()) ); + case 1: return QVariant( DbU::toPhysical(nodeSets[row]->getHeight(), DbU::Micro) ); + case 2: return QVariant( DbU::toPhysical(nodeSets[row]->getWidth (), DbU::Micro) ); + case 3: return QVariant( nodeSets[row]->getOccupationArea() ); + case 4: return QVariant( nodeSets[row]->getCpt() ); + case 5: return QVariant( nodeSets[row]->getRatio() ); case 6: return QVariant( DbU::getPhysical( nodeSets[row]->getWidth() ,DbU::Micro) * DbU::getPhysical( nodeSets[row]->getHeight(),DbU::Micro) ); default: diff --git a/bora/src/bora/BoxSet.h b/bora/src/bora/BoxSet.h index d20cf8fb..82417571 100644 --- a/bora/src/bora/BoxSet.h +++ b/bora/src/bora/BoxSet.h @@ -87,7 +87,7 @@ namespace Bora { inline DbU::Unit BoxSet::getWidth () const { return _width; } inline unsigned int BoxSet::getCpt () const { return _cpt; } inline void BoxSet::incrementCpt () { _cpt++; } - inline double BoxSet::getRatio () { return _width/_height; } + inline double BoxSet::getRatio () { return (double)_width/(double)_height; } inline double BoxSet::getArea () { return _width*_height; } inline unsigned int BoxSet::getType () const { return UnknownType; } inline double BoxSet::getOccupationArea () const { return 100; }