Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression test fixes #10511

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ void RimRegularLegendConfig::sendChangedSignal( const caf::PdmFieldHandle* chang
}
}

auto computeAdjustedMinMax = []( double minimum, double maximum, double precision ) -> std::pair<double, double>
{
const double threshold = 1e-9;

if ( std::fabs( maximum - minimum ) < threshold )
{
return std::make_pair( minimum, maximum );
}

auto adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( minimum, precision );
auto adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( maximum, precision );

return std::make_pair( adjustedMin, adjustedMax );
};

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -403,24 +418,21 @@ void RimRegularLegendConfig::updateLegend()

if ( m_rangeMode == RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( m_globalAutoMin, m_precision );
adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( m_globalAutoMax, m_precision );
std::tie( adjustedMin, adjustedMax ) = computeAdjustedMinMax( m_globalAutoMin, m_globalAutoMax, m_precision );

posClosestToZero = m_globalAutoPosClosestToZero;
negClosestToZero = m_globalAutoNegClosestToZero;
}
else if ( m_rangeMode == RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( m_localAutoMin, m_precision );
adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( m_localAutoMax, m_precision );
std::tie( adjustedMin, adjustedMax ) = computeAdjustedMinMax( m_localAutoMin, m_localAutoMax, m_precision );

posClosestToZero = m_localAutoPosClosestToZero;
negClosestToZero = m_localAutoNegClosestToZero;
}
else
{
adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( m_userDefinedMinValue, m_precision );
adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( m_userDefinedMaxValue, m_precision );
std::tie( adjustedMin, adjustedMax ) = computeAdjustedMinMax( m_userDefinedMinValue, m_userDefinedMaxValue, m_precision );

posClosestToZero = m_globalAutoPosClosestToZero;
negClosestToZero = m_globalAutoNegClosestToZero;
Expand Down Expand Up @@ -626,17 +638,8 @@ void RimRegularLegendConfig::disableAllTimeStepsRange( bool doDisable )
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::setAutomaticRanges( double globalMin, double globalMax, double localMin, double localMax )
{
double candidateGlobalAutoMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( globalMin, m_precision );
double candidateGlobalAutoMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( globalMax, m_precision );

double candidateLocalAutoMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( localMin, m_precision );
double candidateLocalAutoMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( localMax, m_precision );

m_globalAutoMin = candidateGlobalAutoMin;
m_globalAutoMax = candidateGlobalAutoMax;

m_localAutoMin = candidateLocalAutoMin;
m_localAutoMax = candidateLocalAutoMax;
std::tie( m_globalAutoMin, m_globalAutoMax ) = computeAdjustedMinMax( globalMin, globalMax, m_precision );
std::tie( m_localAutoMin, m_localAutoMax ) = computeAdjustedMinMax( localMin, localMax, m_precision );

updateLegend();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,6 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
std::vector<unsigned> triangleIndices;
std::vector<cvf::Vec3d> vertices;

cvf::Vec3st min, max;
if ( activeCells )
{
activeCells->IJKBoundingBox( min, max );
}

for ( size_t i = minI; i <= maxI; i++ )
{
for ( size_t j = minJ; j <= maxJ; j++ )
Expand All @@ -316,14 +310,9 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()

size_t currentCellIndex = grid->cellIndexFromIJK( i, j, zeroBasedLayerIndex );
const auto& cell = grid->cell( currentCellIndex );
if ( cell.isInvalid() ) continue;

if ( !m_includeInactiveCells() && activeCells )
{
if ( i < min.x() || i > max.x() ) continue;
if ( j < min.y() || j > max.y() ) continue;
if ( zeroBasedLayerIndex < min.z() || zeroBasedLayerIndex > max.z() ) continue;
}
if ( cell.isInvalid() ) continue;
if ( !m_includeInactiveCells() && activeCells && !activeCells->isActive( currentCellIndex ) ) continue;

cvf::Vec3d currentCornerVerts[8];

Expand Down
1 change: 0 additions & 1 deletion Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ static double adjust(double domainValue, double decadeValue, unsigned int decade
void ScalarMapperRangeBased::majorTickValues( std::vector<double>* domainValues) const
{
CVF_ASSERT(domainValues != NULL);
CVF_ASSERT(m_rangeMin != cvf::UNDEFINED_DOUBLE && m_rangeMax != cvf::UNDEFINED_DOUBLE);

if (m_userDefinedLevelValues.empty())
{
Expand Down
Loading