• Objectarx之分批存储相连实体


    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();
    }
    }
    }

  • 相关阅读:
    Dilworth定理,链还是反链?
    pku 3259Wormholes
    hdu 2612 Find a way
    hdu 2614
    hdu 2544 最短路
    hdu 2553 N皇后问题
    hdu2717 Catch That Cow
    hdu 1874 畅通工程续
    jquery学习必备代码和技巧
    HTML5 WebApp part4:使用 Web Workers 来加速您的移动 Web 应用程序(上)
  • 原文地址:https://www.cnblogs.com/Pond-ZZC/p/11813590.html
Copyright © 2020-2023  润新知