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

  • 相关阅读:
    初识JSP知识
    Session每次访问都回新建对象问题的处理
    C++ 重载中括号
    C++ 重载输出符号
    C++ 单目运算 and 双目运算符重载complex
    C++运算符重载范例
    c++ 运算符重载之成员函数重载
    c++ 友元函数
    c++ static 类
    c++ const 类
  • 原文地址:https://www.cnblogs.com/Pond-ZZC/p/11813590.html
Copyright © 2020-2023  润新知