453 lines
7.9 KiB
C++
453 lines
7.9 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : XDcStream 类
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: XDcStream 定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "XDcStream.h"
|
|
#include "XGlobalFunc.h"
|
|
#include "XGlobalCurveFunc.h"
|
|
#include "XConfigBase.h"
|
|
|
|
XDcStream::XDcStream()
|
|
{
|
|
m_bClip = true;
|
|
}
|
|
|
|
XDcStream::~XDcStream()
|
|
{
|
|
DeleteAll();
|
|
}
|
|
|
|
void XDcStream::DeleteAll()
|
|
{
|
|
XDcClip* pBd = NULL;
|
|
for (long i = 0; i < m_lstClip.GetSize(); i++)
|
|
{
|
|
pBd = (XDcClip*)m_lstClip.GetAt(i);
|
|
delete pBd;
|
|
}
|
|
m_lstClip.RemoveAll();
|
|
}
|
|
|
|
void XDcStream::PushClip(const XPoly2D& poly,int flag)
|
|
{
|
|
if (!IsDragging())
|
|
{
|
|
m_lstClip.Add(new XDcClip(poly,flag));
|
|
}
|
|
}
|
|
|
|
void XDcStream::PopClip()
|
|
{
|
|
if (m_lstClip.GetSize() > 0)
|
|
{
|
|
XDcClip* pClipBd = (XDcClip*)m_lstClip.GetAt(m_lstClip.GetSize() - 1);
|
|
m_lstClip.RemoveAt(m_lstClip.GetSize() - 1);
|
|
delete pClipBd;
|
|
}
|
|
}
|
|
|
|
void XDcStream::DrawXPoint(const XPoint &pt)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawXPoints(const XPointList &pts)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawX3DFace(const X3DFace &face)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawXEntity(const Entity& ent)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawSolid(const XPoly2D &polyOutline)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawHatch(const XPoly2D &polyOutline, const TCHAR *pszPattern, double nScale)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawHatchEx(const XPoly2D &polyOutline, const TCHAR *pszPattern, double nScale,double rotation)
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawEntity(const AcDbEntity& ent)const
|
|
{
|
|
|
|
}
|
|
|
|
void XDcStream::DrawBlock(const AcDbBlockTableRecord &blockRec, const XPoint &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
|
|
{
|
|
|
|
}
|
|
|
|
XDcStream & XDcStream::operator << (const XPointList &pts)
|
|
{
|
|
DrawXPoints(pts);
|
|
return *this;
|
|
}
|
|
|
|
XDcStream & XDcStream::operator << (const X3DFace &face)
|
|
{
|
|
DrawX3DFace(face);
|
|
return *this;
|
|
}
|
|
|
|
XDcStream & XDcStream::operator << (const Entity &e)
|
|
{
|
|
DrawXEntity(e);
|
|
return *this;
|
|
}
|
|
|
|
bool XDcStream::HasClip()const
|
|
{
|
|
return m_lstClip.GetSize() > 0;
|
|
}
|
|
|
|
const TCHAR *XDcStream::Desc()
|
|
{
|
|
return _T("XDcStream");
|
|
}
|
|
|
|
Adesk::Boolean XDcStream::IsDragging() const
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XPoint& pt)
|
|
{
|
|
if (HasClip())
|
|
{
|
|
//裁剪
|
|
for (long i = 0; i < m_lstClip.GetSize(); i++)
|
|
{
|
|
if ( ((XDcClip*)m_lstClip[i])->IsClip(pt))
|
|
{
|
|
return *this;
|
|
}
|
|
}
|
|
}
|
|
|
|
DrawXPoint(pt);
|
|
return *this;
|
|
}
|
|
|
|
XDcStream & XDcStream::operator << (const DList<XCurveSegment> &lstCv)
|
|
{
|
|
if (HasClip())
|
|
{
|
|
//modify by zjq on 100709 解决分解对象后影响裁剪的问题
|
|
CString strCmd;
|
|
XConfigBase* 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;
|
|
}
|
|
|
|
XPoint ptMin,ptMax;
|
|
AcDbExtents ext;
|
|
DList<XCurveSegment> lstCurve;
|
|
for (long i = 0; i < lstCv.Length(); i++)
|
|
{
|
|
lstCurve.Append(new XCurveSegment(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 (int i = 0; i < m_lstClip.GetSize() && lstCurve.Length() > 0; i++)
|
|
{
|
|
if ((bSkipExt) || ((XDcClip*)m_lstClip[i])->IsExtentsClip(ext) )
|
|
{
|
|
((XDcClip*)m_lstClip[i])->DoClip(lstCurve);
|
|
}
|
|
}
|
|
}
|
|
|
|
//输出
|
|
for (int i = 0; i < lstCurve.Length(); i++)
|
|
{
|
|
DrawXCurve(*lstCurve[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (long i = 0; i < lstCv.Length(); i++)
|
|
{
|
|
DrawXCurve(lstCv[i]);
|
|
}
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XCurveSegment& seg)
|
|
{
|
|
DList<XCurveSegment> lstCurve;
|
|
lstCurve.Append(new XCurveSegment(seg));
|
|
|
|
return (*this) << lstCurve;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const AcDbEntity &ent)
|
|
{
|
|
if (HasClip())
|
|
{
|
|
DList<AcDbEntity> lstEnt;
|
|
lstEnt.Append((AcDbEntity*)ent.clone());
|
|
|
|
//裁剪
|
|
for (long i = 0; i < m_lstClip.GetSize() && lstEnt.Length() > 0; i++)
|
|
{
|
|
((XDcClip*)m_lstClip[i])->DoClip(lstEnt);
|
|
}
|
|
|
|
//输出
|
|
for (int i = 0; i < lstEnt.Length(); i++)
|
|
{
|
|
DrawEntity(*lstEnt[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DrawEntity(ent);
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XBlockRef& block)
|
|
{
|
|
AcDbBlockTableRecord *pRec = NULL;
|
|
acdbOpenObject(pRec,block.m_idBlock,AcDb::kForRead);
|
|
if (pRec != NULL)
|
|
{
|
|
if (HasClip())
|
|
{
|
|
long i(0);
|
|
for (i = 0; i < m_lstClip.GetSize(); i++)
|
|
{
|
|
if ((((XDcClip*)m_lstClip[i])->GetClipType() & XDcClip::kAcGiClip) == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (i < m_lstClip.GetSize())
|
|
{
|
|
DList<XCurveSegment> lstSeg;
|
|
ads_matrix mat;
|
|
get_matrix(XPoint(),block.m_ptLocation,block.m_scale3d[0], block.m_scale3d[1], block.m_scale3d[2], block.m_nRotation,mat);
|
|
|
|
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;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XPoly2D& poly)
|
|
{
|
|
if (HasClip())
|
|
{
|
|
for (int i = 0; i < poly.TotalSegments(); i++)
|
|
{
|
|
XCurveSegment cv;
|
|
poly.Nth(i, cv);
|
|
|
|
*this << cv;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DrawXPoly(poly);
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XRectAngle &box)
|
|
{
|
|
XPoly2D poly(1);
|
|
box.AsPoly2D(poly);
|
|
|
|
return *this << poly;
|
|
}
|
|
|
|
XDcStream &XDcStream::operator <<(const XHatch& hatch)
|
|
{
|
|
DList<XPoly2D> lstPoly;
|
|
lstPoly.Append(new XPoly2D(hatch.GetHatchPoly()));
|
|
|
|
//裁剪
|
|
for (long i = 0; i < m_lstClip.GetSize() && lstPoly.Length() > 0; i++)
|
|
{
|
|
((XDcClip*)m_lstClip[i])->DoClip(lstPoly);
|
|
}
|
|
|
|
//输出
|
|
for (int i = 0; i < lstPoly.Length(); i++)
|
|
{
|
|
DrawHatchEx(*lstPoly[i],hatch.GetHatchName(),hatch.GetHatchScale(),hatch.GetHatchRotation());
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
XDcStream &XDcStream::operator <<(const XSolid&solid)
|
|
{
|
|
DList<XPoly2D> lstPoly;
|
|
lstPoly.Append(new XPoly2D(solid.m_poly));
|
|
|
|
//裁剪
|
|
if (m_bClip)
|
|
{
|
|
for (long i = 0; i < m_lstClip.GetSize() && lstPoly.Length() > 0; i++)
|
|
{
|
|
((XDcClip*)m_lstClip[i])->DoClip(lstPoly);
|
|
}
|
|
}
|
|
|
|
for (long i = 0; i < lstPoly.Length(); i++)
|
|
{
|
|
DrawSolid(*lstPoly[i]);
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
//由两曲线连接成的封闭区域进行填充
|
|
XDcStream &XDcStream::operator <<(const XSolidCurve& sc)
|
|
{
|
|
XCurveSegment cvOut = sc.m_cvOut,cvIn = sc.m_cvIn;
|
|
BOOL bDrawSolid = TRUE;
|
|
if (cvOut.Is(CURVE_ARC) && cvIn.Is(CURVE_ARC))
|
|
{
|
|
XArc arOut = cvOut.GetArc();
|
|
XArc arIn = cvIn.GetArc();
|
|
if (arOut.AngleFlag(arIn.MidAngle()) == PR_OUTSIDE
|
|
|| arIn.AngleFlag(arOut.MidAngle()) == PR_OUTSIDE)
|
|
{
|
|
bDrawSolid = FALSE;
|
|
}
|
|
}
|
|
|
|
if (bDrawSolid)
|
|
{
|
|
XPoly2D polySolid(1);
|
|
polySolid.AppendNode(cvOut.StartPoint(), cvOut.GetBulge());
|
|
polySolid.AppendNode(cvOut.EndPoint());
|
|
polySolid.AppendNode(cvIn.EndPoint(), -cvIn.GetBulge());
|
|
polySolid.AppendNode(cvIn.StartPoint());
|
|
|
|
*this << XSolid(polySolid);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XLine &line)
|
|
{
|
|
XCurveSegment seg;
|
|
seg = line;
|
|
|
|
return *this << seg;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XArc &arc)
|
|
{
|
|
XCurveSegment seg;
|
|
seg = arc;
|
|
|
|
return *this << seg;
|
|
}
|
|
|
|
XDcStream& XDcStream::operator <<(const XCircle &cir)
|
|
{
|
|
XCurveSegment seg;
|
|
seg = cir;
|
|
|
|
return *this << seg;
|
|
}
|
|
|
|
void XDcStream::DrawXPoly(const XPoly2D &poly,double nThick)
|
|
{
|
|
int len = poly.TotalSegments();
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
XCurveSegment cv;
|
|
poly.Nth(i, cv);
|
|
|
|
DrawXCurve(cv,nThick);
|
|
}
|
|
}
|
|
|
|
bool XDcStream::GetClipFlg()
|
|
{
|
|
return m_bClip;
|
|
}
|
|
|
|
void XDcStream::SetClipFlg(bool bTrue)
|
|
{
|
|
m_bClip = bTrue;
|
|
}
|