casa
$Rev:20696$
|
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 adressed 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: Gridder.h 21024 2011-03-01 11:46:18Z gervandiepen $ 00028 00029 #ifndef SCIMATH_GRIDDER_H 00030 #define SCIMATH_GRIDDER_H 00031 00032 #include <casa/Arrays/Array.h> 00033 #include <casa/Arrays/Vector.h> 00034 #include <casa/Arrays/Matrix.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 class IPosition; 00039 00040 // <summary> 00041 // A base class for gridding 00042 // </summary> 00043 00044 template <class Domain, class Range> 00045 class Gridder { 00046 public: 00047 00048 Gridder(); 00049 00050 Gridder(const IPosition& shape, const Vector<Domain>& scale, 00051 const Vector<Domain>& offset); 00052 00053 virtual ~Gridder(); 00054 00055 virtual Bool grid(Array<Range>&, const Vector<Domain>& position, 00056 const Range& value) = 0; 00057 00058 virtual Bool degrid(const Array<Range>&, const Vector<Domain>& position, 00059 Range& value) = 0; 00060 00061 virtual Range correct(const IPosition& loc); 00062 00063 // Return a correction vector in x for loc y 00064 virtual void correctX1D(Vector<Range>& factor, const Int locy); 00065 00066 Vector<Int>& location(Vector<Int>& loc, const Vector<Domain>& pos); 00067 00068 Vector<Domain>& position(Vector<Domain>& gpos, const Vector<Domain>& pos); 00069 00070 virtual Bool onGrid(const Vector<Int>& loc); 00071 00072 virtual Bool onGrid(const Vector<Int>& loc, const Vector<Int>& delta); 00073 00074 virtual Bool onGrid(const Vector<Domain>& pos); 00075 00076 void setOffset(const Vector<Int>& off); 00077 00078 void setOffset(const IPosition& off); 00079 00080 protected: 00081 00082 Int nint(Double val) {return Int(std::floor(val+0.5));} 00083 00084 virtual void fillCorrectionVectors(); 00085 00086 // Correction factor for 1 dimension. This is virtual and 00087 // must be assigned appropriately for derived classes 00088 virtual Range correctionFactor1D(Int loc, Int len) = 0; 00089 00090 Int ndim; 00091 IPosition shape; // Shape of array 00092 00093 Vector<Domain> scale; // Scaling from world to pixel 00094 Vector<Domain> offset; // Scaling from world to pixel 00095 00096 Vector<Domain> posVec; // Scaled location 00097 00098 Vector<Int> locVec; // Vector for location type quantities 00099 Vector<Int> shapeVec; // Vector for shape 00100 Vector<Int> zeroShapeVec; // Vector for zero shape 00101 Vector<Int> offsetVec; // Offset to be added to coordinates 00102 Vector<Int> centerVec; // IPosition for center 00103 00104 Vector <Vector<Range> > correctionVectors; 00105 00106 }; 00107 00108 } //# NAMESPACE CASA - END 00109 00110 #ifndef CASACORE_NO_AUTO_TEMPLATES 00111 #include <scimath/Mathematics/Gridder.tcc> 00112 #endif //# CASACORE_NO_AUTO_TEMPLATES 00113 #endif