- UID
- 674793
- 积分
- 1875
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2013-4-1
- 最后登录
- 1970-1-1
|
发表于 2014-6-9 16:54:01
|
显示全部楼层
本帖最后由 牢固 于 2014-6-9 16:57 编辑
AcGeInterval类难道是AutoCAD公司和我们开了一个玩笑?
- static void XLRXAPI_IntVal(void)
- {
- Acad::ErrorStatus es;
- ads_name e1,e2;
- ads_point p1,p2;
- AcDbEntity *pEnt1,*pEnt2;
- AcDbObjectId Id1,Id2;
- AcDbCurve *pDbCurve1,*pDbCurve2;
- AcGeCurve2d *pGeCurve1,*pGeCurve2;
- AcGeInterval GeIntVal1,GeIntVal2,GeIntVal3;
- double lower1,upper1,lower2,upper2,lower3,upper3;
- int rc = acedEntSel(_T("\n第一条曲线:"),e1,p1);
- if (rc != RTNORM)
- {
- return;
- }
- acdbGetObjectId(Id1,e1);
- es = acdbOpenObject(pEnt1,Id1,AcDb::kForRead);
- if (es != Acad::eOk)
- {
- return;
- }
- if (!pEnt1->isKindOf(AcDbCurve::desc()))
- {
- pEnt1->close();
- return;
- }
- pDbCurve1 = AcDbCurve::cast(pEnt1);
- rc = acedEntSel(_T("\n第二条曲线:"),e2,p2);
- if (rc != RTNORM)
- {
- return;
- }
- acdbGetObjectId(Id2,e2);
- es = acdbOpenObject(pEnt2,Id2,AcDb::kForRead);
- if (es != Acad::eOk)
- {
- pEnt1->close();
- return;
- }
- if (!pEnt2->isKindOf(AcDbCurve::desc()))
- {
- pEnt1->close();
- pEnt2->close();
- return;
- }
- pDbCurve2 = AcDbCurve::cast(pEnt2);
- es = CCurve::AcDbCurveToAcGeCurve(pGeCurve1,pDbCurve1);
- if (es != Acad::eOk)
- {
- pEnt1->close();
- pEnt2->close();
- return;
- }
- CCurve::AcDbCurveToAcGeCurve(pGeCurve2,pDbCurve2);
- if (es != Acad::eOk)
- {
- delete pGeCurve1;
- pEnt1->close();
- pEnt2->close();
- return;
- }
- AcDbCurve *pC1,*pC2;
- if (Acad::eOk == CCurve::AcGeCurveToAcDbCurve(pC1,pGeCurve1))
- {
- pC1->setColorIndex(1);
- CCreateEnt::PostToSpace(pC1);
- }
- if (Acad::eOk == CCurve::AcGeCurveToAcDbCurve(pC2,pGeCurve2)){
- pC2->setColorIndex(2);
- CCreateEnt::PostToSpace(pC2);
- }
- pGeCurve1->getInterval(GeIntVal1);
- GeIntVal1.getBounds(lower1,upper1);
- pGeCurve2->getInterval(GeIntVal2);
- GeIntVal2.getBounds(lower2,upper2);
- acutPrintf(_T("\n曲线1:lower = %0.3f, upper = %0.3f length = %0.3f 曲线2:lower = %0.3f, upper = %0.3f length = %0.3f "),
- lower1,upper1,GeIntVal1.length(),lower2,upper2,GeIntVal2.length());
- if (GeIntVal1.isDisjoint(GeIntVal2))
- {
- acutPrintf(_T("\n两曲线不相交!"));
- pEnt1->close();
- pEnt2->close();
- delete pGeCurve1;
- delete pGeCurve2;
- return;
- }
- if (GeIntVal1.intersectWith(GeIntVal2,GeIntVal3))
- {
- GeIntVal3.getBounds(lower3,upper3);
- acutPrintf(_T("\n相交后曲线:lower = %0.3f, upper = %0.3f length = %0.3f "),GeIntVal3.lowerBound(),GeIntVal3.upperBound(),GeIntVal3.length());
- }
-
- pEnt1->close();
- pEnt2->close();
- delete pGeCurve1;
- delete pGeCurve2;
- return;
- }
命令: intval
第一条曲线:
第二条曲线:
曲线1:lower = 0.000, upper = 1321.959 length = 1321.959 曲线2:lower = 0.000, upper
= 1042.697 length = 1042.697
相交后曲线:lower = 0.000, upper = 1042.697 length = 1042.697
命令:
没有效果!
|
|