|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832 |
- // ************************************************************************** //
- // Copyright(c)2010 Naiky Company. All rights reserved.
- //
- // Abstract:
- // Cadʵ
- // ********************************************* ---- 2010-09-08 ***** //
- #include "stdafx.h"
- #include "Intersect.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- using namespace ncmath;
-
- // ܽӿڶ --- 2010 09 10
- int nce::GetIntersection(IN const CCadObject* pCadObject1_,
- IN const CCadObject* pCadObject2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadObject1_);
- ASSERT(pCadObject2_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // תβΣ֤_pCadObject1Typeֵ_pCadObject2
- // Typeֵ ---- 2010-09-14
- const CCadObject* _pCadObject1 = pCadObject1_;
- const CCadObject* _pCadObject2 = pCadObject2_;
- if ((UINT)_pCadObject1->GetType() > (UINT)_pCadObject2->GetType())
- {
- _pCadObject1 = pCadObject2_;
- _pCadObject2 = pCadObject1_;
- }
-
- // 32λʾ_pCadObject1_pCadObject2(Ϸʽ)ǰߵ
- // ΪType1ߵΪType2Ϊ (Type1 << 16 | Type2)
- // ʾʽжTypeֵ0xFFFF ---- 2010-09-14
- UINT _nType1 = _pCadObject1->GetType();
- UINT _nType2 = _pCadObject2->GetType();
- ASSERT(_nType1 < 0xFFFF && _nType2 < 0xFFFF);
-
- // ͷ⣬switch-caseʵһά_nType1_nType2Ϊ
- // ñֵѯӦĴ·()
- // ABĽӦͬBAĽˣΪСѯ
- // ṩ˴ֻѯϽǿ(_nType1<=_nType2)½ǿ
- // ϽӦλ(ǰĴ) ---- 2010-09-14
- int _nResult = 0;
- ASSERT(_nType1 <= _nType2);
- switch(_nType1 << 16 | _nType2)
- {
- // ߶κ߶ --- 2010 09 19
- case (cadline << 16 | cadline):
- {
- C_ASSERT(cadline <= cadline);
-
- const CCadLine* _pCadLine1 = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadLine* _pCadLine2 = dynamic_cast<const CCadLine*>(_pCadObject2);
- _nResult = Intersect_CadLineWithCadLine(_pCadLine1, _pCadLine2, pvectorIntersect_);
- }
- break;
-
- // ߶κֱ --- 2010 09 19
- case (cadline << 16 | cadbeeline):
- {
- C_ASSERT(cadline <= cadbeeline);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject2);
- _nResult = Intersect_CadLineWithCadBeeline(_pCadLine, _pCadBeeline, pvectorIntersect_);
- }
- break;
-
- // ߶κԲ --- 2010 09 19
- case (cadline << 16 | cadcircle):
- {
- C_ASSERT(cadline <= cadcircle);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*>(_pCadObject2);
- _nResult = Intersect_CadLineWithCadCircle(_pCadLine, _pCadCircle, pvectorIntersect_);
- }
- break;
-
- // ߶κԲ --- 2010 09 19
- case (cadline << 16 | cadarc):
- {
- C_ASSERT(cadline <= cadarc);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadArc * _pCadArc = dynamic_cast<const CCadArc *>(_pCadObject2);
- _nResult = Intersect_CadLineWithCadArc(_pCadLine, _pCadArc, pvectorIntersect_);
- }
- break;
-
- // ߶κԲ --- 2010 09 19
- case (cadline << 16 | cadellipse):
- {
- C_ASSERT(cadline <= cadellipse);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
- _nResult = Intersect_CadLineWithCadEllipse(_pCadLine, _pCadEllipse, pvectorIntersect_);
- }
- break;
-
- // ߶κԲ --- 2010 09 19
- case (cadline << 16 | cadellipsearc):
- {
- C_ASSERT(cadline <= cadellipsearc);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadLineWithCadEllipseArc(_pCadLine, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ߶κͶ --- 2010 09 19
- case (cadline << 16 | cadmultisegments):
- case (cadline << 16 | cadrectangle):
- case (cadline << 16 | cadstar):
- case (cadline << 16 | cadpolygon):
- case (cadline << 16 | cadpolyline):
- {
- C_ASSERT(cadline <= cadmultisegments &&
- cadline <= cadrectangle &&
- cadline <= cadstar &&
- cadline <= cadpolygon &&
- cadline <= cadpolyline);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadLineWithCadMultiSegments(_pCadLine, _pCadMultiSegments, pvectorIntersect_);
- }
- break;
-
- // ߶κȺ --- 2010 10 21
- case (cadline << 16 | cadgroup):
- {
- C_ASSERT(cadline <= cadgroup);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadLine, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // ߶κ --- 2010 10 21
- case (cadline << 16 | cadtext):
- {
- C_ASSERT(cadline <= cadtext);
-
- const CCadLine* _pCadLine = dynamic_cast<const CCadLine*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadLine, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ֱߺֱ --- 2010 09 19
- case (cadbeeline << 16 | cadbeeline):
- {
- C_ASSERT(cadbeeline <= cadbeeline);
-
- const CCadBeeline* _pCadBeeline1 = dynamic_cast<const CCadBeeline*> (_pCadObject1);
- const CCadBeeline* _pCadBeeline2 = dynamic_cast<const CCadBeeline*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadBeeline(_pCadBeeline1, _pCadBeeline2, pvectorIntersect_);
- }
- break;
-
- // ֱߺԲ --- 2010 09 19
- case (cadbeeline << 16 | cadcircle):
- {
- C_ASSERT(cadbeeline <= cadcircle);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadCircle(_pCadBeeline, _pCadCircle, pvectorIntersect_);
- }
- break;
-
- // ֱߺԲ --- 2010 09 19
- case (cadbeeline << 16 | cadarc):
- {
- C_ASSERT(cadbeeline <= cadarc);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadArc(_pCadBeeline, _pCadArc, pvectorIntersect_);
- }
- break;
-
- // ֱߺԲ --- 2010 09 19
- case (cadbeeline << 16 | cadellipse):
- {
- C_ASSERT(cadbeeline <= cadellipse);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadEllipse(_pCadBeeline, _pCadEllipse, pvectorIntersect_);
- }
- break;
-
- // ֱߺԲ --- 2010 09 19
- case (cadbeeline << 16 | cadellipsearc):
- {
- C_ASSERT(cadbeeline <= cadellipsearc);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadEllipseArc(_pCadBeeline, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ֱߺͶ --- 2010 09 19
- case (cadbeeline << 16 | cadmultisegments):
- case (cadbeeline << 16 | cadrectangle):
- case (cadbeeline << 16 | cadstar):
- case (cadbeeline << 16 | cadpolygon):
- case (cadbeeline << 16 | cadpolyline):
- {
- C_ASSERT(cadbeeline <= cadmultisegments &&
- cadbeeline <= cadrectangle &&
- cadbeeline <= cadstar &&
- cadbeeline <= cadpolygon &&
- cadbeeline <= cadpolyline);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadBeelineWithCadMultiSegments(_pCadBeeline, _pCadMultiSegments, pvectorIntersect_);
- }
- break;
-
- // ֱߺȺ --- 2010 10 21
- case (cadbeeline << 16 | cadgroup):
- {
- C_ASSERT(cadbeeline <= cadgroup);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadBeeline, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // ֱߺ --- 2010 10 21
- case (cadbeeline << 16 | cadtext):
- {
- C_ASSERT(cadbeeline <= cadtext);
-
- const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadBeeline, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadcircle << 16 | cadcircle):
- {
- C_ASSERT(cadcircle <= cadcircle);
-
- const CCadCircle* _pCadCircle1 = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadCircle* _pCadCircle2 = dynamic_cast<const CCadCircle*> (_pCadObject2);
- _nResult = Intersect_CadCircleWithCadCircle(_pCadCircle1, _pCadCircle2, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadcircle << 16 | cadarc):
- {
- C_ASSERT(cadcircle <= cadarc);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject2);
- _nResult = Intersect_CadArcWithCadCircle(_pCadArc, _pCadCircle, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadcircle << 16 | cadellipse):
- {
- C_ASSERT(cadcircle <= cadellipse);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
- _nResult = Intersect_CadCircleWithCadEllipse(_pCadCircle, _pCadEllipse, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadcircle << 16 | cadellipsearc):
- {
- C_ASSERT(cadcircle <= cadellipsearc);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadCircleWithCadEllipseArc(_pCadCircle, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ԲͶ --- 2010 09 19
- case (cadcircle << 16 | cadmultisegments):
- case (cadcircle << 16 | cadrectangle):
- case (cadcircle << 16 | cadstar):
- case (cadcircle << 16 | cadpolygon):
- case (cadcircle << 16 | cadpolyline):
- {
- C_ASSERT(cadcircle <= cadmultisegments &&
- cadcircle <= cadrectangle &&
- cadcircle <= cadstar &&
- cadcircle <= cadpolygon &&
- cadcircle <= cadpolyline);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadCircleWithCadMultiSegments(_pCadCircle, _pCadMultiSegments, pvectorIntersect_);
- }
- break;
-
- // ԲȺ --- 2010 10 21
- case (cadcircle << 16 | cadgroup):
- {
- C_ASSERT(cadcircle <= cadgroup);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadCircle, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // Բ --- 2010 10 21
- case (cadcircle<< 16 | cadtext):
- {
- C_ASSERT(cadcircle <= cadtext);
-
- const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadCircle, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadarc << 16 | cadarc):
- {
- C_ASSERT(cadarc <= cadarc);
-
- const CCadArc* _pCadArc1 = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadArc* _pCadArc2 = dynamic_cast<const CCadArc*> (_pCadObject2);
- _nResult = Intersect_CadArcWithCadArc(_pCadArc1, _pCadArc2, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadarc << 16 | cadellipse):
- {
- C_ASSERT(cadarc <= cadellipse);
-
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
- _nResult = Intersect_CadArcWithCadEllipse(_pCadArc, _pCadEllipse, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadarc << 16 | cadellipsearc):
- {
- C_ASSERT(cadarc <= cadellipsearc);
-
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadArcWithCadEllipseArc(_pCadArc, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ԲͶ --- 2010 09 19
- case (cadarc << 16 | cadmultisegments):
- case (cadarc << 16 | cadrectangle):
- case (cadarc << 16 | cadstar):
- case (cadarc << 16 | cadpolygon):
- case (cadarc << 16 | cadpolyline):
- {
- C_ASSERT(cadarc <= cadmultisegments &&
- cadarc <= cadrectangle &&
- cadarc <= cadstar &&
- cadarc <= cadpolygon &&
- cadarc <= cadpolyline);
-
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadArcWithCadMultiSegments(_pCadArc, _pCadMultiSegments, pvectorIntersect_);
- }
- break;
-
- // ԲȺ --- 2010 10 21
- case (cadarc << 16 | cadgroup):
- {
- C_ASSERT(cadarc <= cadgroup);
-
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadArc, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // Բ --- 2010 10 21
- case (cadarc<< 16 | cadtext):
- {
- C_ASSERT(cadarc <= cadtext);
-
- const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadArc, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadellipse << 16 | cadellipse):
- {
- C_ASSERT(cadellipse <= cadellipse);
-
- const CCadEllipse* _pCadEllipse1 = dynamic_cast<const CCadEllipse*> (_pCadObject1);
- const CCadEllipse* _pCadEllipse2 = dynamic_cast<const CCadEllipse*> (_pCadObject2);
- _nResult = Intersect_CadEllipseWithCadEllipse(_pCadEllipse1, _pCadEllipse2, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadellipse << 16 | cadellipsearc):
- {
- C_ASSERT(cadellipse <= cadellipsearc);
-
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadEllipseWithCadEllipseArc(_pCadEllipse, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ԲͶ --- 2010 09 19
- case (cadellipse << 16 | cadmultisegments):
- case (cadellipse << 16 | cadrectangle):
- case (cadellipse << 16 | cadstar):
- case (cadellipse << 16 | cadpolygon):
- case (cadellipse << 16 | cadpolyline):
- {
- C_ASSERT(cadellipse <= cadmultisegments &&
- cadellipse <= cadrectangle &&
- cadellipse <= cadstar &&
- cadellipse <= cadpolygon &&
- cadellipse <= cadpolyline);
-
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadMultiSegmentsWithCadEllipse(_pCadMultiSegments, _pCadEllipse, pvectorIntersect_);
- }
- break;
-
- // ԲȺ --- 2010 10 21
- case (cadellipse << 16 | cadgroup):
- {
- C_ASSERT(cadellipse <= cadgroup);
-
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadEllipse, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // Բ --- 2010 10 21
- case (cadellipse<< 16 | cadtext):
- {
- C_ASSERT(cadellipse <= cadtext);
-
- const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadEllipse, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ԲԲ --- 2010 09 19
- case (cadellipsearc << 16 | cadellipsearc):
- {
- C_ASSERT(cadellipsearc <= cadellipsearc);
-
- const CCadEllipseArc* _pCadEllipseArc1 = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
- const CCadEllipseArc* _pCadEllipseArc2 = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
- _nResult = Intersect_CadEllipseArcWithCadEllipseArc(_pCadEllipseArc1, _pCadEllipseArc2, pvectorIntersect_);
- }
- break;
-
- // ԲͶ --- 2010 09 19
- case (cadellipsearc << 16 | cadmultisegments):
- case (cadellipsearc << 16 | cadrectangle):
- case (cadellipsearc << 16 | cadstar):
- case (cadellipsearc << 16 | cadpolygon):
- case (cadellipsearc << 16 | cadpolyline):
- {
- C_ASSERT(cadellipsearc <= cadmultisegments &&
- cadellipsearc <= cadrectangle &&
- cadellipsearc <= cadstar &&
- cadellipsearc <= cadpolygon &&
- cadellipsearc <= cadpolyline);
-
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadMultiSegmentsWithCadEllipseArc(_pCadMultiSegments, _pCadEllipseArc, pvectorIntersect_);
- }
- break;
-
- // ԲȺ --- 2010 10 21
- case (cadellipsearc << 16 | cadgroup):
- {
- C_ASSERT(cadellipsearc <= cadgroup);
-
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadEllipseArc, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // Բ --- 2010 10 21
- case (cadellipsearc<< 16 | cadtext):
- {
- C_ASSERT(cadellipsearc <= cadtext);
-
- const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadEllipseArc, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ߺͶ --- 2010 09 19
- case (cadmultisegments << 16 | cadmultisegments):
- case (cadmultisegments << 16 | cadrectangle):
- case (cadmultisegments << 16 | cadpolygon):
- case (cadmultisegments << 16 | cadstar):
- case (cadmultisegments << 16 | cadpolyline):
- case (cadrectangle << 16 | cadrectangle):
- case (cadrectangle << 16 | cadpolygon):
- case (cadrectangle << 16 | cadstar):
- case (cadrectangle << 16 | cadpolyline):
- case (cadpolygon << 16 | cadpolygon):
- case (cadpolygon << 16 | cadstar):
- case (cadpolygon << 16 | cadpolyline):
- case (cadstar << 16 | cadstar):
- case (cadstar << 16 | cadpolyline):
- case (cadpolyline << 16 | cadpolyline):
- {
- C_ASSERT(cadmultisegments <= cadrectangle &&
- cadrectangle <= cadpolygon &&
- cadpolygon <= cadstar &&
- cadstar <= cadpolyline);
-
- const CCadMultiSegments* _pCadMultiSegments1 = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
- const CCadMultiSegments* _pCadMultiSegments2 = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
- _nResult = Intersect_CadMultiSegmentsWithCadMultiSegments(_pCadMultiSegments1, _pCadMultiSegments2, pvectorIntersect_);
- }
- break;
-
- // ߺȺ --- 2010 10 21
- case (cadmultisegments << 16 | cadgroup):
- case (cadrectangle << 16 | cadgroup):
- case (cadpolygon << 16 | cadgroup):
- case (cadstar << 16 | cadgroup):
- case (cadpolyline << 16 | cadgroup):
- {
- C_ASSERT(cadmultisegments <= cadgroup &&
- cadrectangle <= cadgroup &&
- cadpolygon <= cadgroup &&
- cadstar <= cadgroup &&
- cadpolyline <= cadgroup);
-
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadGroup(_pCadMultiSegments, _pCadGroup, pvectorIntersect_);
- }
- break;
-
- // ߺ --- 2010 10 21
- case (cadmultisegments << 16 | cadtext):
- case (cadrectangle << 16 | cadtext):
- case (cadpolygon << 16 | cadtext):
- case (cadstar << 16 | cadtext):
- case (cadpolyline << 16 | cadtext):
- {
- C_ASSERT(cadmultisegments <= cadtext &&
- cadrectangle <= cadtext &&
- cadpolygon <= cadtext &&
- cadstar <= cadtext &&
- cadpolyline <= cadtext);
-
- const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadObjectWithCadText(_pCadMultiSegments, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ԲȺ --- 2010 10 21
- case (cadgroup << 16 | cadgroup):
- {
- C_ASSERT(cadgroup <= cadgroup);
-
- const CCadGroup* _pCadGroup1 = dynamic_cast<const CCadGroup*> (_pCadObject1);
- const CCadGroup* _pCadGroup2 = dynamic_cast<const CCadGroup*> (_pCadObject2);
- _nResult = Intersect_CadGroupWithCadGroup(_pCadGroup1, _pCadGroup2, pvectorIntersect_);
- }
- break;
-
- // Ⱥ --- 2010 10 21
- case (cadgroup<< 16 | cadtext):
- {
- C_ASSERT(cadgroup <= cadtext);
-
- const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject1);
- const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadGroupWithCadText(_pCadGroup, _pCadText, pvectorIntersect_);
- }
- break;
-
- // ֺ --- 2010 10 21
- case (cadtext<< 16 | cadtext):
- {
- C_ASSERT(cadgroup <= cadtext);
-
- const CCadText* _pCadText1 = dynamic_cast<const CCadText*> (_pCadObject1);
- const CCadText* _pCadText2 = dynamic_cast<const CCadText*> (_pCadObject2);
- _nResult = Intersect_CadTextWithCadText(_pCadText1, _pCadText2, pvectorIntersect_);
- }
- break;
-
- default:
- break;
- }
-
- return _nResult;
- }
-
- int nce::Intersect_CadArcWithCadArc(IN const CCadArc* pCadArc1_,
- IN const CCadArc* pCadArc2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc1_);
- ASSERT(pCadArc2_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc1_->GetLength()));
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc2_->GetLength()));
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptArc1Center = pCadArc1_->GetCenterPoint();
- DPOINT2 _ptArc2Center = pCadArc2_->GetCenterPoint();
-
- double _nArc1Radius = pCadArc1_->GetRadius();
- double _nArc2Radius = pCadArc2_->GetRadius();
-
- double _nArc1StartAngle = pCadArc1_->GetStartAngle();
- double _nArc2StartAngle = pCadArc2_->GetStartAngle();
-
- double _nFactor1 = pCadArc1_->IsNormalDir() ? 1 : -1;
- double _nFactor2 = pCadArc2_->IsNormalDir() ? 1 : -1;
-
- double _nArc1CentralAngle = pCadArc1_->GetCentralAngle() * _nFactor1;
- double _nArc2CentralAngle = pCadArc2_->GetCentralAngle() * _nFactor2;
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_ArcWithArc(_ptArc1Center, _nArc1Radius, _nArc1StartAngle, _nArc1CentralAngle,
- _ptArc2Center, _nArc2Radius, _nArc2StartAngle, _nArc2CentralAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadArcWithCadCircle(IN const CCadArc* pCadArc_,
- IN const CCadCircle* pCadCircle_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc_);
- ASSERT(pCadCircle_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
- ASSERT(DOUBLE_GREAT_ZERO(pCadCircle_->GetLength()));
-
- // Բ --- 2010 09 09
- DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
- DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
-
- // 뾶 --- 2010 09 09
- double _nArcRadius = pCadArc_->GetRadius();
- double _nCircleRadius = pCadCircle_->GetRadius();
-
- // ԲʼǺĽ --- 2010 09 09
- double _nArcStartAngle = pCadArc_->GetStartAngle();
- double _nArcCentralAngle = pCadArc_->GetCentralAngle();
-
- // ĽǸ跽 --- 2010 09 09
- double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
- _nArcCentralAngle *= _nFactor;
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_CircleWithArc(_ptCircleCenter, _nCircleRadius, _ptArcCenter,
- _nArcRadius, _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadArcWithCadEllipse(IN const CCadArc* pCadArc_,
- IN const CCadEllipse* pCadEllipse_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc_);
- ASSERT(pCadEllipse_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
- double _nRadius = pCadArc_->GetRadius();
- double _nArcStartAngle = pCadArc_->GetStartAngle();
- double _nArcSweptAngle = pCadArc_->GetCentralAngle();
- if (!pCadArc_->IsNormalDir())
- _nArcSweptAngle *= -1;
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptEllipseCenter = pCadEllipse_->GetCenterPoint();
- double _nLongRadius = pCadEllipse_->GetLongRadius();
- double _nShortRadius = pCadEllipse_->GetShortRadius();
- double _nAngle = pCadEllipse_->GetAngle();
-
- int _nRet = 0;
- if (!pvectorIntersect_)
- {
- _nRet = Intersect_ArcWithEllipse(_ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
- _ptEllipseCenter, _nLongRadius, _nShortRadius, _nAngle);
- }
- else
- {
- _nRet = Intersect_ArcWithEllipse(_ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
- _ptEllipseCenter, _nLongRadius, _nShortRadius, _nAngle, *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadArcWithCadEllipseArc(IN const CCadArc* pCadArc_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc_);
- ASSERT(pCadEllipseArc_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
- double _nRadius = pCadArc_->GetRadius();
- double _nArcStartAngle = pCadArc_->GetStartAngle();
- double _nArcSweptAngle = pCadArc_->GetCentralAngle();
- if (!pCadArc_->IsNormalDir())
- _nArcSweptAngle *= -1;
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptEllipseArcCenter = pCadEllipseArc_->GetCenterPoint();
- double _nLongRadius = pCadEllipseArc_->GetLongRadius();
- double _nShortRadius = pCadEllipseArc_->GetShortRadius();
- double _nAngle = pCadEllipseArc_->GetAngle();
- double _nEllipseArcStartAngle = pCadEllipseArc_->GetStartAngle();
- double _nEllipseArcSweptAngle = pCadEllipseArc_->GetCentralAngle();
- if (!pCadEllipseArc_->IsNormalDir())
- _nEllipseArcSweptAngle *= -1;
-
- int _nRet = 0;
- if (!pvectorIntersect_)
- {
- _nRet = Intersect_ArcWithEllipseArc(
- _ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
- _ptEllipseArcCenter, _nLongRadius, _nShortRadius, _nAngle,
- _nEllipseArcStartAngle, _nEllipseArcSweptAngle);
- }
- else
- {
- _nRet = Intersect_ArcWithEllipseArc(
- _ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
- _ptEllipseArcCenter, _nLongRadius, _nShortRadius, _nAngle,
- _nEllipseArcStartAngle, _nEllipseArcSweptAngle, *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadArcWithCadMultiSegments(IN const CCadArc* pCadArc_,
- IN const CCadMultiSegments* pCadMultiSegments_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc_);
- ASSERT(pCadMultiSegments_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
- ASSERT(DOUBLE_GREAT_ZERO(pCadMultiSegments_->GetLength()));
-
- // Ϣȡ --- 2010 09 19
- DPOINT2 _ptArc1Center = pCadArc_->GetCenterPoint();
- double _nArc1Radius = pCadArc_->GetRadius();
- double _nArc1StartAngle = pCadArc_->GetStartAngle();
-
- double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
- double _nArc1CentralAngle = _nFactor * pCadArc_->GetCentralAngle();
-
- int _nResult = 0;
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- // Բͬ߸Ƭ --- 2010 09 19
- for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
- {
- SEGMENT _Segment = pCadMultiSegments_->GetSegment(_i);
- std::vector<DPOINT2> _vectorTemp;
-
- switch(_Segment.nType)
- {
- // Բ --- 2010 09 19
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArc2Center(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArc2Radius = 0.0;
- double _nArc2StartAngle = 0.0;
- double _nArc2CentralAngle = 0.0;
-
- SEGMENT::SolveArc(_Segment.ptStart, _Segment.ptEnd, _Segment.nBulge,
- &_ptArc2Center, &_nArc2Radius, &_nArc2StartAngle, &_nArc2CentralAngle);
-
- _nResult += ncmath::Intersect_ArcWithArc(_ptArc1Center, _nArc1Radius, _nArc1StartAngle,
- _nArc1CentralAngle, _ptArc2Center, _nArc2Radius,
- _nArc2StartAngle, _nArc2CentralAngle, _vectorTemp,
- _nNeed);
- }
- break;
-
- // ߶ --- 2010 09 19
- case SEGMENT::LINE:
- {
- _nResult += ncmath::Intersect_LineWithArc(_Segment.ptStart, _Segment.ptEnd, _ptArc1Center,
- _nArc1Radius, _nArc1StartAngle, _nArc1CentralAngle, _vectorTemp, _nNeed);
- }
- break;
-
- // ֵ֧ĸʽ --- 2010 09 19
- case SEGMENT::BEZIER:
- default:
- ASSERT(false);
- }
-
- if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
- copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
- }
- return _nResult;
- }
-
- int nce::Intersect_CadBeelineWithCadArc(IN const CCadBeeline* pCadBeeline_,
- IN const CCadArc* pCadArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadArc_);
- ASSERT(pCadBeeline_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
-
- //ֱߺԲϢȡ --- 2010 09 19
- DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
- double _nAngle = pCadBeeline_->GetAngle();
-
- DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
- double _nArcRadius = pCadArc_->GetRadius();
- double _nArcStartAngle = pCadArc_->GetStartAngle();
-
- double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
- double _nArcCentralAngle = _nFactor * pCadArc_->GetCentralAngle();
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_BeelineWithArc(_ptBeeline, _nAngle, _ptArcCenter,_nArcRadius,
- _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadBeelineWithCadBeeline(IN const CCadBeeline* pCadBeeline1_,
- IN const CCadBeeline* pCadBeeline2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadBeeline1_);
- ASSERT(pCadBeeline2_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
-
- // ֱϢȡ --- 2010 09 19
- DPOINT2 _ptBeeline1 = pCadBeeline1_->GetPoint();
- double _nAngle1 = pCadBeeline1_->GetAngle();
-
- DPOINT2 _ptBeeline2 = pCadBeeline2_->GetPoint();
- double _nAngle2 = pCadBeeline2_->GetAngle();
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_BeelineWithBeeline(_ptBeeline1, _nAngle1,
- _ptBeeline2, _nAngle2, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadBeelineWithCadCircle(IN const CCadBeeline* pCadBeeline_,
- IN const CCadCircle* pCadCircle_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadBeeline_);
- ASSERT(pCadCircle_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadCircle_->GetLength()));
-
- DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
- double _nAngle = pCadBeeline_->GetAngle();
-
- DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
- double _nCircleRadius = pCadCircle_->GetRadius();
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_BeelineWithCircle(_ptBeeline, _nAngle,_ptCircleCenter,
- _nCircleRadius, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadBeelineWithCadEllipse(IN const CCadBeeline* pCadBeeline_,
- IN const CCadEllipse* pCadEllipse_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadBeeline_);
- ASSERT(pCadEllipse_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
-
- // ֱߺԲϢȡ --- 2010 09 19
- DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
- double _nAngle = pCadBeeline_->GetAngle();
-
- DPOINT2 _ptCenter = pCadEllipse_->GetCenterPoint();
- double _nLRadius = pCadEllipse_->GetLongRadius();
- double _nSRadius = pCadEllipse_->GetShortRadius();
- double _nUAngle = pCadEllipse_->GetAngle();
-
- return ncmath::Intersect_BeelineWithEllipse(_ptBeeline, _nAngle, _ptCenter, _nLRadius,
- _nSRadius, _nUAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadBeelineWithCadEllipseArc(IN const CCadBeeline* pCadBeeline_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadBeeline_);
- ASSERT(pCadEllipseArc_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
-
- // ֱϢȡ --- 2010 09 19
- DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
- double _nAngle = pCadBeeline_->GetAngle();
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptCenter = pCadEllipseArc_->GetCenterPoint();
- double _nLRadius = pCadEllipseArc_->GetLongRadius();
- double _nSRadius = pCadEllipseArc_->GetShortRadius();
- double _nUAngle = pCadEllipseArc_->GetAngle();
- double _nStartAngle = pCadEllipseArc_->GetStartAngle();
- double _nFactor = pCadEllipseArc_->IsNormalDir() ? 1 : -1;
- double _nCentralAngle = pCadEllipseArc_->GetCentralAngle() * _nFactor;
-
- return ncmath::Intersect_BeelineWithEllipseArc(_ptBeeline, _nAngle, _ptCenter, _nLRadius, _nSRadius,
- _nUAngle,_nStartAngle, _nCentralAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadBeelineWithCadMultiSegments(IN const CCadBeeline* pCadBeeline_,
- IN const CCadMultiSegments* pCadMultiSegments_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadBeeline_);
- ASSERT(pCadMultiSegments_);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadMultiSegments_->GetLength()));
-
- DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
- double _nAngle = pCadBeeline_->GetAngle();
-
- int _nResult = 0;
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- for (int _i = 0; _i < pCadMultiSegments_->GetSegmentCount(); ++_i)
- {
- SEGMENT _Segment = pCadMultiSegments_->GetSegment(_i);
- std::vector<DPOINT2> _vectorTemp;
-
- switch(_Segment.nType)
- {
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0;
- double _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(_Segment.ptStart, _Segment.ptEnd, _Segment.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
-
- _nResult += ncmath::Intersect_BeelineWithArc(_ptBeeline, _nAngle, _ptArcCenter,
- _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vectorTemp, _nNeed);
- }
- break;
-
- case SEGMENT::LINE:
- {
- _nResult += ncmath::Intersect_BeelineWithLine(_ptBeeline, _nAngle, _Segment.ptStart,
- _Segment.ptEnd, _vectorTemp, _nNeed);
- }
- break;
- default:
- ASSERT(false);
- }
-
- // нҪ洢洢 --- 2010 09 19
- if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
- copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
- }
-
- return _nResult;
- }
-
- int nce::Intersect_CadCircleWithCadCircle(IN const CCadCircle* pCadCircle1_,
- IN const CCadCircle* pCadCircle2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadCircle1_ != NULL);
- ASSERT(pCadCircle1_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_CircleWithCircle(pCadCircle1_->GetCenterPoint(), pCadCircle1_->GetRadius(),
- pCadCircle2_->GetCenterPoint(), pCadCircle2_->GetRadius(), *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadCircleWithCadEllipse(IN const CCadCircle* pCadCircle_,
- IN const CCadEllipse* pCadEllipse_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadCircle_);
- ASSERT(pCadEllipse_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
- double _nRadius = pCadCircle_->GetRadius();
- DPOINT2 _ptEllipseCenter = pCadEllipse_->GetCenterPoint();
- double _nLongRadius = pCadEllipse_->GetLongRadius();
- double _nShortRadius = pCadEllipse_->GetShortRadius();
- double _nAngle = pCadEllipse_->GetAngle();
-
- int _nRet = 0;
- if (!pvectorIntersect_)
- {
- _nRet = Intersect_CircleWithEllipse(_ptCircleCenter, _nRadius, _ptEllipseCenter,
- _nLongRadius, _nShortRadius, _nAngle);
- }
- else
- {
- _nRet = Intersect_CircleWithEllipse(_ptCircleCenter, _nRadius, _ptEllipseCenter,
- _nLongRadius, _nShortRadius, _nAngle, *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadCircleWithCadEllipseArc(IN const CCadCircle* pCadCircle_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadCircle_);
- ASSERT(pCadEllipseArc_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
- double _nRadius = pCadCircle_->GetRadius();
- DPOINT2 _ptEllipseArcCenter = pCadEllipseArc_->GetCenterPoint();
- double _nLongRadius = pCadEllipseArc_->GetLongRadius();
- double _nShortRadius = pCadEllipseArc_->GetShortRadius();
- double _nAngle = pCadEllipseArc_->GetAngle();
- double _nStartAngle = pCadEllipseArc_->GetStartAngle();
- double _nSweptAngle = pCadEllipseArc_->GetCentralAngle();
-
- if (!pCadEllipseArc_->IsNormalDir())
- _nSweptAngle *= -1;
-
- int _nRet = 0;
- if (!pvectorIntersect_)
- {
- _nRet = Intersect_CircleWithEllipseArc(_ptCircleCenter, _nRadius, _ptEllipseArcCenter,
- _nLongRadius, _nShortRadius, _nAngle, _nStartAngle, _nSweptAngle);
- }
- else
- {
- _nRet = Intersect_CircleWithEllipseArc(_ptCircleCenter, _nRadius, _ptEllipseArcCenter,
- _nLongRadius, _nShortRadius, _nAngle,_nStartAngle, _nSweptAngle, *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadCircleWithCadMultiSegments(IN const CCadCircle* pCadCircle_,
- IN const CCadMultiSegments* pCadMultiSegments_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadCircle_ != NULL);
- ASSERT(pCadMultiSegments_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- int _nSegCount = pCadMultiSegments_->GetSegmentCount();
- for (int _i = 0; _i < _nSegCount; ++_i)
- {
- std::vector<DPOINT2> _vecTmp;
-
- SEGMENT _segTmp = pCadMultiSegments_->GetSegment(_i);
- switch (_segTmp.nType)
- {
- case SEGMENT::ARC:
- {
-
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(_segTmp.ptStart, _segTmp.ptEnd, _segTmp.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
-
- _nResult += ncmath::Intersect_CircleWithArc(pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(),
- _ptArcCenter, _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vecTmp);
- }
- break;
-
- case SEGMENT::LINE:
- _nResult += ncmath::Intersect_LineWithCircle(_segTmp.ptStart, _segTmp.ptEnd,
- pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(), _vecTmp);
- break;
-
- case SEGMENT::BEZIER:
- default:
- // ѡ׳쳣 --- wanghong 2010 09 12
- ASSERT(false);
- }
-
- if (pvectorIntersect_ != NULL && !_vecTmp.empty())
- std::copy(_vecTmp.begin(), _vecTmp.end(), std::back_inserter(*pvectorIntersect_));
- }
-
- return _nResult;
- }
-
- int nce::Intersect_CadEllipseWithCadEllipse(IN const CCadEllipse* pCadEllipse1_,
- IN const CCadEllipse* pCadEllipse2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadEllipse1_);
- ASSERT(pCadEllipse2_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // ȡβԲļβУĵ㡢ᡢ̰ᡢX
- // ǡ ---- 2010-09-14
- DPOINT2 _ptCenter1 = pCadEllipse1_->GetCenterPoint();
- double _nURadius1 = pCadEllipse1_->GetLongRadius();
- double _nVRadius1 = pCadEllipse1_->GetShortRadius();
- double _nUAngle1 = pCadEllipse1_->GetAngle();
- DPOINT2 _ptCenter2 = pCadEllipse2_->GetCenterPoint();
- double _nURadius2 = pCadEllipse2_->GetLongRadius();
- double _nVRadius2 = pCadEllipse2_->GetShortRadius();
- double _nUAngle2 = pCadEllipse2_->GetAngle();
-
- // ѧ㽻 ---- 2010-09-14
- int _nRet = 0;
- if (pvectorIntersect_ == NULL)
- {
- _nRet = ncmath::Intersect_EllipseWithEllipse(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2);
- }
- else
- {
- _nRet = ncmath::Intersect_EllipseWithEllipse(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2,
- *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadEllipseWithCadEllipseArc(IN const CCadEllipse* pCadEllipse_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadEllipse_);
- ASSERT(pCadEllipseArc_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // ȡβԲļβУĵ㡢ᡢ̰ᡢX
- // ǣԲļβУĵ㡢ᡢ̰ᡢX
- // ǡʼǡɨǡ ---- 2010-09-14
- DPOINT2 _ptCenter1 = pCadEllipse_->GetCenterPoint();
- double _nURadius1 = pCadEllipse_->GetLongRadius();
- double _nVRadius1 = pCadEllipse_->GetShortRadius();
- double _nUAngle1 = pCadEllipse_->GetAngle();
- DPOINT2 _ptCenter2 = pCadEllipseArc_->GetCenterPoint();
- double _nURadius2 = pCadEllipseArc_->GetLongRadius();
- double _nVRadius2 = pCadEllipseArc_->GetShortRadius();
- double _nUAngle2 = pCadEllipseArc_->GetAngle();
- double _nStartAngle2 = pCadEllipseArc_->GetStartAngle();
- double _nSweptAngle2 = pCadEllipseArc_->GetCentralAngle();
- if (!pCadEllipseArc_->IsNormalDir())
- {
- // ѧֻʱԲ ---- 2010-09-14
- _nStartAngle2 -= _nSweptAngle2;
-
- while (_nStartAngle2 < 0.0)
- {
- _nStartAngle2 += 2.0 * c_nPIE;
- }
-
- while (_nStartAngle2 >= 2.0 * c_nPIE)
- {
- _nStartAngle2 -= 2.0 * c_nPIE;
- }
- }
-
- // ѧ㽻 ---- 2010-09-14
- int _nRet = 0;
- if (pvectorIntersect_ == NULL)
- {
- _nRet = ncmath::Intersect_EllipseWithEllipseArc(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2);
- }
- else
- {
- _nRet = ncmath::Intersect_EllipseWithEllipseArc(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2,
- *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadEllipseArcWithCadEllipseArc(IN const CCadEllipseArc* pCadEllipseArc1_,
- IN const CCadEllipseArc* pCadEllipseArc2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadEllipseArc1_);
- ASSERT(pCadEllipseArc2_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // ȡβԲļβУĵ㡢ᡢ̰ᡢX
- // ǡʼǡɨǡ ---- 2010-09-14
- DPOINT2 _ptCenter1 = pCadEllipseArc1_->GetCenterPoint();
- double _nURadius1 = pCadEllipseArc1_->GetLongRadius();
- double _nVRadius1 = pCadEllipseArc1_->GetShortRadius();
- double _nUAngle1 = pCadEllipseArc1_->GetAngle();
- double _nStartAngle1 = pCadEllipseArc1_->GetStartAngle();
- double _nSweptAngle1 = pCadEllipseArc1_->GetCentralAngle();
- if (!pCadEllipseArc1_->IsNormalDir())
- {
- // ѧֻʱԲ ---- 2010-09-14
- _nStartAngle1 -= _nSweptAngle1;
-
- while (_nStartAngle1 < 0.0)
- {
- _nStartAngle1 += 2.0 * c_nPIE;
- }
-
- while (_nStartAngle1 >= 2.0 * c_nPIE)
- {
- _nStartAngle1 -= 2.0 * c_nPIE;
- }
- }
-
- // ͬ ---- 2010-09-14
- DPOINT2 _ptCenter2 = pCadEllipseArc2_->GetCenterPoint();
- double _nURadius2 = pCadEllipseArc2_->GetLongRadius();
- double _nVRadius2 = pCadEllipseArc2_->GetShortRadius();
- double _nUAngle2 = pCadEllipseArc2_->GetAngle();
- double _nStartAngle2 = pCadEllipseArc2_->GetStartAngle();
- double _nSweptAngle2 = pCadEllipseArc2_->GetCentralAngle();
- if (!pCadEllipseArc2_->IsNormalDir())
- {
- _nStartAngle2 -= _nSweptAngle2;
-
- while (_nStartAngle2 < 0.0)
- {
- _nStartAngle2 += 2.0 * c_nPIE;
- }
-
- while (_nStartAngle2 >= 2.0 * c_nPIE)
- {
- _nStartAngle2 -= 2.0 * c_nPIE;
- }
- }
-
- // ѧ㽻 ---- 2010-09-14
- int _nRet = 0;
- if (pvectorIntersect_ == NULL)
- {
- _nRet = ncmath::Intersect_EllipseArcWithEllipseArc(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1, _nStartAngle1, _nSweptAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2);
- }
- else
- {
- _nRet = ncmath::Intersect_EllipseArcWithEllipseArc(
- _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1, _nStartAngle1, _nSweptAngle1,
- _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2,
- *pvectorIntersect_);
- }
-
- return _nRet;
- }
-
- int nce::Intersect_CadLineWithCadArc(IN const CCadLine* pCadLine_,
- IN const CCadArc* pCadArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_);
- ASSERT(pCadArc_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadLine_->GetLength()));
- ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
-
- // ߶Ϣȡ --- 2010 09 19
- DPOINT2 _ptLineStart = pCadLine_->GetStartPoint();
- DPOINT2 _ptLineEnd = pCadLine_->GetEndPoint();
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
- double _nArcRadius = pCadArc_->GetRadius();
- double _nArcStartAngle = pCadArc_->GetStartAngle();
-
- double _nArcCentralAngle = pCadArc_->GetCentralAngle();
- double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
- _nArcCentralAngle *= _nFactor;
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_LineWithArc(_ptLineStart, _ptLineEnd, _ptArcCenter,_nArcRadius,
- _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadBeeline(IN const CCadLine* pCadLine_,
- IN const CCadBeeline* pCadBeeline_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_ != NULL);
- ASSERT(pCadBeeline_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_BeelineWithLine(pCadBeeline_->GetPoint(), pCadBeeline_->GetAngle(),
- pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(), *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadCircle(IN const CCadLine* pCadLine_,
- IN const CCadCircle* pCadCircle_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_ != NULL);
- ASSERT(pCadCircle_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_LineWithCircle(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
- pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(), *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadEllipse(IN const CCadLine* pCadLine_,
- IN const CCadEllipse* pCadEllipse_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_ && pCadEllipse_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
-
- // ߶Ϣȡ --- 2010 09 19
- DPOINT2 _ptStart = pCadLine_->GetStartPoint();
- DPOINT2 _ptEnd = pCadLine_->GetEndPoint();
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptCenter = pCadEllipse_->GetCenterPoint();
- double _nLRadius = pCadEllipse_->GetLongRadius();
- double _nSRadius = pCadEllipse_->GetShortRadius();
- double _nUAngle = pCadEllipse_->GetAngle();
-
- return ncmath::Intersect_LineWithEllipse(_ptStart, _ptEnd,
- _ptCenter, _nLRadius, _nSRadius, _nUAngle,
- *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadEllipseArc(IN const CCadLine* pCadLine_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_ && pCadEllipseArc_);
- ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
-
- // ߶Ϣȡ --- 2010 09 19
- DPOINT2 _ptStart = pCadLine_->GetStartPoint();
- DPOINT2 _ptEnd = pCadLine_->GetEndPoint();
-
- // ԲϢȡ --- 2010 09 19
- DPOINT2 _ptCenter = pCadEllipseArc_->GetCenterPoint();
- double _nLRadius = pCadEllipseArc_->GetLongRadius();
- double _nSRadius = pCadEllipseArc_->GetShortRadius();
- double _nUAngle = pCadEllipseArc_->GetAngle();
- double _nStartAngle = pCadEllipseArc_->GetStartAngle();
- double _nFactor = pCadEllipseArc_->IsNormalDir() ? 1 : -1;
- double _nCentralAngle = pCadEllipseArc_->GetCentralAngle() * _nFactor;
-
- return ncmath::Intersect_LineWithEllipseArc(_ptStart, _ptEnd,
- _ptCenter, _nLRadius, _nSRadius, _nUAngle, _nStartAngle, _nCentralAngle,
- *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadLine(IN const CCadLine* pCadLine1_,
- IN const CCadLine* pCadLine2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine1_);
- ASSERT(pCadLine2_);
- ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
- ASSERT(DOUBLE_GREAT_ZERO(pCadLine1_->GetLength()));
- ASSERT(DOUBLE_GREAT_ZERO(pCadLine2_->GetLength()));
-
- // ߶Ϣȡ --- 2010 09 19
- DPOINT2 _ptLine1Start = pCadLine1_->GetStartPoint();
- DPOINT2 _ptLine2Start = pCadLine2_->GetStartPoint();
- DPOINT2 _ptLine1End = pCadLine1_->GetEndPoint();
- DPOINT2 _ptLine2End = pCadLine2_->GetEndPoint();
-
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- return ncmath::Intersect_LineWithLine(_ptLine1Start, _ptLine1End,
- _ptLine2Start, _ptLine2End, *pvectorIntersect_, _nNeed);
- }
-
- int nce::Intersect_CadLineWithCadMultiSegments(IN const CCadLine* pCadLine_,
- IN const CCadMultiSegments* pCadMultiSegments_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadLine_ != NULL);
- ASSERT(pCadMultiSegments_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- // Ҫ 0Ҫ-1ܶ --- 2010 09 19
- int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
- int _nSegCount = pCadMultiSegments_->GetSegmentCount();
- for (int _i = 0; _i < _nSegCount; ++_i)
- {
- std::vector<DPOINT2> _vecTmp;
-
- SEGMENT _segTmp = pCadMultiSegments_->GetSegment(_i);
- switch (_segTmp.nType)
- {
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(_segTmp.ptStart, _segTmp.ptEnd, _segTmp.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
-
- _nResult += ncmath::Intersect_LineWithArc(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
- _ptArcCenter, _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vecTmp, _nNeed);
- }
- break;
-
- case SEGMENT::LINE:
- _nResult += ncmath::Intersect_LineWithLine(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
- _segTmp.ptStart, _segTmp.ptEnd, _vecTmp, _nNeed);
- break;
-
- case SEGMENT::BEZIER:
- default:
- // ѡ׳쳣 --- wanghong 2010 09 12
- ASSERT(false);
- }
-
- if (pvectorIntersect_ != NULL && !_vecTmp.empty())
- std::copy(_vecTmp.begin(), _vecTmp.end(), std::back_inserter(*pvectorIntersect_));
- }
-
- return _nResult;
- }
-
- int nce::Intersect_CadObjectWithCadGroup(IN const CCadObject* pCadObject_,
- IN const CCadGroup* pCadGroup_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadObject_ && pCadGroup_);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
- ASSERT(pCadObject_->GetType() != cadgroup);
-
- int _nResult = 0;
- for (int _i = 0; _i != pCadGroup_->GetNumOfChild(); ++_i)
- {
- const CCadObject* _pCadObjectTemp = pCadGroup_->GetAt(_i);
- int _nNum = 0;
-
- if (pvectorIntersect_ != NULL)
- {
- std::vector<DPOINT2> _vecTmp;
- if (_nNum = GetIntersection(pCadObject_, _pCadObjectTemp, &_vecTmp))
- {
- _nResult += _nNum;
- copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
- }
- }
- else
- {
- if (_nNum = GetIntersection(pCadObject_, _pCadObjectTemp, NULL))
- _nResult += _nNum;
- }
- }
-
- return _nResult;
- }
-
- int nce::Intersect_CadObjectWithCadText(IN const CCadObject* pCadObject_,
- IN const CCadText* pCadText_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadObject_ && pCadText_);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
- ASSERT(pCadObject_->GetType() != cadtext);
-
- const CCadGroup* _pCadGroup = pCadText_->GetTextGroup();
- return GetIntersection(pCadObject_, _pCadGroup, pvectorIntersect_);
- }
-
- // ȺȺ
- int nce::Intersect_CadGroupWithCadGroup(IN const CCadGroup* pCadGroup1_,
- IN const CCadGroup* pCadGroup2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadGroup1_ && pCadGroup1_->GetType() == cadgroup);
- ASSERT(pCadGroup2_ && pCadGroup2_->GetType() == cadgroup);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- for (int _i = 0; _i != pCadGroup1_->GetNumOfChild(); ++_i)
- {
- const CCadObject* _pCadObjectTemp = pCadGroup1_->GetAt(_i);
- int _nNum = 0;
-
- if (pvectorIntersect_ != NULL)
- {
- std::vector<DPOINT2> _vecTmp;
- if (_nNum = GetIntersection(_pCadObjectTemp, pCadGroup2_, &_vecTmp))
- {
- _nResult += _nNum;
- copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
- }
- }
- else
- {
- if (_nNum = GetIntersection(_pCadObjectTemp, pCadGroup2_, NULL))
- _nResult += _nNum;
- }
- }
-
- return _nResult;
- }
-
- // Ⱥ
- int nce::Intersect_CadGroupWithCadText(IN const CCadGroup* pCadGroup_,
- IN const CCadText* pCadText_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadGroup_ && pCadGroup_->GetType() == cadgroup);
- ASSERT(pCadText_ && pCadText_->GetType() == cadtext);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- for (int _i = 0; _i != pCadGroup_->GetNumOfChild(); ++_i)
- {
- const CCadObject* _pCadObjectTemp = pCadGroup_->GetAt(_i);
- int _nNum = 0;
-
- if (pvectorIntersect_ != NULL)
- {
- std::vector<DPOINT2> _vecTmp;
- if (_nNum = GetIntersection(_pCadObjectTemp, pCadText_, &_vecTmp))
- {
- _nResult += _nNum;
- copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
- }
- }
- else
- {
- if (_nNum = GetIntersection(_pCadObjectTemp, pCadText_, NULL))
- _nResult += _nNum;
- }
- }
-
- return _nResult;
- }
-
- // Ⱥ
- int nce::Intersect_CadTextWithCadText(IN const CCadText* pCadText1_,
- IN const CCadText* pCadText2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadText1_ && pCadText1_->GetType() == cadtext);
- ASSERT(pCadText2_ && pCadText2_->GetType() == cadtext);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- const CCadGroup* _pCadGroup1 = pCadText1_->GetTextGroup();
- const CCadGroup* _pCadGroup2 = pCadText2_->GetTextGroup();
-
- return Intersect_CadGroupWithCadGroup(_pCadGroup1, _pCadGroup2, pvectorIntersect_);
- }
-
- int nce::Intersect_CadMultiSegmentsWithCadEllipse(IN const CCadMultiSegments* pCadMultiSegments_,
- IN const CCadEllipse* pCadEllipse_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadMultiSegments_ != NULL);
- ASSERT(pCadEllipse_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- // еĸԲ --- 2010 09 19
- for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
- {
- SEGMENT _SegmentOut = pCadMultiSegments_->GetSegment(_i);
- std::vector<DPOINT2> _vectorTemp;
-
- switch(_SegmentOut.nType)
- {
- case SEGMENT::LINE:
- {
- CCadLine _CadLine(_SegmentOut.ptStart, _SegmentOut.ptEnd);
-
- if (pvectorIntersect_ != NULL)
- _nResult += Intersect_CadLineWithCadEllipse(&_CadLine, pCadEllipse_, &_vectorTemp);
- else
- _nResult += Intersect_CadLineWithCadEllipse(&_CadLine, pCadEllipse_, NULL);
- }
- break;
-
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(_SegmentOut.ptStart, _SegmentOut.ptEnd, _SegmentOut.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
- CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), _SegmentOut.nBulge > 0);
-
- if (pvectorIntersect_ != NULL)
- _nResult += Intersect_CadArcWithCadEllipse(&_CadArc, pCadEllipse_, &_vectorTemp);
- else
- _nResult += Intersect_CadArcWithCadEllipse(&_CadArc, pCadEllipse_, NULL);
- }
- break;
-
- case SEGMENT::BEZIER:
- default:
- ASSERT(false);
- }
-
- // Ҫȡ㣬ȡ㲻Ϊд洢 --- 2010 09 19
- if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
- {
- copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
- }
- }
- return _nResult;
- }
-
- int nce::Intersect_CadMultiSegmentsWithCadEllipseArc(IN const CCadMultiSegments* pCadMultiSegments_,
- IN const CCadEllipseArc* pCadEllipseArc_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadMultiSegments_ != NULL);
- ASSERT(pCadEllipseArc_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- // еĸͬԲ --- 2010 09 19
- for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
- {
- SEGMENT _SegmentOut = pCadMultiSegments_->GetSegment(_i);
- std::vector<DPOINT2> _vectorTemp;
-
- switch(_SegmentOut.nType)
- {
- case SEGMENT::LINE:
- {
- CCadLine _CadLine(_SegmentOut.ptStart, _SegmentOut.ptEnd);
-
- if (pvectorIntersect_ != NULL)
- _nResult += Intersect_CadLineWithCadEllipseArc(&_CadLine, pCadEllipseArc_, &_vectorTemp);
- else
- _nResult += Intersect_CadLineWithCadEllipseArc(&_CadLine, pCadEllipseArc_, NULL);
- }
- break;
-
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(_SegmentOut.ptStart, _SegmentOut.ptEnd, _SegmentOut.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
- CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), _SegmentOut.nBulge > 0);
-
- if (pvectorIntersect_ != NULL)
- _nResult += Intersect_CadArcWithCadEllipseArc(&_CadArc, pCadEllipseArc_, &_vectorTemp);
- else
- _nResult += Intersect_CadArcWithCadEllipseArc(&_CadArc, pCadEllipseArc_, NULL);
- }
- break;
-
- case SEGMENT::BEZIER:
- default:
- ASSERT(false);
- }
-
- if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
- {
- copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
- }
- }
- return _nResult;
- }
-
- int nce::Intersect_CadMultiSegmentsWithCadMultiSegments(IN const CCadMultiSegments* pCadMultiSegments1_,
- IN const CCadMultiSegments* pCadMultiSegments2_,
- OUT std::vector<DPOINT2>* pvectorIntersect_)
- {
- ASSERT(pCadMultiSegments1_ != NULL);
- ASSERT(pCadMultiSegments2_ != NULL);
- ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
-
- int _nResult = 0;
- // еĸ߽ͬ --- 2010 09 19
- for (int _i = 0; _i != pCadMultiSegments1_->GetSegmentCount(); ++_i)
- {
- SEGMENT _SegmentOut = pCadMultiSegments1_->GetSegment(_i);
-
- CCadObject* _pCadObjectOut = NULL;
- if (!GetCadObjectFromSegment(_SegmentOut, &_pCadObjectOut))
- continue;
-
- std::vector<DPOINT2> _vectorTemp;
- int _j = pCadMultiSegments1_->GetID() == pCadMultiSegments2_->GetID() ? _i + 1 : 0;
- for (; _j < pCadMultiSegments2_->GetSegmentCount(); ++_j)
- {
- SEGMENT _SegmentIn = pCadMultiSegments2_->GetSegment(_j);
-
- CCadObject* _pCadObjectIn = NULL;
- if (!GetCadObjectFromSegment(_SegmentIn, &_pCadObjectIn))
- continue;
-
- std::vector<DPOINT2> _vectorTemp;
- if (pvectorIntersect_ != NULL)
- _nResult += GetIntersection(_pCadObjectOut, _pCadObjectIn, &_vectorTemp);
- else
- _nResult += GetIntersection(_pCadObjectOut, _pCadObjectIn, NULL);
-
- if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
- {
- copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
- }
- delete _pCadObjectIn;
- }
- delete _pCadObjectOut;
- }
- return _nResult;
- }
-
- bool nce::GetCadObjectFromSegment(IN const SEGMENT& Segment_, OUT CCadObject** ppCadObject_)
- {
- ASSERT(IsValidDouble(Segment_.ptStart.x));
- ASSERT(IsValidDouble(Segment_.ptStart.y));
- ASSERT(IsValidDouble(Segment_.ptEnd.x));
- ASSERT(IsValidDouble(Segment_.ptEnd.y));
- ASSERT(IsValidDouble(Segment_.nBulge));
- ASSERT(*ppCadObject_ == NULL);
-
- switch(Segment_.nType)
- {
- case SEGMENT::LINE:
- {
- CCadLine _CadLine(Segment_.ptStart, Segment_.ptEnd);
- *ppCadObject_ = _CadLine.Clone();
- }
- break;
-
- case SEGMENT::ARC:
- {
- DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
- double _nArcRadius = 0.0;
- double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
-
- SEGMENT::SolveArc(Segment_.ptStart, Segment_.ptEnd, Segment_.nBulge,
- &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
- CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), Segment_.nBulge > 0);
-
- *ppCadObject_ = _CadArc.Clone();
- }
- break;
-
- // ֵ֧ --- 2010 09 19
- case SEGMENT::BEZIER:
- default:
- return false;
- }
-
- return true;
- }
|