150 lines
2.4 KiB
C++
150 lines
2.4 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TGPoint2D.cpp
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 类的定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TGPoint2D.h"
|
|
#include "TGPoint3D.h"
|
|
#include "TGRegion2D.h"
|
|
|
|
IMPLEMENT_RUN_TIME_CLASS1(TGPoint2D,"TGPoint2D",TGObject2D)
|
|
|
|
TGPoint2D::TGPoint2D(double X,double Y,double Z)
|
|
: TGPoint(X,Y,Z)
|
|
{
|
|
|
|
}
|
|
|
|
TGPoint2D::TGPoint2D(double *p)
|
|
: TGPoint(p)
|
|
{
|
|
|
|
}
|
|
|
|
TGPoint2D::TGPoint2D(float *p)
|
|
: TGPoint(p)
|
|
{
|
|
|
|
}
|
|
|
|
TGPoint2D::TGPoint2D(const TGPoint&pt)
|
|
: TGPoint(pt)
|
|
{
|
|
|
|
}
|
|
|
|
TGPoint2D::~TGPoint2D()
|
|
{
|
|
|
|
}
|
|
|
|
bool TGPoint2D::operator == (const TGPoint&pt) const
|
|
{
|
|
return Equal2D(pt);
|
|
}
|
|
|
|
bool TGPoint2D::operator!=(const TGPoint&pt) const
|
|
{
|
|
return !Equal2D(pt);
|
|
}
|
|
|
|
double TGPoint2D::Distance(const TGPoint&pt) const
|
|
{
|
|
return TchSubPrivate::Distance2D(*this,pt);
|
|
}
|
|
|
|
void TGPoint2D::SetElev(double elev)
|
|
{
|
|
z = elev;
|
|
}
|
|
|
|
double TGPoint2D::GetElev() const
|
|
{
|
|
return z;
|
|
}
|
|
|
|
bool TGPoint2D::IsValid() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void TGPoint2D::TransformBy(const TGMatrix&matrix)
|
|
{
|
|
matrix.Transform2D(*this);
|
|
}
|
|
|
|
TGObject * TGPoint2D::Clone() const
|
|
{
|
|
return new TGPoint2D(*this);
|
|
}
|
|
|
|
GRelation TGPoint2D::HitTest(const TGPoint&pt) const
|
|
{
|
|
return *this == pt ? GR_IN : GR_OUT;
|
|
}
|
|
|
|
bool TGPoint2D::GetExtend2D(TPGeExtend2D& ext) const
|
|
{
|
|
ext.SetRange(x,x,y,y);
|
|
return true;
|
|
}
|
|
|
|
bool TGPoint2D::GetExtend3D(TPGeExtend3D& ext) const
|
|
{
|
|
ext.SetRange(x,x,y,y,z,z);
|
|
return true;
|
|
}
|
|
|
|
TGPoint TGPoint2D::GetSamplePoint() const
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
bool TGPoint2D::Intersect(const TGObject&obj,TGObjectList&res) const
|
|
{
|
|
if(IS_TYPE(&obj,TGPoint2D))
|
|
{
|
|
if(*this == (const TGPoint2D&)obj)
|
|
{
|
|
res << new TGPoint2D(*this);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else if(obj.HitTest(*this).Is(GR_IN))
|
|
{
|
|
res << new TGPoint2D(*this);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool TGPoint2D::IsInclude(const TGObject&obj) const
|
|
{
|
|
if(IS_TYPE(&obj,TGPoint2D))
|
|
{
|
|
return *this == (const TGPoint2D&)obj;
|
|
}
|
|
else if(IS_CLASS(&obj,TPGeCurve2D) || IS_CLASS(&obj,TGRegion2D))
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return TGObject2D::IsInclude(obj);
|
|
}
|
|
}
|
|
|
|
TGObject3D * TGPoint2D::Convert3D() const
|
|
{
|
|
return new TGPoint3D(*this);
|
|
} |