perf: AcDbX3dSolid 几何改为懒重建
- 新增 m_bNeedCreate 标志与 EnsureCreated():dwgInFields 与拷贝构造 不再立即 ReCreate,延迟到首次访问几何时重建 - 开图时不再对每个单元逐个走 SAT 临时文件(acisOut/acisIn), 显著降低开图耗时;Clone 也省掉一次重建 - 所有读取 m_pSolid/m_pSubDMesh 的入口统一走 EnsureCreated: GetNative3dSolid / GetDraw3dSolid / GetNativeSubDMesh / GetDrawSubDMesh / GetDrawSubDMesh2D / GetCentoridPoint - GetDrawSubDMesh 补 m_pSubDMesh 空指针保护 - TransformBy 保持原有行为(参数变更后必须重建)
This commit is contained in:
1 parent
fabaca58df
commit
81215c8fe1
2 files changed
+25
-6
No files matched your search
@@ -219,6 +219,7 @@ AcDbX3dSolid::AcDbX3dSolid(void)
|
|||||||
|
|
||||||
m_pSolidDraw = NULL;
|
m_pSolidDraw = NULL;
|
||||||
m_pSolid = NULL;
|
m_pSolid = NULL;
|
||||||
|
m_bNeedCreate = false;
|
||||||
#if ARX > 17
|
#if ARX > 17
|
||||||
m_pSubDMesh = NULL;
|
m_pSubDMesh = NULL;
|
||||||
m_pSubDMeshDraw = NULL;
|
m_pSubDMeshDraw = NULL;
|
||||||
@@ -274,11 +275,11 @@ AcDbX3dSolid::AcDbX3dSolid(const AcDbX3dSolid& xSolid)
|
|||||||
|
|
||||||
m_pSolid = NULL;
|
m_pSolid = NULL;
|
||||||
m_pSolidDraw = NULL;
|
m_pSolidDraw = NULL;
|
||||||
|
m_bNeedCreate = true; //延迟到首次访问几何时重建
|
||||||
#if ARX > 17
|
#if ARX > 17
|
||||||
m_pSubDMesh = NULL;
|
m_pSubDMesh = NULL;
|
||||||
m_pSubDMeshDraw = NULL;
|
m_pSubDMeshDraw = NULL;
|
||||||
#endif
|
#endif
|
||||||
ReCreate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AcDbX3dSolid::~AcDbX3dSolid(void)
|
AcDbX3dSolid::~AcDbX3dSolid(void)
|
||||||
@@ -3846,11 +3847,13 @@ bool AcDbX3dSolid::CreateLadder(const AcGePoint3d& ptFr,const AcGeVector3d& vtD
|
|||||||
|
|
||||||
AcDb3dSolid* AcDbX3dSolid::GetNative3dSolid() const
|
AcDb3dSolid* AcDbX3dSolid::GetNative3dSolid() const
|
||||||
{
|
{
|
||||||
|
EnsureCreated();
|
||||||
return m_pSolid;
|
return m_pSolid;
|
||||||
}
|
}
|
||||||
|
|
||||||
AcDb3dSolid* AcDbX3dSolid::GetDraw3dSolid() const
|
AcDb3dSolid* AcDbX3dSolid::GetDraw3dSolid() const
|
||||||
{
|
{
|
||||||
|
EnsureCreated();
|
||||||
if (m_pSolid != NULL)
|
if (m_pSolid != NULL)
|
||||||
{
|
{
|
||||||
AcDb3dSolid* pSolid = (AcDb3dSolid*)m_pSolid->clone();
|
AcDb3dSolid* pSolid = (AcDb3dSolid*)m_pSolid->clone();
|
||||||
@@ -3883,6 +3886,7 @@ AcDb3dSolid* AcDbX3dSolid::GetDraw3dSolid() const
|
|||||||
#if ARX > 17
|
#if ARX > 17
|
||||||
AcDbSubDMesh* AcDbX3dSolid::GetNativeSubDMesh() const
|
AcDbSubDMesh* AcDbX3dSolid::GetNativeSubDMesh() const
|
||||||
{
|
{
|
||||||
|
EnsureCreated();
|
||||||
return m_pSubDMesh;
|
return m_pSubDMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3890,6 +3894,8 @@ AcDbSubDMesh* AcDbX3dSolid::GetDrawSubDMesh() const
|
|||||||
{
|
{
|
||||||
if (m_eType != kFrom3JS) return NULL;
|
if (m_eType != kFrom3JS) return NULL;
|
||||||
|
|
||||||
|
EnsureCreated();
|
||||||
|
if (!m_pSubDMesh) return NULL;
|
||||||
return (AcDbSubDMesh*)m_pSubDMesh->clone();
|
return (AcDbSubDMesh*)m_pSubDMesh->clone();
|
||||||
|
|
||||||
// 移动和旋转操作在Group内完成,这里属于预留
|
// 移动和旋转操作在Group内完成,这里属于预留
|
||||||
@@ -3925,6 +3931,7 @@ AcDbSubDMesh* AcDbX3dSolid::GetDrawSubDMesh() const
|
|||||||
|
|
||||||
void AcDbX3dSolid::GetDrawSubDMesh2D(AcArray<AcGeLineSeg3d> &ar) const
|
void AcDbX3dSolid::GetDrawSubDMesh2D(AcArray<AcGeLineSeg3d> &ar) const
|
||||||
{
|
{
|
||||||
|
EnsureCreated();
|
||||||
ar.append(m_pSubDMesh2Ds);
|
ar.append(m_pSubDMesh2Ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4610,9 +4617,21 @@ Acad::ErrorStatus AcDbX3dSolid::ReCreate()
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bNeedCreate = false;
|
||||||
return Acad::eOk;
|
return Acad::eOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AcDbX3dSolid::EnsureCreated() const
|
||||||
|
{
|
||||||
|
if (!m_bNeedCreate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//先清标志再重建,避免 ReCreate 内部再次触发 EnsureCreated 造成递归
|
||||||
|
m_bNeedCreate = false;
|
||||||
|
const_cast<AcDbX3dSolid*>(this)->ReCreate();
|
||||||
|
}
|
||||||
|
|
||||||
bool AcDbX3dSolid::GetLoftReducerSides(CString& sPoint2ds,AcGePoint2dArray& arTopPts,AcGePoint2dArray& arBomPts)
|
bool AcDbX3dSolid::GetLoftReducerSides(CString& sPoint2ds,AcGePoint2dArray& arTopPts,AcGePoint2dArray& arBomPts)
|
||||||
{
|
{
|
||||||
CString sTemp = sPoint2ds;
|
CString sTemp = sPoint2ds;
|
||||||
@@ -4750,7 +4769,7 @@ Acad::ErrorStatus AcDbX3dSolid::dwgInFields (AcDbDwgFiler* pFiler)
|
|||||||
CoreTools::PolylineToString(&poly, m_sszPoint2ds, false);
|
CoreTools::PolylineToString(&poly, m_sszPoint2ds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReCreate();
|
m_bNeedCreate = true; //延迟到首次访问几何时重建,避免开图时逐个走 SAT 临时文件
|
||||||
|
|
||||||
return pFiler->filerStatus();
|
return pFiler->filerStatus();
|
||||||
}
|
}
|
||||||
@@ -5458,10 +5477,7 @@ bool AcDbX3dSolid::ByJson(const SHJson::WValue &v)
|
|||||||
AcGePoint3d AcDbX3dSolid::GetCentoridPoint()
|
AcGePoint3d AcDbX3dSolid::GetCentoridPoint()
|
||||||
{
|
{
|
||||||
AcGePoint3d pt;
|
AcGePoint3d pt;
|
||||||
if (!m_pSolid)
|
EnsureCreated();
|
||||||
{
|
|
||||||
ReCreate();
|
|
||||||
}
|
|
||||||
if (m_pSolid)
|
if (m_pSolid)
|
||||||
{
|
{
|
||||||
double v;
|
double v;
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public:
|
|||||||
//ext: Create(kBox,3,10.0,10.0,12.0);
|
//ext: Create(kBox,3,10.0,10.0,12.0);
|
||||||
bool Create(AcDbX3dSolid::Primitive eType,const AcGePoint3d& ptOrg,const AcGeVector3d& vtZ,int n,...);
|
bool Create(AcDbX3dSolid::Primitive eType,const AcGePoint3d& ptOrg,const AcGeVector3d& vtZ,int n,...);
|
||||||
Acad::ErrorStatus ReCreate();
|
Acad::ErrorStatus ReCreate();
|
||||||
|
//按需重建几何:m_bNeedCreate 为真时才调用 ReCreate,供所有读取 m_pSolid/m_pSubDMesh 的入口使用
|
||||||
|
void EnsureCreated() const;
|
||||||
|
|
||||||
//起点长度管廊段
|
//起点长度管廊段
|
||||||
bool CreateEarthWorm(const AcGePoint3d& ptOrg,const AcGeVector3d& vtZ,LPCTSTR pszScr,double dLen,const AcGeVector3d& vtLast,const AcGeVector3d& vtNext);
|
bool CreateEarthWorm(const AcGePoint3d& ptOrg,const AcGeVector3d& vtZ,LPCTSTR pszScr,double dLen,const AcGeVector3d& vtLast,const AcGeVector3d& vtNext);
|
||||||
@@ -253,6 +255,7 @@ protected:
|
|||||||
|
|
||||||
//以上数据创建的模型,->不序列化
|
//以上数据创建的模型,->不序列化
|
||||||
AcDb3dSolid* m_pSolid; //原始solid元,不序列化
|
AcDb3dSolid* m_pSolid; //原始solid元,不序列化
|
||||||
|
mutable bool m_bNeedCreate; //几何待重建标志,不序列化
|
||||||
AcDbVoidPtrArray m_arCurPtrs; //创建的二维曲线
|
AcDbVoidPtrArray m_arCurPtrs; //创建的二维曲线
|
||||||
|
|
||||||
#if ARX > 17
|
#if ARX > 17
|
||||||
|
|||||||
Reference in new issue
Block a user