Gridder.h

Go to the documentation of this file.
00001 //# Gridder.h: Definition for Gridder
00002 //# Copyright (C) 1996,1997,1999,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef SCIMATH_GRIDDER_H
00030 #define SCIMATH_GRIDDER_H
00031 
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/Arrays/Array.h>
00034 #include <casacore/casa/Arrays/Vector.h>
00035 #include <casacore/casa/Arrays/Matrix.h>
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039 class IPosition;
00040 
00041 // <summary>
00042 // A base class for gridding
00043 // </summary>
00044 
00045 template <class Domain, class Range>
00046 class Gridder {
00047 public:
00048 
00049   Gridder();
00050 
00051   Gridder(const IPosition& shape, const Vector<Domain>& scale,
00052           const Vector<Domain>& offset);
00053 
00054   virtual ~Gridder();
00055 
00056   virtual Bool grid(Array<Range>&, const Vector<Domain>& position,
00057                     const Range& value) = 0;
00058 
00059   virtual Bool degrid(const Array<Range>&, const Vector<Domain>& position,
00060                       Range& value) = 0;
00061 
00062   virtual Range correct(const IPosition& loc);
00063 
00064   // Return a correction vector in x for loc y
00065   virtual void correctX1D(Vector<Range>& factor, const Int locy);
00066 
00067   Vector<Int>& location(Vector<Int>& loc, const Vector<Domain>& pos);
00068 
00069   Vector<Domain>& position(Vector<Domain>& gpos, const Vector<Domain>& pos);
00070 
00071   virtual Bool onGrid(const Vector<Int>& loc);
00072 
00073   virtual Bool onGrid(const Vector<Int>& loc, const Vector<Int>& delta);
00074 
00075   virtual Bool onGrid(const Vector<Domain>& pos);
00076 
00077   void setOffset(const Vector<Int>& off);
00078 
00079   void setOffset(const IPosition& off);
00080 
00081 protected:
00082 
00083   Int nint(Double val) {return Int(std::floor(val+0.5));}
00084 
00085   virtual void fillCorrectionVectors();
00086 
00087   // Correction factor for 1 dimension. This is virtual and
00088   // must be assigned appropriately for derived classes
00089   virtual Range correctionFactor1D(Int loc, Int len) = 0;
00090 
00091   Int ndim;
00092   IPosition shape;              // Shape of array
00093 
00094   Vector<Domain> scale;         // Scaling from world to pixel
00095   Vector<Domain> offset;        // Scaling from world to pixel
00096 
00097   Vector<Domain> posVec;        // Scaled location
00098 
00099   Vector<Int> locVec;           // Vector for location type quantities
00100   Vector<Int> shapeVec;         // Vector for shape
00101   Vector<Int> zeroShapeVec;     // Vector for zero shape
00102   Vector<Int> offsetVec;        // Offset to be added to coordinates
00103   Vector<Int> centerVec;        // IPosition for center
00104 
00105   Vector <Vector<Range> > correctionVectors;
00106 
00107 };
00108 
00109 } //# NAMESPACE CASACORE - END
00110 
00111 #ifndef CASACORE_NO_AUTO_TEMPLATES
00112 #include <casacore/scimath/Mathematics/Gridder.tcc>
00113 #endif //# CASACORE_NO_AUTO_TEMPLATES
00114 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1