arx、CSCAD获取三维实体边、面,并高亮

void
highlightEdge(const AcDbObjectId& objId, const int marker)
{
    TCHAR dummy[133]; // space for acedGetStringB pauses below

    AcDbEntity *pEnt;
    acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
    AcGePoint3d pickpnt;
    AcGeMatrix3d xform;
    int numIds;
    AcDbFullSubentPath *subentIds;
    pEnt->getSubentPathsAtGsMarker(AcDb::kEdgeSubentType,
        marker, pickpnt, xform, numIds, subentIds);

    // At this point the subentId's variable contains the
    // address of an array of AcDbFullSubentPath objects.
    // The array should be one element long, so the picked
    // edge's AcDbFullSubentPath is in subentIds[0].
    //
    // For objects with no edges (such as a sphere), the
    // code to highlight an edge is meaningless and must
    // be skipped.
    //
    if (numIds > 0) {
        // Highlight the edge.
        //
        pEnt->highlight(subentIds[0]);

        // Pause to let user see the effect.
        //
        acedGetString(0, _T("\npress <RETURN> to continue..."),
            dummy);

        // Unhighlight the picked edge.
        //
        pEnt->unhighlight(subentIds[0]);

        // Get a copy of the edge, and add it to the database.
        //
        AcDbEntity *pEntCpy = pEnt->subentPtr(subentIds[0]);
        AcDbObjectId objId;
        addToModelSpace(objId, pEntCpy);

    }
    delete []subentIds;

    pEnt->close();
}
void
highlightFaces(const AcDbObjectId& objId, const int marker)
{
    TCHAR dummy[133];

    AcDbEntity *pEnt;
    acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);

    // Get the subentIds for the faces.
    //
    AcGePoint3d pickpnt;
    AcGeMatrix3d xform;
    int numIds;
    AcDbFullSubentPath *subentIds;
    pEnt->getSubentPathsAtGsMarker(AcDb::kFaceSubentType,
        marker, pickpnt, xform, numIds, subentIds);

    // Walk the subentIds list, highlighting each face subentity.
    //
    for (int i = 0;i < numIds; i++) {
        pEnt->highlight(subentIds[i]); // Highlight face.

        // Pause to let the user see the effect.
        //
        acedGetString(0, _T("\npress <RETURN> to continue..."),
            dummy);

        pEnt->unhighlight(subentIds[i]);
    }
    delete []subentIds;
    pEnt->close();
}
void
highlightAll(const AcDbObjectId& objId)
{
    TCHAR dummy[133];

    AcDbEntity *pEnt;
    acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);

    // Highlight the whole solid.
    //
    pEnt->highlight();

    // Pause to let user see the effect.
    //
    acedGetString(0, _T("\npress <RETURN> to continue..."),
        dummy);

    pEnt->unhighlight();
    pEnt->close();
}


Acad::ErrorStatus
addToModelSpace(AcDbObjectId &objId, AcDbEntity* pEntity)
{
    AcDbBlockTable *pBlockTable;
    AcDbBlockTableRecord *pSpaceRecord;

    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);

    pBlockTable->getAt(ACDB_MODEL_SPACE, pSpaceRecord,
        AcDb::kForWrite);

    pSpaceRecord->appendAcDbEntity(objId, pEntity);

    pBlockTable->close();
    pEntity->close();
    pSpaceRecord->close();

    return Acad::eOk;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值