155 lines
3.4 KiB
C++
155 lines
3.4 KiB
C++
//-------------------------------------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TPGeExtend2D 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TPGeExtend2D 定义
|
|
// = Maintainers:
|
|
//
|
|
//-------------------------------------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TPGeExtend2D.h"
|
|
|
|
TPGeExtend2D::TPGeExtend2D(double xMin,double xMax,double yMin,double yMax) : m_xExt(xMin,xMax),m_yExt(yMin,yMax)
|
|
{
|
|
|
|
}
|
|
TPGeExtend2D::TPGeExtend2D(const TPGeExtend&xExt,const TPGeExtend&yExt) : m_xExt(xExt),m_yExt(yExt)
|
|
{
|
|
|
|
}
|
|
|
|
TPGeExtend2D::~TPGeExtend2D()
|
|
{
|
|
|
|
}
|
|
|
|
void TPGeExtend2D::SetRange(double xMin,double xMax,double yMin,double yMax)
|
|
{
|
|
m_xExt.SetRange(xMin,xMax);
|
|
m_yExt.SetRange(yMin,yMax);
|
|
}
|
|
void TPGeExtend2D::SetRange(const TPGeExtend&xExt,const TPGeExtend&yExt)
|
|
{
|
|
m_xExt = xExt;
|
|
m_yExt = yExt;
|
|
}
|
|
|
|
TPGeExtend TPGeExtend2D::GetXExtend() const
|
|
{
|
|
return m_xExt;
|
|
}
|
|
|
|
TPGeExtend TPGeExtend2D::GetYExtend() const
|
|
{
|
|
return m_yExt;
|
|
}
|
|
|
|
double TPGeExtend2D::GetLength() const
|
|
{
|
|
return m_xExt.GetLength();
|
|
}
|
|
|
|
double TPGeExtend2D::GetHeight() const
|
|
{
|
|
return m_yExt.GetLength();
|
|
}
|
|
|
|
double TPGeExtend2D::GetArea() const
|
|
{
|
|
return GetLength()*GetHeight();
|
|
}
|
|
|
|
bool TPGeExtend2D::IsValid() const
|
|
{
|
|
return m_xExt.IsValid() && m_yExt.IsValid();
|
|
}
|
|
|
|
bool TPGeExtend2D::operator == (const TPGeExtend2D& ext) const
|
|
{
|
|
return m_xExt == ext.GetXExtend() && m_yExt == ext.GetYExtend();
|
|
}
|
|
|
|
bool TPGeExtend2D::operator!=(const TPGeExtend2D& ext) const
|
|
{
|
|
return !(*this == ext);
|
|
}
|
|
|
|
bool TPGeExtend2D::operator > (const TPGeExtend2D& ext) const
|
|
{
|
|
return m_xExt>ext.m_xExt && m_yExt>ext.m_yExt;
|
|
}
|
|
|
|
bool TPGeExtend2D::operator >=(const TPGeExtend2D& ext) const
|
|
{
|
|
return m_xExt >= ext.m_xExt && m_yExt >= ext.m_yExt;
|
|
}
|
|
|
|
bool TPGeExtend2D::operator < (const TPGeExtend2D& ext) const
|
|
{
|
|
return ext>*this;
|
|
}
|
|
|
|
bool TPGeExtend2D::operator <=(const TPGeExtend2D& ext) const
|
|
{
|
|
return ext >= *this;
|
|
}
|
|
|
|
bool TPGeExtend2D::IsSameWith(const TPGeExtend2D*pExt) const
|
|
{
|
|
return this == pExt;
|
|
}
|
|
|
|
bool TPGeExtend2D::IsInclude(double x,double y) const
|
|
{
|
|
return m_xExt.IsInclude(x) && m_yExt.IsInclude(y);
|
|
}
|
|
|
|
bool TPGeExtend2D::IsInside(double x,double y) const
|
|
{
|
|
return m_xExt.IsInside(x) && m_yExt.IsInside(y);
|
|
}
|
|
|
|
bool TPGeExtend2D::IsInside(const TPGeExtend2D&ext) const
|
|
{
|
|
return m_xExt.IsInside(ext.GetXExtend()) && m_yExt.IsInside(ext.GetYExtend());
|
|
}
|
|
|
|
bool TPGeExtend2D::IsInclude(const TPGeExtend2D& ext) const
|
|
{
|
|
return m_xExt.IsInclude(ext.GetXExtend()) && m_yExt.IsInclude(ext.GetYExtend());
|
|
}
|
|
|
|
bool TPGeExtend2D::IsIntersect(const TPGeExtend2D& ext) const
|
|
{
|
|
return m_xExt.IsIntersect(ext.GetXExtend()) && m_yExt.IsIntersect(ext.GetYExtend());
|
|
}
|
|
|
|
bool TPGeExtend2D::IsConnect(const TPGeExtend2D&ext) const
|
|
{
|
|
return m_xExt.IsConnect(ext.GetXExtend()) && m_yExt.IsConnect(ext.GetYExtend());
|
|
}
|
|
|
|
TPGeExtend2D TPGeExtend2D::operator &(const TPGeExtend2D& ext) const
|
|
{
|
|
return TPGeExtend2D(m_xExt & ext.GetXExtend(), m_yExt & ext.GetYExtend());
|
|
}
|
|
|
|
TPGeExtend2D TPGeExtend2D::operator +(const TPGeExtend2D& ext) const
|
|
{
|
|
return TPGeExtend2D(m_xExt + ext.GetXExtend(),m_yExt + ext.GetYExtend());
|
|
}
|
|
|
|
TPGeExtend2D& TPGeExtend2D::operator += (const TPGeExtend2D& ext)
|
|
{
|
|
m_xExt += ext.GetXExtend();
|
|
m_yExt += ext.GetYExtend();
|
|
return *this;
|
|
}
|
|
|
|
void TPGeExtend2D::Inflate(double d)
|
|
{
|
|
m_xExt.Inflate(d);
|
|
m_yExt.Inflate(d);
|
|
} |