測試結果:
主要思路:拾取乙個點作為矩形的插入點,分別以該點進行兩次jig操作,就能得到白色的兩個相交的polyline,之後需要變成紅色的封閉多段線。做法就是:求出兩個白色矩形的面域,然後通過bool操作的並集,使得兩個面域合併成乙個面域。最後就把這個面域在轉換成polyline就完成了。其中要注意, 要想在使用嚮導建立的工程裡使用面域的類,需要在標頭檔案:stdafx.h 中寫上這句巨集命令#define _brep_support_,就不需要引用庫檔案了。下面給出詳細**:
拖動矩形的jig操作:
drawrecjig::drawrecjig()view codedrawrecjig::~drawrecjig()
acedjig::dragstatus drawrecjig::sampler()
else
if (status ==dragstatus::knormal)
return
status;
}bool
drawrecjig::update()
acdbentity * drawrecjig::entity() const
bool drawrecjig::doit(acgepoint3d & ptcenter, acdbobjectid &plid)
pl->setclosed(true
); setdispprompt(l
"請拖動滑鼠:");
if (drag()==knormal)
else
}
命令類:
static面域轉acgepoint3d:void
ecdmygroupeunion()
if(recjig.doit(aspnt3d(pt), oid2))
acdbvoidptrarray curvesegments;
acdbvoidptrarray regions;
if (acdbregion::createfromcurves(curvesegments, regions) ==acad::eok)
region->close();
acdbpolyline *pltemp1 = new
acdbpolyline();
for (int i = 0; i )
pltemp1->setclosed(adesk::ktrue);
pltemp1->setcolorindex(1
); cdwgdatabaseutil::posttomodelspace(pltemp1);
pltemp1->close();
}pl1->close();
pl2->close();}}
void cregionutil::getregionpoints(acdbregion* pregion,acgepoint3darray &points)view code} //else its an isolated loop
} }
delete
pbrep;
}
求三個矩形的相交矩形。
給定乙個矩形結構體 struct rect 要求實現函式 rect intersectrect const rect recta,const rect recta,const rect recta 若三個矩形有相交矩形,則返回相交矩形,若沒有,則設定返回矩形的x y w h均為 1。分析 1.首先要...
求兩個矩形是否相交
getregion double x1,double y1,double x2,double y2,double dir,double allowshift 3 math.pi 180 else if math.abs dir math.pi 2 allowshift else if math.ab...
線段 矩形 矩形與矩形 相交
csharp view plain copy print?功能 判斷線段和矩形是否相交 先判斷線段的倆個端點是否在矩形的內部,在就必然相交 其次判斷線段的包圍盒是否和矩形相交,不相交的話線段和矩形肯定也不相交 最後判斷,矩形的四個頂點是否位於線段的兩側,是則必然相交,否則就不相交 csharp vi...