LCOV - code coverage report
Current view: top level - components/ComponentModels/test - dPointShape.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 26 36 72.2 %
Date: 2024-11-06 17:42:47 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //# dPointCompRep.cc:
       2             : //# Copyright (C) 1997,1998,1999,2000,2001
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: dPointShape.cc 18093 2004-11-30 17:51:10Z ddebonis $
      27             : 
      28             : #include <casacore/casa/aips.h>
      29             : #include <components/ComponentModels/Flux.h>
      30             : #include <components/ComponentModels/PointShape.h>
      31             : #include <components/ComponentModels/SkyComponent.h>
      32             : #include <components/ComponentModels/ConstantSpectrum.h>
      33             : #include <components/ComponentModels/ComponentType.h>
      34             : #include <components/ComponentModels/ComponentShape.h>
      35             : #include <casacore/casa/Exceptions/Error.h>
      36             : #include <casacore/measures/Measures/MDirection.h>
      37             : #include <casacore/casa/Quanta/Quantum.h>
      38             : #include <casacore/casa/Quanta/MVAngle.h>
      39             : #include <casacore/casa/BasicSL/String.h>
      40             : 
      41             : #include <casacore/casa/namespace.h>
      42             : 
      43             : using namespace casa;
      44             : 
      45           2 : void printShape(const ComponentShape& theShape) {
      46           4 :   cout << "This is a " << ComponentType::name(theShape.type())
      47           2 :        << " shape " << endl 
      48           2 :        << "with a reference direction of "
      49           2 :        << theShape.refDirection() << endl;
      50           2 : }
      51             : 
      52           1 : int main() {
      53             :   try {
      54           1 :     MDirection J1934_dir;
      55             :     { // get the right direction into J1934_dir
      56           1 :       Quantity J1934_ra; MVAngle::read(J1934_ra, "19:39:");
      57           1 :       Quantity J1934_dec; MVAngle::read(J1934_dec, "-63.43.");
      58           1 :       J1934_dir = MDirection(J1934_ra, J1934_dec, MDirection::J2000);
      59           1 :     }
      60             :     { // One way to construct the SkyComponent
      61           1 :       SkyComponent J1934(ComponentType::POINT, ComponentType::CONSTANT_SPECTRUM);
      62           1 :       J1934.shape().setRefDirection(J1934_dir);
      63           1 :       J1934.flux() = Flux<Double>(6.28, 0.1, 0.15, 0.01);
      64           1 :       printShape(J1934.shape());
      65           1 :     }
      66             :     { // An alternative way to construct the SkyComponent
      67           1 :       const Flux<Double> flux(6.28, 0.1, 0.15, 0.01);
      68           1 :       const PointShape shape(J1934_dir);
      69           1 :       const ConstantSpectrum spectrum;
      70           1 :       SkyComponent component(flux, shape, spectrum);
      71           1 :       printShape(component.shape());
      72           1 :     }
      73           1 :   }
      74           0 :   catch (AipsError x) {
      75           0 :     cerr << x.getMesg() << endl;
      76           0 :     cout << "FAIL" << endl;
      77           0 :     return 1;
      78           0 :   }
      79           0 :   catch (...) {
      80           0 :     cerr << "Exception not derived from AipsError" << endl;
      81           0 :     cout << "FAIL" << endl;
      82           0 :     return 2;
      83           0 :   }
      84           1 :   cout << "OK" << endl;
      85           1 :   return 0;
      86             : }
      87             : // Local Variables: 
      88             : // compile-command: "gmake OPTLIB=1 dPointShape"
      89             : // End: 

Generated by: LCOV version 1.16