137 lines
2.9 KiB
C++
137 lines
2.9 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TGGeHatch 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TGGeHatch 类定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TGGeHatch.h"
|
|
|
|
TGGeHatch::TGGeHatch(TGGePoly2D poly,const TCHAR* sName,double nScale)
|
|
: m_poly(poly), m_polys(1),m_sHatchName(sName),m_dScale(nScale),m_dRotation(0.0)
|
|
{
|
|
// 对房间实体的填充而言,初始化所
|
|
m_polys[0] = poly;
|
|
}
|
|
|
|
TGGeHatch::TGGeHatch(TGGePoly2D poly,const TCHAR* sName,double nScale,double nAngle)
|
|
: m_poly(poly),m_polys(1),m_sHatchName(sName),m_dScale(nScale),m_dRotation(nAngle)
|
|
{
|
|
m_polys[0] = poly;
|
|
}
|
|
|
|
TGGeHatch::~TGGeHatch()
|
|
{
|
|
|
|
}
|
|
|
|
bool TGGeHatch::IsKindOf(TGGeEntity::TEntityId entType) const
|
|
{
|
|
switch(entType)
|
|
{
|
|
case TGGeEntity::eEntity:
|
|
case TGGeEntity::eHatch:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
TGGeEntity::TEntityId TGGeHatch::Type() const
|
|
{
|
|
return TGGeEntity::eHatch;
|
|
}
|
|
|
|
void TGGeHatch::CopyFrom(const TGGeEntity* pSrc)
|
|
{
|
|
if (this != pSrc && pSrc->IsKindOf(TGGeEntity::eHatch))
|
|
{
|
|
m_poly = ((TGGeHatch*)pSrc)->GetHatchPoly();
|
|
m_polys = ((TGGeHatch*)pSrc)->m_polys;
|
|
m_sHatchName = ((TGGeHatch*)pSrc)->GetHatchName();
|
|
m_dScale = ((TGGeHatch*)pSrc)->GetHatchScale();
|
|
m_dRotation = ((TGGeHatch*)pSrc)->GetHatchRotation();
|
|
}
|
|
}
|
|
|
|
bool TGGeHatch::IsSolid()const
|
|
{
|
|
return _tcscmp(m_sHatchName,_T("SOLID")) == 0;
|
|
}
|
|
|
|
TGGePoly2D TGGeHatch::GetHatchPoly()const
|
|
{
|
|
return m_poly;
|
|
}
|
|
|
|
void TGGeHatch::SetHatchPoly(TGGePoly2D poly)
|
|
{
|
|
m_poly = poly;
|
|
}
|
|
|
|
CString TGGeHatch::GetHatchName()const
|
|
{
|
|
return m_sHatchName;
|
|
}
|
|
|
|
void TGGeHatch::SetHatchName(CString sHatchName)
|
|
{
|
|
m_sHatchName = sHatchName;
|
|
}
|
|
|
|
double TGGeHatch::GetHatchScale()const
|
|
{
|
|
return m_dScale;
|
|
}
|
|
|
|
void TGGeHatch::SetHatchScale(double dScale)
|
|
{
|
|
m_dScale = dScale;
|
|
}
|
|
|
|
double TGGeHatch::GetHatchRotation()const
|
|
{
|
|
return m_dRotation;
|
|
}
|
|
|
|
void TGGeHatch::SetHatchRotation(double dRotation)
|
|
{
|
|
m_dRotation = dRotation;
|
|
}
|
|
|
|
#include "TGGeCurveInline.h"
|
|
namespace
|
|
{
|
|
bool IsPolyAInPolyB(const TGGePoly2D &A, const TGGePoly2D &B)
|
|
{
|
|
TADSGePoint3d pt;
|
|
TGGePoly2D polyB(B);
|
|
for (int i = 0; i < A.Length(); ++i)
|
|
{
|
|
pt = A.GetAt(i);
|
|
if ((pt & polyB) != PR_INSIDE) return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void TGGeHatch::AppendPoly(const TGGePoly2D &poly)
|
|
{
|
|
if (IsPolyAInPolyB(poly, m_poly))
|
|
m_polys.push_back(poly);
|
|
}
|
|
|
|
void TGGeHatch::AppendPoly(const std::vector<TGGePoly2D> &polys)
|
|
{
|
|
for (size_t i = 0; i < polys.size(); ++i)
|
|
{
|
|
const TGGePoly2D &poly = polys[i];
|
|
if (!IsPolyAInPolyB(poly, m_poly))
|
|
return; // 由于房间文字非常密集。故只要有一个洞口不在,则全部洞口都不添加。
|
|
}
|
|
m_polys.insert(m_polys.end(), polys.begin(), polys.end());
|
|
}
|