perf: X3dPart 布尔结果改为按需重建,开图不再逐件建体
方案 A(见 AcDbX3dSolid-refactor-plan.md 第 13 节)。开图慢的瓶颈是 AecDbX3dPartEntity::dwgInFields 无条件调 m_pPart->Create(),每个 part 都要 N 次建体 + N 次布尔。 A1:引入 m_bDirty - AecDbX3dPart 增加 m_bDirty,构造/拷贝构造置 true - 15 个改参数的接口置脏:AddX3dSolid、RemoveAt、RemoveAll3dSolidRec、 SetOrgPoint、SetAxis、SetBoolOperFor、SetHide、SetActive、PeelOffTheSkin、 AddMove×2、ResetMove、AddRotate、ResetRotate、CopyFrom - 新增 Rebuild()(protected):清标志后无条件重建,原 Create() 的函数体 - 新增 EnsureCreated():m_bDirty 或 m_pSolid 为空时才 Rebuild Create() 保持「显式调用一律重建」的语义,内部转调 Rebuild()。原因是外部 有 10 处先取 GetX3dSolid(0) 直接改(如 AecDbBDPipeBase:941 调 TransformBy) 再调 Create(),部件感知不到这类改动,做成幂等会漏掉重建。 A2:开图不建几何 - AecDbX3dPartEntity::dwgInFields 去掉 m_pPart->Create(),由 AecDbX3dPart::dwgInFields 结尾置脏 - 读入口统一先 EnsureCreated:CreateDraw3dSolid、Draw3d、getOsnapPoints、 GetForHouseSubtract 收益:关闭/冻结图层、视口外、XREF/审核/发布等不绘制的场景完全省掉建体与 布尔;全图可见时开图时间下降、首次 regen 补回。
This commit is contained in:
1 parent
b75b779518
commit
5a5cd08721
3 files changed
+49
-1
No files matched your search
@@ -48,6 +48,7 @@ AecDbX3dPart::AecDbX3dPart(void)
|
||||
m_nBoolOper = 0;
|
||||
m_pSolidDraw = NULL;
|
||||
m_pSolid = NULL;
|
||||
m_bDirty = true;
|
||||
m_sName = _T("");
|
||||
m_sGUID = IDCreate();
|
||||
m_bActive = false;
|
||||
@@ -60,6 +61,7 @@ AecDbX3dPart::AecDbX3dPart(const AecDbX3dPart& pPart)
|
||||
{
|
||||
m_pSolidDraw = NULL;
|
||||
m_pSolid = NULL;
|
||||
m_bDirty = true;
|
||||
|
||||
m_sName = pPart.m_sName;
|
||||
m_sGUID = pPart.m_sGUID;
|
||||
@@ -150,6 +152,7 @@ void AecDbX3dPart::ReCreateGUID()
|
||||
|
||||
void AecDbX3dPart::AddX3dSolid(AcDbX3dSolid* pXSolid,AcDb::BoolOperType bType /*AcDb::kBoolUnite*/,bool bForHouseSub /*= false*/)
|
||||
{
|
||||
m_bDirty = true;
|
||||
if (bType == AcDb::kBoolUnite)
|
||||
{
|
||||
m_arX3DSolidPtrsUnite.append(pXSolid);
|
||||
@@ -169,6 +172,7 @@ void AecDbX3dPart::AddX3dSolid(AcDbX3dSolid* pXSolid,AcDb::BoolOperType bType /
|
||||
|
||||
void AecDbX3dPart::SetOrgPoint(const AcGePoint3d& ptOrg)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_ptOrg = ptOrg;
|
||||
}
|
||||
|
||||
@@ -467,6 +471,7 @@ bool AecDbX3dPart::GetActiveInf(CPoint& ptRC) const
|
||||
|
||||
void AecDbX3dPart::RemoveAll3dSolidRec()
|
||||
{
|
||||
m_bDirty = true;
|
||||
AcDbX3dSolid* pXSolid = NULL;
|
||||
for (int i = 0;i < m_arX3DSolidPtrsUnite.length();i++)
|
||||
{
|
||||
@@ -503,6 +508,7 @@ void AecDbX3dPart::RemoveAll3dSolidRec()
|
||||
|
||||
void AecDbX3dPart::RemoveAt(int nIndex,AcDb::BoolOperType bType/* = AcDb::kBoolUnite*/,bool bForHouseSub/* = false*/)
|
||||
{
|
||||
m_bDirty = true;
|
||||
AcDbX3dSolid* pXSolid = NULL;
|
||||
if (bForHouseSub)
|
||||
{
|
||||
@@ -581,6 +587,7 @@ AcDbX3dSolid* AecDbX3dPart::GetX3dSolid(int nIndex,AcDb::BoolOperType bType/* =
|
||||
|
||||
bool AecDbX3dPart::SetAxis(int nIndex,const AcGeVector3d& vtAxis)
|
||||
{
|
||||
m_bDirty = true;
|
||||
if (nIndex >= 0 && nIndex < MAX_AXISROTATS)
|
||||
{
|
||||
m_arVtAxis.setAt(nIndex,vtAxis);
|
||||
@@ -607,6 +614,7 @@ void AecDbX3dPart::SetHideShow( )
|
||||
|
||||
void AecDbX3dPart::SetHide(bool bHide)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_mapXData.SetAt(_T("Hide"),bHide ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -622,6 +630,7 @@ bool AecDbX3dPart::IsHide() const
|
||||
|
||||
void AecDbX3dPart::PeelOffTheSkin(int nPos)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_nPeelOff = nPos;
|
||||
|
||||
if (m_pSolidDraw != NULL)
|
||||
@@ -638,11 +647,13 @@ bool AecDbX3dPart::IsPeelOffTheSkin() const
|
||||
|
||||
void AecDbX3dPart::SetActive(bool bActive)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_bActive = bActive;
|
||||
}
|
||||
|
||||
void AecDbX3dPart::AddMove(const AcGeVector3d& vtMove)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_vtMove += vtMove;
|
||||
|
||||
if (m_pSolidDraw != NULL)
|
||||
@@ -654,6 +665,7 @@ void AecDbX3dPart::AddMove(const AcGeVector3d& vtMove)
|
||||
|
||||
void AecDbX3dPart::AddMove(const AcGeMatrix3d& xMirror)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_vtMove += xMirror.translation();
|
||||
|
||||
if (m_pSolidDraw != NULL)
|
||||
@@ -670,6 +682,7 @@ AcGeVector3d AecDbX3dPart::GetMove() const
|
||||
|
||||
void AecDbX3dPart::ResetMove()
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_vtMove = AcGeVector3d::kIdentity;
|
||||
|
||||
if (m_pSolidDraw != NULL)
|
||||
@@ -681,6 +694,7 @@ void AecDbX3dPart::ResetMove()
|
||||
|
||||
void AecDbX3dPart::AddRotate(int nAxisIndex,double dRot)
|
||||
{
|
||||
m_bDirty = true;
|
||||
if (nAxisIndex >= 0 && nAxisIndex <= MAX_AXISROTATS )
|
||||
{
|
||||
m_dAxisRotats[nAxisIndex] += dRot;
|
||||
@@ -704,6 +718,7 @@ double AecDbX3dPart::GetRotate(int nAxisIndex) const
|
||||
|
||||
void AecDbX3dPart::ResetRotate(int nAxisIndex)
|
||||
{
|
||||
m_bDirty = true;
|
||||
if (nAxisIndex >= 0 && nAxisIndex < MAX_AXISROTATS)
|
||||
{
|
||||
m_dAxisRotats[nAxisIndex] = 0.0;
|
||||
@@ -765,6 +780,7 @@ void AecDbX3dPart::Transformby(AcGeVector3d& vt) const
|
||||
|
||||
void AecDbX3dPart::SetBoolOperFor(int nOper)
|
||||
{
|
||||
m_bDirty = true;
|
||||
m_nBoolOper = nOper;
|
||||
}
|
||||
|
||||
@@ -785,6 +801,16 @@ const AecDbObjXDataMap* AecDbX3dPart::GetSpecialtyData() const
|
||||
|
||||
bool AecDbX3dPart::Create()
|
||||
{
|
||||
//显式调用一律重建:外部可能直接改过 x3dsolid(如对 GetX3dSolid(0)
|
||||
//调 TransformBy 后再 Create),部件无法感知,只能无条件重算
|
||||
return Rebuild();
|
||||
}
|
||||
|
||||
bool AecDbX3dPart::Rebuild()
|
||||
{
|
||||
//先清标志再重建,避免构建过程中再次触发 EnsureCreated 造成递归
|
||||
m_bDirty = false;
|
||||
|
||||
if (m_pSolid != NULL)
|
||||
DELETE_PTR(m_pSolid);
|
||||
|
||||
@@ -900,8 +926,18 @@ bool AecDbX3dPart::Create()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AecDbX3dPart::EnsureCreated() const
|
||||
{
|
||||
if (!m_bDirty && m_pSolid != NULL)
|
||||
return true;
|
||||
|
||||
return const_cast<AecDbX3dPart*>(this)->Rebuild();
|
||||
}
|
||||
|
||||
int AecDbX3dPart::GetForHouseSubtract(AcDbVoidPtrArray& arSolidPtrs) const
|
||||
{
|
||||
EnsureCreated();
|
||||
|
||||
AcDbX3dSolid* pXSolid = NULL;
|
||||
|
||||
AcGePoint3d ptOrg = m_ptOrg;
|
||||
@@ -939,6 +975,8 @@ int AecDbX3dPart::GetForHouseSubtract(AcDbVoidPtrArray& arSolidPtrs) const
|
||||
|
||||
AcDb3dSolid* AecDbX3dPart::CreateDraw3dSolid() const
|
||||
{
|
||||
EnsureCreated();
|
||||
|
||||
AcDb3dSolid* pDraw = NULL;
|
||||
if (m_pSolid != NULL)
|
||||
{
|
||||
@@ -968,6 +1006,8 @@ Acad::ErrorStatus AecDbX3dPart::Draw2d(AcGiDraw &dc) const
|
||||
|
||||
Acad::ErrorStatus AecDbX3dPart::Draw3d(AcGiDraw &dc) const
|
||||
{
|
||||
EnsureCreated();
|
||||
|
||||
if (m_pSolidDraw == NULL)
|
||||
{
|
||||
m_pSolidDraw = CreateDraw3dSolid();
|
||||
@@ -1102,6 +1142,8 @@ Acad::ErrorStatus AecDbX3dPart::getOsnapPoints( AcDb::OsnapMode osnapMode,
|
||||
AcGePoint3dArray& snapPoints,
|
||||
AcDbIntArray& geomIds) const
|
||||
{
|
||||
EnsureCreated();
|
||||
|
||||
if (m_pSolidDraw != NULL)
|
||||
{
|
||||
m_pSolidDraw->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
||||
@@ -1188,6 +1230,7 @@ Acad::ErrorStatus AecDbX3dPart::dwgInFields (AcDbDwgFiler* pFiler)
|
||||
pFiler->readBytes(m_dAxisRotats,sizeof(double) * MAX_AXISROTATS);
|
||||
m_mapXData.dwgInFields(pFiler);
|
||||
|
||||
m_bDirty = true; //开图时不建几何,首次绘制或取几何时再重建
|
||||
return Acad::eOk;
|
||||
}
|
||||
|
||||
@@ -1254,6 +1297,7 @@ Acad::ErrorStatus AecDbX3dPart::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||||
|
||||
Acad::ErrorStatus AecDbX3dPart::CopyFrom(AecDbX3dPart* pSrcPart)
|
||||
{
|
||||
m_bDirty = true;
|
||||
if (pSrcPart == NULL)
|
||||
return Acad::eInvalidInput;
|
||||
|
||||
|
||||
@@ -1821,7 +1821,7 @@ Acad::ErrorStatus AecDbX3dPartEntity::dwgInFields (AcDbDwgFiler* pFiler)
|
||||
return (Acad::eMakeMeProxy) ;
|
||||
|
||||
m_pPart->dwgInFields(pFiler);
|
||||
m_pPart->Create();
|
||||
//开图时不建布尔结果:dwgInFields 里已置脏,首次绘制或取几何时由 EnsureCreated 重建
|
||||
|
||||
m_drawable2d.dwgInFields(pFiler, version);
|
||||
|
||||
|
||||
Reference in new issue
Block a user