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

448 lines
8.4 KiB
C++

#include "StdAfx.h"
#include "TGGiDrawStreamBase.h"
#include "TGGiClipBoundary.h"
#include "globalFunc.h"
TGGiDrawStreamBase::TGGiDrawStreamBase()
{
m_bClip = true;
}
TGGiDrawStreamBase::~TGGiDrawStreamBase()
{
DeleteAll();
}
void TGGiDrawStreamBase::DeleteAll()
{
TGGiClipBoundary* pBd = NULL;
for (long i = 0; i < m_lstClip.GetSize(); i++)
{
pBd = (TGGiClipBoundary*)m_lstClip.GetAt(i);
delete pBd;
}
m_lstClip.RemoveAll();
}
void TGGiDrawStreamBase::PushClip(const GePoly2D& poly,int flag)
{
if (!IsDragging())
{
m_lstClip.Add(new TGGiClipBoundary(poly,flag));
}
}
void TGGiDrawStreamBase::PopClip()
{
if (m_lstClip.GetSize() > 0)
{
TGGiClipBoundary* pClipBd = (TGGiClipBoundary*)m_lstClip.GetAt(m_lstClip.GetSize() - 1);
m_lstClip.RemoveAt(m_lstClip.GetSize() - 1);
delete pClipBd;
}
}
void TGGiDrawStreamBase::DrawXPoint(const ADSGePoint3d &pt)
{
}
void TGGiDrawStreamBase::DrawXPoints(const ADSGePointList &pts)
{
}
void TGGiDrawStreamBase::DrawX3DFace(const Ge3DFace &face)
{
}
void TGGiDrawStreamBase::DrawXEntity(const EntitySet& ent)
{
}
void TGGiDrawStreamBase::DrawSolid(const GePoly2D &polyOutline)
{
}
void TGGiDrawStreamBase::DrawHatch(const GePoly2D &polyOutline, const TCHAR *pszPattern, double nScale)
{
}
void TGGiDrawStreamBase::DrawHatchEx(const GePoly2D &polyOutline, const TCHAR *pszPattern, double nScale,double rotation)
{
}
void TGGiDrawStreamBase::DrawHatchEx(const GeHatch &hatch)
{
}
void TGGiDrawStreamBase::DrawEntity(const AcDbEntity& ent)const
{
}
void TGGiDrawStreamBase::DrawBlock(const AcDbBlockTableRecord &blockRec, const ADSGePoint3d &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
{
}
TGGiDrawStreamBase & TGGiDrawStreamBase::operator << (const ADSGePointList &pts)
{
DrawXPoints(pts);
return *this;
}
TGGiDrawStreamBase & TGGiDrawStreamBase::operator << (const Ge3DFace &face)
{
DrawX3DFace(face);
return *this;
}
TGGiDrawStreamBase & TGGiDrawStreamBase::operator << (const EntitySet &e)
{
DrawXEntity(e);
return *this;
}
bool TGGiDrawStreamBase::HasClip()const
{
return m_lstClip.GetSize() > 0;
}
const TCHAR *TGGiDrawStreamBase::Desc()
{
return _T("TGGiDrawStreamBase");
}
Adesk::Boolean TGGiDrawStreamBase::IsDragging() const
{
return Adesk::kFalse;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const ADSGePoint3d& pt)
{
if (HasClip())
{
//裁剪
for (long i = 0; i < m_lstClip.GetSize(); i++)
{
if ( ((TGGiClipBoundary*)m_lstClip[i])->IsClip(pt))
{
return *this;
}
}
}
DrawXPoint(pt);
return *this;
}
TGGiDrawStreamBase & TGGiDrawStreamBase::operator << (const PtrList<GeCurveSegment> &lstCv)
{
if (HasClip())
{
//modify by xlc on 100709 解决分解对象后影响裁剪的问题
CString strCmd = GlobalFunc::getCurrentCmdNames();
//TConfigBase* pBase = GetGlobalConfigBase();
//if (pBase != NULL)
//{
// strCmd = pBase->GetCurrentCommand();
// pBase->Close();
//}
BOOL bSkipExt = FALSE; //是否忽略求包围盒
strCmd.MakeUpper();
if (strCmd.Find(_T("TEXPLODE")) >= 0
||strCmd.Find(_T("TSAVEAS")) >= 0
||strCmd.Find(_T("TBATSAVE")) >= 0)
{
bSkipExt = TRUE;
}
ADSGePoint3d ptMin,ptMax;
AcDbExtents ext;
PtrList<GeCurveSegment> lstCurve;
for (long i = 0; i < lstCv.Length(); i++)
{
lstCurve.Append(new GeCurveSegment(lstCv[i]));
if (!bSkipExt)
{
lstCv[i].GetExtend(ptMin,ptMax);
if (i == 0)
{
ext.set(ptMin,ptMax);
}
else
{
ext.addPoint(ptMin);
ext.addPoint(ptMax);
}
}
}
//裁剪
if(m_bClip)
{
for (i = 0; i < m_lstClip.GetSize() && lstCurve.Length() > 0; i++)
{
if ((bSkipExt) || ((TGGiClipBoundary*)m_lstClip[i])->IsExtentsClip(ext) )
{
((TGGiClipBoundary*)m_lstClip[i])->DoClip(lstCurve);
}
}
}
//输出
for (i = 0; i < lstCurve.Length(); i++)
{
DrawXCurve(*lstCurve[i]);
}
}
else
{
for (long i = 0; i < lstCv.Length(); i++)
{
DrawXCurve(lstCv[i]);
}
}
return *this;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GeCurveSegment& seg)
{
PtrList<GeCurveSegment> lstCurve;
lstCurve.Append(new GeCurveSegment(seg));
return (*this) << lstCurve;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const AcDbEntity &ent)
{
if (HasClip())
{
PtrList<AcDbEntity> lstEnt;
lstEnt.Append((AcDbEntity*)ent.clone());
//裁剪
for (long i = 0; i < m_lstClip.GetSize() && lstEnt.Length() > 0; i++)
{
((TGGiClipBoundary*)m_lstClip[i])->DoClip(lstEnt);
}
//输出
for (i = 0; i < lstEnt.Length(); i++)
{
DrawEntity(*lstEnt[i]);
}
}
else
{
DrawEntity(ent);
}
return *this;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const TAcDbBlockRefData& block)
{
AcDbBlockTableRecord *pRec = NULL;
acdbOpenObject(pRec,block.m_idBlock,AcDb::kForRead);
if (pRec != NULL)
{
if (HasClip())
{
for (long i = 0; i < m_lstClip.GetSize(); i++)
{
if ((((TGGiClipBoundary*)m_lstClip[i])->GetClipType() & TGGiClipBoundary::kAcGiClip) == 0)
{
break;
}
}
if (i < m_lstClip.GetSize())
{
PtrList<GeCurveSegment> lstSeg;
ads_matrix mat;
GlobalFunc::ConstructMatrix(ADSGePoint3d(),block.m_ptLocation,block.m_scale3d[0], block.m_scale3d[1], block.m_scale3d[2], block.m_nRotation,mat);
GlobalFunc::Get2DCurveFromBlock(*pRec, mat,lstSeg);
(*this) << lstSeg;
}
else
{
DrawBlock(*pRec,block.m_ptLocation,block.m_scale3d,block.m_nRotation,block.m_bMakeBlock);
}
}
else
{
DrawBlock(*pRec,block.m_ptLocation,block.m_scale3d,block.m_nRotation,block.m_bMakeBlock);
}
pRec->close();
}
return *this;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GePoly2D& poly)
{
if (HasClip())
{
for (int i = 0; i < poly.TotalSegments(); i++)
{
GeCurveSegment cv;
poly.Nth(i, cv);
*this << cv;
}
}
else
{
DrawXPoly(poly);
}
return *this;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GeRectAngle &box)
{
GePoly2D poly(1);
box.AsPoly2D(poly);
return *this << poly;
}
TGGiDrawStreamBase &TGGiDrawStreamBase::operator <<(const GeHatch& hatch)
{
PtrList<GePoly2D> lstPoly;
lstPoly.Append(new GePoly2D(hatch.GetHatchPoly()));
//裁剪
for (long i = 0; i < m_lstClip.GetSize() && lstPoly.Length() > 0; i++)
{
((TGGiClipBoundary*)m_lstClip[i])->DoClip(lstPoly);
}
if (hatch.GetPolys().size() != 1)//房间填充
DrawHatchEx(hatch);
else
{
for (i = 0; i < lstPoly.Length(); i++)
{
DrawHatchEx(*lstPoly[i],hatch.GetHatchName(),hatch.GetHatchScale(),hatch.GetHatchRotation());
}
}
return *this;
}
TGGiDrawStreamBase &TGGiDrawStreamBase::operator <<(const GeSolid&solid)
{
PtrList<GePoly2D> lstPoly;
lstPoly.Append(new GePoly2D(solid.m_poly));
//裁剪
if (m_bClip)
{
for (long i = 0; i < m_lstClip.GetSize() && lstPoly.Length() > 0; i++)
{
((TGGiClipBoundary*)m_lstClip[i])->DoClip(lstPoly);
}
}
for (long i = 0; i < lstPoly.Length(); i++)
{
DrawSolid(*lstPoly[i]);
}
return *this;
}
//由两曲线连接成的封闭区域进行填充
TGGiDrawStreamBase &TGGiDrawStreamBase::operator <<(const GeSolidCurve& sc)
{
GeCurveSegment cvOut = sc.m_cvOut,cvIn = sc.m_cvIn;
BOOL bDrawSolid = TRUE;
if (cvOut.Is(CURVE_ARC) && cvIn.Is(CURVE_ARC))
{
GeArc arOut = cvOut.GetArc();
GeArc arIn = cvIn.GetArc();
if (arOut.AngleFlag(arIn.MidAngle()) == PR_OUTSIDE
|| arIn.AngleFlag(arOut.MidAngle()) == PR_OUTSIDE)
{
bDrawSolid = FALSE;
}
}
if (bDrawSolid)
{
GePoly2D polySolid(1);
polySolid.AppendNode(cvOut.StartPoint(), cvOut.GetBulge());
polySolid.AppendNode(cvOut.EndPoint());
polySolid.AppendNode(cvIn.EndPoint(), -cvIn.GetBulge());
polySolid.AppendNode(cvIn.StartPoint());
*this << GeSolid(polySolid);
}
else
{
}
return *this;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GeLine &line)
{
GeCurveSegment seg;
seg = line;
return *this << seg;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GeArc &arc)
{
GeCurveSegment seg;
seg = arc;
return *this << seg;
}
TGGiDrawStreamBase& TGGiDrawStreamBase::operator <<(const GeCircle &cir)
{
GeCurveSegment seg;
seg = cir;
return *this << seg;
}
void TGGiDrawStreamBase::DrawXPoly(const GePoly2D &poly,double nThick)
{
int len = poly.TotalSegments();
for (int i = 0; i < len; i++)
{
GeCurveSegment cv;
poly.Nth(i, cv);
DrawXCurve(cv,nThick);
}
}
bool TGGiDrawStreamBase::GetClipFlg()
{
return m_bClip;
}
void TGGiDrawStreamBase::SetClipFlg(bool bTrue)
{
m_bClip = bTrue;
}