////////////////////////////////////////////////////////////////////////////////
// 
// RegularityCheck.hh 
//
//    produced: 2001/10/20 jr
// last change: 2001/10/20 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef REGULARITYCHECK_WORKAROUND_HH
#define REGULARITYCHECK_WORKAROUND_HH


#include "RegularityCheckCache.hh"

class RegularityCheck {
private:
  Matrix                    _coeffs;
  const PointConfiguration* _pointsptr;
  const Chirotope*          _chiroptr;
  const SimplicialComplex*  _triangptr;
private:
  RegularityCheck();
public:
  // constructors:
  RegularityCheck(const PointConfiguration& points, 
		  const Chirotope& chiro, 
		  const SimplicialComplex& t): 
        _pointsptr(&points),
        _chiroptr (&chiro),
        _triangptr(&t)
   {
      //gkz_type gkz(points);
   }
  inline RegularityCheck(const RegularityCheck&);
  inline RegularityCheck(const RegularityCheck&, const Flip&);
  // destructor:
  inline ~RegularityCheck();
  // assignments:
  inline RegularityCheck& operator=(const RegularityCheck&);
  // accessors:
  inline const Matrix     coeffs()   const { return _coeffs; }
  inline const Chirotope* chiroptr() const { return _chiroptr; }
  // functions:
  inline const bool is_regular() const;
};

// constructors:

inline RegularityCheck::RegularityCheck(const RegularityCheck&) {
  std::cerr << "RegularityCheck::RegularityCheck(const RegularityCheck&): not yet implemented!" << std::endl;
}

inline RegularityCheck::RegularityCheck(const RegularityCheck&, const Flip&){
  std::cerr << "RegularityCheck::RegularityCheck(const RegularityCheck&, const Flip&): not yet implemented!" << std::endl;
}

// destructor:
inline RegularityCheck::~RegularityCheck() {}

// assignment:
inline RegularityCheck& RegularityCheck::operator=(const RegularityCheck& rc) {
  if (this == &rc) {
    return *this;
  }
  _coeffs   = rc._coeffs;
  _chiroptr = rc._chiroptr;
  return *this;
}

// functions:
inline const bool RegularityCheck::is_regular() const {
   pm::Array<pm::Set<Int>> pmMC(_triangptr->card());
   Int i = 0;
   for (SimplicialComplex::const_iterator iter1 = _triangptr->begin();
       iter1 != _triangptr->end();
       ++iter1) {
      pmMC[i] = pm::convert_to<pm::Set<Int>>(*iter1);
      i++;
   }
   static RegularityCheckCache rcc(100, *_pointsptr, *_chiroptr, CommandlineOptions::polymake_lp_client());
   return rcc.subdivision_is_regular(pmMC);
}

#endif

// eof RegularityCheck.hh
