void CCommonFuntion::BatchStorageEnt(AcDbObjectIdArray& inputId, std::vector<std::vector<AcDbObjectId>>& outputId)
{
AcDbEntity *pEnt = NULL;
AcDbEntity *tempEnt = NULL;
if (inputId.length() == 1)
{
std::vector<AcDbObjectId> tempcompare;
tempcompare.push_back(inputId[0]);
outputId.push_back(tempcompare);
}
else
{
for (int i = 0; i < inputId.length(); i++)
{
bool tag = true;
if (Acad::eOk != acdbOpenObject(pEnt, inputId[i], AcDb::kForRead))
continue;
for (int j = 0; j < inputId.length(); j++)
{
std::vector<AcDbObjectId> tempcompare;
if (inputId[i] == inputId[j])
continue;
if (Acad::eOk != acdbOpenObject(tempEnt, inputId[j], AcDb::kForRead))
continue;
AcGePoint3dArray intersectPoints;
tempEnt->intersectWith(pEnt, AcDb::kOnBothOperands, intersectPoints);
if (intersectPoints.length() > 0)
{
tag = false;
bool ent_tag = true;
int ent_num = 0;
for (int k = 0; k < outputId.size(); k++)
{
if (std::find(outputId[k].begin(), outputId[k].end(), inputId[i]) != outputId[k].end())//存在实体ID
{
ent_tag = false;
ent_num = k;
break;
}
}
bool tement_tag = true;
int tempent_num = 0;
for (int k = 0; k < outputId.size(); k++)
{
if (std::find(outputId[k].begin(), outputId[k].end(), inputId[j]) != outputId[k].end())//存在实体ID
{
tement_tag = false;
tempent_num = k;
break;
}
}
if (ent_tag)
{
if (tement_tag)
{
tempcompare.push_back(inputId[i]);
tempcompare.push_back(inputId[j]);
outputId.push_back(tempcompare);
}
else
outputId[tempent_num].push_back(inputId[i]);
}
else
{
if (tement_tag)
outputId[ent_num].push_back(inputId[j]);
else
{
if (tempent_num != ent_num)
{
for (int Num = 0; Num < outputId[tempent_num].size(); Num++)
{
outputId[ent_num].push_back(outputId[tempent_num][Num]);
}
std::remove(outputId.begin(), outputId.end(), outputId[tempent_num]);
}
}
}
}
if (tempEnt)
tempEnt->close();
}
if (tag)
{
std::vector<AcDbObjectId> tempvector;
tempvector.push_back(inputId[i]);
outputId.push_back(tempvector);
}
if (pEnt)
pEnt->close();
}
}
}