Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

127 lines
2.4 KiB
C++

#include "StdAfx.h"
#include "GeHatch.h"
GeHatch::GeHatch(GePoly2D 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;
}
GeHatch::GeHatch(GePoly2D 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;
}
GeHatch::~GeHatch()
{
}
bool GeHatch::IsKindOf(GeEntity::TEntityId entType) const
{
switch(entType)
{
case GeEntity::eEntity:
case GeEntity::eHatch:
return true;
}
return false;
}
GeEntity::TEntityId GeHatch::Type() const
{
return GeEntity::eHatch;
}
void GeHatch::CopyFrom(const GeEntity* pSrc)
{
if (this != pSrc && pSrc->IsKindOf(GeEntity::eHatch))
{
m_poly = ((GeHatch*)pSrc)->GetHatchPoly();
m_polys = ((GeHatch*)pSrc)->m_polys;
m_sHatchName = ((GeHatch*)pSrc)->GetHatchName();
m_dScale = ((GeHatch*)pSrc)->GetHatchScale();
m_dRotation = ((GeHatch*)pSrc)->GetHatchRotation();
}
}
bool GeHatch::IsSolid()const
{
return _tcscmp(m_sHatchName,_T("SOLID")) == 0;
}
GePoly2D GeHatch::GetHatchPoly()const
{
return m_poly;
}
void GeHatch::SetHatchPoly(GePoly2D poly)
{
m_poly = poly;
}
CString GeHatch::GetHatchName()const
{
return m_sHatchName;
}
void GeHatch::SetHatchName(CString sHatchName)
{
m_sHatchName = sHatchName;
}
double GeHatch::GetHatchScale()const
{
return m_dScale;
}
void GeHatch::SetHatchScale(double dScale)
{
m_dScale = dScale;
}
double GeHatch::GetHatchRotation()const
{
return m_dRotation;
}
void GeHatch::SetHatchRotation(double dRotation)
{
m_dRotation = dRotation;
}
#include "GeCurveInline.h"
namespace
{
bool IsPolyAInPolyB(const GePoly2D &A, const GePoly2D &B)
{
ADSGePoint3d pt;
GePoly2D polyB(B);
for (int i = 0; i < A.Length(); ++i)
{
pt = A.GetAt(i);
if ((pt & polyB) != PR_INSIDE) return false;
}
return true;
}
}
void GeHatch::AppendPoly(const GePoly2D &poly)
{
if (IsPolyAInPolyB(poly, m_poly))
m_polys.push_back(poly);
}
void GeHatch::AppendPoly(const std::vector<GePoly2D> &polys)
{
for (size_t i = 0; i < polys.size(); ++i)
{
const GePoly2D &poly = polys[i];
if (!IsPolyAInPolyB(poly, m_poly))
return; // 由于房间文字非常密集。故只要有一个洞口不在,则全部洞口都不添加。
}
m_polys.insert(m_polys.end(), polys.begin(), polys.end());
}