From 4d39136212f6ba856dc1d6afa7ce7d0da466151c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 19 Feb 2018 09:29:14 +0100 Subject: [PATCH] #2403 Extraction curves: Fix curves without vertical connections --- .../RigWellLogCurveData.cpp | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp index 8afe4b9163..674a6bc46d 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -274,11 +274,11 @@ void RigWellLogCurveData::calculateIntervalsOfContinousValidValues() //-------------------------------------------------------------------------------------------------- /// Splits the start stop interval between cells that are not close enough. -/// The depth values are expected to contain pair of depths: Depth at cell enter, and cell leave //-------------------------------------------------------------------------------------------------- -void RigWellLogCurveData::splitIntervalAtEmptySpace(const std::vector& depthValues, - size_t startIdx, size_t stopIdx, - std::vector< std::pair >* intervals) +void RigWellLogCurveData::splitIntervalAtEmptySpace(const std::vector& depthValues, + size_t startIdx, + size_t stopIdx, + std::vector< std::pair >* intervals) { CVF_ASSERT(intervals); @@ -293,20 +293,31 @@ void RigWellLogCurveData::splitIntervalAtEmptySpace(const std::vector& d // !! TODO: Find a reasonable tolerance const double depthDiffTolerance = 0.1; - // Find intervals containing depth values that should be connected - size_t intStartIdx = startIdx; - for (size_t vIdx = startIdx + 1; vIdx < stopIdx; vIdx += 2) + // Find intervals containing depth values that should be connected: + // + // vIdx = 0 is the first point of a well, usually outside of the model. Further depth values are + // organized in pairs of depths (in and out of a cell), and sometimes the depths varies slightly. If + // the distance between a depth pair is larger than the depthDiffTolerance, the two sections will be split + // into two intervals. + // + // The first pair is located at vIdx = 1 & 2. If startIdx = 0, an offset of 1 is added to vIdx, to access + // that pair in the loop. If startIdx = 1 (can happen if the start point is inside of the model and invalid), + // the offset is not needed. + + size_t intervalStartIdx = startIdx; + size_t offset = 1 - startIdx % 2; + for (size_t vIdx = startIdx + offset; vIdx < stopIdx; vIdx += 2) { if (cvf::Math::abs(depthValues[vIdx + 1] - depthValues[vIdx]) > depthDiffTolerance) { - intervals->push_back(std::make_pair(intStartIdx, vIdx)); - intStartIdx = vIdx + 1; + intervals->push_back(std::make_pair(intervalStartIdx, vIdx)); + intervalStartIdx = vIdx + 1; } } - if (intStartIdx <= stopIdx) + if (intervalStartIdx <= stopIdx) { - intervals->push_back(std::make_pair(intStartIdx, stopIdx)); + intervals->push_back(std::make_pair(intervalStartIdx, stopIdx)); } }