/** * \return The vector in the given vectors that is closest to this vector * or an invalid vector if the given vector does not contain any * (valid) vectors. */ RVector RVector::getClosest(const QList<RVector>& list) const { int index = getClosestIndex(list); if (index==-1) { return RVector::invalid; } return list[index]; }
void PlaneWellLog::updateFilledLogColor() { if( getLogItem() == SEISMIC_ONLY ) { for ( unsigned int idx=0; idx<_logPath->size(); idx++ ) { (*_logColors)[2*idx] = _colorTable->at(1); (*_logColors)[2*idx+1] = _colorTable->at(1); } return ; } if ( !_shapeLog->size() || !_isFilled) return; const float clrStep = ( _maxFillValue - _minFillValue ) / 255; int clrIndex = 0; const int nrSamples = _logPath->size(); _outFillIndex.clear(); const osg::FloatArray::iterator itmin = std::min_element( _fillLogDepths->begin(), _fillLogDepths->end()); const float minfillz = *itmin; const osg::FloatArray::iterator itmax = std::max_element( _fillLogDepths->begin(), _fillLogDepths->end()); const float maxfillz = *itmax; for ( int idx=0; idx<nrSamples; idx++ ) { const osg::Vec3f pos = _logPath->at(idx); if( pos[2] < minfillz || pos[2] > maxfillz ) { _outFillIndex.push_back(idx); continue; } const int fillIndex = getClosestIndex(*_fillLogDepths, pos[2]); if ( fillIndex < 0 ) continue; const float fillLogVal = _fillLog->at(fillIndex); clrIndex = (int)((fillLogVal-_minFillValue )/clrStep); clrIndex = (clrIndex > 255) ? 255 : clrIndex; clrIndex = (clrIndex < 0 ) ? 0 : clrIndex; (*_logColors)[2*idx] = _colorTable->at(clrIndex); (*_logColors)[2*idx+1] = _colorTable->at(clrIndex); } _colorTableChanged = false; }