Files
envi-code/SourceCode/Code2026/tg_shs/shs_kernal/TDbExtentsZoneTable.cpp
T
2026-09-28 15:28:50 +08:00

771 lines
18 KiB
C++

//------------------------------------------------------------------------+
// Copyright (C), 1998-2011, Beijing Tangent Software Co. Ltd.
// = FileName : TDbExtentsZoneTable类
// = Version : ver1.0
// = Author : cet
// = CreateDate : 2011-08-12
// = Description: 分区表类实现
// = Maintainers:
//
//------------------------------------------------------------------------+
#include "StdAfx.h"
#ifdef TASD
#include "TDbExtentsZoneTable.h"
#include "TDbStruEntityBase.h"
extern TARCH_IMPEXP BOOL g_bUseCellBox;
ACRX_DXF_DEFINE_MEMBERS(ATSExtentsZoneTable, AcDbObject,AcDb::kDHL_CURRENT,
AcDb::kMReleaseCurrent,1, ATS_STRUEXENTSZONETABLE, "ATS_STRUEXENTSZONETABLE图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
const Adesk::UInt8 TDbExtentsZoneTable::g_nVersion = 1;
TDbExtentsZoneTable::TDbExtentsZoneTable( double dXAxis /*= 1000*/,double dYAxis /*= 1000*/,double dZAxis /*= 1000*/ )
{
m_dXAxis = dXAxis;
m_dYAxis = dYAxis;
m_dZAxis = dZAxis;
}
TDbExtentsZoneTable& TDbExtentsZoneTable::operator=( const TDbExtentsZoneTable &table )
{
if (this == &table)
{
return *this;
}
m_pPartition = table.m_pPartition;
m_extents = table.m_extents;
m_dXAxis = table.m_dXAxis;
m_dYAxis = table.m_dYAxis;
m_dZAxis = table.m_dZAxis;
return *this;
}
TDbExtentsZoneTable::~TDbExtentsZoneTable()
{
}
Acad::ErrorStatus TDbExtentsZoneTable::dwgInFields( AcDbDwgFiler* pFiler )
{
assertWriteEnabled();
Acad::ErrorStatus es=Acad::eOk;
es = AcDbObject::dwgInFields(pFiler);
if(es != Acad::eOk)
{
return es;
}
Adesk::UInt8 nVer = 0;
pFiler->readItem(&nVer);
if(nVer > g_nVersion) // Version is too new
{
return Acad::eMakeMeProxy;
}
pFiler->readItem(&m_dXAxis);
pFiler->readItem(&m_dYAxis);
pFiler->readItem(&m_dZAxis);
AcGePoint3d ptMin, ptMax;
pFiler->readItem(&ptMin);
pFiler->readItem(&ptMax);
SetExtents(ptMin, ptMax);
// 表长度
Adesk::Int32 nXSize = 0, nYSize = 0, nZSize = 0;
pFiler->readItem(&nXSize);
pFiler->readItem(&nYSize);
pFiler->readItem(&nZSize);
// 表原点
Adesk::Int32 nX = 0, nY = 0, nZ = 0;
pFiler->readItem(&nX);
pFiler->readItem(&nY);
pFiler->readItem(&nZ);
//add by xlc on 120120 是否创建参数为保存,导致未创建时直接保存再次打开崩溃
bool bCreate = false;
pFiler->readItem(&bCreate);
if (bCreate)
{
m_pPartition.InitArray(nX, nY, nZ, nXSize, nYSize, nZSize);
m_pPartition.Create(); // 创建表
// 表中内容
dwgInFields(pFiler,0);
dwgInFields(pFiler,1);
dwgInFields(pFiler,2);
dwgInFields(pFiler,3);
dwgInFields(pFiler,4);
dwgInFields(pFiler,5);
dwgInFields(pFiler,6);
dwgInFields(pFiler,7);
}
return es;
}
Acad::ErrorStatus TDbExtentsZoneTable::dwgInFields( AcDbDwgFiler* pFiler, int nQuadrant )
{
if (!g_bUseCellBox)
{
return Acad::eOk;
}
int nMinX = 0, nMinY = 0, nMinZ = 0;
int nMaxX = 0, nMaxY = 0, nMaxZ = 0;
m_pPartition.GetXYZ(nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ,nQuadrant);
TDbExtentsZoneTableRecord *pRec = NULL;
for (int x = nMinX; x <= nMaxX; x++)
{
for(int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
pRec = m_pPartition.GetValue(x,y,z,nQuadrant);
if (pRec != NULL)
{
pRec->dwgInFields(pFiler);
}
}
}
}
return Acad::eOk;
}
Acad::ErrorStatus TDbExtentsZoneTable::dwgOutFields( AcDbDwgFiler* pFiler ) const
{
assertReadEnabled();
Acad::ErrorStatus es=Acad::eOk;
es = AcDbObject::dwgOutFields(pFiler);
if(es != Acad::eOk)
{
return es;
}
pFiler->writeItem(g_nVersion);
pFiler->writeItem(m_dXAxis);
pFiler->writeItem(m_dYAxis);
pFiler->writeItem(m_dZAxis);
pFiler->writeItem(m_extents.minPoint());
pFiler->writeItem(m_extents.maxPoint());
// 表长度
Adesk::Int32 nX = 0, nY = 0, nZ = 0;
nX = m_pPartition.GetXSize();
nY = m_pPartition.GetYSize();
nZ = m_pPartition.GetZSize();
pFiler->writeItem(nX);
pFiler->writeItem(nY);
pFiler->writeItem(nZ);
// 表原点
int n1 = 0, n2 = 0, n3 = 0;
m_pPartition.GetOrigin(n1, n2, n3);
nX = n1;
nY = n2;
nZ = n3;
pFiler->writeItem(nX);
pFiler->writeItem(nY);
pFiler->writeItem(nZ);
//add by xlc on 120120 是否创建参数为保存,导致未创建时直接保存再次打开崩溃
bool bCreate = m_pPartition.IsCreated();
pFiler->writeItem(bCreate);
if (bCreate)
{ // 表中内容
dwgOutFields(pFiler,0);
dwgOutFields(pFiler,1);
dwgOutFields(pFiler,2);
dwgOutFields(pFiler,3);
dwgOutFields(pFiler,4);
dwgOutFields(pFiler,5);
dwgOutFields(pFiler,6);
dwgOutFields(pFiler,7);
}
return es;
}
Acad::ErrorStatus TDbExtentsZoneTable::dwgOutFields( AcDbDwgFiler* pFiler, int nQuadrant ) const
{
if (!g_bUseCellBox)
{
return Acad::eOk;
}
int nMinX = 0, nMinY = 0, nMinZ = 0;
int nMaxX = 0, nMaxY = 0, nMaxZ = 0;
m_pPartition.GetXYZ(nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ,nQuadrant);
TDbExtentsZoneTableRecord *pRec = NULL;
for (int x = nMinX; x <= nMaxX; x++)
{
for(int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
pRec = m_pPartition.GetValue(x,y,z,nQuadrant);
if (pRec != NULL)
{
pRec->dwgOutFields(pFiler);
}
}
}
}
return Acad::eOk;
}
int TDbExtentsZoneTable::GetSelection( const AcGePoint3d &ptMin, const AcGePoint3d &ptMax, AcDbObjectIdArray& idArray )
{
if (!g_bUseCellBox)
{
/*
acedGetAcadDwgView()->SetRedraw(FALSE);
AcDbViewTableRecord view;
InitView(view);
TADSGePoint3d pt1= ptMin,pt2= ptMax;
pt1 = pt1 - TADSGePoint3d(1,1,0);
pt2 = pt2 + TADSGePoint3d(1,1,0);
ArxZoom(pt1,pt2);
ads_name ss,ent;
CString strSel(_T("ATS_COLUMN,ATS_OPENING,ATS_WALL,ATS_STRUBEAM,ATS_STRU_FLOORSLAB,ATS_STRUSELFBASE,ATS_STRUBARBASE,ATS_STRUSLABHOLE"));
resbuf *rbFilter = acutBuildList(RTDXF0, strSel, RTNONE);
int nRes = acedSSGet(_T("C"),asDblArray(ptMin),asDblArray(ptMax),rbFilter,ss);
acutRelRb(rbFilter);
acedGetAcadDwgView()->SetRedraw(TRUE);
acedSetCurrentView(&view,NULL);
long lLen = 0;
acedSSLength(ss,&lLen);
idArray.setLogicalLength(0);
AcDbObjectId id;
for (long i = 0;i < lLen;i++)
{
acedSSName(ss,i,ent);
if(acdbGetObjectId(id,ent) == Acad::eOk)
{
idArray.append(id);
}
}
acedSSFree(ss);*/
PickSet ss(SS_FREE);
CString strSel(_T("ATS_COLUMN,ATS_OPENING,ATS_WALL,ATS_STRUBEAM,ATS_STRU_FLOORSLAB,ATS_STRUSELFBASE,ATS_STRUBARBASE,ATS_STRUSLABHOLE"));
if(GetSafeSelection(ss, TRUE, ptMin, ptMax, strSel) == Acad::eOk)
{
ss.AsIdArray(idArray);
}
return RTNORM;
}
// 将点转换成分区表索引值
int nMinX = 0, nMinY = 0, nMinZ = 0; // 区域索引最小值
int nMaxX = 0, nMaxY = 0, nMaxZ = 0; // 区域索引最大值
GetXYZ(ptMin, nMinX, nMinY, nMinZ, false);
GetXYZ(ptMax, nMaxX, nMaxY, nMaxZ, true);
// 根据索引取出相应分区单元中的id存入idArray
int nSize = 0, nX = 0, nY = 0, nZ = 0;
AcDbObjectId id;
TDbExtentsZoneCell cell;
TDbExtentsZoneTableRecord *pRecord = NULL;
for (int x = nMinX; x <= nMaxX; x++)
{
for (int y = nMinY; y <= nMaxY; y++)
{
for(int z = nMinZ; z <= nMaxZ; z++)
{
nX = x;
nY = y;
nZ = z;
nX = nX >= 0 ? x + 1 : x - 1;
nY = nY >= 0 ? y + 1 : y - 1;
nZ = nZ >= 0 ? z + 1 : z - 1;
pRecord = m_pPartition.GetValue(nX, nY, nZ);
if (pRecord != NULL)
{
nSize = pRecord->GetSize();
for (int i = 0; i < nSize; i++)
{
pRecord->GetZoneCell(i, cell);
id = cell.GetObjectId();
int nPos = -1;
idArray.find(id, nPos);
if (nPos == -1)
{
idArray.append(id);
}
}
}
}
}
}
return RTNORM;
}
int TDbExtentsZoneTable::GetSelection2D( const AcGePoint3d &ptMin, const AcGePoint3d &ptMax, AcDbObjectIdArray& idArray )
{
AcGePoint3d pt1 = ptMin, pt2 = ptMax;
pt1.z = m_extents.minPoint().z;
pt2.z = m_extents.minPoint().z;
GetSelection(pt1, pt2, idArray);
return RTNORM;
}
bool TDbExtentsZoneTable::UpdatePartition( const AcDbObjectId &id, const AcDbExtents &ext )
{
// 创建cell
AcDbEntity *pBase = NULL;
Acad::ErrorStatus st = acdbOpenObject(pBase, id, AcDb::kForRead);
if (pBase == NULL)
{
return false;
}
const ACHAR* pszDxfName = pBase->isA()->dxfName();
TADSGePoint3d ptLow, ptUp;
if (pBase->isKindOf(TDbWall::desc()))
{
((TDbWall*)pBase)->GetExtents(ptLow, ptUp);
pBase->close();
}
else if (pBase->isKindOf(TDbColumn::desc()))
{
((TDbColumn*)pBase)->GetExtents(ptLow, ptUp);
XPoint ptLoc = ((TDbColumn*)pBase)->GetLocation();
double dHeight = ((TDbColumn*)pBase)->GetHeight();
ptLow.z = ptLoc.z;
ptUp.z = ptLoc.z + dHeight;
pBase->close();
}
else if (pBase->isKindOf(TDbStruEntityBase::desc()))
{
((TDbStruEntityBase*)pBase)->GetExtents(ptLow, ptUp);
pBase->close();
}
else if (pBase->isKindOf(TDbOpening::desc()))
{
((TDbOpening*)pBase)->GetExtents(ptLow, ptUp);
XPoint ptLoc = ((TDbOpening*)pBase)->GetLocation();
double dHeight = ((TDbOpening*)pBase)->GetHeight();
ptLow.z = ptLoc.z;
ptUp.z = ptLoc.z + dHeight;
pBase->close();
}
else
{
pBase->close();
return false;
}
// 删除id
RemoveBoxZoneCell(id);
TDbExtentsZoneCell cell;
cell.SetObjectId(id);
cell.SetDxf(pszDxfName);
//delete[] pszDxfName;
cell.SetPtMax(ext.maxPoint());
cell.SetPtMin(ext.minPoint());
// 重新插入
AddBoxZoneCell(cell);
return true;
}
bool TDbExtentsZoneTable::UpdatePartition( const AcDbObjectId &id, const AcGeMatrix3d &xform )
{
return true;
}
bool TDbExtentsZoneTable::AddBoxZoneCell( TDbExtentsZoneCell& boxCell )
{
// 检查cell是否在当前创建的区域呢
AcGePoint3d ptMin = m_extents.minPoint(), ptMax = m_extents.maxPoint();
m_extents.addPoint(boxCell.GetPtMin());
m_extents.addPoint(boxCell.GetPtMax());
AcGePoint3d pt1 = m_extents.minPoint(), pt2 = m_extents.maxPoint();
if (pt1.distanceTo(ptMin) > _DIST_SNAP || pt2.distanceTo(ptMax) > _DIST_SNAP) // 不在区域内,扩充区域大小
{
UpdateTable(pt1, pt2); //更新分区表以容纳cell
}
// 根据cell的最大值和最小值以及分区大小计算出cell所在的分区位置
ptMin = boxCell.GetPtMin();
ptMax = boxCell.GetPtMax();
int nMinX = 0, nMinY = 0, nMinZ = 0;
int nMaxX = 0, nMaxY = 0, nMaxZ = 0;
nMinX = static_cast<int>(floor(ptMin.x / m_dXAxis));
nMinY = static_cast<int>(floor(ptMin.y / m_dYAxis));
nMinZ = static_cast<int>(floor(ptMin.z / m_dZAxis));
nMaxX = static_cast<int>(ceil(ptMax.x / m_dXAxis));
nMaxY = static_cast<int>(ceil(ptMax.y / m_dYAxis));
nMaxZ = static_cast<int>(ceil(ptMax.z / m_dZAxis));
int nX = 0, nY = 0, nZ = 0;
TDbExtentsZoneTableRecord *pRec = NULL;
for(int x = nMinX; x <= nMaxX; x++)
{
for (int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
nX = x;
nY = y;
nZ = z;
nX = nX >= 0 ? x + 1 : x - 1;
nY = nY >= 0 ? y + 1 : y - 1;
nZ = nZ >= 0 ? z + 1 : z - 1;
pRec = m_pPartition.GetValue(nX, nY, nZ);
if (pRec != NULL)
{
pRec->AddZoneCell(boxCell);
}
}
}
}
return true;
}
bool TDbExtentsZoneTable::AddBoxZoneCell(const AcDbObjectId &id)
{
AcDbEntity *pBase = NULL;
Acad::ErrorStatus st = acdbOpenObject(pBase, id, AcDb::kForRead);
if (pBase == NULL)
{
return false;
}
const ACHAR* pszDxfName = pBase->isA()->dxfName();
TADSGePoint3d ptLow, ptUp;
if (pBase->isKindOf(TDbWall::desc()))
{
((TDbWall*)pBase)->GetExtents(ptLow, ptUp);
pBase->close();
}
else if (pBase->isKindOf(TDbColumn::desc()))
{
((TDbColumn*)pBase)->GetExtents(ptLow, ptUp);
XPoint ptLoc = ((TDbColumn*)pBase)->GetLocation();
double dHeight = ((TDbColumn*)pBase)->GetHeight();
ptLow.z = ptLoc.z;
ptUp.z = ptLoc.z + dHeight;
pBase->close();
}
else if (pBase->isKindOf(TDbStruEntityBase::desc()))
{
((TDbStruEntityBase*)pBase)->GetExtents(ptLow, ptUp);
pBase->close();
}
else if (pBase->isKindOf(TDbOpening::desc()))
{
((TDbOpening*)pBase)->GetExtents(ptLow, ptUp);
XPoint ptLoc = ((TDbOpening*)pBase)->GetLocation();
double dHeight = ((TDbOpening*)pBase)->GetHeight();
ptLow.z = ptLoc.z;
ptUp.z = ptLoc.z + dHeight;
pBase->close();
}
else
{
pBase->close();
return false;
}
TDbExtentsZoneCell cell;
cell.SetObjectId(id);
cell.SetDxf(pszDxfName);
//delete[] pszDxfName;
cell.SetPtMax(ptUp);
cell.SetPtMin(ptLow);
AddBoxZoneCell(cell);
return true;
}
void TDbExtentsZoneTable::SetDimension( int nXOri, int nYOri, int nZOri,int nX, int nY, int nZ )
{
}
void TDbExtentsZoneTable::SetExtents( const AcGePoint3d &ptMin,const AcGePoint3d &ptMax )
{
m_extents.set(ptMin, ptMax);
}
void TDbExtentsZoneTable::RemoveBoxZoneCell( const AcDbObjectId &id )
{
if (!g_bUseCellBox)
{
return;
}
// 删除各区域id
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::kXYZ);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::k_XYZ);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::k_X_YZ);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::kX_YZ);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::kXY_Z);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::k_XY_Z);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::k_X_Y_Z);
RemoveBoxZoneCell(id, T3DimArray<TDbExtentsZoneTableRecord>::kX_Y_Z);
}
void TDbExtentsZoneTable::RemoveBoxZoneCell( const AcDbObjectId &id, int nQuadrant )
{
if (!g_bUseCellBox)
{
return;
}
int nMinX = 0, nMinY = 0, nMinZ = 0; // 某区域索引最小值
int nMaxX = 0, nMaxY = 0, nMaxZ = 0; // 某区域索引最大值
m_pPartition.GetXYZ(nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ, nQuadrant);
TDbExtentsZoneTableRecord *pRecord = NULL;
for(int x = nMinX; x <= nMaxX; x++)
{
for (int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
pRecord = m_pPartition.GetValue(x, y, z, nQuadrant);
if (pRecord != NULL)
{
pRecord->RemoveZoneCell(id);
}
}
}
}
}
void TDbExtentsZoneTable::CreateTable()
{
if (!g_bUseCellBox)
{
return;
}
// 计算原点和数组XYZ值大小
AcGePoint3d ptMin, ptMax;
ptMin = m_extents.minPoint();
ptMax = m_extents.maxPoint();
int nXSize = 0, nYSize = 0, nZSize = 0;
int nOriginX , nOriginY, nOriginZ;
AcGePoint3d ptOrigin, ptSize;
GetTableData(ptMin, ptMax, ptOrigin, ptSize);
nOriginX = static_cast<int>(ptOrigin.x);
nOriginY = static_cast<int>(ptOrigin.y);
nOriginZ = static_cast<int>(ptOrigin.z);
nXSize = static_cast<int>(ptSize.x);
nYSize = static_cast<int>(ptSize.y);
nZSize = static_cast<int>(ptSize.z);
m_pPartition.InitArray(nOriginX, nOriginY, nOriginZ, nXSize, nYSize, nZSize); // 设置原点和区域大小
m_pPartition.Create();
}
void TDbExtentsZoneTable::UpdateTable(const AcGePoint3d &ptMin, const AcGePoint3d &ptMax)
{
if (!g_bUseCellBox)
{
return;
}
// 确定分区表原点和xyz的长度
int nX = 0, nY = 0, nZ = 0;
int nXSize = 0, nYSize = 0, nZSize = 0;
AcGePoint3d ptOrigin, ptSize;
GetTableData(ptMin, ptMax, ptOrigin, ptSize);
nX = static_cast<int>(ptOrigin.x);
nY = static_cast<int>(ptOrigin.y);
nZ = static_cast<int>(ptOrigin.z);
nXSize = static_cast<int>(ptSize.x);
nYSize = static_cast<int>(ptSize.y);
nZSize = static_cast<int>(ptSize.z);
// 更新分区表原点和xyz长度
m_pPartition.AddArray(nX, nY, nZ, nXSize, nYSize, nZSize);
}
void TDbExtentsZoneTable::GetXYZ( const AcGePoint3d &pt, int &nX, int &nY, int &nZ, bool bUp )
{
double dX = pt.x / m_dXAxis;
double dY = pt.y / m_dYAxis;
double dZ = pt.z / m_dZAxis;
if (bUp)
{
nX = static_cast<int>(ceil(dX));
nY = static_cast<int>(ceil(dY));
nZ = static_cast<int>(ceil(dZ));
}
else
{
nX = static_cast<int>(floor(dX));
nY = static_cast<int>(floor(dY));
nZ = static_cast<int>(floor(dZ));
}
}
void TDbExtentsZoneTable::GetTableData( const AcGePoint3d &ptMin, const AcGePoint3d &ptMax, AcGePoint3d &ptOrigin, AcGePoint3d &ptSize )
{
if (!g_bUseCellBox)
{
return;
}
// 确定分区表原点和xyz的长度
int nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ;
nMinX = static_cast<int>(floor(ptMin.x / m_dXAxis));
nMinY = static_cast<int>(floor(ptMin.y / m_dYAxis));
nMinZ = static_cast<int>(floor(ptMin.z / m_dZAxis));
nMaxX = static_cast<int>(ceil(ptMax.x / m_dXAxis));
nMaxY = static_cast<int>(ceil(ptMax.y / m_dYAxis));
nMaxZ = static_cast<int>(ceil(ptMax.z / m_dZAxis));
AcGePoint3d pt1(nMinX, nMinY, nMinZ), pt2(nMaxX, nMaxY, nMaxZ);
if(pt1.x * pt2.x < 0)
{
ptSize.x = fabs(pt1.x) + fabs(pt2.x) + 1;
}
else
{
ptSize.x = fabs(fabs(pt2.x) - fabs(pt1.x)) + 1;
}
if(pt1.y * pt2.y < 0)
{
ptSize.y = fabs(pt1.y) + fabs(pt2.y) + 1;
}
else
{
ptSize.y = fabs(fabs(pt2.y) - fabs(pt1.y)) + 1;
}
if(pt1.z * pt2.z < 0)
{
ptSize.z = fabs(pt1.z) + fabs(pt2.z) + 1;
}
else
{
ptSize.z = fabs(fabs(pt2.z) - fabs(pt1.z)) + 1;
}
// 将原点和大小扩大一些,以便容纳计算误差导致的存储错误
ptOrigin = pt1;
ptOrigin.x -= 1;
ptOrigin.y -= 1;
ptOrigin.z -= 1;
ptSize.x += 3;
ptSize.y += 3;
ptSize.z += 3;
}
void TDbExtentsZoneTable::GetTableObjects( AcDbObjectIdArray &arIds )
{
GetObjectIds(arIds, 0);
GetObjectIds(arIds, 1);
GetObjectIds(arIds, 2);
GetObjectIds(arIds, 3);
GetObjectIds(arIds, 4);
GetObjectIds(arIds, 5);
GetObjectIds(arIds, 6);
GetObjectIds(arIds, 7);
}
void TDbExtentsZoneTable::GetObjectIds( AcDbObjectIdArray &arIds, int nQuadrant )
{
if (!g_bUseCellBox)
{
return;
}
int nMinX = 0, nMinY = 0, nMinZ = 0; // 区域索引最小值
int nMaxX = 0, nMaxY = 0, nMaxZ = 0; // 区域索引最大值
m_pPartition.GetXYZ(nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ, nQuadrant);
TDbExtentsZoneTableRecord *pRec = NULL;
TDbExtentsZoneCell cell;
AcDbObjectId id;
for (int x = nMinX; x <= nMaxX; x++)
{
for (int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
pRec = m_pPartition.GetValue(x, y, z, nQuadrant);
if (pRec != NULL)
{
for (int i = 0; i < pRec->GetSize(); i++)
{
if (pRec->GetZoneCell(i, cell))
{
id = cell.GetObjectId();
int nPos = -1;
arIds.find(id, nPos);
if (nPos == -1)
{
arIds.append(id);
}
}
}
}
}
}
}
}
void TDbExtentsZoneTable::GetTableEnt( const AcDbObjectId &idEnt, int nQuadrant, int &nNum )
{
if (!g_bUseCellBox)
{
return;
}
nNum = 0;
int nMinX = 0, nMinY = 0, nMinZ = 0; // 区域索引最小值
int nMaxX = 0, nMaxY = 0, nMaxZ = 0; // 区域索引最大值
m_pPartition.GetXYZ(nMinX, nMinY, nMinZ, nMaxX, nMaxY, nMaxZ, nQuadrant);
TDbExtentsZoneTableRecord *pRec = NULL;
TDbExtentsZoneCell cell;
AcDbObjectId id;
for (int x = nMinX; x <= nMaxX; x++)
{
for (int y = nMinY; y <= nMaxY; y++)
{
for (int z = nMinZ; z <= nMaxZ; z++)
{
pRec = m_pPartition.GetValue(x, y, z, nQuadrant);
if (pRec != NULL)
{
for (int i = 0; i < pRec->GetSize(); i++)
{
if (pRec->GetZoneCell(i, cell))
{
id = cell.GetObjectId();
if (id == idEnt)
{
++nNum;
break;
}
}
}
}
}
}
}
}
void InitDbExtentsZoneTable(bool bTrue)
{
if (bTrue)
{
TDbExtentsZoneTable::rxInit();
}
else
{
deleteAcRxClass(TDbExtentsZoneTable::desc());
}
}
#endif