LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - ImageRotator.tcc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 43 0.0 %
Date: 2023-11-06 10:06:49 Functions: 0 4 0.0 %

          Line data    Source code
       1             : //# Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
       2             : //# Associated Universities, Inc. Washington DC, USA.
       3             : //#
       4             : //# This library is free software; you can redistribute it and/or modify it
       5             : //# under the terms of the GNU Library General Public License as published by
       6             : //# the Free Software Foundation; either version 2 of the License, or (at your
       7             : //# option) any later version.
       8             : //#
       9             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      10             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      12             : //# License for more details.
      13             : //#
      14             : //# You should have received a copy of the GNU Library General Public License
      15             : //# along with this library; if not, write to the Free Software Foundation,
      16             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      17             : //#
      18             : //# Correspondence concerning AIPS++ should be addressed as follows:
      19             : //#        Internet email: aips2-request@nrao.edu.
      20             : //#        Postal address: AIPS++ Project Office
      21             : //#                        National Radio Astronomy Observatory
      22             : //#                        520 Edgemont Road
      23             : //#                        Charlottesville, VA 22903-2475 USA
      24             : //#
      25             : 
      26             : #ifndef IMAGEANALYSIS_IMAGEROTATOR_TCC
      27             : #define IMAGEANALYSIS_IMAGEROTATOR_TCC
      28             : 
      29             : #include <imageanalysis/ImageAnalysis/ImageRotator.h>
      30             : 
      31             : #include <imageanalysis/ImageAnalysis/ImageRegridder.h>
      32             : 
      33             : #include <memory>
      34             : 
      35             : using namespace casacore;
      36             : 
      37             : namespace casa {
      38             : 
      39             : template <class T> const String ImageRotator<T>::CLASS_NAME = "ImageRotator";
      40             : 
      41           0 : template <class T> ImageRotator<T>::ImageRotator(
      42             :         const SPCIIT image, const Record *const &regionPtr,
      43             :     const String& mask,const String& outname, Bool overwrite
      44           0 : ) : ImageTask<T>(image, "", regionPtr, "", "", "", mask, outname, overwrite) {
      45           0 :         this->_construct(true);
      46           0 : }
      47             : 
      48           0 : template <class T> ImageRotator<T>::~ImageRotator() {}
      49             : 
      50           0 : template <class T> SPIIT ImageRotator<T>::rotate() {
      51           0 :     *this->_getLog() << LogOrigin(getClass(), __func__);
      52           0 :     if (_shape.empty()) {
      53           0 :         const auto imShape = this->_getImage()->shape();
      54           0 :         _shape = this->_getDropDegen() ? imShape.nonDegenerate() : imShape;
      55             :     }
      56           0 :     auto subImage = SubImageFactory<T>::createSubImageRO(
      57           0 :         *this->_getImage(), *this->_getRegion(), this->_getMask(),
      58           0 :         this->_getLog().get(), AxesSpecifier(! this->_getDropDegen()),
      59             :         this->_getStretch()
      60             :     );
      61           0 :     const auto& cSysFrom = subImage->coordinates();
      62           0 :     auto cSysTo = cSysFrom;
      63             :     // We automatically find a DirectionCoordinate or LInearCoordinate
      64             :     // These must hold *only* 2 axes at this point (restriction in ImageRegrid)
      65           0 :     Vector<Int> pixelAxes;
      66           0 :     if (cSysTo.hasDirectionCoordinate()) {
      67           0 :         auto index = cSysTo.directionCoordinateNumber();
      68           0 :         pixelAxes = cSysTo.pixelAxes(index);
      69           0 :         std::unique_ptr<DirectionCoordinate> dc(
      70           0 :             dynamic_cast<DirectionCoordinate *>(
      71           0 :                 cSysTo.directionCoordinate().rotate(_angle)
      72             :             )
      73             :         );
      74           0 :         cSysTo.replaceCoordinate(*dc, (uInt)index);
      75           0 :         *this->_getLog() << "Rotating DirectionCoordinate holding axes "
      76           0 :             << pixelAxes << LogIO::POST;
      77             :     }
      78           0 :     else if (cSysTo.hasLinearCoordinate()) {
      79           0 :         auto index = cSysTo.linearCoordinateNumber();
      80           0 :         pixelAxes = cSysTo.pixelAxes(index);
      81           0 :         ThrowIf(
      82             :             pixelAxes.size() != 2,
      83             :             "Can only rotate a linear coordinate with exactly two axes"
      84             :         );
      85           0 :         std::unique_ptr<LinearCoordinate> lc(
      86           0 :             dynamic_cast<LinearCoordinate *>(
      87           0 :                 cSysTo.linearCoordinate(index).rotate(_angle)
      88             :             )
      89             :         );
      90           0 :         cSysTo.replaceCoordinate(*lc, (uInt)index);
      91             :     }
      92             :     else {
      93           0 :         ThrowCc(
      94             :             "Can only rotate a direction coordinate or a linear "
      95             :             "coordiante with exactly two axes"
      96             :         );
      97             :     }
      98           0 :     IPosition axes2(pixelAxes);
      99           0 :     ImageRegridder<T> regridder(
     100             :         subImage, nullptr, "", this->_getOutname(),
     101           0 :         this->_getOverwrite(), cSysTo, axes2, _shape
     102             :     );
     103           0 :     regridder.setDecimate(_decimate);
     104           0 :     regridder.setMethod(_method);
     105           0 :     regridder.setReplicate(_replicate);
     106           0 :     regridder.setShape(_shape);
     107           0 :     regridder.addHistory(this->getHistory());
     108           0 :     return regridder.regrid();
     109             : }
     110             : 
     111             : }
     112             : 
     113             : #endif

Generated by: LCOV version 1.16