最小外包矩形对象的封装

最小外包矩形MBR就是包围图元,且平行于X,Y轴的最小外接矩形。

    template<class T>
    struct CGeoRect
    {
        // Four corner points
        T m_minX; 
        T m_minY;
        T m_maxX;
        T m_maxY;
		
        //
        // Constructors and deconstructor
        //
        /**
        * Default constructor with no any sense.
		*
		* Note: 
		* 1) If passed by self-defined data type, it must have copy constructor being responsible for
		* converting doulbe to it.
		* 2) Since we adopt UEZERO as invalid point which makes sense when not initialized before being used, 
		* we had better notice the assertion happen before correctly using one geometry.
        */
        CGeoRect() : m_minX(-1.), m_minY(-1.), m_maxX(-1.), m_maxY(-1.)
        {
        }
        
        /**
        * Default constructor with specified corner values.
        */
        CGeoRect(const T &minX, const T &minY, const T &maxX, const T& maxY) : m_minX(minX), 
			m_minY(minY), m_maxX(maxX), m_maxY(maxY)
        {
        }

        /**
        * Copy constructor.
		*
		* Note: If passed by self-defined data type, it must overload assignment operator
        */
        CGeoRect(const CGeoRect &other)
        {
            m_minX = other.m_minX;
            m_maxY = other.m_maxY;
            m_maxX = other.m_maxX;
            m_minY = other.m_minY;
  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值