#include "ImageExprCalculator.h"
#include <casacore/casa/BasicSL/String.h>
#include <casacore/images/Images/ImageBeamSet.h>
#include <casacore/images/Images/ImageInterface.h>
#include <casacore/images/Images/ImageProxy.h>
#include <imageanalysis/ImageTypedefs.h>
#include <imageanalysis/ImageAnalysis/ImageFactory.h>
#include <imageanalysis/ImageAnalysis/PixelValueManipulator.h>
template<class T> ImageExprCalculator<T>::ImageExprCalculator(
const casacore::String& expression, const casacore::String& outname, casacore::Bool overwrite
) : _expr(expression), _outname(outname),
_overwrite(overwrite), _log() {
ThrowIf(_expr.empty(), "You must specify an expression");
if (! outname.empty() && ! overwrite) {
//casacore::NewFile validfile;
! casacore::NewFile().valueOK(outname, errmsg), errmsg
template<class T> SPIIT ImageExprCalculator<T>::compute() const {
_log << casacore::LogOrigin(getClass(), __func__);
casacore::Record regions;
// Get casacore::LatticeExprNode (tree) from parser. Substitute possible
// object-id's by a sequence number, while creating a
// casacore::LatticeExprNode for it. Convert the GlishRecord containing
// regions to a casacore::PtrBlock<const casacore::ImageRegion*>.
casacore::Block<casacore::LatticeExprNode> temps;
casacore::String exprName;
casacore::PtrBlock<const casacore::ImageRegion*> tempRegs;
_makeRegionBlock(tempRegs, regions);
casacore::LatticeExprNode node = casacore::ImageExprParse::command(_expr, temps, tempRegs);
// Delete the ImageRegions (by using an empty casacore::Record).
_makeRegionBlock(tempRegs, casacore::Record());
// Get the shape of the expression
const casacore::IPosition shape = node.shape();
// Get the casacore::CoordinateSystem of the expression
const casacore::LELAttribute attr = node.getAttribute();
const casacore::LELLattCoordBase* lattCoord = &(attr.coordinates().coordinates());
! lattCoord->hasCoordinates()
|| lattCoord->classname() != "LELImageCoord",
"Images in expression have no coordinates"
const casacore::LELImageCoord* imCoord =
dynamic_cast<const casacore::LELImageCoord*> (lattCoord);
AlwaysAssert (imCoord != 0, casacore::AipsError);
casacore::CoordinateSystem csys = imCoord->coordinates();
//DataType type = node.dataType();