/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This file contains the declaration of the CUnion class.             //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
#ifndef __CUNION_HPP__
#define __CUNION_HPP__


#include "CBooleanSurface.hpp"


/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This class is a constructive geometry implementation for boolean    //
// union of two surfaces.                                              //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
class CUnion : public CBooleanSurface
{
public:
  inline CUnion(const std::string& strName,
                CSurface* pOrigSurface1,
                CSurface* pOrigSurface2);
  virtual ~CUnion();


  // Interface implementation
  inline virtual CUnion* Copy() const;


protected:
  // This function describes the boolean operation representing this
  // surface
  virtual bool IsIn(bool surface1, bool surface2) const;

  // This function does the concrete OpenGL drawing of the surface
  virtual void ConcreteDrawGL() const;
};




inline CUnion::CUnion(const std::string& strName,
                      CSurface* pOrigSurface1,
                      CSurface* pOrigSurface2)
  : CBooleanSurface(strName,
                    pOrigSurface1,
                    pOrigSurface2)
{
}
inline CUnion::~CUnion()
{
}
inline CUnion* CUnion::Copy() const
{
  return new CUnion(*this);
}

inline bool CUnion::IsIn(bool surface1, bool surface2) const
{
  return (surface1 || surface2);
}
inline void CUnion::ConcreteDrawGL() const
{
  pSurface1.get()->DrawGL();
  pSurface2.get()->DrawGL();
}




#endif // __CUNION_HPP__
