设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 190|回复: 0

[图块] 获取块索引的XCLIP边界(Get the XCLIPped boundary of BlockReferences

[复制链接]
  • TA的每日心情
    开心
    2021-6-19 14:40
  • 签到天数: 1539 天

    [LV.Master]伴坛终老

    发表于 2021-1-8 15:08 | 显示全部楼层 |阅读模式
    1.   // Draw a red polyline by the given points etc.  //--------------------------------------------------  static BOOL drawAPlineWithPropertiesFromBlockRef(AcGePoint2dArray pts,                 AcDbBlockReference* ref, double elevation, AcGeVector3d& normal)  {    AcDbPolyline *pl = new AcDbPolyline;    AcDbObjectId owner;    pl->setDatabaseDefaults();    pl->setClosed(Adesk::kTrue);    pl->setThickness(0.0);    if (ref != NULL) {        owner=ref->ownerId();        pl->setPropertiesFrom(ref);    }    pl->setNormal(normal);    for (int i=0; i < pts.length(); i++)    {        pl->addVertexAt(i, pts<i>);    }    pl->setElevation(elevation);    pl->setColorIndex(1); // Red    AcDbBlockTableRecord *rec=NULL;    acdbOpenObject(rec, owner, AcDb::kForWrite);    if (rec != NULL)    {        AcDbObjectId id;        rec->appendAcDbEntity(id, pl);        pl->close();        rec->close();    }    else    {        delete pl;        return false;    }    return true;  } // End of drawAPlineWithPropertiesFromBlockRef()  // Get the boundary from a Block Reference given by the blk parameter.  // Transform that boundary to the WCS.  //-------------------------------------------------------------------  static BOOL GetBlockClippingPolyline(ads_name blk)  {    BOOL ret = FALSE;    AcDbBlockReference *ref = NULL;    AcDbObjectId insId = AcDbObjectId::kNull;    acdbGetObjectId(insId, blk);    if (acdbOpenObject(ref, insId, AcDb::kForRead) != Acad::eOk)      return ret;    // Find the clipping object (AcDbSpatialFilter) in the ExtDict of the BlockRef    AcDbObjectId extDicId = ref->extensionDictionary();    if( extDicId == AcDbObjectId::kNull )      return ret;    AcDbDictionary *extDict=NULL, *acadFilterDict=NULL;    if (acdbOpenObject(extDict, extDicId, AcDb::kForRead) != Acad::eOk)        return ret;    Acad::ErrorStatus err = extDict->getAt(_T("ACAD_FILTER"), (AcDbObject*&)acadFilterDict, AcDb::kForRead);    extDict->close();    if( err != Acad::eOk )        return ret;    AcDbSpatialFilter *filter=NULL;    err = acadFilterDict->getAt(_T("SPATIAL"), (AcDbObject*&)filter, AcDb::kForRead);    acadFilterDict->close();    if ( err != Acad::eOk)      return ret;    // Get the transform matrix stored in the XClip boundary    AcGeMatrix3d xformInBoundary = filter->getClipSpaceToWCSMatrix( xformInBoundary );    // and the transform of the BlockRef at the time when the Filter was set    AcGeMatrix3d xformRefOrig = filter->getOriginalInverseBlockXform( xformRefOrig );    // Get the transform matrix that the current BlockRef has, so, we can find the difference    //   with the xformRefOrig    AcGeMatrix3d refMatrix = ref->blockTransform();    refMatrix = refMatrix.postMultBy(xformRefOrig );    // Calculate the final transform matrix which applies to the points    // returned from filter->getDefinition().    AcGeMatrix3d finalMatrix = refMatrix.postMultBy(xformInBoundary);    AcGePoint2dArray pts;    AcGePoint3dArray pts3d;    AcGeVector3d normal;    double elevation = 0, frontClip = 0, backClip = 0;    Adesk::Boolean enabled  = false;    // Get all boundary points    if (filter->getDefinition(pts, normal, elevation, frontClip, backClip, enabled) == Acad::eOk)    {      // Rectanglar boundary      if (pts.length() == 2)      {        AcGePoint2d p1(pts[1].x, pts[0].y);        AcGePoint2d p3(pts[0].x, pts[1].y);        pts.insertAt(1, p1);        pts.insertAt(3, p3);      }      // Transform all points with the transform matrix we calculated      for(int i=0; i<pts.length(); i++)      {        AcGePoint2d pt2d;        AcGePoint3d pt3d;        pt2d = pts<i>;        pt3d[0] = pt2d[0]; pt3d[1] = pt2d[1]; pt3d[2] = 0;        pt3d.transformBy(finalMatrix);        pts3d.append(pt3d);      }    }    // Get the new normal and new ECS information for the polyline.    AcGeVector3d xfnorm = normal.transformBy(finalMatrix);    AcGeMatrix3d plineECS;    AcDbPolyline* pline = new AcDbPolyline();    pline->setNormal(xfnorm);    pline->getEcs(plineECS);    delete pline; pline = NULL;    AcGeMatrix3d plineECSInv = plineECS.inverse();    double xfelev = 0.0;    for (int i = 0; i < pts.length(); i++)    {      pts<i>.x = pts3d<i>.x;      pts<i>.y = pts3d<i>.y;      if (i == 0)        xfelev = pts3d<i>.z;      // Should be identical to within roundoff      assert(fabs(xfelev - pts3d<i>.z) < 1.0e-10);    }    // Show the boundary    drawAPlineWithPropertiesFromBlockRef(pts, ref, xfelev, xfnorm);    filter->close();    ref->close();    return true;  } // End of GetBlockClippingPolyline()  // "MClip" test command for the GetBlockClippingPolyline() function. static void MMRCplusplus_MClip(void)  {    ads_name en;    AcGePoint3d pt;    if (acedEntSel(_T("\nSelect an INSERT clipped by XCLIP command: "), en, asDblArray(pt)) != RTNORM)    {      acutPrintf(_T("\nNothing selected"));      return;    }    assert(GetBlockClippingPolyline(en)==TRUE);  }
    复制代码
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛