refactor: X3dPart 的懒加载标志改名 m_bNeedCreate 并加 mutable

与 AcDbX3dSolid::m_bNeedCreate 对齐:同一个语义(派生几何缓存失效,
首次使用时再算),用同一个名字,避免 m_bDirty 被理解成"参数没写完"。
声明为 mutable,与 AcDbX3dSolid 一致;清标志仍在 Rebuild() 里做。
This commit is contained in:
company-desktop-computer committed 2026-10-22 15:41:14 +08:00
1 parent 5a5cd08721
commit 8ca9519320
2 files changed
+21 -21

No files matched your search

@@ -48,7 +48,7 @@ AecDbX3dPart::AecDbX3dPart(void)
m_nBoolOper = 0; m_nBoolOper = 0;
m_pSolidDraw = NULL; m_pSolidDraw = NULL;
m_pSolid = NULL; m_pSolid = NULL;
m_bDirty = true; m_bNeedCreate = true;
m_sName = _T(""); m_sName = _T("");
m_sGUID = IDCreate(); m_sGUID = IDCreate();
m_bActive = false; m_bActive = false;
@@ -61,7 +61,7 @@ AecDbX3dPart::AecDbX3dPart(const AecDbX3dPart& pPart)
{ {
m_pSolidDraw = NULL; m_pSolidDraw = NULL;
m_pSolid = NULL; m_pSolid = NULL;
m_bDirty = true; m_bNeedCreate = true;
m_sName = pPart.m_sName; m_sName = pPart.m_sName;
m_sGUID = pPart.m_sGUID; m_sGUID = pPart.m_sGUID;
@@ -152,7 +152,7 @@ void AecDbX3dPart::ReCreateGUID()
void AecDbX3dPart::AddX3dSolid(AcDbX3dSolid* pXSolid,AcDb::BoolOperType bType /*AcDb::kBoolUnite*/,bool bForHouseSub /*= false*/) void AecDbX3dPart::AddX3dSolid(AcDbX3dSolid* pXSolid,AcDb::BoolOperType bType /*AcDb::kBoolUnite*/,bool bForHouseSub /*= false*/)
{ {
m_bDirty = true; m_bNeedCreate = true;
if (bType == AcDb::kBoolUnite) if (bType == AcDb::kBoolUnite)
{ {
m_arX3DSolidPtrsUnite.append(pXSolid); m_arX3DSolidPtrsUnite.append(pXSolid);
@@ -172,7 +172,7 @@ void AecDbX3dPart::AddX3dSolid(AcDbX3dSolid* pXSolid,AcDb::BoolOperType bType /
void AecDbX3dPart::SetOrgPoint(const AcGePoint3d& ptOrg) void AecDbX3dPart::SetOrgPoint(const AcGePoint3d& ptOrg)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_ptOrg = ptOrg; m_ptOrg = ptOrg;
} }
@@ -471,7 +471,7 @@ bool AecDbX3dPart::GetActiveInf(CPoint& ptRC) const
void AecDbX3dPart::RemoveAll3dSolidRec() void AecDbX3dPart::RemoveAll3dSolidRec()
{ {
m_bDirty = true; m_bNeedCreate = true;
AcDbX3dSolid* pXSolid = NULL; AcDbX3dSolid* pXSolid = NULL;
for (int i = 0;i < m_arX3DSolidPtrsUnite.length();i++) for (int i = 0;i < m_arX3DSolidPtrsUnite.length();i++)
{ {
@@ -508,7 +508,7 @@ void AecDbX3dPart::RemoveAll3dSolidRec()
void AecDbX3dPart::RemoveAt(int nIndex,AcDb::BoolOperType bType/* = AcDb::kBoolUnite*/,bool bForHouseSub/* = false*/) void AecDbX3dPart::RemoveAt(int nIndex,AcDb::BoolOperType bType/* = AcDb::kBoolUnite*/,bool bForHouseSub/* = false*/)
{ {
m_bDirty = true; m_bNeedCreate = true;
AcDbX3dSolid* pXSolid = NULL; AcDbX3dSolid* pXSolid = NULL;
if (bForHouseSub) if (bForHouseSub)
{ {
@@ -587,7 +587,7 @@ AcDbX3dSolid* AecDbX3dPart::GetX3dSolid(int nIndex,AcDb::BoolOperType bType/* =
bool AecDbX3dPart::SetAxis(int nIndex,const AcGeVector3d& vtAxis) bool AecDbX3dPart::SetAxis(int nIndex,const AcGeVector3d& vtAxis)
{ {
m_bDirty = true; m_bNeedCreate = true;
if (nIndex >= 0 && nIndex < MAX_AXISROTATS) if (nIndex >= 0 && nIndex < MAX_AXISROTATS)
{ {
m_arVtAxis.setAt(nIndex,vtAxis); m_arVtAxis.setAt(nIndex,vtAxis);
@@ -614,7 +614,7 @@ void AecDbX3dPart::SetHideShow( )
void AecDbX3dPart::SetHide(bool bHide) void AecDbX3dPart::SetHide(bool bHide)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_mapXData.SetAt(_T("Hide"),bHide ? 1 : 0); m_mapXData.SetAt(_T("Hide"),bHide ? 1 : 0);
} }
@@ -630,7 +630,7 @@ bool AecDbX3dPart::IsHide() const
void AecDbX3dPart::PeelOffTheSkin(int nPos) void AecDbX3dPart::PeelOffTheSkin(int nPos)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_nPeelOff = nPos; m_nPeelOff = nPos;
if (m_pSolidDraw != NULL) if (m_pSolidDraw != NULL)
@@ -647,13 +647,13 @@ bool AecDbX3dPart::IsPeelOffTheSkin() const
void AecDbX3dPart::SetActive(bool bActive) void AecDbX3dPart::SetActive(bool bActive)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_bActive = bActive; m_bActive = bActive;
} }
void AecDbX3dPart::AddMove(const AcGeVector3d& vtMove) void AecDbX3dPart::AddMove(const AcGeVector3d& vtMove)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_vtMove += vtMove; m_vtMove += vtMove;
if (m_pSolidDraw != NULL) if (m_pSolidDraw != NULL)
@@ -665,7 +665,7 @@ void AecDbX3dPart::AddMove(const AcGeVector3d& vtMove)
void AecDbX3dPart::AddMove(const AcGeMatrix3d& xMirror) void AecDbX3dPart::AddMove(const AcGeMatrix3d& xMirror)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_vtMove += xMirror.translation(); m_vtMove += xMirror.translation();
if (m_pSolidDraw != NULL) if (m_pSolidDraw != NULL)
@@ -682,7 +682,7 @@ AcGeVector3d AecDbX3dPart::GetMove() const
void AecDbX3dPart::ResetMove() void AecDbX3dPart::ResetMove()
{ {
m_bDirty = true; m_bNeedCreate = true;
m_vtMove = AcGeVector3d::kIdentity; m_vtMove = AcGeVector3d::kIdentity;
if (m_pSolidDraw != NULL) if (m_pSolidDraw != NULL)
@@ -694,7 +694,7 @@ void AecDbX3dPart::ResetMove()
void AecDbX3dPart::AddRotate(int nAxisIndex,double dRot) void AecDbX3dPart::AddRotate(int nAxisIndex,double dRot)
{ {
m_bDirty = true; m_bNeedCreate = true;
if (nAxisIndex >= 0 && nAxisIndex <= MAX_AXISROTATS ) if (nAxisIndex >= 0 && nAxisIndex <= MAX_AXISROTATS )
{ {
m_dAxisRotats[nAxisIndex] += dRot; m_dAxisRotats[nAxisIndex] += dRot;
@@ -718,7 +718,7 @@ double AecDbX3dPart::GetRotate(int nAxisIndex) const
void AecDbX3dPart::ResetRotate(int nAxisIndex) void AecDbX3dPart::ResetRotate(int nAxisIndex)
{ {
m_bDirty = true; m_bNeedCreate = true;
if (nAxisIndex >= 0 && nAxisIndex < MAX_AXISROTATS) if (nAxisIndex >= 0 && nAxisIndex < MAX_AXISROTATS)
{ {
m_dAxisRotats[nAxisIndex] = 0.0; m_dAxisRotats[nAxisIndex] = 0.0;
@@ -780,7 +780,7 @@ void AecDbX3dPart::Transformby(AcGeVector3d& vt) const
void AecDbX3dPart::SetBoolOperFor(int nOper) void AecDbX3dPart::SetBoolOperFor(int nOper)
{ {
m_bDirty = true; m_bNeedCreate = true;
m_nBoolOper = nOper; m_nBoolOper = nOper;
} }
@@ -809,7 +809,7 @@ bool AecDbX3dPart::Create()
bool AecDbX3dPart::Rebuild() bool AecDbX3dPart::Rebuild()
{ {
//先清标志再重建,避免构建过程中再次触发 EnsureCreated 造成递归 //先清标志再重建,避免构建过程中再次触发 EnsureCreated 造成递归
m_bDirty = false; m_bNeedCreate = false;
if (m_pSolid != NULL) if (m_pSolid != NULL)
DELETE_PTR(m_pSolid); DELETE_PTR(m_pSolid);
@@ -928,7 +928,7 @@ bool AecDbX3dPart::Rebuild()
bool AecDbX3dPart::EnsureCreated() const bool AecDbX3dPart::EnsureCreated() const
{ {
if (!m_bDirty && m_pSolid != NULL) if (!m_bNeedCreate && m_pSolid != NULL)
return true; return true;
return const_cast<AecDbX3dPart*>(this)->Rebuild(); return const_cast<AecDbX3dPart*>(this)->Rebuild();
@@ -1230,7 +1230,7 @@ Acad::ErrorStatus AecDbX3dPart::dwgInFields (AcDbDwgFiler* pFiler)
pFiler->readBytes(m_dAxisRotats,sizeof(double) * MAX_AXISROTATS); pFiler->readBytes(m_dAxisRotats,sizeof(double) * MAX_AXISROTATS);
m_mapXData.dwgInFields(pFiler); m_mapXData.dwgInFields(pFiler);
m_bDirty = true; //开图时不建几何,首次绘制或取几何时再重建 m_bNeedCreate = true; //开图时不建几何,首次绘制或取几何时再重建
return Acad::eOk; return Acad::eOk;
} }
@@ -1297,7 +1297,7 @@ Acad::ErrorStatus AecDbX3dPart::dwgOutFields(AcDbDwgFiler* pFiler) const
Acad::ErrorStatus AecDbX3dPart::CopyFrom(AecDbX3dPart* pSrcPart) Acad::ErrorStatus AecDbX3dPart::CopyFrom(AecDbX3dPart* pSrcPart)
{ {
m_bDirty = true; m_bNeedCreate = true;
if (pSrcPart == NULL) if (pSrcPart == NULL)
return Acad::eInvalidInput; return Acad::eInvalidInput;
+1 -1
View File
@@ -141,7 +141,7 @@ protected:
bool m_bActive; //活动状态 bool m_bActive; //活动状态
int m_nPeelOff; //是否需要剖开 int m_nPeelOff; //是否需要剖开
AcDb3dSolid* m_pSolid; //原始solid元 AcDb3dSolid* m_pSolid; //原始solid元
bool m_bDirty; //参数已变更,几何待重建 mutable bool m_bNeedCreate; //几何待重建,首次使用时再算
mutable AcDb3dSolid* m_pSolidDraw; //临时绘制solid元 mutable AcDb3dSolid* m_pSolidDraw; //临时绘制solid元
mutable SHJson::WValue m_json; mutable SHJson::WValue m_json;
}; };