You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Intersect.cpp 66 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832
  1. // ************************************************************************** //
  2. // Copyright(c)2010 Naiky Company. All rights reserved.
  3. //
  4. // Abstract:
  5. // Cad󽻺ʵ
  6. // ********************************************* ---- 2010-09-08 ***** //
  7. #include "stdafx.h"
  8. #include "Intersect.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. using namespace ncmath;
  15. // ܽӿڶ --- 2010 09 10
  16. int nce::GetIntersection(IN const CCadObject* pCadObject1_,
  17. IN const CCadObject* pCadObject2_,
  18. OUT std::vector<DPOINT2>* pvectorIntersect_)
  19. {
  20. ASSERT(pCadObject1_);
  21. ASSERT(pCadObject2_);
  22. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  23. // תβΣ֤_pCadObject1Typeֵ_pCadObject2
  24. // Typeֵ ----  2010-09-14
  25. const CCadObject* _pCadObject1 = pCadObject1_;
  26. const CCadObject* _pCadObject2 = pCadObject2_;
  27. if ((UINT)_pCadObject1->GetType() > (UINT)_pCadObject2->GetType())
  28. {
  29. _pCadObject1 = pCadObject2_;
  30. _pCadObject2 = pCadObject1_;
  31. }
  32. // 32λʾ_pCadObject1_pCadObject2(Ϸʽ)ǰߵ
  33. // ΪType1ߵΪType2Ϊ (Type1 << 16 | Type2)
  34. // ʾʽжTypeֵ0xFFFF ----  2010-09-14
  35. UINT _nType1 = _pCadObject1->GetType();
  36. UINT _nType2 = _pCadObject2->GetType();
  37. ASSERT(_nType1 < 0xFFFF && _nType2 < 0xFFFF);
  38. // ͷ⣬switch-caseʵһά_nType1_nType2Ϊ
  39. // ñֵѯӦĴ·()
  40. // AB󽻵ĽӦͬBA󽻵ĽˣΪСѯ
  41. // ṩ˴ֻѯϽǿ(_nType1<=_nType2)½ǿ
  42. // ϽӦλ(ǰĴ) ----  2010-09-14
  43. int _nResult = 0;
  44. ASSERT(_nType1 <= _nType2);
  45. switch(_nType1 << 16 | _nType2)
  46. {
  47. // ߶κ߶ --- 2010 09 19
  48. case (cadline << 16 | cadline):
  49. {
  50. C_ASSERT(cadline <= cadline);
  51. const CCadLine* _pCadLine1 = dynamic_cast<const CCadLine*>(_pCadObject1);
  52. const CCadLine* _pCadLine2 = dynamic_cast<const CCadLine*>(_pCadObject2);
  53. _nResult = Intersect_CadLineWithCadLine(_pCadLine1, _pCadLine2, pvectorIntersect_);
  54. }
  55. break;
  56. // ߶κֱ --- 2010 09 19
  57. case (cadline << 16 | cadbeeline):
  58. {
  59. C_ASSERT(cadline <= cadbeeline);
  60. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  61. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject2);
  62. _nResult = Intersect_CadLineWithCadBeeline(_pCadLine, _pCadBeeline, pvectorIntersect_);
  63. }
  64. break;
  65. // ߶κԲ --- 2010 09 19
  66. case (cadline << 16 | cadcircle):
  67. {
  68. C_ASSERT(cadline <= cadcircle);
  69. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  70. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*>(_pCadObject2);
  71. _nResult = Intersect_CadLineWithCadCircle(_pCadLine, _pCadCircle, pvectorIntersect_);
  72. }
  73. break;
  74. // ߶κԲ --- 2010 09 19
  75. case (cadline << 16 | cadarc):
  76. {
  77. C_ASSERT(cadline <= cadarc);
  78. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  79. const CCadArc * _pCadArc = dynamic_cast<const CCadArc *>(_pCadObject2);
  80. _nResult = Intersect_CadLineWithCadArc(_pCadLine, _pCadArc, pvectorIntersect_);
  81. }
  82. break;
  83. // ߶κԲ --- 2010 09 19
  84. case (cadline << 16 | cadellipse):
  85. {
  86. C_ASSERT(cadline <= cadellipse);
  87. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  88. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
  89. _nResult = Intersect_CadLineWithCadEllipse(_pCadLine, _pCadEllipse, pvectorIntersect_);
  90. }
  91. break;
  92. // ߶κԲ --- 2010 09 19
  93. case (cadline << 16 | cadellipsearc):
  94. {
  95. C_ASSERT(cadline <= cadellipsearc);
  96. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  97. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  98. _nResult = Intersect_CadLineWithCadEllipseArc(_pCadLine, _pCadEllipseArc, pvectorIntersect_);
  99. }
  100. break;
  101. // ߶κͶ --- 2010 09 19
  102. case (cadline << 16 | cadmultisegments):
  103. case (cadline << 16 | cadrectangle):
  104. case (cadline << 16 | cadstar):
  105. case (cadline << 16 | cadpolygon):
  106. case (cadline << 16 | cadpolyline):
  107. {
  108. C_ASSERT(cadline <= cadmultisegments &&
  109. cadline <= cadrectangle &&
  110. cadline <= cadstar &&
  111. cadline <= cadpolygon &&
  112. cadline <= cadpolyline);
  113. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*>(_pCadObject1);
  114. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  115. _nResult = Intersect_CadLineWithCadMultiSegments(_pCadLine, _pCadMultiSegments, pvectorIntersect_);
  116. }
  117. break;
  118. // ߶κȺ --- 2010 10 21
  119. case (cadline << 16 | cadgroup):
  120. {
  121. C_ASSERT(cadline <= cadgroup);
  122. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*> (_pCadObject1);
  123. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  124. _nResult = Intersect_CadObjectWithCadGroup(_pCadLine, _pCadGroup, pvectorIntersect_);
  125. }
  126. break;
  127. // ߶κ --- 2010 10 21
  128. case (cadline << 16 | cadtext):
  129. {
  130. C_ASSERT(cadline <= cadtext);
  131. const CCadLine* _pCadLine = dynamic_cast<const CCadLine*> (_pCadObject1);
  132. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  133. _nResult = Intersect_CadObjectWithCadText(_pCadLine, _pCadText, pvectorIntersect_);
  134. }
  135. break;
  136. // ֱߺֱ --- 2010 09 19
  137. case (cadbeeline << 16 | cadbeeline):
  138. {
  139. C_ASSERT(cadbeeline <= cadbeeline);
  140. const CCadBeeline* _pCadBeeline1 = dynamic_cast<const CCadBeeline*> (_pCadObject1);
  141. const CCadBeeline* _pCadBeeline2 = dynamic_cast<const CCadBeeline*> (_pCadObject2);
  142. _nResult = Intersect_CadBeelineWithCadBeeline(_pCadBeeline1, _pCadBeeline2, pvectorIntersect_);
  143. }
  144. break;
  145. // ֱߺԲ --- 2010 09 19
  146. case (cadbeeline << 16 | cadcircle):
  147. {
  148. C_ASSERT(cadbeeline <= cadcircle);
  149. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
  150. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject2);
  151. _nResult = Intersect_CadBeelineWithCadCircle(_pCadBeeline, _pCadCircle, pvectorIntersect_);
  152. }
  153. break;
  154. // ֱߺԲ --- 2010 09 19
  155. case (cadbeeline << 16 | cadarc):
  156. {
  157. C_ASSERT(cadbeeline <= cadarc);
  158. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
  159. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject2);
  160. _nResult = Intersect_CadBeelineWithCadArc(_pCadBeeline, _pCadArc, pvectorIntersect_);
  161. }
  162. break;
  163. // ֱߺԲ --- 2010 09 19
  164. case (cadbeeline << 16 | cadellipse):
  165. {
  166. C_ASSERT(cadbeeline <= cadellipse);
  167. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
  168. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
  169. _nResult = Intersect_CadBeelineWithCadEllipse(_pCadBeeline, _pCadEllipse, pvectorIntersect_);
  170. }
  171. break;
  172. // ֱߺԲ --- 2010 09 19
  173. case (cadbeeline << 16 | cadellipsearc):
  174. {
  175. C_ASSERT(cadbeeline <= cadellipsearc);
  176. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*> (_pCadObject1);
  177. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  178. _nResult = Intersect_CadBeelineWithCadEllipseArc(_pCadBeeline, _pCadEllipseArc, pvectorIntersect_);
  179. }
  180. break;
  181. // ֱߺͶ --- 2010 09 19
  182. case (cadbeeline << 16 | cadmultisegments):
  183. case (cadbeeline << 16 | cadrectangle):
  184. case (cadbeeline << 16 | cadstar):
  185. case (cadbeeline << 16 | cadpolygon):
  186. case (cadbeeline << 16 | cadpolyline):
  187. {
  188. C_ASSERT(cadbeeline <= cadmultisegments &&
  189. cadbeeline <= cadrectangle &&
  190. cadbeeline <= cadstar &&
  191. cadbeeline <= cadpolygon &&
  192. cadbeeline <= cadpolyline);
  193. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
  194. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  195. _nResult = Intersect_CadBeelineWithCadMultiSegments(_pCadBeeline, _pCadMultiSegments, pvectorIntersect_);
  196. }
  197. break;
  198. // ֱߺȺ --- 2010 10 21
  199. case (cadbeeline << 16 | cadgroup):
  200. {
  201. C_ASSERT(cadbeeline <= cadgroup);
  202. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
  203. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  204. _nResult = Intersect_CadObjectWithCadGroup(_pCadBeeline, _pCadGroup, pvectorIntersect_);
  205. }
  206. break;
  207. // ֱߺ --- 2010 10 21
  208. case (cadbeeline << 16 | cadtext):
  209. {
  210. C_ASSERT(cadbeeline <= cadtext);
  211. const CCadBeeline* _pCadBeeline = dynamic_cast<const CCadBeeline*>(_pCadObject1);
  212. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  213. _nResult = Intersect_CadObjectWithCadText(_pCadBeeline, _pCadText, pvectorIntersect_);
  214. }
  215. break;
  216. // ԲԲ --- 2010 09 19
  217. case (cadcircle << 16 | cadcircle):
  218. {
  219. C_ASSERT(cadcircle <= cadcircle);
  220. const CCadCircle* _pCadCircle1 = dynamic_cast<const CCadCircle*> (_pCadObject1);
  221. const CCadCircle* _pCadCircle2 = dynamic_cast<const CCadCircle*> (_pCadObject2);
  222. _nResult = Intersect_CadCircleWithCadCircle(_pCadCircle1, _pCadCircle2, pvectorIntersect_);
  223. }
  224. break;
  225. // ԲԲ --- 2010 09 19
  226. case (cadcircle << 16 | cadarc):
  227. {
  228. C_ASSERT(cadcircle <= cadarc);
  229. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  230. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject2);
  231. _nResult = Intersect_CadArcWithCadCircle(_pCadArc, _pCadCircle, pvectorIntersect_);
  232. }
  233. break;
  234. // ԲԲ --- 2010 09 19
  235. case (cadcircle << 16 | cadellipse):
  236. {
  237. C_ASSERT(cadcircle <= cadellipse);
  238. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  239. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
  240. _nResult = Intersect_CadCircleWithCadEllipse(_pCadCircle, _pCadEllipse, pvectorIntersect_);
  241. }
  242. break;
  243. // ԲԲ --- 2010 09 19
  244. case (cadcircle << 16 | cadellipsearc):
  245. {
  246. C_ASSERT(cadcircle <= cadellipsearc);
  247. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  248. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  249. _nResult = Intersect_CadCircleWithCadEllipseArc(_pCadCircle, _pCadEllipseArc, pvectorIntersect_);
  250. }
  251. break;
  252. // ԲͶ --- 2010 09 19
  253. case (cadcircle << 16 | cadmultisegments):
  254. case (cadcircle << 16 | cadrectangle):
  255. case (cadcircle << 16 | cadstar):
  256. case (cadcircle << 16 | cadpolygon):
  257. case (cadcircle << 16 | cadpolyline):
  258. {
  259. C_ASSERT(cadcircle <= cadmultisegments &&
  260. cadcircle <= cadrectangle &&
  261. cadcircle <= cadstar &&
  262. cadcircle <= cadpolygon &&
  263. cadcircle <= cadpolyline);
  264. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  265. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  266. _nResult = Intersect_CadCircleWithCadMultiSegments(_pCadCircle, _pCadMultiSegments, pvectorIntersect_);
  267. }
  268. break;
  269. // ԲȺ --- 2010 10 21
  270. case (cadcircle << 16 | cadgroup):
  271. {
  272. C_ASSERT(cadcircle <= cadgroup);
  273. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  274. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  275. _nResult = Intersect_CadObjectWithCadGroup(_pCadCircle, _pCadGroup, pvectorIntersect_);
  276. }
  277. break;
  278. // Բ --- 2010 10 21
  279. case (cadcircle<< 16 | cadtext):
  280. {
  281. C_ASSERT(cadcircle <= cadtext);
  282. const CCadCircle* _pCadCircle = dynamic_cast<const CCadCircle*> (_pCadObject1);
  283. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  284. _nResult = Intersect_CadObjectWithCadText(_pCadCircle, _pCadText, pvectorIntersect_);
  285. }
  286. break;
  287. // ԲԲ --- 2010 09 19
  288. case (cadarc << 16 | cadarc):
  289. {
  290. C_ASSERT(cadarc <= cadarc);
  291. const CCadArc* _pCadArc1 = dynamic_cast<const CCadArc*> (_pCadObject1);
  292. const CCadArc* _pCadArc2 = dynamic_cast<const CCadArc*> (_pCadObject2);
  293. _nResult = Intersect_CadArcWithCadArc(_pCadArc1, _pCadArc2, pvectorIntersect_);
  294. }
  295. break;
  296. // ԲԲ --- 2010 09 19
  297. case (cadarc << 16 | cadellipse):
  298. {
  299. C_ASSERT(cadarc <= cadellipse);
  300. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
  301. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject2);
  302. _nResult = Intersect_CadArcWithCadEllipse(_pCadArc, _pCadEllipse, pvectorIntersect_);
  303. }
  304. break;
  305. // ԲԲ --- 2010 09 19
  306. case (cadarc << 16 | cadellipsearc):
  307. {
  308. C_ASSERT(cadarc <= cadellipsearc);
  309. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
  310. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  311. _nResult = Intersect_CadArcWithCadEllipseArc(_pCadArc, _pCadEllipseArc, pvectorIntersect_);
  312. }
  313. break;
  314. // ԲͶ --- 2010 09 19
  315. case (cadarc << 16 | cadmultisegments):
  316. case (cadarc << 16 | cadrectangle):
  317. case (cadarc << 16 | cadstar):
  318. case (cadarc << 16 | cadpolygon):
  319. case (cadarc << 16 | cadpolyline):
  320. {
  321. C_ASSERT(cadarc <= cadmultisegments &&
  322. cadarc <= cadrectangle &&
  323. cadarc <= cadstar &&
  324. cadarc <= cadpolygon &&
  325. cadarc <= cadpolyline);
  326. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
  327. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  328. _nResult = Intersect_CadArcWithCadMultiSegments(_pCadArc, _pCadMultiSegments, pvectorIntersect_);
  329. }
  330. break;
  331. // ԲȺ --- 2010 10 21
  332. case (cadarc << 16 | cadgroup):
  333. {
  334. C_ASSERT(cadarc <= cadgroup);
  335. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
  336. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  337. _nResult = Intersect_CadObjectWithCadGroup(_pCadArc, _pCadGroup, pvectorIntersect_);
  338. }
  339. break;
  340. // Բ --- 2010 10 21
  341. case (cadarc<< 16 | cadtext):
  342. {
  343. C_ASSERT(cadarc <= cadtext);
  344. const CCadArc* _pCadArc = dynamic_cast<const CCadArc*> (_pCadObject1);
  345. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  346. _nResult = Intersect_CadObjectWithCadText(_pCadArc, _pCadText, pvectorIntersect_);
  347. }
  348. break;
  349. // ԲԲ --- 2010 09 19
  350. case (cadellipse << 16 | cadellipse):
  351. {
  352. C_ASSERT(cadellipse <= cadellipse);
  353. const CCadEllipse* _pCadEllipse1 = dynamic_cast<const CCadEllipse*> (_pCadObject1);
  354. const CCadEllipse* _pCadEllipse2 = dynamic_cast<const CCadEllipse*> (_pCadObject2);
  355. _nResult = Intersect_CadEllipseWithCadEllipse(_pCadEllipse1, _pCadEllipse2, pvectorIntersect_);
  356. }
  357. break;
  358. // ԲԲ --- 2010 09 19
  359. case (cadellipse << 16 | cadellipsearc):
  360. {
  361. C_ASSERT(cadellipse <= cadellipsearc);
  362. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
  363. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  364. _nResult = Intersect_CadEllipseWithCadEllipseArc(_pCadEllipse, _pCadEllipseArc, pvectorIntersect_);
  365. }
  366. break;
  367. // ԲͶ --- 2010 09 19
  368. case (cadellipse << 16 | cadmultisegments):
  369. case (cadellipse << 16 | cadrectangle):
  370. case (cadellipse << 16 | cadstar):
  371. case (cadellipse << 16 | cadpolygon):
  372. case (cadellipse << 16 | cadpolyline):
  373. {
  374. C_ASSERT(cadellipse <= cadmultisegments &&
  375. cadellipse <= cadrectangle &&
  376. cadellipse <= cadstar &&
  377. cadellipse <= cadpolygon &&
  378. cadellipse <= cadpolyline);
  379. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
  380. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  381. _nResult = Intersect_CadMultiSegmentsWithCadEllipse(_pCadMultiSegments, _pCadEllipse, pvectorIntersect_);
  382. }
  383. break;
  384. // ԲȺ --- 2010 10 21
  385. case (cadellipse << 16 | cadgroup):
  386. {
  387. C_ASSERT(cadellipse <= cadgroup);
  388. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
  389. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  390. _nResult = Intersect_CadObjectWithCadGroup(_pCadEllipse, _pCadGroup, pvectorIntersect_);
  391. }
  392. break;
  393. // Բ --- 2010 10 21
  394. case (cadellipse<< 16 | cadtext):
  395. {
  396. C_ASSERT(cadellipse <= cadtext);
  397. const CCadEllipse* _pCadEllipse = dynamic_cast<const CCadEllipse*> (_pCadObject1);
  398. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  399. _nResult = Intersect_CadObjectWithCadText(_pCadEllipse, _pCadText, pvectorIntersect_);
  400. }
  401. break;
  402. // ԲԲ --- 2010 09 19
  403. case (cadellipsearc << 16 | cadellipsearc):
  404. {
  405. C_ASSERT(cadellipsearc <= cadellipsearc);
  406. const CCadEllipseArc* _pCadEllipseArc1 = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
  407. const CCadEllipseArc* _pCadEllipseArc2 = dynamic_cast<const CCadEllipseArc*> (_pCadObject2);
  408. _nResult = Intersect_CadEllipseArcWithCadEllipseArc(_pCadEllipseArc1, _pCadEllipseArc2, pvectorIntersect_);
  409. }
  410. break;
  411. // ԲͶ --- 2010 09 19
  412. case (cadellipsearc << 16 | cadmultisegments):
  413. case (cadellipsearc << 16 | cadrectangle):
  414. case (cadellipsearc << 16 | cadstar):
  415. case (cadellipsearc << 16 | cadpolygon):
  416. case (cadellipsearc << 16 | cadpolyline):
  417. {
  418. C_ASSERT(cadellipsearc <= cadmultisegments &&
  419. cadellipsearc <= cadrectangle &&
  420. cadellipsearc <= cadstar &&
  421. cadellipsearc <= cadpolygon &&
  422. cadellipsearc <= cadpolyline);
  423. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
  424. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  425. _nResult = Intersect_CadMultiSegmentsWithCadEllipseArc(_pCadMultiSegments, _pCadEllipseArc, pvectorIntersect_);
  426. }
  427. break;
  428. // ԲȺ --- 2010 10 21
  429. case (cadellipsearc << 16 | cadgroup):
  430. {
  431. C_ASSERT(cadellipsearc <= cadgroup);
  432. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
  433. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  434. _nResult = Intersect_CadObjectWithCadGroup(_pCadEllipseArc, _pCadGroup, pvectorIntersect_);
  435. }
  436. break;
  437. // Բ --- 2010 10 21
  438. case (cadellipsearc<< 16 | cadtext):
  439. {
  440. C_ASSERT(cadellipsearc <= cadtext);
  441. const CCadEllipseArc* _pCadEllipseArc = dynamic_cast<const CCadEllipseArc*> (_pCadObject1);
  442. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  443. _nResult = Intersect_CadObjectWithCadText(_pCadEllipseArc, _pCadText, pvectorIntersect_);
  444. }
  445. break;
  446. // ߺͶ --- 2010 09 19
  447. case (cadmultisegments << 16 | cadmultisegments):
  448. case (cadmultisegments << 16 | cadrectangle):
  449. case (cadmultisegments << 16 | cadpolygon):
  450. case (cadmultisegments << 16 | cadstar):
  451. case (cadmultisegments << 16 | cadpolyline):
  452. case (cadrectangle << 16 | cadrectangle):
  453. case (cadrectangle << 16 | cadpolygon):
  454. case (cadrectangle << 16 | cadstar):
  455. case (cadrectangle << 16 | cadpolyline):
  456. case (cadpolygon << 16 | cadpolygon):
  457. case (cadpolygon << 16 | cadstar):
  458. case (cadpolygon << 16 | cadpolyline):
  459. case (cadstar << 16 | cadstar):
  460. case (cadstar << 16 | cadpolyline):
  461. case (cadpolyline << 16 | cadpolyline):
  462. {
  463. C_ASSERT(cadmultisegments <= cadrectangle &&
  464. cadrectangle <= cadpolygon &&
  465. cadpolygon <= cadstar &&
  466. cadstar <= cadpolyline);
  467. const CCadMultiSegments* _pCadMultiSegments1 = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
  468. const CCadMultiSegments* _pCadMultiSegments2 = dynamic_cast<const CCadMultiSegments*> (_pCadObject2);
  469. _nResult = Intersect_CadMultiSegmentsWithCadMultiSegments(_pCadMultiSegments1, _pCadMultiSegments2, pvectorIntersect_);
  470. }
  471. break;
  472. // ߺȺ --- 2010 10 21
  473. case (cadmultisegments << 16 | cadgroup):
  474. case (cadrectangle << 16 | cadgroup):
  475. case (cadpolygon << 16 | cadgroup):
  476. case (cadstar << 16 | cadgroup):
  477. case (cadpolyline << 16 | cadgroup):
  478. {
  479. C_ASSERT(cadmultisegments <= cadgroup &&
  480. cadrectangle <= cadgroup &&
  481. cadpolygon <= cadgroup &&
  482. cadstar <= cadgroup &&
  483. cadpolyline <= cadgroup);
  484. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
  485. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject2);
  486. _nResult = Intersect_CadObjectWithCadGroup(_pCadMultiSegments, _pCadGroup, pvectorIntersect_);
  487. }
  488. break;
  489. // ߺ --- 2010 10 21
  490. case (cadmultisegments << 16 | cadtext):
  491. case (cadrectangle << 16 | cadtext):
  492. case (cadpolygon << 16 | cadtext):
  493. case (cadstar << 16 | cadtext):
  494. case (cadpolyline << 16 | cadtext):
  495. {
  496. C_ASSERT(cadmultisegments <= cadtext &&
  497. cadrectangle <= cadtext &&
  498. cadpolygon <= cadtext &&
  499. cadstar <= cadtext &&
  500. cadpolyline <= cadtext);
  501. const CCadMultiSegments* _pCadMultiSegments = dynamic_cast<const CCadMultiSegments*> (_pCadObject1);
  502. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  503. _nResult = Intersect_CadObjectWithCadText(_pCadMultiSegments, _pCadText, pvectorIntersect_);
  504. }
  505. break;
  506. // ԲȺ --- 2010 10 21
  507. case (cadgroup << 16 | cadgroup):
  508. {
  509. C_ASSERT(cadgroup <= cadgroup);
  510. const CCadGroup* _pCadGroup1 = dynamic_cast<const CCadGroup*> (_pCadObject1);
  511. const CCadGroup* _pCadGroup2 = dynamic_cast<const CCadGroup*> (_pCadObject2);
  512. _nResult = Intersect_CadGroupWithCadGroup(_pCadGroup1, _pCadGroup2, pvectorIntersect_);
  513. }
  514. break;
  515. // Ⱥ --- 2010 10 21
  516. case (cadgroup<< 16 | cadtext):
  517. {
  518. C_ASSERT(cadgroup <= cadtext);
  519. const CCadGroup* _pCadGroup = dynamic_cast<const CCadGroup*> (_pCadObject1);
  520. const CCadText* _pCadText = dynamic_cast<const CCadText*> (_pCadObject2);
  521. _nResult = Intersect_CadGroupWithCadText(_pCadGroup, _pCadText, pvectorIntersect_);
  522. }
  523. break;
  524. // ֺ --- 2010 10 21
  525. case (cadtext<< 16 | cadtext):
  526. {
  527. C_ASSERT(cadgroup <= cadtext);
  528. const CCadText* _pCadText1 = dynamic_cast<const CCadText*> (_pCadObject1);
  529. const CCadText* _pCadText2 = dynamic_cast<const CCadText*> (_pCadObject2);
  530. _nResult = Intersect_CadTextWithCadText(_pCadText1, _pCadText2, pvectorIntersect_);
  531. }
  532. break;
  533. default:
  534. break;
  535. }
  536. return _nResult;
  537. }
  538. int nce::Intersect_CadArcWithCadArc(IN const CCadArc* pCadArc1_,
  539. IN const CCadArc* pCadArc2_,
  540. OUT std::vector<DPOINT2>* pvectorIntersect_)
  541. {
  542. ASSERT(pCadArc1_);
  543. ASSERT(pCadArc2_);
  544. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  545. ASSERT(DOUBLE_GREAT_ZERO(pCadArc1_->GetLength()));
  546. ASSERT(DOUBLE_GREAT_ZERO(pCadArc2_->GetLength()));
  547. // ԲϢȡ --- 2010 09 19
  548. DPOINT2 _ptArc1Center = pCadArc1_->GetCenterPoint();
  549. DPOINT2 _ptArc2Center = pCadArc2_->GetCenterPoint();
  550. double _nArc1Radius = pCadArc1_->GetRadius();
  551. double _nArc2Radius = pCadArc2_->GetRadius();
  552. double _nArc1StartAngle = pCadArc1_->GetStartAngle();
  553. double _nArc2StartAngle = pCadArc2_->GetStartAngle();
  554. double _nFactor1 = pCadArc1_->IsNormalDir() ? 1 : -1;
  555. double _nFactor2 = pCadArc2_->IsNormalDir() ? 1 : -1;
  556. double _nArc1CentralAngle = pCadArc1_->GetCentralAngle() * _nFactor1;
  557. double _nArc2CentralAngle = pCadArc2_->GetCentralAngle() * _nFactor2;
  558. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  559. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  560. return ncmath::Intersect_ArcWithArc(_ptArc1Center, _nArc1Radius, _nArc1StartAngle, _nArc1CentralAngle,
  561. _ptArc2Center, _nArc2Radius, _nArc2StartAngle, _nArc2CentralAngle, *pvectorIntersect_, _nNeed);
  562. }
  563. int nce::Intersect_CadArcWithCadCircle(IN const CCadArc* pCadArc_,
  564. IN const CCadCircle* pCadCircle_,
  565. OUT std::vector<DPOINT2>* pvectorIntersect_)
  566. {
  567. ASSERT(pCadArc_);
  568. ASSERT(pCadCircle_);
  569. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  570. ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
  571. ASSERT(DOUBLE_GREAT_ZERO(pCadCircle_->GetLength()));
  572. // Բ --- 2010 09 09
  573. DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
  574. DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
  575. // 뾶 --- 2010 09 09
  576. double _nArcRadius = pCadArc_->GetRadius();
  577. double _nCircleRadius = pCadCircle_->GetRadius();
  578. // ԲʼǺĽ --- 2010 09 09
  579. double _nArcStartAngle = pCadArc_->GetStartAngle();
  580. double _nArcCentralAngle = pCadArc_->GetCentralAngle();
  581. // ĽǸ跽 --- 2010 09 09
  582. double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
  583. _nArcCentralAngle *= _nFactor;
  584. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  585. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  586. return ncmath::Intersect_CircleWithArc(_ptCircleCenter, _nCircleRadius, _ptArcCenter,
  587. _nArcRadius, _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
  588. }
  589. int nce::Intersect_CadArcWithCadEllipse(IN const CCadArc* pCadArc_,
  590. IN const CCadEllipse* pCadEllipse_,
  591. OUT std::vector<DPOINT2>* pvectorIntersect_)
  592. {
  593. ASSERT(pCadArc_);
  594. ASSERT(pCadEllipse_);
  595. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  596. // ԲϢȡ --- 2010 09 19
  597. DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
  598. double _nRadius = pCadArc_->GetRadius();
  599. double _nArcStartAngle = pCadArc_->GetStartAngle();
  600. double _nArcSweptAngle = pCadArc_->GetCentralAngle();
  601. if (!pCadArc_->IsNormalDir())
  602. _nArcSweptAngle *= -1;
  603. // ԲϢȡ --- 2010 09 19
  604. DPOINT2 _ptEllipseCenter = pCadEllipse_->GetCenterPoint();
  605. double _nLongRadius = pCadEllipse_->GetLongRadius();
  606. double _nShortRadius = pCadEllipse_->GetShortRadius();
  607. double _nAngle = pCadEllipse_->GetAngle();
  608. int _nRet = 0;
  609. if (!pvectorIntersect_)
  610. {
  611. _nRet = Intersect_ArcWithEllipse(_ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
  612. _ptEllipseCenter, _nLongRadius, _nShortRadius, _nAngle);
  613. }
  614. else
  615. {
  616. _nRet = Intersect_ArcWithEllipse(_ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
  617. _ptEllipseCenter, _nLongRadius, _nShortRadius, _nAngle, *pvectorIntersect_);
  618. }
  619. return _nRet;
  620. }
  621. int nce::Intersect_CadArcWithCadEllipseArc(IN const CCadArc* pCadArc_,
  622. IN const CCadEllipseArc* pCadEllipseArc_,
  623. OUT std::vector<DPOINT2>* pvectorIntersect_)
  624. {
  625. ASSERT(pCadArc_);
  626. ASSERT(pCadEllipseArc_);
  627. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  628. // ԲϢȡ --- 2010 09 19
  629. DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
  630. double _nRadius = pCadArc_->GetRadius();
  631. double _nArcStartAngle = pCadArc_->GetStartAngle();
  632. double _nArcSweptAngle = pCadArc_->GetCentralAngle();
  633. if (!pCadArc_->IsNormalDir())
  634. _nArcSweptAngle *= -1;
  635. // ԲϢȡ --- 2010 09 19
  636. DPOINT2 _ptEllipseArcCenter = pCadEllipseArc_->GetCenterPoint();
  637. double _nLongRadius = pCadEllipseArc_->GetLongRadius();
  638. double _nShortRadius = pCadEllipseArc_->GetShortRadius();
  639. double _nAngle = pCadEllipseArc_->GetAngle();
  640. double _nEllipseArcStartAngle = pCadEllipseArc_->GetStartAngle();
  641. double _nEllipseArcSweptAngle = pCadEllipseArc_->GetCentralAngle();
  642. if (!pCadEllipseArc_->IsNormalDir())
  643. _nEllipseArcSweptAngle *= -1;
  644. int _nRet = 0;
  645. if (!pvectorIntersect_)
  646. {
  647. _nRet = Intersect_ArcWithEllipseArc(
  648. _ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
  649. _ptEllipseArcCenter, _nLongRadius, _nShortRadius, _nAngle,
  650. _nEllipseArcStartAngle, _nEllipseArcSweptAngle);
  651. }
  652. else
  653. {
  654. _nRet = Intersect_ArcWithEllipseArc(
  655. _ptArcCenter, _nRadius, _nArcStartAngle, _nArcSweptAngle,
  656. _ptEllipseArcCenter, _nLongRadius, _nShortRadius, _nAngle,
  657. _nEllipseArcStartAngle, _nEllipseArcSweptAngle, *pvectorIntersect_);
  658. }
  659. return _nRet;
  660. }
  661. int nce::Intersect_CadArcWithCadMultiSegments(IN const CCadArc* pCadArc_,
  662. IN const CCadMultiSegments* pCadMultiSegments_,
  663. OUT std::vector<DPOINT2>* pvectorIntersect_)
  664. {
  665. ASSERT(pCadArc_);
  666. ASSERT(pCadMultiSegments_);
  667. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  668. ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
  669. ASSERT(DOUBLE_GREAT_ZERO(pCadMultiSegments_->GetLength()));
  670. // Ϣȡ --- 2010 09 19
  671. DPOINT2 _ptArc1Center = pCadArc_->GetCenterPoint();
  672. double _nArc1Radius = pCadArc_->GetRadius();
  673. double _nArc1StartAngle = pCadArc_->GetStartAngle();
  674. double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
  675. double _nArc1CentralAngle = _nFactor * pCadArc_->GetCentralAngle();
  676. int _nResult = 0;
  677. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  678. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  679. // Բͬ߸Ƭ --- 2010 09 19
  680. for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
  681. {
  682. SEGMENT _Segment = pCadMultiSegments_->GetSegment(_i);
  683. std::vector<DPOINT2> _vectorTemp;
  684. switch(_Segment.nType)
  685. {
  686. // Բ --- 2010 09 19
  687. case SEGMENT::ARC:
  688. {
  689. DPOINT2 _ptArc2Center(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  690. double _nArc2Radius = 0.0;
  691. double _nArc2StartAngle = 0.0;
  692. double _nArc2CentralAngle = 0.0;
  693. SEGMENT::SolveArc(_Segment.ptStart, _Segment.ptEnd, _Segment.nBulge,
  694. &_ptArc2Center, &_nArc2Radius, &_nArc2StartAngle, &_nArc2CentralAngle);
  695. _nResult += ncmath::Intersect_ArcWithArc(_ptArc1Center, _nArc1Radius, _nArc1StartAngle,
  696. _nArc1CentralAngle, _ptArc2Center, _nArc2Radius,
  697. _nArc2StartAngle, _nArc2CentralAngle, _vectorTemp,
  698. _nNeed);
  699. }
  700. break;
  701. // ߶ --- 2010 09 19
  702. case SEGMENT::LINE:
  703. {
  704. _nResult += ncmath::Intersect_LineWithArc(_Segment.ptStart, _Segment.ptEnd, _ptArc1Center,
  705. _nArc1Radius, _nArc1StartAngle, _nArc1CentralAngle, _vectorTemp, _nNeed);
  706. }
  707. break;
  708. // ֵ֧ĸʽ --- 2010 09 19
  709. case SEGMENT::BEZIER:
  710. default:
  711. ASSERT(false);
  712. }
  713. if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
  714. copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
  715. }
  716. return _nResult;
  717. }
  718. int nce::Intersect_CadBeelineWithCadArc(IN const CCadBeeline* pCadBeeline_,
  719. IN const CCadArc* pCadArc_,
  720. OUT std::vector<DPOINT2>* pvectorIntersect_)
  721. {
  722. ASSERT(pCadArc_);
  723. ASSERT(pCadBeeline_);
  724. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  725. ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
  726. //ֱߺԲϢȡ --- 2010 09 19
  727. DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
  728. double _nAngle = pCadBeeline_->GetAngle();
  729. DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
  730. double _nArcRadius = pCadArc_->GetRadius();
  731. double _nArcStartAngle = pCadArc_->GetStartAngle();
  732. double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
  733. double _nArcCentralAngle = _nFactor * pCadArc_->GetCentralAngle();
  734. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  735. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  736. return ncmath::Intersect_BeelineWithArc(_ptBeeline, _nAngle, _ptArcCenter,_nArcRadius,
  737. _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
  738. }
  739. int nce::Intersect_CadBeelineWithCadBeeline(IN const CCadBeeline* pCadBeeline1_,
  740. IN const CCadBeeline* pCadBeeline2_,
  741. OUT std::vector<DPOINT2>* pvectorIntersect_)
  742. {
  743. ASSERT(pCadBeeline1_);
  744. ASSERT(pCadBeeline2_);
  745. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  746. // ֱϢȡ --- 2010 09 19
  747. DPOINT2 _ptBeeline1 = pCadBeeline1_->GetPoint();
  748. double _nAngle1 = pCadBeeline1_->GetAngle();
  749. DPOINT2 _ptBeeline2 = pCadBeeline2_->GetPoint();
  750. double _nAngle2 = pCadBeeline2_->GetAngle();
  751. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  752. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  753. return ncmath::Intersect_BeelineWithBeeline(_ptBeeline1, _nAngle1,
  754. _ptBeeline2, _nAngle2, *pvectorIntersect_, _nNeed);
  755. }
  756. int nce::Intersect_CadBeelineWithCadCircle(IN const CCadBeeline* pCadBeeline_,
  757. IN const CCadCircle* pCadCircle_,
  758. OUT std::vector<DPOINT2>* pvectorIntersect_)
  759. {
  760. ASSERT(pCadBeeline_);
  761. ASSERT(pCadCircle_);
  762. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  763. ASSERT(DOUBLE_GREAT_ZERO(pCadCircle_->GetLength()));
  764. DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
  765. double _nAngle = pCadBeeline_->GetAngle();
  766. DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
  767. double _nCircleRadius = pCadCircle_->GetRadius();
  768. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  769. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  770. return ncmath::Intersect_BeelineWithCircle(_ptBeeline, _nAngle,_ptCircleCenter,
  771. _nCircleRadius, *pvectorIntersect_, _nNeed);
  772. }
  773. int nce::Intersect_CadBeelineWithCadEllipse(IN const CCadBeeline* pCadBeeline_,
  774. IN const CCadEllipse* pCadEllipse_,
  775. OUT std::vector<DPOINT2>* pvectorIntersect_)
  776. {
  777. ASSERT(pCadBeeline_);
  778. ASSERT(pCadEllipse_);
  779. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  780. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  781. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  782. // ֱߺԲϢȡ --- 2010 09 19
  783. DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
  784. double _nAngle = pCadBeeline_->GetAngle();
  785. DPOINT2 _ptCenter = pCadEllipse_->GetCenterPoint();
  786. double _nLRadius = pCadEllipse_->GetLongRadius();
  787. double _nSRadius = pCadEllipse_->GetShortRadius();
  788. double _nUAngle = pCadEllipse_->GetAngle();
  789. return ncmath::Intersect_BeelineWithEllipse(_ptBeeline, _nAngle, _ptCenter, _nLRadius,
  790. _nSRadius, _nUAngle, *pvectorIntersect_, _nNeed);
  791. }
  792. int nce::Intersect_CadBeelineWithCadEllipseArc(IN const CCadBeeline* pCadBeeline_,
  793. IN const CCadEllipseArc* pCadEllipseArc_,
  794. OUT std::vector<DPOINT2>* pvectorIntersect_)
  795. {
  796. ASSERT(pCadBeeline_);
  797. ASSERT(pCadEllipseArc_);
  798. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  799. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  800. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  801. // ֱϢȡ --- 2010 09 19
  802. DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
  803. double _nAngle = pCadBeeline_->GetAngle();
  804. // ԲϢȡ --- 2010 09 19
  805. DPOINT2 _ptCenter = pCadEllipseArc_->GetCenterPoint();
  806. double _nLRadius = pCadEllipseArc_->GetLongRadius();
  807. double _nSRadius = pCadEllipseArc_->GetShortRadius();
  808. double _nUAngle = pCadEllipseArc_->GetAngle();
  809. double _nStartAngle = pCadEllipseArc_->GetStartAngle();
  810. double _nFactor = pCadEllipseArc_->IsNormalDir() ? 1 : -1;
  811. double _nCentralAngle = pCadEllipseArc_->GetCentralAngle() * _nFactor;
  812. return ncmath::Intersect_BeelineWithEllipseArc(_ptBeeline, _nAngle, _ptCenter, _nLRadius, _nSRadius,
  813. _nUAngle,_nStartAngle, _nCentralAngle, *pvectorIntersect_, _nNeed);
  814. }
  815. int nce::Intersect_CadBeelineWithCadMultiSegments(IN const CCadBeeline* pCadBeeline_,
  816. IN const CCadMultiSegments* pCadMultiSegments_,
  817. OUT std::vector<DPOINT2>* pvectorIntersect_)
  818. {
  819. ASSERT(pCadBeeline_);
  820. ASSERT(pCadMultiSegments_);
  821. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  822. ASSERT(DOUBLE_GREAT_ZERO(pCadMultiSegments_->GetLength()));
  823. DPOINT2 _ptBeeline = pCadBeeline_->GetPoint();
  824. double _nAngle = pCadBeeline_->GetAngle();
  825. int _nResult = 0;
  826. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  827. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  828. for (int _i = 0; _i < pCadMultiSegments_->GetSegmentCount(); ++_i)
  829. {
  830. SEGMENT _Segment = pCadMultiSegments_->GetSegment(_i);
  831. std::vector<DPOINT2> _vectorTemp;
  832. switch(_Segment.nType)
  833. {
  834. case SEGMENT::ARC:
  835. {
  836. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  837. double _nArcRadius = 0.0;
  838. double _nArcStartAngle = 0.0;
  839. double _nArcCentralAngle = 0.0;
  840. SEGMENT::SolveArc(_Segment.ptStart, _Segment.ptEnd, _Segment.nBulge,
  841. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  842. _nResult += ncmath::Intersect_BeelineWithArc(_ptBeeline, _nAngle, _ptArcCenter,
  843. _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vectorTemp, _nNeed);
  844. }
  845. break;
  846. case SEGMENT::LINE:
  847. {
  848. _nResult += ncmath::Intersect_BeelineWithLine(_ptBeeline, _nAngle, _Segment.ptStart,
  849. _Segment.ptEnd, _vectorTemp, _nNeed);
  850. }
  851. break;
  852. default:
  853. ASSERT(false);
  854. }
  855. // нҪ洢洢 --- 2010 09 19
  856. if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
  857. copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
  858. }
  859. return _nResult;
  860. }
  861. int nce::Intersect_CadCircleWithCadCircle(IN const CCadCircle* pCadCircle1_,
  862. IN const CCadCircle* pCadCircle2_,
  863. OUT std::vector<DPOINT2>* pvectorIntersect_)
  864. {
  865. ASSERT(pCadCircle1_ != NULL);
  866. ASSERT(pCadCircle1_ != NULL);
  867. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  868. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  869. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  870. return ncmath::Intersect_CircleWithCircle(pCadCircle1_->GetCenterPoint(), pCadCircle1_->GetRadius(),
  871. pCadCircle2_->GetCenterPoint(), pCadCircle2_->GetRadius(), *pvectorIntersect_, _nNeed);
  872. }
  873. int nce::Intersect_CadCircleWithCadEllipse(IN const CCadCircle* pCadCircle_,
  874. IN const CCadEllipse* pCadEllipse_,
  875. OUT std::vector<DPOINT2>* pvectorIntersect_)
  876. {
  877. ASSERT(pCadCircle_);
  878. ASSERT(pCadEllipse_);
  879. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  880. DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
  881. double _nRadius = pCadCircle_->GetRadius();
  882. DPOINT2 _ptEllipseCenter = pCadEllipse_->GetCenterPoint();
  883. double _nLongRadius = pCadEllipse_->GetLongRadius();
  884. double _nShortRadius = pCadEllipse_->GetShortRadius();
  885. double _nAngle = pCadEllipse_->GetAngle();
  886. int _nRet = 0;
  887. if (!pvectorIntersect_)
  888. {
  889. _nRet = Intersect_CircleWithEllipse(_ptCircleCenter, _nRadius, _ptEllipseCenter,
  890. _nLongRadius, _nShortRadius, _nAngle);
  891. }
  892. else
  893. {
  894. _nRet = Intersect_CircleWithEllipse(_ptCircleCenter, _nRadius, _ptEllipseCenter,
  895. _nLongRadius, _nShortRadius, _nAngle, *pvectorIntersect_);
  896. }
  897. return _nRet;
  898. }
  899. int nce::Intersect_CadCircleWithCadEllipseArc(IN const CCadCircle* pCadCircle_,
  900. IN const CCadEllipseArc* pCadEllipseArc_,
  901. OUT std::vector<DPOINT2>* pvectorIntersect_)
  902. {
  903. ASSERT(pCadCircle_);
  904. ASSERT(pCadEllipseArc_);
  905. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  906. DPOINT2 _ptCircleCenter = pCadCircle_->GetCenterPoint();
  907. double _nRadius = pCadCircle_->GetRadius();
  908. DPOINT2 _ptEllipseArcCenter = pCadEllipseArc_->GetCenterPoint();
  909. double _nLongRadius = pCadEllipseArc_->GetLongRadius();
  910. double _nShortRadius = pCadEllipseArc_->GetShortRadius();
  911. double _nAngle = pCadEllipseArc_->GetAngle();
  912. double _nStartAngle = pCadEllipseArc_->GetStartAngle();
  913. double _nSweptAngle = pCadEllipseArc_->GetCentralAngle();
  914. if (!pCadEllipseArc_->IsNormalDir())
  915. _nSweptAngle *= -1;
  916. int _nRet = 0;
  917. if (!pvectorIntersect_)
  918. {
  919. _nRet = Intersect_CircleWithEllipseArc(_ptCircleCenter, _nRadius, _ptEllipseArcCenter,
  920. _nLongRadius, _nShortRadius, _nAngle, _nStartAngle, _nSweptAngle);
  921. }
  922. else
  923. {
  924. _nRet = Intersect_CircleWithEllipseArc(_ptCircleCenter, _nRadius, _ptEllipseArcCenter,
  925. _nLongRadius, _nShortRadius, _nAngle,_nStartAngle, _nSweptAngle, *pvectorIntersect_);
  926. }
  927. return _nRet;
  928. }
  929. int nce::Intersect_CadCircleWithCadMultiSegments(IN const CCadCircle* pCadCircle_,
  930. IN const CCadMultiSegments* pCadMultiSegments_,
  931. OUT std::vector<DPOINT2>* pvectorIntersect_)
  932. {
  933. ASSERT(pCadCircle_ != NULL);
  934. ASSERT(pCadMultiSegments_ != NULL);
  935. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  936. int _nResult = 0;
  937. int _nSegCount = pCadMultiSegments_->GetSegmentCount();
  938. for (int _i = 0; _i < _nSegCount; ++_i)
  939. {
  940. std::vector<DPOINT2> _vecTmp;
  941. SEGMENT _segTmp = pCadMultiSegments_->GetSegment(_i);
  942. switch (_segTmp.nType)
  943. {
  944. case SEGMENT::ARC:
  945. {
  946. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  947. double _nArcRadius = 0.0;
  948. double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
  949. SEGMENT::SolveArc(_segTmp.ptStart, _segTmp.ptEnd, _segTmp.nBulge,
  950. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  951. _nResult += ncmath::Intersect_CircleWithArc(pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(),
  952. _ptArcCenter, _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vecTmp);
  953. }
  954. break;
  955. case SEGMENT::LINE:
  956. _nResult += ncmath::Intersect_LineWithCircle(_segTmp.ptStart, _segTmp.ptEnd,
  957. pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(), _vecTmp);
  958. break;
  959. case SEGMENT::BEZIER:
  960. default:
  961. // ѡ׳쳣 --- wanghong 2010 09 12
  962. ASSERT(false);
  963. }
  964. if (pvectorIntersect_ != NULL && !_vecTmp.empty())
  965. std::copy(_vecTmp.begin(), _vecTmp.end(), std::back_inserter(*pvectorIntersect_));
  966. }
  967. return _nResult;
  968. }
  969. int nce::Intersect_CadEllipseWithCadEllipse(IN const CCadEllipse* pCadEllipse1_,
  970. IN const CCadEllipse* pCadEllipse2_,
  971. OUT std::vector<DPOINT2>* pvectorIntersect_)
  972. {
  973. ASSERT(pCadEllipse1_);
  974. ASSERT(pCadEllipse2_);
  975. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  976. // ȡβԲļβУĵ㡢ᡢ̰ᡢX
  977. // ǡ ----  2010-09-14
  978. DPOINT2 _ptCenter1 = pCadEllipse1_->GetCenterPoint();
  979. double _nURadius1 = pCadEllipse1_->GetLongRadius();
  980. double _nVRadius1 = pCadEllipse1_->GetShortRadius();
  981. double _nUAngle1 = pCadEllipse1_->GetAngle();
  982. DPOINT2 _ptCenter2 = pCadEllipse2_->GetCenterPoint();
  983. double _nURadius2 = pCadEllipse2_->GetLongRadius();
  984. double _nVRadius2 = pCadEllipse2_->GetShortRadius();
  985. double _nUAngle2 = pCadEllipse2_->GetAngle();
  986. // ѧ㽻 ----  2010-09-14
  987. int _nRet = 0;
  988. if (pvectorIntersect_ == NULL)
  989. {
  990. _nRet = ncmath::Intersect_EllipseWithEllipse(
  991. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
  992. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2);
  993. }
  994. else
  995. {
  996. _nRet = ncmath::Intersect_EllipseWithEllipse(
  997. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
  998. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2,
  999. *pvectorIntersect_);
  1000. }
  1001. return _nRet;
  1002. }
  1003. int nce::Intersect_CadEllipseWithCadEllipseArc(IN const CCadEllipse* pCadEllipse_,
  1004. IN const CCadEllipseArc* pCadEllipseArc_,
  1005. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1006. {
  1007. ASSERT(pCadEllipse_);
  1008. ASSERT(pCadEllipseArc_);
  1009. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  1010. // ȡβԲļβУĵ㡢ᡢ̰ᡢX
  1011. // ǣԲļβУĵ㡢ᡢ̰ᡢX
  1012. // ǡʼǡɨǡ ----  2010-09-14
  1013. DPOINT2 _ptCenter1 = pCadEllipse_->GetCenterPoint();
  1014. double _nURadius1 = pCadEllipse_->GetLongRadius();
  1015. double _nVRadius1 = pCadEllipse_->GetShortRadius();
  1016. double _nUAngle1 = pCadEllipse_->GetAngle();
  1017. DPOINT2 _ptCenter2 = pCadEllipseArc_->GetCenterPoint();
  1018. double _nURadius2 = pCadEllipseArc_->GetLongRadius();
  1019. double _nVRadius2 = pCadEllipseArc_->GetShortRadius();
  1020. double _nUAngle2 = pCadEllipseArc_->GetAngle();
  1021. double _nStartAngle2 = pCadEllipseArc_->GetStartAngle();
  1022. double _nSweptAngle2 = pCadEllipseArc_->GetCentralAngle();
  1023. if (!pCadEllipseArc_->IsNormalDir())
  1024. {
  1025. // ѧֻʱԲ ----  2010-09-14
  1026. _nStartAngle2 -= _nSweptAngle2;
  1027. while (_nStartAngle2 < 0.0)
  1028. {
  1029. _nStartAngle2 += 2.0 * c_nPIE;
  1030. }
  1031. while (_nStartAngle2 >= 2.0 * c_nPIE)
  1032. {
  1033. _nStartAngle2 -= 2.0 * c_nPIE;
  1034. }
  1035. }
  1036. // ѧ㽻 ----  2010-09-14
  1037. int _nRet = 0;
  1038. if (pvectorIntersect_ == NULL)
  1039. {
  1040. _nRet = ncmath::Intersect_EllipseWithEllipseArc(
  1041. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
  1042. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2);
  1043. }
  1044. else
  1045. {
  1046. _nRet = ncmath::Intersect_EllipseWithEllipseArc(
  1047. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1,
  1048. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2,
  1049. *pvectorIntersect_);
  1050. }
  1051. return _nRet;
  1052. }
  1053. int nce::Intersect_CadEllipseArcWithCadEllipseArc(IN const CCadEllipseArc* pCadEllipseArc1_,
  1054. IN const CCadEllipseArc* pCadEllipseArc2_,
  1055. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1056. {
  1057. ASSERT(pCadEllipseArc1_);
  1058. ASSERT(pCadEllipseArc2_);
  1059. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  1060. // ȡβԲļβУĵ㡢ᡢ̰ᡢX
  1061. // ǡʼǡɨǡ ----  2010-09-14
  1062. DPOINT2 _ptCenter1 = pCadEllipseArc1_->GetCenterPoint();
  1063. double _nURadius1 = pCadEllipseArc1_->GetLongRadius();
  1064. double _nVRadius1 = pCadEllipseArc1_->GetShortRadius();
  1065. double _nUAngle1 = pCadEllipseArc1_->GetAngle();
  1066. double _nStartAngle1 = pCadEllipseArc1_->GetStartAngle();
  1067. double _nSweptAngle1 = pCadEllipseArc1_->GetCentralAngle();
  1068. if (!pCadEllipseArc1_->IsNormalDir())
  1069. {
  1070. // ѧֻʱԲ ----  2010-09-14
  1071. _nStartAngle1 -= _nSweptAngle1;
  1072. while (_nStartAngle1 < 0.0)
  1073. {
  1074. _nStartAngle1 += 2.0 * c_nPIE;
  1075. }
  1076. while (_nStartAngle1 >= 2.0 * c_nPIE)
  1077. {
  1078. _nStartAngle1 -= 2.0 * c_nPIE;
  1079. }
  1080. }
  1081. // ͬ ----  2010-09-14
  1082. DPOINT2 _ptCenter2 = pCadEllipseArc2_->GetCenterPoint();
  1083. double _nURadius2 = pCadEllipseArc2_->GetLongRadius();
  1084. double _nVRadius2 = pCadEllipseArc2_->GetShortRadius();
  1085. double _nUAngle2 = pCadEllipseArc2_->GetAngle();
  1086. double _nStartAngle2 = pCadEllipseArc2_->GetStartAngle();
  1087. double _nSweptAngle2 = pCadEllipseArc2_->GetCentralAngle();
  1088. if (!pCadEllipseArc2_->IsNormalDir())
  1089. {
  1090. _nStartAngle2 -= _nSweptAngle2;
  1091. while (_nStartAngle2 < 0.0)
  1092. {
  1093. _nStartAngle2 += 2.0 * c_nPIE;
  1094. }
  1095. while (_nStartAngle2 >= 2.0 * c_nPIE)
  1096. {
  1097. _nStartAngle2 -= 2.0 * c_nPIE;
  1098. }
  1099. }
  1100. // ѧ㽻 ----  2010-09-14
  1101. int _nRet = 0;
  1102. if (pvectorIntersect_ == NULL)
  1103. {
  1104. _nRet = ncmath::Intersect_EllipseArcWithEllipseArc(
  1105. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1, _nStartAngle1, _nSweptAngle1,
  1106. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2);
  1107. }
  1108. else
  1109. {
  1110. _nRet = ncmath::Intersect_EllipseArcWithEllipseArc(
  1111. _ptCenter1, _nURadius1, _nVRadius1, _nUAngle1, _nStartAngle1, _nSweptAngle1,
  1112. _ptCenter2, _nURadius2, _nVRadius2, _nUAngle2, _nStartAngle2, _nSweptAngle2,
  1113. *pvectorIntersect_);
  1114. }
  1115. return _nRet;
  1116. }
  1117. int nce::Intersect_CadLineWithCadArc(IN const CCadLine* pCadLine_,
  1118. IN const CCadArc* pCadArc_,
  1119. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1120. {
  1121. ASSERT(pCadLine_);
  1122. ASSERT(pCadArc_);
  1123. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  1124. ASSERT(DOUBLE_GREAT_ZERO(pCadLine_->GetLength()));
  1125. ASSERT(DOUBLE_GREAT_ZERO(pCadArc_->GetLength()));
  1126. // ߶Ϣȡ --- 2010 09 19
  1127. DPOINT2 _ptLineStart = pCadLine_->GetStartPoint();
  1128. DPOINT2 _ptLineEnd = pCadLine_->GetEndPoint();
  1129. // ԲϢȡ --- 2010 09 19
  1130. DPOINT2 _ptArcCenter = pCadArc_->GetCenterPoint();
  1131. double _nArcRadius = pCadArc_->GetRadius();
  1132. double _nArcStartAngle = pCadArc_->GetStartAngle();
  1133. double _nArcCentralAngle = pCadArc_->GetCentralAngle();
  1134. double _nFactor = pCadArc_->IsNormalDir() ? 1 : -1;
  1135. _nArcCentralAngle *= _nFactor;
  1136. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1137. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1138. return ncmath::Intersect_LineWithArc(_ptLineStart, _ptLineEnd, _ptArcCenter,_nArcRadius,
  1139. _nArcStartAngle, _nArcCentralAngle, *pvectorIntersect_, _nNeed);
  1140. }
  1141. int nce::Intersect_CadLineWithCadBeeline(IN const CCadLine* pCadLine_,
  1142. IN const CCadBeeline* pCadBeeline_,
  1143. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1144. {
  1145. ASSERT(pCadLine_ != NULL);
  1146. ASSERT(pCadBeeline_ != NULL);
  1147. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1148. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1149. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1150. return ncmath::Intersect_BeelineWithLine(pCadBeeline_->GetPoint(), pCadBeeline_->GetAngle(),
  1151. pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(), *pvectorIntersect_, _nNeed);
  1152. }
  1153. int nce::Intersect_CadLineWithCadCircle(IN const CCadLine* pCadLine_,
  1154. IN const CCadCircle* pCadCircle_,
  1155. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1156. {
  1157. ASSERT(pCadLine_ != NULL);
  1158. ASSERT(pCadCircle_ != NULL);
  1159. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1160. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1161. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1162. return ncmath::Intersect_LineWithCircle(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
  1163. pCadCircle_->GetCenterPoint(), pCadCircle_->GetRadius(), *pvectorIntersect_, _nNeed);
  1164. }
  1165. int nce::Intersect_CadLineWithCadEllipse(IN const CCadLine* pCadLine_,
  1166. IN const CCadEllipse* pCadEllipse_,
  1167. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1168. {
  1169. ASSERT(pCadLine_ && pCadEllipse_);
  1170. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  1171. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1172. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1173. // ߶Ϣȡ --- 2010 09 19
  1174. DPOINT2 _ptStart = pCadLine_->GetStartPoint();
  1175. DPOINT2 _ptEnd = pCadLine_->GetEndPoint();
  1176. // ԲϢȡ --- 2010 09 19
  1177. DPOINT2 _ptCenter = pCadEllipse_->GetCenterPoint();
  1178. double _nLRadius = pCadEllipse_->GetLongRadius();
  1179. double _nSRadius = pCadEllipse_->GetShortRadius();
  1180. double _nUAngle = pCadEllipse_->GetAngle();
  1181. return ncmath::Intersect_LineWithEllipse(_ptStart, _ptEnd,
  1182. _ptCenter, _nLRadius, _nSRadius, _nUAngle,
  1183. *pvectorIntersect_, _nNeed);
  1184. }
  1185. int nce::Intersect_CadLineWithCadEllipseArc(IN const CCadLine* pCadLine_,
  1186. IN const CCadEllipseArc* pCadEllipseArc_,
  1187. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1188. {
  1189. ASSERT(pCadLine_ && pCadEllipseArc_);
  1190. ASSERT(!pvectorIntersect_ || pvectorIntersect_->empty());
  1191. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1192. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1193. // ߶Ϣȡ --- 2010 09 19
  1194. DPOINT2 _ptStart = pCadLine_->GetStartPoint();
  1195. DPOINT2 _ptEnd = pCadLine_->GetEndPoint();
  1196. // ԲϢȡ --- 2010 09 19
  1197. DPOINT2 _ptCenter = pCadEllipseArc_->GetCenterPoint();
  1198. double _nLRadius = pCadEllipseArc_->GetLongRadius();
  1199. double _nSRadius = pCadEllipseArc_->GetShortRadius();
  1200. double _nUAngle = pCadEllipseArc_->GetAngle();
  1201. double _nStartAngle = pCadEllipseArc_->GetStartAngle();
  1202. double _nFactor = pCadEllipseArc_->IsNormalDir() ? 1 : -1;
  1203. double _nCentralAngle = pCadEllipseArc_->GetCentralAngle() * _nFactor;
  1204. return ncmath::Intersect_LineWithEllipseArc(_ptStart, _ptEnd,
  1205. _ptCenter, _nLRadius, _nSRadius, _nUAngle, _nStartAngle, _nCentralAngle,
  1206. *pvectorIntersect_, _nNeed);
  1207. }
  1208. int nce::Intersect_CadLineWithCadLine(IN const CCadLine* pCadLine1_,
  1209. IN const CCadLine* pCadLine2_,
  1210. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1211. {
  1212. ASSERT(pCadLine1_);
  1213. ASSERT(pCadLine2_);
  1214. ASSERT(pvectorIntersect_== NULL || pvectorIntersect_->empty());
  1215. ASSERT(DOUBLE_GREAT_ZERO(pCadLine1_->GetLength()));
  1216. ASSERT(DOUBLE_GREAT_ZERO(pCadLine2_->GetLength()));
  1217. // ߶Ϣȡ --- 2010 09 19
  1218. DPOINT2 _ptLine1Start = pCadLine1_->GetStartPoint();
  1219. DPOINT2 _ptLine2Start = pCadLine2_->GetStartPoint();
  1220. DPOINT2 _ptLine1End = pCadLine1_->GetEndPoint();
  1221. DPOINT2 _ptLine2End = pCadLine2_->GetEndPoint();
  1222. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1223. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1224. return ncmath::Intersect_LineWithLine(_ptLine1Start, _ptLine1End,
  1225. _ptLine2Start, _ptLine2End, *pvectorIntersect_, _nNeed);
  1226. }
  1227. int nce::Intersect_CadLineWithCadMultiSegments(IN const CCadLine* pCadLine_,
  1228. IN const CCadMultiSegments* pCadMultiSegments_,
  1229. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1230. {
  1231. ASSERT(pCadLine_ != NULL);
  1232. ASSERT(pCadMultiSegments_ != NULL);
  1233. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1234. int _nResult = 0;
  1235. // Ҫ 0Ҫ-1ܶ --- 2010 09 19
  1236. int _nNeed = (pvectorIntersect_ == NULL) ? 0 : -1;
  1237. int _nSegCount = pCadMultiSegments_->GetSegmentCount();
  1238. for (int _i = 0; _i < _nSegCount; ++_i)
  1239. {
  1240. std::vector<DPOINT2> _vecTmp;
  1241. SEGMENT _segTmp = pCadMultiSegments_->GetSegment(_i);
  1242. switch (_segTmp.nType)
  1243. {
  1244. case SEGMENT::ARC:
  1245. {
  1246. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  1247. double _nArcRadius = 0.0;
  1248. double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
  1249. SEGMENT::SolveArc(_segTmp.ptStart, _segTmp.ptEnd, _segTmp.nBulge,
  1250. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  1251. _nResult += ncmath::Intersect_LineWithArc(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
  1252. _ptArcCenter, _nArcRadius, _nArcStartAngle, _nArcCentralAngle, _vecTmp, _nNeed);
  1253. }
  1254. break;
  1255. case SEGMENT::LINE:
  1256. _nResult += ncmath::Intersect_LineWithLine(pCadLine_->GetStartPoint(), pCadLine_->GetEndPoint(),
  1257. _segTmp.ptStart, _segTmp.ptEnd, _vecTmp, _nNeed);
  1258. break;
  1259. case SEGMENT::BEZIER:
  1260. default:
  1261. // ѡ׳쳣 --- wanghong 2010 09 12
  1262. ASSERT(false);
  1263. }
  1264. if (pvectorIntersect_ != NULL && !_vecTmp.empty())
  1265. std::copy(_vecTmp.begin(), _vecTmp.end(), std::back_inserter(*pvectorIntersect_));
  1266. }
  1267. return _nResult;
  1268. }
  1269. int nce::Intersect_CadObjectWithCadGroup(IN const CCadObject* pCadObject_,
  1270. IN const CCadGroup* pCadGroup_,
  1271. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1272. {
  1273. ASSERT(pCadObject_ && pCadGroup_);
  1274. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1275. ASSERT(pCadObject_->GetType() != cadgroup);
  1276. int _nResult = 0;
  1277. for (int _i = 0; _i != pCadGroup_->GetNumOfChild(); ++_i)
  1278. {
  1279. const CCadObject* _pCadObjectTemp = pCadGroup_->GetAt(_i);
  1280. int _nNum = 0;
  1281. if (pvectorIntersect_ != NULL)
  1282. {
  1283. std::vector<DPOINT2> _vecTmp;
  1284. if (_nNum = GetIntersection(pCadObject_, _pCadObjectTemp, &_vecTmp))
  1285. {
  1286. _nResult += _nNum;
  1287. copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
  1288. }
  1289. }
  1290. else
  1291. {
  1292. if (_nNum = GetIntersection(pCadObject_, _pCadObjectTemp, NULL))
  1293. _nResult += _nNum;
  1294. }
  1295. }
  1296. return _nResult;
  1297. }
  1298. int nce::Intersect_CadObjectWithCadText(IN const CCadObject* pCadObject_,
  1299. IN const CCadText* pCadText_,
  1300. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1301. {
  1302. ASSERT(pCadObject_ && pCadText_);
  1303. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1304. ASSERT(pCadObject_->GetType() != cadtext);
  1305. const CCadGroup* _pCadGroup = pCadText_->GetTextGroup();
  1306. return GetIntersection(pCadObject_, _pCadGroup, pvectorIntersect_);
  1307. }
  1308. // ȺȺ
  1309. int nce::Intersect_CadGroupWithCadGroup(IN const CCadGroup* pCadGroup1_,
  1310. IN const CCadGroup* pCadGroup2_,
  1311. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1312. {
  1313. ASSERT(pCadGroup1_ && pCadGroup1_->GetType() == cadgroup);
  1314. ASSERT(pCadGroup2_ && pCadGroup2_->GetType() == cadgroup);
  1315. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1316. int _nResult = 0;
  1317. for (int _i = 0; _i != pCadGroup1_->GetNumOfChild(); ++_i)
  1318. {
  1319. const CCadObject* _pCadObjectTemp = pCadGroup1_->GetAt(_i);
  1320. int _nNum = 0;
  1321. if (pvectorIntersect_ != NULL)
  1322. {
  1323. std::vector<DPOINT2> _vecTmp;
  1324. if (_nNum = GetIntersection(_pCadObjectTemp, pCadGroup2_, &_vecTmp))
  1325. {
  1326. _nResult += _nNum;
  1327. copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
  1328. }
  1329. }
  1330. else
  1331. {
  1332. if (_nNum = GetIntersection(_pCadObjectTemp, pCadGroup2_, NULL))
  1333. _nResult += _nNum;
  1334. }
  1335. }
  1336. return _nResult;
  1337. }
  1338. // Ⱥ
  1339. int nce::Intersect_CadGroupWithCadText(IN const CCadGroup* pCadGroup_,
  1340. IN const CCadText* pCadText_,
  1341. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1342. {
  1343. ASSERT(pCadGroup_ && pCadGroup_->GetType() == cadgroup);
  1344. ASSERT(pCadText_ && pCadText_->GetType() == cadtext);
  1345. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1346. int _nResult = 0;
  1347. for (int _i = 0; _i != pCadGroup_->GetNumOfChild(); ++_i)
  1348. {
  1349. const CCadObject* _pCadObjectTemp = pCadGroup_->GetAt(_i);
  1350. int _nNum = 0;
  1351. if (pvectorIntersect_ != NULL)
  1352. {
  1353. std::vector<DPOINT2> _vecTmp;
  1354. if (_nNum = GetIntersection(_pCadObjectTemp, pCadText_, &_vecTmp))
  1355. {
  1356. _nResult += _nNum;
  1357. copy(_vecTmp.begin(), _vecTmp.end(), back_inserter(*pvectorIntersect_));
  1358. }
  1359. }
  1360. else
  1361. {
  1362. if (_nNum = GetIntersection(_pCadObjectTemp, pCadText_, NULL))
  1363. _nResult += _nNum;
  1364. }
  1365. }
  1366. return _nResult;
  1367. }
  1368. // Ⱥ
  1369. int nce::Intersect_CadTextWithCadText(IN const CCadText* pCadText1_,
  1370. IN const CCadText* pCadText2_,
  1371. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1372. {
  1373. ASSERT(pCadText1_ && pCadText1_->GetType() == cadtext);
  1374. ASSERT(pCadText2_ && pCadText2_->GetType() == cadtext);
  1375. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1376. const CCadGroup* _pCadGroup1 = pCadText1_->GetTextGroup();
  1377. const CCadGroup* _pCadGroup2 = pCadText2_->GetTextGroup();
  1378. return Intersect_CadGroupWithCadGroup(_pCadGroup1, _pCadGroup2, pvectorIntersect_);
  1379. }
  1380. int nce::Intersect_CadMultiSegmentsWithCadEllipse(IN const CCadMultiSegments* pCadMultiSegments_,
  1381. IN const CCadEllipse* pCadEllipse_,
  1382. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1383. {
  1384. ASSERT(pCadMultiSegments_ != NULL);
  1385. ASSERT(pCadEllipse_ != NULL);
  1386. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1387. int _nResult = 0;
  1388. // еĸԲ --- 2010 09 19
  1389. for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
  1390. {
  1391. SEGMENT _SegmentOut = pCadMultiSegments_->GetSegment(_i);
  1392. std::vector<DPOINT2> _vectorTemp;
  1393. switch(_SegmentOut.nType)
  1394. {
  1395. case SEGMENT::LINE:
  1396. {
  1397. CCadLine _CadLine(_SegmentOut.ptStart, _SegmentOut.ptEnd);
  1398. if (pvectorIntersect_ != NULL)
  1399. _nResult += Intersect_CadLineWithCadEllipse(&_CadLine, pCadEllipse_, &_vectorTemp);
  1400. else
  1401. _nResult += Intersect_CadLineWithCadEllipse(&_CadLine, pCadEllipse_, NULL);
  1402. }
  1403. break;
  1404. case SEGMENT::ARC:
  1405. {
  1406. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  1407. double _nArcRadius = 0.0;
  1408. double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
  1409. SEGMENT::SolveArc(_SegmentOut.ptStart, _SegmentOut.ptEnd, _SegmentOut.nBulge,
  1410. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  1411. CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), _SegmentOut.nBulge > 0);
  1412. if (pvectorIntersect_ != NULL)
  1413. _nResult += Intersect_CadArcWithCadEllipse(&_CadArc, pCadEllipse_, &_vectorTemp);
  1414. else
  1415. _nResult += Intersect_CadArcWithCadEllipse(&_CadArc, pCadEllipse_, NULL);
  1416. }
  1417. break;
  1418. case SEGMENT::BEZIER:
  1419. default:
  1420. ASSERT(false);
  1421. }
  1422. // Ҫȡ㣬ȡ㲻Ϊд洢 --- 2010 09 19
  1423. if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
  1424. {
  1425. copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
  1426. }
  1427. }
  1428. return _nResult;
  1429. }
  1430. int nce::Intersect_CadMultiSegmentsWithCadEllipseArc(IN const CCadMultiSegments* pCadMultiSegments_,
  1431. IN const CCadEllipseArc* pCadEllipseArc_,
  1432. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1433. {
  1434. ASSERT(pCadMultiSegments_ != NULL);
  1435. ASSERT(pCadEllipseArc_ != NULL);
  1436. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1437. int _nResult = 0;
  1438. // еĸͬԲ --- 2010 09 19
  1439. for (int _i = 0; _i != pCadMultiSegments_->GetSegmentCount(); ++_i)
  1440. {
  1441. SEGMENT _SegmentOut = pCadMultiSegments_->GetSegment(_i);
  1442. std::vector<DPOINT2> _vectorTemp;
  1443. switch(_SegmentOut.nType)
  1444. {
  1445. case SEGMENT::LINE:
  1446. {
  1447. CCadLine _CadLine(_SegmentOut.ptStart, _SegmentOut.ptEnd);
  1448. if (pvectorIntersect_ != NULL)
  1449. _nResult += Intersect_CadLineWithCadEllipseArc(&_CadLine, pCadEllipseArc_, &_vectorTemp);
  1450. else
  1451. _nResult += Intersect_CadLineWithCadEllipseArc(&_CadLine, pCadEllipseArc_, NULL);
  1452. }
  1453. break;
  1454. case SEGMENT::ARC:
  1455. {
  1456. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  1457. double _nArcRadius = 0.0;
  1458. double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
  1459. SEGMENT::SolveArc(_SegmentOut.ptStart, _SegmentOut.ptEnd, _SegmentOut.nBulge,
  1460. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  1461. CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), _SegmentOut.nBulge > 0);
  1462. if (pvectorIntersect_ != NULL)
  1463. _nResult += Intersect_CadArcWithCadEllipseArc(&_CadArc, pCadEllipseArc_, &_vectorTemp);
  1464. else
  1465. _nResult += Intersect_CadArcWithCadEllipseArc(&_CadArc, pCadEllipseArc_, NULL);
  1466. }
  1467. break;
  1468. case SEGMENT::BEZIER:
  1469. default:
  1470. ASSERT(false);
  1471. }
  1472. if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
  1473. {
  1474. copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
  1475. }
  1476. }
  1477. return _nResult;
  1478. }
  1479. int nce::Intersect_CadMultiSegmentsWithCadMultiSegments(IN const CCadMultiSegments* pCadMultiSegments1_,
  1480. IN const CCadMultiSegments* pCadMultiSegments2_,
  1481. OUT std::vector<DPOINT2>* pvectorIntersect_)
  1482. {
  1483. ASSERT(pCadMultiSegments1_ != NULL);
  1484. ASSERT(pCadMultiSegments2_ != NULL);
  1485. ASSERT(pvectorIntersect_ == NULL || pvectorIntersect_->empty());
  1486. int _nResult = 0;
  1487. // еĸ߽ͬ --- 2010 09 19
  1488. for (int _i = 0; _i != pCadMultiSegments1_->GetSegmentCount(); ++_i)
  1489. {
  1490. SEGMENT _SegmentOut = pCadMultiSegments1_->GetSegment(_i);
  1491. CCadObject* _pCadObjectOut = NULL;
  1492. if (!GetCadObjectFromSegment(_SegmentOut, &_pCadObjectOut))
  1493. continue;
  1494. std::vector<DPOINT2> _vectorTemp;
  1495. int _j = pCadMultiSegments1_->GetID() == pCadMultiSegments2_->GetID() ? _i + 1 : 0;
  1496. for (; _j < pCadMultiSegments2_->GetSegmentCount(); ++_j)
  1497. {
  1498. SEGMENT _SegmentIn = pCadMultiSegments2_->GetSegment(_j);
  1499. CCadObject* _pCadObjectIn = NULL;
  1500. if (!GetCadObjectFromSegment(_SegmentIn, &_pCadObjectIn))
  1501. continue;
  1502. std::vector<DPOINT2> _vectorTemp;
  1503. if (pvectorIntersect_ != NULL)
  1504. _nResult += GetIntersection(_pCadObjectOut, _pCadObjectIn, &_vectorTemp);
  1505. else
  1506. _nResult += GetIntersection(_pCadObjectOut, _pCadObjectIn, NULL);
  1507. if (pvectorIntersect_ != NULL && !_vectorTemp.empty())
  1508. {
  1509. copy(_vectorTemp.begin(), _vectorTemp.end(), back_inserter(*pvectorIntersect_));
  1510. }
  1511. delete _pCadObjectIn;
  1512. }
  1513. delete _pCadObjectOut;
  1514. }
  1515. return _nResult;
  1516. }
  1517. bool nce::GetCadObjectFromSegment(IN const SEGMENT& Segment_, OUT CCadObject** ppCadObject_)
  1518. {
  1519. ASSERT(IsValidDouble(Segment_.ptStart.x));
  1520. ASSERT(IsValidDouble(Segment_.ptStart.y));
  1521. ASSERT(IsValidDouble(Segment_.ptEnd.x));
  1522. ASSERT(IsValidDouble(Segment_.ptEnd.y));
  1523. ASSERT(IsValidDouble(Segment_.nBulge));
  1524. ASSERT(*ppCadObject_ == NULL);
  1525. switch(Segment_.nType)
  1526. {
  1527. case SEGMENT::LINE:
  1528. {
  1529. CCadLine _CadLine(Segment_.ptStart, Segment_.ptEnd);
  1530. *ppCadObject_ = _CadLine.Clone();
  1531. }
  1532. break;
  1533. case SEGMENT::ARC:
  1534. {
  1535. DPOINT2 _ptArcCenter(ncmath::c_nINVALID_DOUBLE, ncmath::c_nINVALID_DOUBLE);
  1536. double _nArcRadius = 0.0;
  1537. double _nArcStartAngle = 0.0, _nArcCentralAngle = 0.0;
  1538. SEGMENT::SolveArc(Segment_.ptStart, Segment_.ptEnd, Segment_.nBulge,
  1539. &_ptArcCenter, &_nArcRadius, &_nArcStartAngle, &_nArcCentralAngle);
  1540. CCadArc _CadArc(_ptArcCenter, _nArcRadius, _nArcStartAngle, fabs(_nArcCentralAngle), Segment_.nBulge > 0);
  1541. *ppCadObject_ = _CadArc.Clone();
  1542. }
  1543. break;
  1544. // ֵ֧ --- 2010 09 19
  1545. case SEGMENT::BEZIER:
  1546. default:
  1547. return false;
  1548. }
  1549. return true;
  1550. }

No Description

Contributors (2)