Amplitude Spectrum::getAt(const PpmPoint & point, bool fill, bool fold ) const { Dimension dimCount = getDimCount(); assert( point.size() == dimCount ); if( fold ) { Buffer b; Spectrum* s = (Spectrum*) this; s->fillSlice( b, DimX, point, fill, fold ); return b[ 0 ]; }else { Point roi; // Point of Interest. roi.assign( dimCount, 0 ); for( Dimension d = 0; d < dimCount; d++ ) { const Scale& scale = getScale( d ); roi[ d ] = scale.getIndex( point[ d ] ); } if( fill ) { try { return getAt( roi ); }catch( ... ) { return 0; } }else return getAt( roi ); } return 0; }
Amplitude Spectrum::getAt(const PpmCube & c, bool fold) const { assert( c.size() == getDimCount() ); Amplitude _max = 0, _min = 0; Amplitude p, m; Buffer b; PpmCube c2 = c; for( Dimension d = 0; d < c.size(); d++ ) { c2.center(); c2[ d ] = c[ d ]; try { Spectrum* s = (Spectrum*) this; s->fillSlice( b, d, c2, true, fold ); b.calcMinMax( m, p ); if( p > _max ) _max = p; if( m < _min ) _min = m; }catch( ... ) { // NOP } } if( Math::fabs( _min ) > _max ) return _min; else return _max; }