Changeset 3041
- Timestamp:
- 07/27/15 18:44:50 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/GenericEdgeDetector.cpp
r2639 r3041 11 11 // 12 12 #include <math.h> 13 #include <limits.h> 14 #include <stdint.h> 13 15 14 16 #include <casa/Arrays/Vector.h> … … 167 169 dx_ = dy_ / decCorr ; 168 170 169 nx_ = uInt( ceil( wx / dx_ ) ) ; 170 ny_ = uInt( ceil( wy / dy_ ) ) ; 171 Double nxTemp = ceil(wx / dx_); 172 Double nyTemp = ceil(wy / dy_); 173 if (nxTemp > (Double)UINT_MAX || nyTemp > (Double)UINT_MAX) { 174 throw AipsError("Error in setup: Too large number of pixels."); 175 } 176 nx_ = uInt( nxTemp ) ; 177 ny_ = uInt( nyTemp ) ; 171 178 172 179 pcenx_ = 0.5 * Double( nx_ - 1 ) ; … … 186 193 os_.origin(LogOrigin( "GenericEdgeDetector", "countup", WHERE )) ; 187 194 188 uInt *a_p = new uInt[nx_*ny_] ; 189 apix_.takeStorage( IPosition(2,nx_,ny_), a_p, TAKE_OVER ) ; 195 try { 196 size_t n = (size_t)nx_ * (size_t)ny_; 197 uInt *a_p = new uInt[n] ; 198 apix_.takeStorage( IPosition(2,nx_,ny_), a_p, TAKE_OVER ) ; 199 } 200 catch (std::bad_alloc const &e) { 201 os_ << LogIO::SEVERE << "Failed to allocate working array" << LogIO::POST; 202 throw e; 203 } 204 catch (...) { 205 os_ << LogIO::SEVERE << "Failed due to unknown error" << LogIO::POST; 206 throw; 207 } 190 208 apix_ = 0 ; 191 209 … … 198 216 const Double *py_p = pdir_p + 1 ; 199 217 long offset ; 218 // apix_ is always contiguous 219 uInt *a_p = apix_.data(); 200 220 for ( uInt i = 0 ; i < len ; i++ ) { 201 221 ix = uInt(round( *px_p )) ;
Note:
See TracChangeset
for help on using the changeset viewer.