#ifndef FlagAgentShadow_H_
#define FlagAgentShadow_H_
#include <flagging/Flagging/FlagAgentBase.h>
#include <measures/Measures/MeasFrame.h>
#include <measures/Measures/MBaseline.h>
#include <measures/Measures/MCBaseline.h>
#include <measures/Measures/Muvw.h>
#include <measures/Measures/MCuvw.h>
#include <casa/Quanta/MVuvw.h>
#include <measures/Measures/MEpoch.h>
#include <measures/Measures/MPosition.h>
#include <measures/Measures/MCPosition.h>
#include <measures/Measures/MDirection.h>
#include <casa/Quanta/MVDirection.h>
#include <measures/Measures.h>
#include <casa/Utilities/DataType.h>
#include <casa/Containers/Record.h>
namespace casa {
class FlagAgentShadow : public FlagAgentBase {
public:
FlagAgentShadow(FlagDataHandler *dh, casacore::Record config, casacore::Bool writePrivateFlagCube = false, casacore::Bool flag = true);
~FlagAgentShadow();
protected:
void preProcessBuffer(const vi::VisBuffer2 &visBuffer);
void preProcessBufferCore(const vi::VisBuffer2 &visBuffer);
bool computeRowFlags(const vi::VisBuffer2 &visBuffer, FlagMapper &flags, casacore::uInt row);
void setAgentParameters(casacore::Record config);
private:
casacore::Bool computeAntUVW(const vi::VisBuffer2 &vb, casacore::Int rownr);
void calculateShadowedAntennas(const vi::VisBuffer2 &visBuffer, casacore::Int rownr);
void decideBaselineShadow(casacore::Double uvDistance, casacore::Double w, casacore::Int antenna1, casacore::Int antenna2);
casacore::uInt baselineIndex(casacore::uInt nAnt, casacore::uInt a1, casacore::uInt a2);
casacore::Double shadowTolerance_p;
casacore::Record additionalAntennas_p;
casacore::Vector<casacore::Double> shadowAntennaDiameters_p;
casacore::Vector<casacore::MPosition> shadowAntennaPositions_p;