设为首页收藏本站

中国膜结构网

 找回密码
 立即注册
膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 24|回复: 1

Intersection of 2 Hatch

[复制链接]
  • TA的每日心情
    开心
    2021-3-7 10:01
  • 签到天数: 1440 天

    连续签到: 19 天

    [LV.10]以坛为家III

    发表于 2021-2-8 01:55 | 显示全部楼层 |阅读模式
    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构咨询服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系QQ:463017170.
    The only way I have found is obtainig the loops and intersecting them (Thanks Ing. B.C.). This is my code snippet. It only works when the number of Loops are equal and loops are built from lines. This is enough for me. I dont know if there is a simply way to do the same. Any suggestions? bool IntersectionOf2Hatch(AcDbHatch *pHatch1, AcDbHatch *pHatch2) { /* Return: true: Found an intersection false: no intersections */ int loops1 = pHatch1->numLoops(); int loops2 = pHatch2->numLoops(); AcDbObjectIdArray loopIds1; AcDbObjectIdArray loopIds2; for (int i = 0; i < loops1; ++i) { long loopType1; AcGeVoidPointerArray edgePtrs1; AcGeIntArray edgeTypes1; long loopType2; AcGeVoidPointerArray edgePtrs2; AcGeIntArray edgeTypes2; AcDb3dPolyline *pPol1 = NULL; AcDb3dPolyline *pPol2 = NULL; if (pHatch1->getLoopAt(i, loopType1, edgePtrs1, edgeTypes1) == Acad::eOk) { for (int j = 0; j < edgePtrs1.length(); j++) { AcGePoint3d point1; switch (edgeTypes1){ case AcDbHatch::kLine: { AcGeLineSeg3d *pGeLine3d = (AcGeLineSeg3d*)edgePtrs1; point1 = pGeLine3d->startPoint(); AcDb3dPolylineVertex *pVertex = new AcDb3dPolylineVertex(point1); if (pPol1 == NULL) pPol1 = new AcDb3dPolyline(); pPol1->appendVertex(pVertex); } break; case AcDbHatch::kCirArc: case AcDbHatch::kEllArc: case AcDbHatch::kSpline: default: break; } } if (pPol1 != NULL) pPol1->makeClosed(); } if (pHatch2->getLoopAt(i, loopType2, edgePtrs2, edgeTypes2) == Acad::eOk) { for (int k = 0; k < edgePtrs2.length(); k++) { AcGePoint3d point2; switch (edgeTypes2){ case AcDbHatch::kLine: { AcGeLineSeg3d *pGeLine3d = (AcGeLineSeg3d*)edgePtrs2; point2 = pGeLine3d->startPoint(); AcDb3dPolylineVertex *pVertex = new AcDb3dPolylineVertex(point2); if (pPol2 == NULL) pPol2 = new AcDb3dPolyline(); pPol2->appendVertex(pVertex); } break; case AcDbHatch::kCirArc: case AcDbHatch::kEllArc: case AcDbHatch::kSpline: default: break; } } if (pPol2 != NULL) pPol2->makeClosed(); } if (pPol1 != NULL && pPol2 != NULL) { AcGePoint3dArray points; if (pPol1->intersectWith(pPol2, AcDb::kOnBothOperands, points) == Acad::eOk) { if (points.length() > 0) { delete pPol1; delete pPol2; return true; } } } if (pPol1 != NULL) delete pPol1; if (pPol2 != NULL) delete pPol2; } return false; } "developer" escribió en el mensaje news:41ff7ef0$1_1@newsprd01... > Hello, > Is there a way to know if one hatch intersects with another hatch? > Thanks in advance, > Helio. > >
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2021-3-7 10:01
  • 签到天数: 1440 天

    连续签到: 19 天

    [LV.10]以坛为家III

     楼主| 发表于 2021-2-8 01:58 | 显示全部楼层
    mjsduct::intersectWith(const AcDbEntity* pEnt,
    > AcDb::Intersect intType,
    > AcGePoint3dArray& points,
    > int thisGsMarker = 0,
    > int otherGsMarker = 0) const
    > {
    > Acad::ErrorStatus es;
    > AcDbVoidPtrArray ents;
    > try
    > {
    > es = explode(ents); // just in case explode() failed but
    > if( es != Acad::eOk ) // left entities in the array.
    > throw es;
    > for(int i = 0; i < ents.length(); i++)
    > {
    > AcDbEntity* pE = static_cast (ents);
    > ASSERT(pE);
    > es = pE->intersectWith(pEnt, intType, points,
    > thisGsMarker, otherGsMarker);
    > if( es != Acad::eOk && es != Acad::eNotImplemented )
    > throw es; // anything else is regarded as an error
    > }
    > throw Acad::eOk;
    > }
    > catch(const Acad::ErrorStatus e)
    > {
    > for(int i = 0; i < ents.length(); i++)
    > delete static_cast (ents);
    > return e;
    > }
    > return Acad::eOk;
    > }
    >
    >
    >
    > "Martin Schmid" wrote in message
    > news:E3CD0B97ADBC18B2ECA34A0F78B1E22F@in.WebX.maYIadrTaRb...
    > > Here is my explode function... I convert the Entity into a
    > > AcDb3dPolyline(AcDb::k3dSimplePoly) (see below)
    > >
    > > Can you provide a simple example on how I would create the
    insersectWith?
    > I
    > > am only concerned about my class (mjsduct) being able to insersect with
    > > itself for now.
    > >
    > > In the documentation, it says:
    > > "If the intersectWith() function of your custom entity is called with
    > > another entity that is not a native entity, you need to explode your
    > custom
    > > entity (for example, by using the explode() function) to a set of
    > > recognizable native entities, then turn around and call intersectWith()
    on
    > > the entity that came in as an argument to your intersectWith() function.
    > > Because everyone is expected to be able to intersect with native
    entities,
    > > the entity in the argument would be able to intersect with your exploded
    > > version."
    > >
    > > In my intersectWith(), how do I call explode() to get back
    > > AcDb3dPolyline(AcDb::k3dSimplePoly), and how do I then "turn around and
    > call
    > > intersectWith()....."?
    > >
    > > Thanks,
    > > MS
    > >
    > >
    > > Acad::ErrorStatus mjsduct::explode(AcDbVoidPtrArray& entitySet) const
    > > {
    > > assertReadEnabled();
    > >
    > > AcGePoint3dArray PtArray;
    > > AcGePoint3d sp;
    > > AcGePoint3d ep;
    > > AcGePoint3d p1, p2, p3, p4;
    > > AcGeVector3d vec, axis;
    > > double wd;
    > > AcGePoint3d PlinePts[5];
    > >
    > > sp=getDuctStartPoint();
    > > ep=getDuctEndPoint();
    > > wd=getDuctWidth();
    > >
    > > vec.set(ep[0]-sp[0],ep[1]-sp[1],ep[2]-sp[2]);
    > > axis=vec.perpVector();
    > > axis.set(0.0,0.0,1.0);
    > >
    > > vec=vec.rotateBy(-pi/2.0,axis);
    > > vec=vec.normalize();
    > > p1=sp+vec*wd/2;
    > > p2=ep+vec*wd/2;
    > >
    > > vec.rotateBy(pi,axis);
    > > p3=ep+vec*wd/2;
    > > p4=sp+vec*wd/2;
    > >
    > > PtArray.append(p1);
    > > PtArray.append(p2);
    > > PtArray.append(p3);
    > > PtArray.append(p4);
    > >
    > > AcDb3dPolyline *pPoly=new
    > > AcDb3dPolyline(AcDb::k3dSimplePoly,PtArray,Adesk::kTrue);
    > > entitySet.append(pPoly);
    > > return Acad::eOk;
    > > }
    回复 支持 反对

    使用道具 举报

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

    本版积分规则

    关闭

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

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

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

    GMT+8, 2021-3-8 02:34 , Processed in 0.296418 second(s), 22 queries .

    Powered by 中国膜结构网->膜材采购->膜结构设计->膜结构安装->膜结构维修

    © 2014-2020 膜结构协会->进口膜材->国产膜材->PVDF膜材->PTFE膜材->ETFE膜材.

    快速回复 返回顶部 返回列表