CalculateElement.js 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657
  1. function CalculateElement(layer) {
  2. this.layer = layer
  3. this.calculateLine = this.layer.calculateLine;
  4. };
  5. CalculateElement.prototype.getSquarePointsFromStair = function (line1, line2, verticalLine1, verticalLine2) {
  6. var tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine1, line1);
  7. var tempjoin3 = this.calculateLine.getIntersectionPoint(verticalLine1, line2);
  8. var tempjoin2 = this.calculateLine.getIntersectionPoint(verticalLine2, line1);
  9. var tempjoin4 = this.calculateLine.getIntersectionPoint(verticalLine2, line2);
  10. var distance = BABYLON.Vector2.Distance(tempjoin1, tempjoin2);
  11. var num = parseInt(distance / this.layer.parameter.staircell);
  12. var count = 1;
  13. var linkedpoints = [];
  14. linkedpoints.push({ 1: tempjoin1, 2: tempjoin3 });
  15. while (count < num) {
  16. var verticalLine = null;
  17. if (verticalLine2.hasOwnProperty('x')) {
  18. diff = (verticalLine2.x - verticalLine1.x) / num;
  19. verticalLine = { a: 0, b: 0, x: (verticalLine2.x - diff * count) };
  20. }
  21. else if (verticalLine2.hasOwnProperty('y')) {
  22. diff = (verticalLine2.y - verticalLine1.y) / num;
  23. verticalLine = { a: 0, b: 0, x: (verticalLine2.y - diff * count) };
  24. }
  25. else {
  26. diff = (verticalLine2.b - verticalLine1.b) / num;
  27. verticalLine = { a: verticalLine2.a, b: (verticalLine2.b - diff * count) };
  28. }
  29. var join1 = this.calculateLine.getIntersectionPoint(verticalLine, line1);
  30. var join2 = this.calculateLine.getIntersectionPoint(verticalLine, line2);
  31. linkedpoints.push({ 1: join1, 2: join2 });
  32. ++count;
  33. }
  34. linkedpoints.push({ 1: tempjoin2, 2: tempjoin4 });
  35. return linkedpoints;
  36. };
  37. CalculateElement.prototype.GetSpiralpoints = function (point) {
  38. var line = {};
  39. var points = [];
  40. var verticalLine = {};
  41. var verticalLine1 = {};
  42. var verticalLine2 = {};
  43. points.push({ x: (point.x + this.layer.parameter.spiralR1), y: point.y });
  44. points.push({ x: (point.x - this.layer.parameter.spiralR1), y: point.y });
  45. for (var i = 1; i < 6; ++i) {
  46. line.a = Math.tan(i * 30 * Math.PI / 180);
  47. line.b = point.y - line.a * point.x;
  48. verticalLine.a = -1 / line.a;
  49. verticalLine1.a = -1 / line.a;
  50. verticalLine2.a = -1 / line.a;
  51. verticalLine.b = point.y + 1 / line.a * point.x;
  52. verticalLine1.b = verticalLine.b + this.layer.calculateLine.driftY3(verticalLine.a, this.layer.parameter.spiralR1);
  53. verticalLine2.b = verticalLine.b - this.layer.calculateLine.driftY3(verticalLine.a, this.layer.parameter.spiralR1);
  54. var join1 = this.layer.calculateLine.getIntersectionPoint(verticalLine1, line);
  55. points.push(join1);
  56. var join2 = this.layer.calculateLine.getIntersectionPoint(verticalLine2, line);
  57. points.push(join2);
  58. }
  59. return points;
  60. };
  61. //三个点的时候
  62. CalculateElement.prototype.getAllPointsFromStair = function (points) {
  63. var allpoints = {};
  64. var linkedpoints = [];
  65. //表示不是闭合的
  66. var state = 1;
  67. var interval1 = (this.layer.parameter.stairWidth + this.layer.parameter.stairMeasure);
  68. var interval2 = this.layer.parameter.stairWidth;
  69. //和墙没关系,只是使用了它的函数
  70. var lines = this.getWalllines(points, state, interval1, interval2);
  71. var edgepoints = this.getOutlineMeasureJoin(lines, points, state);
  72. var verticalLine_a = null;
  73. var verticalLine_b = null;
  74. for (var i = 0; i < edgepoints.border1.length - 1; ++i) {
  75. var point11 = edgepoints.border1[i];
  76. var point12 = edgepoints.border1[i + 1];
  77. var point21 = edgepoints.border2[i];
  78. var point22 = edgepoints.border2[i + 1];
  79. var line1 = this.calculateLine.createLine(point11, point12);
  80. var line2 = this.calculateLine.createLine(point21, point22);
  81. var num, extendnum, extenddiff, verticalLine1, verticalLine3;
  82. var join1, join2, join3, join4;
  83. var extendDistance = null;
  84. verticalLine1 = this.calculateLine.getVerticalLine(line2, point21);
  85. verticalLine3 = this.calculateLine.getVerticalLine(line2, point11);
  86. var tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine1, line1);
  87. var distance1 = BABYLON.Vector2.Distance(tempjoin1, point11);
  88. if (distance1 < this.layer.parameter.minInterval) {
  89. linkedpoints.push({ 1: point11, 2: point21 });
  90. verticalLine_a = verticalLine1;
  91. }
  92. else if (this.calculateLine.containPoint(point11, point12, tempjoin1)) {
  93. verticalLine_a = verticalLine1;
  94. num = parseInt(distance1 / this.layer.parameter.staircell);
  95. if (num == 0 && distance1 > this.layer.parameter.minInterval) {
  96. num = 1;
  97. }
  98. var count = 0;
  99. while (count < num) {
  100. var verticalLine = null;
  101. if (verticalLine3.hasOwnProperty('x')) {
  102. diff = (verticalLine3.x - verticalLine1.x) / num;
  103. verticalLine = { a: 0, b: 0, x: (verticalLine3.x - diff * count) };
  104. }
  105. else if (verticalLine3.hasOwnProperty('y')) {
  106. diff = (verticalLine3.y - verticalLine1.y) / num;
  107. verticalLine = { a: 0, b: 0, x: (verticalLine3.y - diff * count) };
  108. }
  109. else {
  110. diff = (verticalLine3.b - verticalLine1.b) / num;
  111. verticalLine = { a: verticalLine3.a, b: (verticalLine3.b - diff * count) };
  112. }
  113. var p = this.calculateLine.getIntersectionPoint(verticalLine, line1);
  114. linkedpoints.push({ 1: p, 2: point21 });
  115. ++count;
  116. }
  117. }
  118. else {
  119. verticalLine_a = verticalLine3;
  120. tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine3, line2);
  121. distance1 = BABYLON.Vector2.Distance(tempjoin1, point21);
  122. num = parseInt(distance1 / this.layer.parameter.staircell);
  123. if (num == 0 && distance1 > this.layer.parameter.minInterval) {
  124. num = 1;
  125. }
  126. var count = 0;
  127. while (count < num) {
  128. var verticalLine = null;
  129. if (verticalLine1.hasOwnProperty('x')) {
  130. diff = (verticalLine1.x - verticalLine3.x) / num;
  131. verticalLine = { a: 0, b: 0, x: (verticalLine1.x - diff * count) };
  132. }
  133. else if (verticalLine1.hasOwnProperty('y')) {
  134. diff = (verticalLine1.y - verticalLine3.y) / num;
  135. verticalLine = { a: 0, b: 0, x: (verticalLine1.y - diff * count) };
  136. }
  137. else {
  138. diff = (verticalLine1.b - verticalLine3.b) / num;
  139. verticalLine = { a: verticalLine1.a, b: (verticalLine1.b - diff * count) };
  140. }
  141. var p = this.calculateLine.getIntersectionPoint(verticalLine, line2);
  142. linkedpoints.push({ 1: point11, 2: p });
  143. ++count;
  144. }
  145. }
  146. var verticalLine2 = this.calculateLine.getVerticalLine(line2, point22);
  147. var verticalLine4 = this.calculateLine.getVerticalLine(line2, point12);
  148. if (i != edgepoints.border1.length - 2) {
  149. var tempjoin2 = this.calculateLine.getIntersectionPoint(verticalLine2, line1);
  150. var distance2 = BABYLON.Vector2.Distance(tempjoin2, point12);
  151. if (distance2 < this.layer.parameter.minInterval) {
  152. linkedpoints.push({ 1: point12, 2: point22 });
  153. verticalLine_b = verticalLine2;
  154. var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
  155. linkedpoints = linkedpoints.concat(linked);
  156. }
  157. else if (this.calculateLine.containPoint(point11, point12, tempjoin2)) {
  158. verticalLine_b = verticalLine2;
  159. var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
  160. linkedpoints = linkedpoints.concat(linked);
  161. verticalLine_a = null;
  162. verticalLine_b = null;
  163. num = parseInt(distance2 / this.layer.parameter.staircell);
  164. if (num == 0 && distance1 > this.layer.parameter.minInterval) {
  165. num = 1;
  166. }
  167. var count = 1;
  168. while (count < num) {
  169. var verticalLine = null;
  170. if (verticalLine4.hasOwnProperty('x')) {
  171. diff = (verticalLine4.x - verticalLine2.x) / num;
  172. verticalLine = { a: 0, b: 0, x: (verticalLine4.x - diff * count) };
  173. }
  174. else if (verticalLine4.hasOwnProperty('y')) {
  175. diff = (verticalLine4.y - verticalLine2.y) / num;
  176. verticalLine = { a: 0, b: 0, x: (verticalLine4.y - diff * count) };
  177. }
  178. else {
  179. diff = (verticalLine4.b - verticalLine2.b) / num;
  180. verticalLine = { a: verticalLine4.a, b: (verticalLine4.b - diff * count) };
  181. }
  182. var p = this.calculateLine.getIntersectionPoint(verticalLine, line1);
  183. linkedpoints.push({ 1: p, 2: point22 });
  184. ++count;
  185. }
  186. }
  187. else {
  188. verticalLine_b = verticalLine4;
  189. var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
  190. linkedpoints = linkedpoints.concat(linked);
  191. verticalLine_a = null;
  192. verticalLine_b = null;
  193. num = parseInt(distance2 / this.layer.parameter.staircell);
  194. if (num == 0 && distance1 > this.layer.parameter.minInterval) {
  195. num = 1;
  196. }
  197. var count = 1;
  198. while (count < num) {
  199. var verticalLine = null;
  200. if (verticalLine2.hasOwnProperty('x')) {
  201. diff = (verticalLine2.x - verticalLine4.x) / num;
  202. verticalLine = { a: 0, b: 0, x: (verticalLine2.x - diff * count) };
  203. }
  204. else if (verticalLine2.hasOwnProperty('y')) {
  205. diff = (verticalLine2.y - verticalLine4.y) / num;
  206. verticalLine = { a: 0, b: 0, x: (verticalLine2.y - diff * count) };
  207. }
  208. else {
  209. diff = (verticalLine2.b - verticalLine4.b) / num;
  210. verticalLine = { a: verticalLine2.a, b: (verticalLine2.b - diff * count) };
  211. }
  212. var p = this.calculateLine.getIntersectionPoint(verticalLine, line2);
  213. linkedpoints.push({ 1: point12, 2: p });
  214. ++count;
  215. }
  216. }
  217. }
  218. else {
  219. verticalLine_b = verticalLine2;
  220. var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
  221. linkedpoints = linkedpoints.concat(linked);
  222. verticalLine_a = null;
  223. verticalLine_b = null;
  224. }
  225. }
  226. allpoints.vertical = linkedpoints;
  227. allpoints.border1 = edgepoints.border1;
  228. allpoints.border2 = edgepoints.border2;
  229. allpoints.arrows1 = edgepoints.arrows1;
  230. allpoints.arrows2 = edgepoints.arrows2;
  231. return allpoints;
  232. };
  233. /*
  234. //两个点的时候
  235. CalculateElement.prototype.getAllPointsFromStair=function(point1,point2)
  236. {
  237. var line = this.calculateLine.createLine(point1,point2);
  238. var lines = this.calculateLine.getParallelLineForDistance(line,this.layer.parameter.stairWidth);
  239. var start1 = this.calculateLine.getJoinLinePoint(point1,lines.line1);
  240. var start2 = this.calculateLine.getJoinLinePoint(point1,lines.line2);
  241. var end1 = this.calculateLine.getJoinLinePoint(point2,lines.line1);
  242. var end2 = this.calculateLine.getJoinLinePoint(point2,lines.line2);
  243. var distance = BABYLON.Vector2.Distance(point1,point2);
  244. var num = parseInt(distance/this.layer.parameter.staircell);
  245. //针对直线的函数
  246. var divide=null;
  247. var verticalLine1 = this.calculateLine.getVerticalLine(line,point1);
  248. var verticalLine2 = this.calculateLine.getVerticalLine(line,point2);
  249. var diff=null;
  250. var count=1;
  251. var points=[];
  252. points.push({1:start1,2:start2});
  253. while(count<num)
  254. {
  255. var verticalLine=null;
  256. if(verticalLine1.hasOwnProperty('x'))
  257. {
  258. diff=(verticalLine1.x-verticalLine2.x)/num;
  259. verticalLine={a:0,b:0,x:(verticalLine1.x-diff*count)};
  260. }
  261. else if(verticalLine1.hasOwnProperty('y'))
  262. {
  263. diff=(verticalLine1.y-verticalLine2.y)/num;
  264. verticalLine={a:0,b:0,x:(verticalLine1.y-diff*count)};
  265. }
  266. else
  267. {
  268. diff=(verticalLine1.b-verticalLine2.b)/num;
  269. verticalLine={a:verticalLine1.a,b:(verticalLine1.b-diff*count)};
  270. }
  271. var p1 = this.calculateLine.getIntersectionPoint(verticalLine,lines.line1);
  272. var p2 = this.calculateLine.getIntersectionPoint(verticalLine,lines.line2);
  273. points.push({1:p1,2:p2});
  274. ++count;
  275. }
  276. points.push({1:end1,2:end2});
  277. return points;
  278. };
  279. */
  280. //点之间的距离小于r,就是包含
  281. CalculateElement.prototype.pointContain = function (point1, point2, r) {
  282. var distance = BABYLON.Vector2.Distance(point1, point2);
  283. if (distance < r) {
  284. return true;
  285. }
  286. else {
  287. return false;
  288. }
  289. };
  290. //point1到point2的直线,宽度是2*deep,是否包含point
  291. CalculateElement.prototype.lineContain = function (point1, point2, point, deep) {
  292. var line = this.calculateLine.createLine(point1, point2);
  293. var join = this.calculateLine.getJoinLinePoint(point, line);
  294. var flag = this.calculateLine.containPoint(point1, point2, join);
  295. if (!flag) {
  296. return false;
  297. }
  298. else if (BABYLON.Vector2.Distance(join, point) < deep) {
  299. return true;
  300. }
  301. else {
  302. return false;
  303. }
  304. };
  305. CalculateElement.prototype.singleSymbolContain = function (point, id) {
  306. if (this.layer.vectors[id].geometry.floor != this.layer.selectFloor) {
  307. return null;
  308. }
  309. var r;
  310. var points = this.layer.vectors[id].geometry.points;
  311. var result = {};
  312. //当是墙的时候
  313. if (this.layer.vectors[id].geometry.geoType == "Wall") {
  314. if (this.layer.vectors[id].geometry.wallType == 1) {
  315. r = wallThickness / 2;
  316. }
  317. else {
  318. r = partitionThickness / 2;
  319. }
  320. }
  321. //当是楼梯的时候
  322. else if (this.layer.vectors[id].geometry.geoType == "WinderStair") {
  323. r = this.layer.parameter.stairWidth;
  324. }
  325. else if (this.layer.vectors[id].geometry.geoType == "Spiral") {
  326. var distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point1);
  327. if (distance < this.layer.parameter.spiralR2) {
  328. result.id = id;
  329. result.type = 0;
  330. result.index = 1;
  331. result.geoType = "Spiral";
  332. return result;
  333. }
  334. distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point2);
  335. if (distance < this.layer.parameter.spiralR2) {
  336. result.id = id;
  337. result.type = 0;
  338. result.index = 2;
  339. result.geoType = "Spiral";
  340. return result;
  341. }
  342. distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point);
  343. if (distance < this.layer.parameter.spiralR1) {
  344. result.id = id;
  345. result.type = 1;
  346. result.index = null;
  347. result.geoType = "Spiral";
  348. return result;
  349. }
  350. return null;
  351. }
  352. if (points.length < 2) {
  353. alert("CalculateElement:10");
  354. return null;
  355. }
  356. var endindex = null;
  357. //判断拐角
  358. for (var i = 0; i < points.length - 1; ++i) {
  359. var point1 = points[i];
  360. if (this.pointContain(point1, point, r)) {
  361. result.id = id;
  362. result.index = i;
  363. result.type = 0;
  364. return result;
  365. }
  366. var point2 = points[i + 1];
  367. if (this.pointContain(point2, point, r)) {
  368. result.id = id;
  369. result.index = i + 1;
  370. result.type = 0;
  371. return result;
  372. }
  373. }
  374. for (var i = 0; i < points.length; ++i) {
  375. var point1 = points[i];
  376. endindex = this.getNextIndex(points, i);
  377. var point2 = points[endindex];
  378. if (i == points.length - 1 && this.layer.vectors[id].geometry.state == 1) {
  379. break;
  380. }
  381. else if (i == points.length - 1 && this.layer.vectors[id].geometry.geoType == "WinderStair") {
  382. break;
  383. }
  384. var line = this.calculateLine.createLine(point1, point2);
  385. if (this.lineContain(point1, point2, point, r)) {
  386. result.id = id;
  387. result.index = i;
  388. result.type = 1;
  389. result.endindex = endindex;
  390. return result;
  391. }
  392. }
  393. return null;
  394. };
  395. //wallId的墙是否包含point,与singleWallContain不同的是当point离wallId的距离小于thick/2就算包含
  396. CalculateElement.prototype.singleWallContain2 = function (point, id, index, wallId) {
  397. var result = this.singleWallContain(point, wallId);
  398. if (result == null) {
  399. result = {};
  400. var d = this.layer.vectors[id].geometry.wallInfo[index].thick / 2;
  401. var points = this.layer.vectors[wallId].geometry.points;
  402. for (var i = 0; i < points.length; ++i) {
  403. var point1 = points[i];
  404. var endindex = this.getNextIndex(points, i);
  405. var point2 = points[endindex];
  406. if (i == points.length - 1 && this.layer.vectors[wallId].geometry.state == 1) {
  407. break;
  408. }
  409. var deep = this.layer.vectors[wallId].geometry.wallInfo[i].thick / 2 + d;
  410. var flag = lineContain(point1, point2, point, deep);
  411. if (flag) {
  412. result.id = wallId;
  413. result.index = Math.min(i, endindex);
  414. result.endindex = Math.max(i, endindex);
  415. result.thick = this.layer.vectors[wallId].geometry.wallInfo[i].thick;
  416. return result;
  417. }
  418. }
  419. return null;
  420. }
  421. }
  422. ///id是wallId的墙是否包含point
  423. CalculateElement.prototype.singleWallContain = function (point, wallId) {
  424. if (this.layer.vectors[wallId].geometry.floor != this.layer.selectFloor) {
  425. return null;
  426. }
  427. var points = this.layer.vectors[wallId].geometry.points;
  428. var type = this.layer.vectors[wallId].geometry.wallType;
  429. var r;
  430. if (type == 1) {
  431. r = wallThickness / 2;
  432. }
  433. else {
  434. r = partitionThickness / 2;
  435. }
  436. if (points.length < 2) {
  437. alert("CalculateElement:10");
  438. return null;
  439. }
  440. var result = {};
  441. var endindex = null;
  442. //判断拐角
  443. for (var i = 0; i < points.length - 1; ++i) {
  444. var point1 = points[i];
  445. if (this.pointContain(point1, point, r)) {
  446. result.id = wallId;
  447. result.index = i;
  448. result.type = 0;
  449. return result;
  450. }
  451. var point2 = points[i + 1];
  452. if (this.pointContain(point2, point, r)) {
  453. result.id = wallId;
  454. result.index = i + 1;
  455. result.type = 0;
  456. return result;
  457. }
  458. }
  459. for (var i = 0; i < points.length; ++i) {
  460. var point1 = points[i];
  461. endindex = this.getNextIndex(points, i);
  462. var point2 = points[endindex];
  463. if (i == points.length - 1 && this.layer.vectors[wallId].geometry.state == 1) {
  464. break;
  465. }
  466. var line = this.calculateLine.createLine(point1, point2);
  467. r = this.layer.vectors[wallId].geometry.wallInfo[i].thick / 2 + wallThickness / 2;
  468. if (this.lineContain(point1, point2, point, r)) {
  469. result.id = wallId;
  470. result.index = i;
  471. result.type = 1;
  472. result.endindex = endindex;
  473. return result;
  474. }
  475. }
  476. return null;
  477. };
  478. //有没有symbol包含point,如果有返回该symbol
  479. //r主要是可能是墙或隔断的宽度
  480. CalculateElement.prototype.symbolsContain = function (point) {
  481. //判断当前选择的有没有symbol
  482. for (var key in this.layer.vectors[this.layer.currentState.currentWallId].symbol2Ds) {
  483. var symbol2d = this.layer.vectors[this.layer.currentState.currentWallId].symbol2Ds[key];
  484. var r = this.layer.vectors[this.layer.currentState.currentWallId].geometry.wallInfo[Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex)].thick;
  485. if (this.lineContain(symbol2d.geometry.point1, symbol2d.geometry.point2, point, r)) {
  486. return symbol2d;
  487. }
  488. }
  489. return null;
  490. };
  491. CalculateElement.prototype.stairsContain = function (point, exceptid) {
  492. var len = this.layer.data2d.stairIds.length;
  493. var result = null;
  494. for (var i = 0; i < len; ++i) {
  495. var stairId = this.layer.data2d.stairIds[i];
  496. if (this.layer.vectors[stairId].geometry.floor != this.layer.selectFloor) {
  497. continue;
  498. }
  499. result = this.singleSymbolContain(point, stairId);
  500. if (result != null) {
  501. this.layer.currentState.currentendlinePointIndex = result.endindex;
  502. this.layer.currentState.currentStairId = stairId;
  503. this.layer.currentState.currentstartlinePointIndex = result.index;
  504. return result;
  505. }
  506. }
  507. return result;
  508. };
  509. //返回0表示当前鼠标指向的是某个点
  510. //返回1表示当前鼠标指向的是某条线
  511. //返回2表示当前鼠标指向的是空白
  512. CalculateElement.prototype.wallsContain = function (point, exceptid) {
  513. var len = this.layer.data2d.wallIds.length;
  514. var result = null;
  515. var result2 = null;
  516. for (var i = 0; i < len; ++i) {
  517. var wallId = this.layer.data2d.wallIds[i];
  518. if (exceptid != null && typeof (exceptid != "undefined")) {
  519. if (wallId == exceptid) {
  520. continue;
  521. }
  522. }
  523. if (this.layer.vectors[wallId].geometry.floor != this.layer.selectFloor) {
  524. continue;
  525. }
  526. result = this.singleWallContain(point, wallId);
  527. if (result != null) {
  528. this.layer.currentState.currentendlinePointIndex = result.endindex;
  529. this.layer.currentState.currentWallId = result.id;
  530. this.layer.currentState.currentstartlinePointIndex = result.index;
  531. if (result.type == 0) {
  532. return result;
  533. }
  534. else {
  535. result2 = result;
  536. }
  537. }
  538. }
  539. return result2;
  540. };
  541. //得到挨着index1,index2的墙的线段
  542. CalculateElement.prototype.getOrginLine = function (len, id, index1, index2) {
  543. var side1 = this.getSideIndex(len, index1);
  544. var side2 = this.getSideIndex(len, index2);
  545. var sideline1 = [];
  546. var sideline2 = [];
  547. var point1index = null;
  548. var point2index = null;
  549. if (side1.pre == index2) {
  550. sideline1.push(index1);
  551. sideline1.push(side1.next);
  552. point1index = side1.next;
  553. }
  554. else {
  555. sideline1.push(index1);
  556. sideline1.push(side1.pre);
  557. point1index = side1.pre;
  558. }
  559. if (side2.pre == index1) {
  560. sideline2.push(index2);
  561. sideline2.push(side2.next);
  562. point2index = side2.next;
  563. }
  564. else {
  565. sideline2.push(index2);
  566. sideline2.push(side2.pre);
  567. point2index = side2.pre;
  568. }
  569. return { line1: sideline1, point1: point1index, line2: sideline2, point2: point2index };
  570. };
  571. //index两旁
  572. CalculateElement.prototype.getSideIndex = function (len, index) {
  573. var pre = index - 1;
  574. var next = index + 1;
  575. if (pre < 0) {
  576. pre = len - 1;
  577. }
  578. if (next == len) {
  579. next = 0;
  580. }
  581. return { pre: pre, next: next };
  582. };
  583. //获取symbol两个端点离鼠标与symbol交点的距离
  584. CalculateElement.prototype.getSymbolDistance = function (line, point, symbol) {
  585. var join = this.calculateLine.getJoinLinePoint(line, point);
  586. var distance1 = BABYLON.Vector2.Distance(join, symbol.point1);
  587. var distance2 = BABYLON.Vector2.Distance(join, symbol.point2);
  588. return { dis1: distance1, dis2: distance2 };
  589. };
  590. //points数组里面,在index前面的点
  591. CalculateElement.prototype.getPrePoint = function (points, index) {
  592. var pre = index - 1;
  593. if (pre > -1) {
  594. return points[pre];
  595. }
  596. else {
  597. return points[points.length - 1];
  598. }
  599. };
  600. //points数组里面,在index前面的序号
  601. CalculateElement.prototype.getPreIndex = function (points, index) {
  602. var pre = index - 1;
  603. if (pre == -1) {
  604. pre = points.length - 1;
  605. }
  606. return pre;
  607. };
  608. //points数组里面,在index后面的点
  609. CalculateElement.prototype.getNextPoint = function (points, index) {
  610. var next = index + 1;
  611. if (next > points.length - 1) {
  612. return points[0];
  613. }
  614. else {
  615. return points[next];
  616. }
  617. };
  618. //points数组里面,在index后面的序号
  619. CalculateElement.prototype.getNextIndex = function (points, index, state) {
  620. var next = index + 1;
  621. if (next > points.length - 1 && (typeof (state) == "undefined" || state == 0)) {
  622. next = 0;
  623. }
  624. else if (next > points.length - 1) {
  625. next = index - 1;
  626. }
  627. return next;
  628. };
  629. //在长度是len的数组里,序号index和num是否相邻
  630. CalculateElement.prototype.isNeighbor = function (len, index, num) {
  631. if (Math.abs(index - num) == 1) {
  632. return true;
  633. }
  634. else if (index == 0 && (num == len - 1)) {
  635. return true;
  636. }
  637. else if ((index == len - 1) && num == 0) {
  638. return true;
  639. }
  640. else {
  641. return false;
  642. }
  643. };
  644. //计算墙的尺寸
  645. CalculateElement.prototype.computerMeasure = function (geometry) {
  646. var points = geometry.points;
  647. var state = geometry.state;
  648. var type = geometry.wallType;
  649. var lines, interval;
  650. /*
  651. if(type==2)
  652. {
  653. interval=partitionThickness;
  654. }
  655. else
  656. {
  657. interval=wallThickness;
  658. }
  659. */
  660. //lines=this.getWalllines(points,state,interval,interval/2);
  661. lines = this.getWalllines2(geometry);
  662. var wallpoint = this.getOutlineMeasureJoin(lines, points, state);
  663. //var wallpoint=this.getOutlineMeasureJoin2(lines,geometry);
  664. return wallpoint;
  665. };
  666. //从一组border里面挑选出合适的
  667. CalculateElement.prototype.getIndexFromLines = function (lines, point1, point2) {
  668. var seg = {};
  669. seg.point1 = point1;
  670. seg.point2 = point2;
  671. var joins = {};
  672. for (var i = 0; i < lines.length; ++i) {
  673. var seg1 = {};
  674. seg1.point1 = this.layer.vectors[lines[i].id].geometry.wallInfo[lines[i].index1][lines[i].border];
  675. seg1.point2 = this.layer.vectors[lines[i].id].geometry.wallInfo[lines[i].index2][lines[i].border];
  676. var join = this.calculateLine.isjoin(seg, seg1);
  677. if (join == null) {
  678. continue;
  679. }
  680. else {
  681. joins[i] = join;
  682. }
  683. }
  684. var index = null;
  685. for (var key in joins) {
  686. if (index == null) {
  687. index = key;
  688. }
  689. else {
  690. var d1 = BABYLON.Vector2.Distance(point2, joins[key]);
  691. var d2 = BABYLON.Vector2.Distance(point2, joins[index]);
  692. if (d1 < d2) {
  693. index = key;
  694. }
  695. }
  696. }
  697. if (index == null) {
  698. return null;
  699. }
  700. else {
  701. return { index: index, join: joins[key] };
  702. }
  703. };
  704. //调整不闭合墙的端点
  705. CalculateElement.prototype.changeEndPointMeasure = function (wallpoint, geometry) {
  706. if (typeof (geometry.firstLines) != "undefined" && geometry.firstLines.length > 0) {
  707. var result = this.singleWallContain(geometry.points[0], geometry.firstLines[0].id);
  708. if (result != null) {
  709. var jo = this.getIndexFromLines(geometry.firstLines, wallpoint.border1[0], wallpoint.border1[1]);
  710. if (jo != null) {
  711. wallpoint.border1[0] = jo["join"];
  712. var arrowjoin1 = this.calculateLine.getJoinLinePoint(jo["join"], this.calculateLine.createLine(wallpoint.arrows1[0], wallpoint.arrows1[1]));
  713. if (arrowjoin1 != null) {
  714. wallpoint.arrows1[0] = arrowjoin1;
  715. }
  716. var seg = {};
  717. seg.point1 = this.layer.vectors[geometry.firstLines[jo["index"]].id].geometry.wallInfo[geometry.firstLines[jo["index"]].index1][geometry.firstLines[jo["index"]].border];
  718. seg.point2 = this.layer.vectors[geometry.firstLines[jo["index"]].id].geometry.wallInfo[geometry.firstLines[jo["index"]].index2][geometry.firstLines[jo["index"]].border];
  719. var jn = this.calculateLine.isjoin(seg, { point1: wallpoint.border2[0], point2: wallpoint.border2[1] });
  720. if (jn != null) {
  721. wallpoint.border2[0] = jn;
  722. var arrowjoin2 = this.calculateLine.getJoinLinePoint(jn, this.calculateLine.createLine(wallpoint.arrows2[0], wallpoint.arrows2[1]));
  723. if (arrowjoin2 != null) {
  724. wallpoint.arrows2[0] = arrowjoin2;
  725. }
  726. }
  727. }
  728. }
  729. else {
  730. delete geometry.firstLines;
  731. }
  732. }
  733. if (typeof (geometry.endLines) != "undefined" && geometry.endLines.length > 0) {
  734. var len = wallpoint.border1.length;
  735. var result = this.singleWallContain(geometry.points[len - 1], geometry.endLines[0].id);
  736. if (result != null) {
  737. var jo = this.getIndexFromLines(geometry.endLines, wallpoint.border1[0], wallpoint.border1[1]);
  738. if (jo != null) {
  739. wallpoint.border1[len - 1] = jo["join"];
  740. var arrowjoin1 = this.calculateLine.getJoinLinePoint(jo["join"], this.calculateLine.createLine(wallpoint.arrows1[len - 1], wallpoint.arrows1[len - 2]));
  741. if (arrowjoin1 != null) {
  742. wallpoint.arrows1[len - 1] = arrowjoin1;
  743. }
  744. var seg = {};
  745. seg.point1 = this.layer.vectors[geometry.endLines[jo["index"]].id].geometry.wallInfo[geometry.endLines[jo["index"]].index1][geometry.endLines[jo["index"]].border];
  746. seg.point2 = this.layer.vectors[geometry.endLines[jo["index"]].id].geometry.wallInfo[geometry.endLines[jo["index"]].index2][geometry.endLines[jo["index"]].border];
  747. var jn = this.calculateLine.isjoin(seg, { point1: wallpoint.border2[len - 2], point2: wallpoint.border2[len - 1] });
  748. if (jn != null) {
  749. wallpoint.border2[len - 1] = jn;
  750. var arrowjoin2 = this.calculateLine.getJoinLinePoint(jn, this.calculateLine.createLine(wallpoint.arrows2[len - 1], wallpoint.arrows2[len - 2]));
  751. if (arrowjoin2 != null) {
  752. wallpoint.arrows2[len - 1] = arrowjoin2;
  753. }
  754. }
  755. }
  756. }
  757. else {
  758. delete geometry.endLines;
  759. }
  760. }
  761. return wallpoint;
  762. };
  763. //获得墙的内外侧
  764. CalculateElement.prototype.getOneWallOutline = function (line, interval1, interval2) {
  765. var border1 = {};
  766. var border2 = {};
  767. var measure1 = {};
  768. var measure2 = {};
  769. if (line.a == 0) {
  770. measure1.a = 0;
  771. measure1.b = 0
  772. measure2.a = 0;
  773. measure2.b = 0
  774. border1.a = 0;
  775. border1.b = 0
  776. border2.a = 0;
  777. border2.b = 0
  778. if (line.hasOwnProperty('x')) {
  779. measure1.x = line.x + interval1;
  780. border1.x = line.x + interval2;
  781. measure2.x = line.x - interval1;
  782. border2.x = line.x - interval2;
  783. }
  784. else if (line.hasOwnProperty('y')) {
  785. measure1.y = line.y + interval1;
  786. border1.y = line.y + interval2;
  787. measure2.y = line.y - interval1;
  788. border2.y = line.y - interval2;
  789. }
  790. }
  791. else {
  792. //测量
  793. measure1.a = line.a;
  794. //measure1.b= line.b+this.calculateLine.driftY(measure1.a,1,type);
  795. measure1.b = line.b + this.calculateLine.driftY3(measure1.a, interval1);
  796. measure2.a = line.a;
  797. //measure2.b= line.b-this.calculateLine.driftY(measure2.a,1,type);
  798. measure2.b = line.b - this.calculateLine.driftY3(measure2.a, interval1);
  799. //墙外侧
  800. border1.a = line.a;
  801. border1.b = line.b + this.calculateLine.driftY3(border1.a, interval2);
  802. border2.a = line.a;
  803. border2.b = line.b - this.calculateLine.driftY3(border2.a, interval2);
  804. }
  805. return { b1: border1, b2: border2, m1: measure1, m2: measure2 };
  806. };
  807. /*
  808. //删除墙后,border变了
  809. CalculateElement.prototype.changeWallEndpoint=function(point,line1,line2)
  810. {
  811. var verticalLine=this.calculateLine.getVerticalLine(line1,point);
  812. var join1=this.getIntersectionPoint(line1,verticalLine);
  813. return join;
  814. }
  815. */
  816. //墙的厚度可变
  817. CalculateElement.prototype.getWalllines2 = function (geometry) {
  818. var points = geometry.points;
  819. var wallInfo = geometry.wallInfo;
  820. var ringflag = geometry.state;
  821. var type = geometry.wallType;
  822. var d;
  823. if (type == 2) {
  824. d = partitionThickness / 2;
  825. }
  826. else {
  827. d = wallThickness / 2;
  828. }
  829. var result = { border1: [], border2: [], arrows1: [], arrows2: [] };
  830. var interval1 = wallInfo[0].thick / 2 + d;
  831. // var interval2 = wallInfo[0].thick / 2;
  832. var interval2 = 0.00001;
  833. var outlines = this.getOneWallOutline(this.calculateLine.createLine(points[0], points[1]), interval1, interval2);
  834. result.border1.push(outlines.b1);
  835. result.border2.push(outlines.b2);
  836. result.arrows1.push(outlines.m1);
  837. result.arrows2.push(outlines.m2);
  838. for (var i = 1; i < points.length; ++i) {
  839. var j = i - 1;
  840. var k = i + 1;
  841. if (i == points.length - 1) {
  842. k = 0;
  843. }
  844. if (ringflag == 1 && i == points.length - 1) //不闭合
  845. {
  846. return result;
  847. }
  848. var line = this.calculateLine.createLine(points[i], points[k]);
  849. var radial = { point1: points[i], point2: points[k] };
  850. var outlines1 = { b1: result.border1[result.border1.length - 1], b2: result.border2[result.border2.length - 1], m1: result.arrows1[result.arrows1.length - 1], m2: result.arrows2[result.arrows2.length - 1] };
  851. interval1 = wallInfo[i].thick / 2 + d;
  852. // interval2 = wallInfo[i].thick / 2;
  853. interval2 = 0.00001;
  854. var outlines2 = this.getOneWallOutline(line, interval1, interval2);
  855. var join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b1);
  856. if (join1 == null) {
  857. join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
  858. }
  859. var join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b2);
  860. if (join2 == null) {
  861. join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
  862. }
  863. var _join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b2);
  864. if (_join1 == null) {
  865. _join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
  866. }
  867. var _join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b1);
  868. if (_join2 == null) {
  869. _join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
  870. }
  871. var line2 = this.calculateLine.createLine(points[i], points[j]);
  872. var radial2 = { point1: points[i], point2: points[j] };
  873. var nextseg1 = {};
  874. var nextseg3 = {};
  875. var nextseg2 = {};
  876. var nextseg4 = {};
  877. nextseg1.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b1);
  878. nextseg1.point2 = join1;
  879. nextseg3.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b2);
  880. nextseg3.point2 = join2;
  881. nextseg2.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b1);
  882. nextseg2.point2 = join1;
  883. nextseg4.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b2);
  884. nextseg4.point2 = join2;
  885. if (this.calculateLine.isjoin3(nextseg1, radial2) || this.calculateLine.isjoin3(nextseg3, radial2) || this.calculateLine.isjoin3(nextseg2, radial) || this.calculateLine.isjoin3(nextseg4, radial) || this.calculateLine.isjoin3(nextseg1, radial) || this.calculateLine.isjoin3(nextseg3, radial) || this.calculateLine.isjoin3(nextseg2, radial2) || this.calculateLine.isjoin3(nextseg4, radial2)) {
  886. result.border1.push(outlines2.b2);
  887. result.border2.push(outlines2.b1);
  888. result.arrows1.push(outlines2.m2);
  889. result.arrows2.push(outlines2.m1);
  890. }
  891. else {
  892. result.border1.push(outlines2.b1);
  893. result.border2.push(outlines2.b2);
  894. result.arrows1.push(outlines2.m1);
  895. result.arrows2.push(outlines2.m2);
  896. }
  897. }
  898. return result;
  899. };
  900. //获取墙的border和arrows
  901. CalculateElement.prototype.getWalllines = function (points, ringflag, interval1, interval2) {
  902. var result = { border1: [], border2: [], arrows1: [], arrows2: [] };
  903. var outlines = this.getOneWallOutline(this.calculateLine.createLine(points[0], points[1]), interval1, interval2);
  904. result.border1.push(outlines.b1);
  905. result.border2.push(outlines.b2);
  906. result.arrows1.push(outlines.m1);
  907. result.arrows2.push(outlines.m2);
  908. for (var i = 1; i < points.length; ++i) {
  909. var j = i - 1;
  910. var k = i + 1;
  911. if (i == points.length - 1) {
  912. k = 0;
  913. }
  914. if (ringflag == 1 && i == points.length - 1) //不闭合
  915. {
  916. return result;
  917. }
  918. var line = this.calculateLine.createLine(points[i], points[k]);
  919. var radial = { point1: points[i], point2: points[k] };
  920. var outlines1 = { b1: result.border1[result.border1.length - 1], b2: result.border2[result.border2.length - 1], m1: result.arrows1[result.arrows1.length - 1], m2: result.arrows2[result.arrows2.length - 1] };
  921. var outlines2 = this.getOneWallOutline(line, interval1, interval2);
  922. var join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b1);
  923. if (join1 == null) {
  924. join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
  925. }
  926. var join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b2);
  927. if (join2 == null) {
  928. join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
  929. }
  930. var _join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b2);
  931. if (_join1 == null) {
  932. _join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
  933. }
  934. var _join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b1);
  935. if (_join2 == null) {
  936. _join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
  937. }
  938. var line2 = this.calculateLine.createLine(points[i], points[j]);
  939. var radial2 = { point1: points[i], point2: points[j] };
  940. var nextseg1 = {};
  941. var nextseg3 = {};
  942. var nextseg2 = {};
  943. var nextseg4 = {};
  944. nextseg1.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b1);
  945. nextseg1.point2 = join1;
  946. nextseg3.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b2);
  947. nextseg3.point2 = join2;
  948. nextseg2.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b1);
  949. nextseg2.point2 = join1;
  950. nextseg4.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b2);
  951. nextseg4.point2 = join2;
  952. if (this.calculateLine.isjoin3(nextseg1, radial2) || this.calculateLine.isjoin3(nextseg3, radial2) || this.calculateLine.isjoin3(nextseg2, radial) || this.calculateLine.isjoin3(nextseg4, radial) || this.calculateLine.isjoin3(nextseg1, radial) || this.calculateLine.isjoin3(nextseg3, radial) || this.calculateLine.isjoin3(nextseg2, radial2) || this.calculateLine.isjoin3(nextseg4, radial2)) {
  953. result.border1.push(outlines2.b2);
  954. result.border2.push(outlines2.b1);
  955. result.arrows1.push(outlines2.m2);
  956. result.arrows2.push(outlines2.m1);
  957. }
  958. else {
  959. result.border1.push(outlines2.b1);
  960. result.border2.push(outlines2.b2);
  961. result.arrows1.push(outlines2.m1);
  962. result.arrows2.push(outlines2.m2);
  963. }
  964. }
  965. return result;
  966. }
  967. //获取交点
  968. CalculateElement.prototype.getOutlineMeasureJoin2 = function (walllines, geometry) {
  969. if (walllines == null) {
  970. return;
  971. }
  972. var state = geometry.state;
  973. var points = geometry.points;
  974. var border1 = geometry.wallInfo[0].border1;
  975. var border2 = geometry.wallInfo[0].border2;
  976. var _border1 = geometry.wallInfo[geometry.points.length - 1].border1;
  977. var _border2 = geometry.wallInfo[geometry.points.length - 1].border2;
  978. var len = walllines.arrows1.length;
  979. var wallpoint = { arrows1: [], arrows2: [], border1: [], border2: [] };
  980. if (len == 1) {
  981. //var joinpoint1=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows1[0]);
  982. var joinpoint1 = this.calculateLine.getJoinLinePoint(border1, walllines.arrows1[0]);
  983. wallpoint.arrows1.push(joinpoint1);
  984. //var joinpoint2=this.calculateLine.getJoinLinePoint(points[1],walllines.arrows1[0]);
  985. var joinpoint2 = this.calculateLine.getJoinLinePoint(_border1, walllines.arrows1[0]);
  986. wallpoint.arrows1.push(joinpoint2);
  987. //var joinpoint3=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows2[0]);
  988. var joinpoint3 = this.calculateLine.getJoinLinePoint(border2, walllines.arrows2[0]);
  989. wallpoint.arrows2.push(joinpoint3);
  990. //var joinpoint4=this.calculateLine.getJoinLinePoint(points[1],walllines.arrows2[0]);
  991. var joinpoint4 = this.calculateLine.getJoinLinePoint(_border2, walllines.arrows2[0]);
  992. wallpoint.arrows2.push(joinpoint4);
  993. //var joinpoint5=this.calculateLine.getJoinLinePoint(points[0],walllines.border1[0]);
  994. var joinpoint5 = this.calculateLine.getJoinLinePoint(border1, walllines.border1[0]);
  995. wallpoint.border1.push(joinpoint5);
  996. //var joinpoint6=this.calculateLine.getJoinLinePoint(points[1],walllines.border1[0]);
  997. var joinpoint6 = this.calculateLine.getJoinLinePoint(_border1, walllines.border1[0]);
  998. wallpoint.border1.push(joinpoint6);
  999. //var joinpoint7=this.calculateLine.getJoinLinePoint(points[0],walllines.border2[0]);
  1000. var joinpoint7 = this.calculateLine.getJoinLinePoint(border2, walllines.border2[0]);
  1001. wallpoint.border2.push(joinpoint7);
  1002. //var joinpoint8=this.calculateLine.getJoinLinePoint(points[1],walllines.border2[0]);
  1003. var joinpoint8 = this.calculateLine.getJoinLinePoint(_border2, walllines.border2[0]);
  1004. wallpoint.border2.push(joinpoint8);
  1005. return wallpoint;
  1006. }
  1007. for (var i = 0; i < len; ++i) {
  1008. if (state == 1) {
  1009. if (i == 0 || i == len - 1) {
  1010. if (i == 0) {
  1011. //var border1join1=this.calculateLine.getJoinLinePoint(points[0],walllines.border1[0]);
  1012. var border1join1 = this.calculateLine.getJoinLinePoint(border1, walllines.border1[0]);
  1013. wallpoint.border1.push(border1join1);
  1014. //var border2join1=this.calculateLine.getJoinLinePoint(points[0],walllines.border2[0]);
  1015. var border2join1 = this.calculateLine.getJoinLinePoint(border2, walllines.border2[0]);
  1016. wallpoint.border2.push(border2join1);
  1017. var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[0], walllines.border1[1]);
  1018. if (border1join2 == null) {
  1019. border1join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
  1020. }
  1021. wallpoint.border1.push(border1join2);
  1022. var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[0], walllines.border2[1]);
  1023. if (border2join2 == null) {
  1024. border2join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
  1025. }
  1026. wallpoint.border2.push(border2join2);
  1027. //var join1=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows1[0]);
  1028. var join1 = this.calculateLine.getJoinLinePoint(border1, walllines.arrows1[0]);
  1029. wallpoint.arrows1.push(join1);
  1030. var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[0]);
  1031. wallpoint.arrows1.push(join2);
  1032. //var join3=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows2[0]);
  1033. var join3 = this.calculateLine.getJoinLinePoint(border2, walllines.arrows2[0]);
  1034. wallpoint.arrows2.push(join3);
  1035. var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[0]);
  1036. wallpoint.arrows2.push(join4);
  1037. }
  1038. else {
  1039. //var border1join1=this.calculateLine.getJoinLinePoint(points[i+1],walllines.border1[i]);
  1040. var border1join1 = this.calculateLine.getJoinLinePoint(_border1, walllines.border1[i]);
  1041. wallpoint.border1.push(border1join1);
  1042. //var border2join1=this.calculateLine.getJoinLinePoint(points[i+1],walllines.border2[i]);
  1043. var border2join1 = this.calculateLine.getJoinLinePoint(_border2, walllines.border2[i]);
  1044. wallpoint.border2.push(border2join1);
  1045. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[i], walllines.arrows1[i]);
  1046. wallpoint.arrows1.push(join1);
  1047. //var join2=this.calculateLine.getJoinLinePoint(points[i+1],walllines.arrows1[i]);
  1048. var join2 = this.calculateLine.getJoinLinePoint(_border1, walllines.arrows1[i]);
  1049. wallpoint.arrows1.push(join2);
  1050. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[i], walllines.arrows2[i]);
  1051. wallpoint.arrows2.push(join3);
  1052. //var join4=this.calculateLine.getJoinLinePoint(points[i+1],walllines.arrows2[i]);
  1053. var join4 = this.calculateLine.getJoinLinePoint(_border2, walllines.arrows2[i]);
  1054. wallpoint.arrows2.push(join4);
  1055. }
  1056. continue;
  1057. }
  1058. else {
  1059. var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1060. if (border1join == null) {
  1061. border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1062. }
  1063. wallpoint.border1.push(border1join);
  1064. var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1065. if (border2join == null) {
  1066. border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1067. }
  1068. wallpoint.border2.push(border2join);
  1069. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
  1070. wallpoint.arrows1.push(join1);
  1071. var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
  1072. wallpoint.arrows1.push(join2);
  1073. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
  1074. wallpoint.arrows2.push(join3);
  1075. var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
  1076. wallpoint.arrows2.push(join4);
  1077. continue;
  1078. }
  1079. }
  1080. else if (state == 0) {
  1081. if (i == 0) {
  1082. var border1join1 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getPreIndex(walllines.border1, i)]);
  1083. if (border1join1 == null) {
  1084. border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1085. }
  1086. wallpoint.border1.push(border1join1);
  1087. var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1088. if (border1join2 == null) {
  1089. border1join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1090. }
  1091. wallpoint.border1.push(border1join2);
  1092. var border2join1 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getPreIndex(walllines.border2, i)]);
  1093. if (border2join1 == null) {
  1094. border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1095. }
  1096. wallpoint.border2.push(border2join1);
  1097. var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1098. if (border2join2 == null) {
  1099. border2join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1100. }
  1101. wallpoint.border2.push(border2join2);
  1102. var join1 = this.calculateLine.getJoinLinePoint(border1join1, walllines.arrows1[i]);
  1103. wallpoint.arrows1.push(join1);
  1104. var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[i]);
  1105. wallpoint.arrows1.push(join2);
  1106. var join3 = this.calculateLine.getJoinLinePoint(border2join1, walllines.arrows2[i]);
  1107. wallpoint.arrows2.push(join3);
  1108. var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[i]);
  1109. wallpoint.arrows2.push(join4);
  1110. continue;
  1111. }
  1112. }
  1113. if (i < len - 1) {
  1114. var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1115. if (border1join == null) {
  1116. border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1117. }
  1118. wallpoint.border1.push(border1join);
  1119. var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1120. if (border2join == null) {
  1121. border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1122. }
  1123. wallpoint.border2.push(border2join);
  1124. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
  1125. wallpoint.arrows1.push(join1);
  1126. var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
  1127. wallpoint.arrows1.push(join2);
  1128. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
  1129. wallpoint.arrows2.push(join3);
  1130. var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
  1131. wallpoint.arrows2.push(join4);
  1132. }
  1133. else {
  1134. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 1], walllines.arrows1[i]);
  1135. wallpoint.arrows1.push(join1);
  1136. var join2 = this.calculateLine.getJoinLinePoint(wallpoint.border1[0], walllines.arrows1[i]);
  1137. wallpoint.arrows1.push(join2);
  1138. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 1], walllines.arrows2[i]);
  1139. wallpoint.arrows2.push(join3);
  1140. var join4 = this.calculateLine.getJoinLinePoint(wallpoint.border2[0], walllines.arrows2[i]);
  1141. wallpoint.arrows2.push(join4);
  1142. }
  1143. }
  1144. return wallpoint;
  1145. };
  1146. //获取交点
  1147. CalculateElement.prototype.getOutlineMeasureJoin = function (walllines, points, state) {
  1148. if (walllines == null) {
  1149. return;
  1150. }
  1151. var len = walllines.arrows1.length;
  1152. var wallpoint = { arrows1: [], arrows2: [], border1: [], border2: [] };
  1153. if (len == 1) {
  1154. var joinpoint1 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows1[0]);
  1155. wallpoint.arrows1.push(joinpoint1);
  1156. var joinpoint2 = this.calculateLine.getJoinLinePoint(points[1], walllines.arrows1[0]);
  1157. wallpoint.arrows1.push(joinpoint2);
  1158. var joinpoint3 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows2[0]);
  1159. wallpoint.arrows2.push(joinpoint3);
  1160. var joinpoint4 = this.calculateLine.getJoinLinePoint(points[1], walllines.arrows2[0]);
  1161. wallpoint.arrows2.push(joinpoint4);
  1162. var joinpoint5 = this.calculateLine.getJoinLinePoint(points[0], walllines.border1[0]);
  1163. wallpoint.border1.push(joinpoint5);
  1164. var joinpoint6 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
  1165. wallpoint.border1.push(joinpoint6);
  1166. var joinpoint7 = this.calculateLine.getJoinLinePoint(points[0], walllines.border2[0]);
  1167. wallpoint.border2.push(joinpoint7);
  1168. var joinpoint8 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
  1169. wallpoint.border2.push(joinpoint8);
  1170. return wallpoint;
  1171. }
  1172. for (var i = 0; i < len; ++i) {
  1173. if (state == 1) {
  1174. if (i == 0 || i == len - 1) {
  1175. if (i == 0) {
  1176. var border1join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.border1[0]);
  1177. wallpoint.border1.push(border1join1);
  1178. var border2join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.border2[0]);
  1179. wallpoint.border2.push(border2join1);
  1180. var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[0], walllines.border1[1]);
  1181. if (border1join2 == null) {
  1182. border1join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
  1183. }
  1184. wallpoint.border1.push(border1join2);
  1185. var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[0], walllines.border2[1]);
  1186. if (border2join2 == null) {
  1187. border2join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
  1188. }
  1189. wallpoint.border2.push(border2join2);
  1190. var join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows1[0]);
  1191. wallpoint.arrows1.push(join1);
  1192. var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[0]);
  1193. wallpoint.arrows1.push(join2);
  1194. var join3 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows2[0]);
  1195. wallpoint.arrows2.push(join3);
  1196. var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[0]);
  1197. wallpoint.arrows2.push(join4);
  1198. }
  1199. else {
  1200. var border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1201. wallpoint.border1.push(border1join1);
  1202. var border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1203. wallpoint.border2.push(border2join1);
  1204. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[i], walllines.arrows1[i]);
  1205. wallpoint.arrows1.push(join1);
  1206. var join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.arrows1[i]);
  1207. wallpoint.arrows1.push(join2);
  1208. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[i], walllines.arrows2[i]);
  1209. wallpoint.arrows2.push(join3);
  1210. var join4 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.arrows2[i]);
  1211. wallpoint.arrows2.push(join4);
  1212. }
  1213. continue;
  1214. }
  1215. else {
  1216. var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1217. if (border1join == null) {
  1218. border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1219. }
  1220. wallpoint.border1.push(border1join);
  1221. var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1222. if (border2join == null) {
  1223. border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1224. }
  1225. wallpoint.border2.push(border2join);
  1226. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
  1227. wallpoint.arrows1.push(join1);
  1228. var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
  1229. wallpoint.arrows1.push(join2);
  1230. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
  1231. wallpoint.arrows2.push(join3);
  1232. var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
  1233. wallpoint.arrows2.push(join4);
  1234. continue;
  1235. }
  1236. }
  1237. else if (state == 0) {
  1238. if (i == 0) {
  1239. var border1join1 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getPreIndex(walllines.border1, i)]);
  1240. if (border1join1 == null) {
  1241. border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1242. }
  1243. wallpoint.border1.push(border1join1);
  1244. var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1245. if (border1join2 == null) {
  1246. border1join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1247. }
  1248. wallpoint.border1.push(border1join2);
  1249. var border2join1 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getPreIndex(walllines.border2, i)]);
  1250. if (border2join1 == null) {
  1251. border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1252. }
  1253. wallpoint.border2.push(border2join1);
  1254. var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1255. if (border2join2 == null) {
  1256. border2join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1257. }
  1258. wallpoint.border2.push(border2join2);
  1259. var join1 = this.calculateLine.getJoinLinePoint(border1join1, walllines.arrows1[i]);
  1260. wallpoint.arrows1.push(join1);
  1261. var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[i]);
  1262. wallpoint.arrows1.push(join2);
  1263. var join3 = this.calculateLine.getJoinLinePoint(border2join1, walllines.arrows2[i]);
  1264. wallpoint.arrows2.push(join3);
  1265. var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[i]);
  1266. wallpoint.arrows2.push(join4);
  1267. continue;
  1268. }
  1269. }
  1270. if (i < len - 1) {
  1271. var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
  1272. if (border1join == null) {
  1273. border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
  1274. }
  1275. wallpoint.border1.push(border1join);
  1276. var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
  1277. if (border2join == null) {
  1278. border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
  1279. }
  1280. wallpoint.border2.push(border2join);
  1281. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
  1282. wallpoint.arrows1.push(join1);
  1283. var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
  1284. wallpoint.arrows1.push(join2);
  1285. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
  1286. wallpoint.arrows2.push(join3);
  1287. var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
  1288. wallpoint.arrows2.push(join4);
  1289. }
  1290. else {
  1291. var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 1], walllines.arrows1[i]);
  1292. wallpoint.arrows1.push(join1);
  1293. var join2 = this.calculateLine.getJoinLinePoint(wallpoint.border1[0], walllines.arrows1[i]);
  1294. wallpoint.arrows1.push(join2);
  1295. var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 1], walllines.arrows2[i]);
  1296. wallpoint.arrows2.push(join3);
  1297. var join4 = this.calculateLine.getJoinLinePoint(wallpoint.border2[0], walllines.arrows2[i]);
  1298. wallpoint.arrows2.push(join4);
  1299. }
  1300. }
  1301. wallpoint.arrows3 = []
  1302. for (var i = 0; i < len; i++) {
  1303. var start = wallpoint.arrows1[i]
  1304. var end = wallpoint.arrows1[i + 1]
  1305. // console.log(i, start.y - end.y)
  1306. }
  1307. return wallpoint;
  1308. };
  1309. //border1,border2是墙的边缘
  1310. //arrow1,arrow2是墙的测量线
  1311. CalculateElement.prototype.getWallMappingPoints = function (wallpoint, points, state) {
  1312. if (wallpoint == null) {
  1313. return;
  1314. }
  1315. var len = points.length;
  1316. var resultLines = [];
  1317. for (var i = 0; i < len; ++i) {
  1318. if (state == 1) {
  1319. if (i == len - 1) {
  1320. break;
  1321. }
  1322. }
  1323. var measureLine = {};
  1324. measureLine.arrow1Line1 = wallpoint.arrows1[2 * i];
  1325. measureLine.arrow1Line2 = wallpoint.arrows1[this.getNextIndex(wallpoint.arrows1, 2 * i)];
  1326. measureLine.text1pt = { x: (measureLine.arrow1Line1.x + measureLine.arrow1Line2.x) / 2, y: (measureLine.arrow1Line1.y + measureLine.arrow1Line2.y) / 2 };
  1327. measureLine.arrow2Line1 = wallpoint.arrows2[2 * i];
  1328. measureLine.arrow2Line2 = wallpoint.arrows2[this.getNextIndex(wallpoint.arrows2, 2 * i)];
  1329. measureLine.text2pt = { x: (measureLine.arrow2Line1.x + measureLine.arrow2Line2.x) / 2, y: (measureLine.arrow2Line1.y + measureLine.arrow2Line2.y) / 2 };
  1330. if (wallpoint.border1 != null) {
  1331. measureLine.border1Line1 = wallpoint.border1[i];
  1332. measureLine.border1Line2 = wallpoint.border1[this.getNextIndex(wallpoint.border1, i)];
  1333. measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.border1Line1, measureLine.border1Line2) / meter;
  1334. } else {
  1335. measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.arrow1Line1, measureLine.arrow1Line2) / meter;
  1336. }
  1337. if (wallpoint.border2 != null) {
  1338. measureLine.border2Line1 = wallpoint.border2[i];
  1339. measureLine.border2Line2 = wallpoint.border2[this.getNextIndex(wallpoint.border2, i)];
  1340. measureLine.distance2 = BABYLON.Vector2.Distance(measureLine.border2Line1, measureLine.border2Line2) / meter;
  1341. } else {
  1342. measureLine.distance2 = BABYLON.Vector2.Distance(measureLine.arrow2Line1, measureLine.arrow2Line2) / meter;
  1343. }
  1344. measureLine.border1Line1 = wallpoint.border1[i];
  1345. measureLine.border1Line2 = wallpoint.border1[this.getNextIndex(wallpoint.border1, i)];
  1346. measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.border1Line1, measureLine.border1Line2) / meter;
  1347. resultLines.push(measureLine);
  1348. }
  1349. return resultLines;
  1350. };
  1351. //9.7
  1352. CalculateElement.prototype.updateSelectWallLineIndex = function (wallId, wallindex1, wallindex2, mergeindex) {
  1353. var len = this.layer.vectors[wallId].geometry.points.length;
  1354. if (this.isNeighbor(len, wallindex1, mergeindex)) {
  1355. this.updateSymbolsWallCornerIndexDelete(wallId, mergeindex, wallindex1);
  1356. if (wallindex1 > mergeindex) {
  1357. if (mergeindex == 0 && wallindex1 != 1) {
  1358. wallindex1 = 0;
  1359. }
  1360. else {
  1361. --wallindex1;
  1362. --wallindex2;
  1363. }
  1364. }
  1365. else if (wallindex1 < mergeindex) {
  1366. if (wallindex1 == 0 && mergeindex == 1) {
  1367. --wallindex2;
  1368. }
  1369. else if (wallindex1 == 0) {
  1370. wallindex2 = mergeindex - 1;
  1371. }
  1372. }
  1373. }
  1374. else if (this.isNeighbor(len, wallindex2, mergeindex)) {
  1375. this.updateSymbolsWallCornerIndexDelete(wallId, mergeindex, wallindex2);
  1376. if (wallindex2 > mergeindex) {
  1377. if (mergeindex == 0 && wallindex2 != 1) {
  1378. wallindex2 = 0;
  1379. }
  1380. else {
  1381. --wallindex1;
  1382. --wallindex2;
  1383. }
  1384. }
  1385. else if (wallindex2 < mergeindex) {
  1386. if (wallindex2 == 0 && mergeindex == 1) {
  1387. --wallindex1;
  1388. }
  1389. else if (wallindex2 == 0) {
  1390. wallindex1 = mergeindex - 1;
  1391. }
  1392. }
  1393. }
  1394. if (wallindex1 < 0) {
  1395. wallindex1 = 0;
  1396. }
  1397. if (wallindex2 < 0) {
  1398. wallindex2 = 0;
  1399. }
  1400. return { wallindex1: wallindex1, wallindex2: wallindex2 };
  1401. };
  1402. CalculateElement.prototype.getIndexsFordeleteWall = function (wallId, index) {
  1403. var result = {};
  1404. var points = this.layer.vectors[wallId].geometry.points;
  1405. for (var i = 0; i < points.length; ++i) {
  1406. if (i == index) {
  1407. continue;
  1408. }
  1409. if (i > index) {
  1410. result[i] = i - 1;
  1411. }
  1412. else {
  1413. result[i] = i;
  1414. }
  1415. }
  1416. return result;
  1417. };
  1418. CalculateElement.prototype.updateIndexAdd = function (len, index, startindex, endindex, symbolpoint1, symbolpoint2, point, wallpoint1, wallpoint2) {
  1419. var temp = null;
  1420. if (startindex > endindex) {
  1421. temp = endindex;
  1422. endindex = startindex;
  1423. startindex = temp;
  1424. }
  1425. if (Math.abs(startindex - endindex) == 1) {
  1426. if (startindex > index && endindex > index) {
  1427. ++startindex;
  1428. ++endindex;
  1429. }
  1430. else if (startindex == index && endindex > index) {
  1431. ++startindex;
  1432. ++endindex;
  1433. }
  1434. else if (startindex < index && endindex == index) {
  1435. //两种情况,双击点在哪一侧?
  1436. if (this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint1) && this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint2)) {
  1437. //什么也不变
  1438. }
  1439. else {
  1440. ++startindex;
  1441. ++endindex;
  1442. }
  1443. }
  1444. }
  1445. else if (index > endindex) {
  1446. //两种情况,双击点在哪一侧?
  1447. if (this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint1) && this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint2)) {
  1448. startindex = endindex;
  1449. endindex = index;
  1450. }
  1451. else {
  1452. startindex = index;
  1453. endindex = 0;
  1454. }
  1455. }
  1456. else {
  1457. ++endindex;
  1458. }
  1459. if (temp == null) {
  1460. return { start: startindex, end: endindex };
  1461. }
  1462. else {
  1463. return { start: endindex, end: startindex };
  1464. }
  1465. };
  1466. //双击墙面
  1467. CalculateElement.prototype.updateSymbolsWallCornerIndexAdd = function (wallId, insertindex, point) {
  1468. var len = this.layer.vectors[wallId].geometry.points.length;
  1469. var wallindex1 = insertindex - 1;
  1470. var wallindex2 = insertindex + 1;
  1471. if (wallindex2 == len) {
  1472. wallindex2 = 0;
  1473. }
  1474. var wallpoint1 = this.layer.vectors[wallId].geometry.points[wallindex1];
  1475. var wallpoint2 = this.layer.vectors[wallId].geometry.points[wallindex2];
  1476. for (var key in this.layer.vectors[wallId].symbol2Ds) {
  1477. var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
  1478. var indexs = this.updateIndexAdd(len, insertindex, symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex, symbol2d.geometry.points[0], symbol2d.geometry.points[1], point, wallpoint1, wallpoint2);
  1479. symbol2d.attributes.wallstartindex = indexs.start;
  1480. symbol2d.attributes.wallendindex = indexs.end;
  1481. }
  1482. }
  1483. //9.7
  1484. CalculateElement.prototype.updateSymbolsWallCornerIndexDelete = function (wallId, mergeindex, selectIndex) {
  1485. var len = this.layer.vectors[wallId].geometry.points.length;
  1486. if (!this.isNeighbor(len, mergeindex, selectIndex)) {
  1487. return;
  1488. }
  1489. for (var key in this.layer.vectors[wallId].symbol2Ds) {
  1490. var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
  1491. var index1 = symbol2d.attributes.wallstartindex;
  1492. var index2 = symbol2d.attributes.wallendindex;
  1493. if (mergeindex != 0 && selectIndex != 0) {
  1494. if (Math.min(index1, index2) > Math.max(mergeindex, selectIndex)) {
  1495. --symbol2d.attributes.wallstartindex;
  1496. --symbol2d.attributes.wallendindex;
  1497. }
  1498. else if (Math.min(index1, index2) == Math.max(mergeindex, selectIndex)) {
  1499. symbol2d.attributes.wallstartindex = Math.min(mergeindex, selectIndex);
  1500. --symbol2d.attributes.wallendindex;
  1501. }
  1502. else if (index1 == 0 && index2 != 1) {
  1503. --symbol2d.attributes.wallendindex;
  1504. }
  1505. else if (index2 == 0 && index1 != 1) {
  1506. --symbol2d.attributes.wallstartindex;
  1507. }
  1508. }
  1509. else if (mergeindex == 1 || selectIndex == 1) {
  1510. --symbol2d.attributes.wallstartindex;
  1511. --symbol2d.attributes.wallendindex;
  1512. if (symbol2d.attributes.wallstartindex < 0) {
  1513. symbol2d.attributes.wallstartindex = 0;
  1514. }
  1515. if (symbol2d.attributes.wallendindex < 0) {
  1516. symbol2d.attributes.wallendindex = 0;
  1517. }
  1518. }
  1519. else if (mergeindex != 1 && selectIndex != 1) {
  1520. if (selectIndex == 0) {
  1521. if (Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex) > 0) {
  1522. --symbol2d.attributes.wallstartindex;
  1523. --symbol2d.attributes.wallendindex;
  1524. }
  1525. else {
  1526. symbol2d.attributes.wallstartindex = 0;
  1527. symbol2d.attributes.wallendindex = mergeindex - 1;
  1528. }
  1529. }
  1530. else {
  1531. if (symbol2d.attributes.wallstartindex == selectIndex) {
  1532. symbol2d.attributes.wallstartindex = 0;
  1533. }
  1534. else if (symbol2d.attributes.wallendindex == selectIndex) {
  1535. symbol2d.attributes.wallendindex = 0;
  1536. }
  1537. }
  1538. }
  1539. }
  1540. };
  1541. //9.7
  1542. CalculateElement.prototype.updateSymbolsForDeleteOnePoint = function (wallId, index) {
  1543. var len = this.layer.vectors[wallId].geometry.points.length;
  1544. for (var key in this.layer.vectors[wallId].symbol2Ds) {
  1545. var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
  1546. var index1 = symbol2d.attributes.wallstartindex;
  1547. var index2 = symbol2d.attributes.wallendindex;
  1548. if (index1 != 0 && index2 != 0) {
  1549. if (index < Math.min(index1, index2)) {
  1550. --symbol2d.attributes.wallstartindex;
  1551. --symbol2d.attributes.wallendindex;
  1552. }
  1553. else if (index == index1) {
  1554. if (index2 > index) {
  1555. index1 = index - 1;
  1556. --index2;
  1557. }
  1558. }
  1559. else if (index == index2) {
  1560. if (index1 > index) {
  1561. index2 = index - 1;
  1562. --index1;
  1563. }
  1564. }
  1565. }
  1566. else if (index1 == 0) {
  1567. if (index2 != 1) {
  1568. if (index != 0) {
  1569. --index2;
  1570. }
  1571. }
  1572. else if (index == 0) {
  1573. index2 = len - 2;
  1574. }
  1575. }
  1576. else if (index2 == 0) {
  1577. if (index1 != 1) {
  1578. if (index != 0) {
  1579. --index1;
  1580. }
  1581. }
  1582. else if (index == 0) {
  1583. index1 = len - 2;
  1584. }
  1585. }
  1586. symbol2d.attributes.wallstartindex = index1;
  1587. symbol2d.attributes.wallendindex = index2;
  1588. }
  1589. };
  1590. CalculateElement.prototype.updateSelectWallCornerIndex = function (wallId, mergeindex, selectIndex) {
  1591. if (!this.isNeighbor(len, mergeindex, selectIndex)) {
  1592. return null;
  1593. }
  1594. if (selectIndex > mergeindex) {
  1595. return mergeindex;
  1596. }
  1597. else if (selectIndex == 0) {
  1598. if (mergeindex != 1) {
  1599. --mergeindex;
  1600. return mergeindex;
  1601. }
  1602. }
  1603. return selectIndex;
  1604. };
  1605. CalculateElement.prototype.updateSymbolsIndexAdd = function (wallId, index, point) {
  1606. var len = this.layer.vectors[wallId].geometry.points.length;
  1607. var wallindex1 = index - 1;
  1608. var wallindex2 = index + 1;
  1609. if (wallindex2 == len) {
  1610. wallindex2 = 0;
  1611. }
  1612. var wallpoint1 = this.layer.vectors[wallId].geometry.points[wallindex1];
  1613. var wallpoint2 = this.layer.vectors[wallId].geometry.points[wallindex2];
  1614. for (var key in this.layer.vectors[wallId].symbol2Ds) {
  1615. var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
  1616. var indexs = this.updateIndexAdd(len, index, symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex, symbol2d.geometry.points[0], symbol2d.geometry.points[1], point, wallpoint1, wallpoint2);
  1617. symbol2d.attributes.wallstartindex = indexs.start;
  1618. symbol2d.attributes.wallendindex = indexs.end;
  1619. }
  1620. };
  1621. CalculateElement.prototype.updateSymbolEndPoint = function (symbol2d, point, wallid, startinidex, endindex) {
  1622. if (wallid == null) {
  1623. return;
  1624. }
  1625. var len = symbol2d.getSymbolLen();
  1626. var point1, point2;
  1627. //不能是墙角
  1628. if (endindex != null && typeof (endindex) != undefined) {
  1629. point1 = this.layer.vectors[wallid].geometry.points[startinidex];
  1630. point2 = this.layer.vectors[wallid].geometry.points[endindex];
  1631. }
  1632. else if (symbol2d.geometry.points.length > 0) {
  1633. point1 = symbol2d.geometry.points[0];
  1634. point2 = symbol2d.geometry.points[1];
  1635. }
  1636. else {
  1637. return;
  1638. }
  1639. var line = this.calculateLine.createLine(point1, point2);
  1640. var endpoint = this.calculateLine.getDisPointsLine(line, point, len / 2, len / 2)
  1641. if (symbol2d.attributes.wallId != wallid) {
  1642. --this.layer.vectors[symbol2d.attributes.wallId].symbol2dsCount;
  1643. delete this.layer.vectors[symbol2d.attributes.wallId].symbol2Ds[symbol2d.id];
  1644. symbol2d.attributes.wallId = wallid;
  1645. ++this.layer.vectors[wallid].symbol2dsCount;
  1646. this.layer.vectors[wallid].symbol2Ds[symbol2d.id] = symbol2d;
  1647. }
  1648. symbol2d.attributes.wallstartindex = startinidex;
  1649. symbol2d.attributes.wallendindex = endindex;
  1650. symbol2d.geometry.point1 = endpoint.newpoint1;
  1651. symbol2d.geometry.point2 = endpoint.newpoint2;
  1652. var thick = this.layer.getThickness(symbol2d.attributes.wallId, symbol2d.attributes.wallstartindex);
  1653. symbol2d.geometry.points = this.getSymbolPoints(endpoint.newpoint1, endpoint.newpoint2, symbol2d.geometry.geoType, symbol2d.attributes.toward, thick)
  1654. this.layer.vectors[symbol2d.attributes.selectSymbolIds[0]].geometry.points[0] = endpoint.newpoint1;
  1655. this.layer.vectors[symbol2d.attributes.selectSymbolIds[0]].geometry.points[1] = endpoint.newpoint2;
  1656. this.layer.vectors[symbol2d.attributes.selectSymbolIds[1]].geometry.x = endpoint.newpoint1.x;
  1657. this.layer.vectors[symbol2d.attributes.selectSymbolIds[1]].geometry.y = endpoint.newpoint1.y;
  1658. this.layer.vectors[symbol2d.attributes.selectSymbolIds[2]].geometry.x = endpoint.newpoint2.x;
  1659. this.layer.vectors[symbol2d.attributes.selectSymbolIds[2]].geometry.y = endpoint.newpoint2.y;
  1660. //symbol2d.select=true;
  1661. //symbol2d.draw(this.layer);
  1662. };
  1663. //point在墙上
  1664. CalculateElement.prototype.getSymbolEndPoint = function (point, wallid, startinidex, endindex, len) {
  1665. var point1 = this.layer.vectors[wallid].geometry.points[startinidex];
  1666. if (typeof (endindex) == "undefined") {
  1667. return null;
  1668. }
  1669. var point2 = this.layer.vectors[wallid].geometry.points[endindex];
  1670. var line = this.calculateLine.createLine(point1, point2);
  1671. var endpoint = this.calculateLine.getDisPointsLine(line, point, len / 2, len / 2)
  1672. return endpoint;
  1673. };
  1674. //point不在墙上
  1675. CalculateElement.prototype.getSymbolEndPoint2 = function (point, wallid, startinidex, endindex, len) {
  1676. if (typeof (endindex) == "undefined") {
  1677. return null;
  1678. }
  1679. var point1 = this.layer.vectors[wallid].geometry.points[startinidex];
  1680. var point2 = this.layer.vectors[wallid].geometry.points[endindex];
  1681. var line = this.calculateLine.createLine(point1, point2);
  1682. var p = this.calculateLine.getJoinLinePoint(point, line);
  1683. if (!this.lineContain(point1, point2, p, 1)) {
  1684. return null;
  1685. }
  1686. else if (BABYLON.Vector2.Distance(point1, p) < len / 2 || BABYLON.Vector2.Distance(point2, p) < len / 2) {
  1687. return null;
  1688. }
  1689. else {
  1690. var endpoint = this.calculateLine.getDisPointsLine(line, p, len / 2, len / 2)
  1691. return endpoint;
  1692. }
  1693. };
  1694. //points中,第1,2点表示与point1和point2构成矩形
  1695. //扇形都是以point2为圆心
  1696. CalculateElement.prototype.getSingleCasementPoints = function (point1, point2, toward, thick) {
  1697. //singleCasementDrift
  1698. var calculateLine = this.calculateLine;
  1699. var line = calculateLine.createLine(point1, point2);
  1700. var arcpoints = [];
  1701. var len = BABYLON.Vector2.Distance(point1, point2);
  1702. var startAngle2, endAngle2;
  1703. var tempPoint = { x: point2.x + 1, y: point2.y };
  1704. if (line.hasOwnProperty('x')) {
  1705. if (toward == 1) {
  1706. arcpoints.push({ x: point2.x - this.layer.parameter.singleCasementDrift, y: point2.y });
  1707. arcpoints.push({ x: point1.x - this.layer.parameter.singleCasementDrift, y: point1.y });
  1708. endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1709. startAngle2 = endAngle2 - Math.PI / 6;
  1710. }
  1711. else {
  1712. arcpoints.push({ x: point2.x + this.layer.parameter.singleCasementDrift, y: point2.y });
  1713. arcpoints.push({ x: point1.x + this.layer.parameter.singleCasementDrift, y: point1.y });
  1714. startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1715. endAngle2 = startAngle2 + Math.PI / 6;
  1716. }
  1717. }
  1718. else if (line.hasOwnProperty('y')) {
  1719. if (toward == 1) {
  1720. arcpoints.push({ x: point2.x, y: point2.y - this.layer.parameter.singleCasementDrift });
  1721. arcpoints.push({ x: point1.x, y: point1.y - this.layer.parameter.singleCasementDrift });
  1722. startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1723. endAngle2 = startAngle2 + Math.PI / 6;
  1724. }
  1725. else {
  1726. arcpoints.push({ x: point2.x, y: point2.y + this.layer.parameter.singleCasementDrift });
  1727. arcpoints.push({ x: point1.x, y: point1.y + this.layer.parameter.singleCasementDrift });
  1728. endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1729. startAngle2 = endAngle2 - Math.PI / 6;
  1730. }
  1731. }
  1732. else {
  1733. var tl = {};
  1734. var a = Math.atan(line.a);
  1735. tl.a = -1 / line.a;
  1736. var temp_line2 = calculateLine.getLineForPoint(tl, point1);
  1737. var temp_line1 = calculateLine.getLineForPoint(tl, point2);
  1738. var p1, p2;
  1739. var drift = (this.layer.parameter.singleCasementDrift) / Math.cos(a);
  1740. var same_line;
  1741. if (toward == 1) {
  1742. same_line = { a: line.a, b: line.b - drift };
  1743. p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
  1744. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
  1745. arcpoints.push(p2);
  1746. arcpoints.push(p1);
  1747. startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1748. endAngle2 = startAngle2 + Math.PI / 6;
  1749. }
  1750. else {
  1751. same_line = { a: line.a, b: line.b + drift };
  1752. p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
  1753. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
  1754. arcpoints.push(p2);
  1755. arcpoints.push(p1);
  1756. endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
  1757. startAngle2 = endAngle2 - Math.PI / 6;
  1758. }
  1759. }
  1760. arcpoints.push(startAngle2);
  1761. arcpoints.push(endAngle2);
  1762. return arcpoints;
  1763. };
  1764. CalculateElement.prototype.getDoubleCasementPoints = function (point1, point2, toward, thick) {
  1765. var calculateLine = this.calculateLine;
  1766. var line = calculateLine.createLine(point1, point2);
  1767. var arcpoints = [];
  1768. var len = BABYLON.Vector2.Distance(point1, point2);
  1769. var midpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
  1770. var startAngle21, startAngle22, endAngle21, endAngle22;
  1771. var tempPoint1 = { x: point1.x + 1, y: point1.y };
  1772. var tempPoint2 = { x: point2.x + 1, y: point2.y };
  1773. if (line.hasOwnProperty('x')) {
  1774. if (toward == 1) {
  1775. arcpoints.push({ x: point2.x - this.layer.parameter.singleCasementDrift, y: point2.y });
  1776. arcpoints.push({ x: point1.x - this.layer.parameter.singleCasementDrift, y: point1.y });
  1777. if (point1.y > point2.y) {
  1778. endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1779. startAngle21 = endAngle21 - Math.PI / 6;
  1780. startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1781. endAngle22 = startAngle22 + Math.PI / 6;
  1782. }
  1783. else {
  1784. endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1785. startAngle21 = endAngle21 - Math.PI / 6;
  1786. startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI + Math.PI;
  1787. endAngle22 = startAngle22 + Math.PI / 6;
  1788. }
  1789. }
  1790. else {
  1791. arcpoints.push({ x: point2.x + this.layer.parameter.singleCasementDrift, y: point2.y });
  1792. arcpoints.push({ x: point1.x + this.layer.parameter.singleCasementDrift, y: point1.y });
  1793. if (point1.y > point2.y) {
  1794. startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1795. endAngle21 = startAngle21 + Math.PI / 6;
  1796. endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1797. startAngle22 = endAngle22 - Math.PI / 6;
  1798. }
  1799. else {
  1800. startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1801. endAngle21 = startAngle21 + Math.PI / 6;
  1802. endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI + Math.PI;
  1803. startAngle22 = endAngle22 - Math.PI / 6;
  1804. }
  1805. }
  1806. }
  1807. else if (line.hasOwnProperty('y')) {
  1808. if (toward == 1) {
  1809. arcpoints.push({ x: point2.x, y: point2.y - this.layer.parameter.singleCasementDrift });
  1810. arcpoints.push({ x: point1.x, y: point1.y - this.layer.parameter.singleCasementDrift });
  1811. if (point1.x > point2.x) {
  1812. endAngle21 = 2 * Math.PI;
  1813. startAngle21 = endAngle21 - Math.PI / 6;
  1814. startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1815. endAngle22 = startAngle22 + Math.PI / 6;
  1816. }
  1817. else {
  1818. startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1819. endAngle21 = startAngle21 + Math.PI / 6;
  1820. endAngle22 = 2 * Math.PI;
  1821. startAngle22 = endAngle22 - Math.PI / 6;
  1822. }
  1823. }
  1824. else {
  1825. arcpoints.push({ x: point2.x, y: point2.y + this.layer.parameter.singleCasementDrift });
  1826. arcpoints.push({ x: point1.x, y: point1.y + this.layer.parameter.singleCasementDrift });
  1827. if (point1.x > point2.x) {
  1828. startAngle21 = 0;
  1829. endAngle21 = startAngle21 + Math.PI / 6;
  1830. endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1831. startAngle22 = endAngle22 - Math.PI / 6;
  1832. }
  1833. else {
  1834. endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1835. startAngle21 = endAngle21 - Math.PI / 6;
  1836. startAngle22 = 0;
  1837. endAngle22 = startAngle22 + Math.PI / 6;
  1838. }
  1839. }
  1840. }
  1841. else {
  1842. var tl = {};
  1843. var a = Math.atan(line.a);
  1844. tl.a = -1 / line.a;
  1845. var temp_line2 = calculateLine.getLineForPoint(tl, point1);
  1846. var temp_line1 = calculateLine.getLineForPoint(tl, point2);
  1847. var temp_midline = calculateLine.getLineForPoint(tl, midpoint);
  1848. var p1, p2;
  1849. var drift = (this.layer.parameter.singleCasementDrift) / Math.cos(a);
  1850. var same_line;
  1851. if (toward == 1) {
  1852. same_line = { a: line.a, b: line.b - drift };
  1853. p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
  1854. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
  1855. arcpoints.push(p2);
  1856. arcpoints.push(p1);
  1857. startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1858. endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1859. endAngle21 = startAngle21 + Math.PI / 6;
  1860. startAngle22 = endAngle22 - Math.PI / 6;
  1861. }
  1862. else {
  1863. same_line = { a: line.a, b: line.b + drift };
  1864. p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
  1865. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
  1866. arcpoints.push(p2);
  1867. arcpoints.push(p1);
  1868. endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
  1869. startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
  1870. startAngle21 = endAngle21 - Math.PI / 6;
  1871. endAngle22 = startAngle22 + Math.PI / 6;
  1872. }
  1873. }
  1874. arcpoints.push(startAngle21);
  1875. arcpoints.push(endAngle21);
  1876. arcpoints.push(startAngle22);
  1877. arcpoints.push(endAngle22);
  1878. return arcpoints;
  1879. };
  1880. CalculateElement.prototype.getSimpleDoorPoints = function (point1, point2, toward, thick) {
  1881. var calculateLine = this.calculateLine;
  1882. var line = calculateLine.createLine(point1, point2);
  1883. var arcpoints = [];
  1884. var doorlength = BABYLON.Vector2.Distance(point1, point2);
  1885. if (line.hasOwnProperty('x')) {
  1886. if (toward == 1) {
  1887. arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
  1888. arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y });
  1889. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y });
  1890. if (point2.y < point1.y) {
  1891. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
  1892. arcpoints.push({ x: point1.x + thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
  1893. }
  1894. else {
  1895. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
  1896. arcpoints.push({ x: point1.x + thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
  1897. }
  1898. arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
  1899. }
  1900. else {
  1901. arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
  1902. arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y });
  1903. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y });
  1904. if (point2.y < point1.y) {
  1905. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
  1906. arcpoints.push({ x: point1.x - thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
  1907. }
  1908. else {
  1909. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
  1910. arcpoints.push({ x: point1.x - thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
  1911. }
  1912. arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
  1913. }
  1914. }
  1915. else if (line.hasOwnProperty('y')) {
  1916. if (toward == 1) {
  1917. arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
  1918. arcpoints.push({ x: point2.x, y: point2.y + thick / 2 + doorlength });
  1919. arcpoints.push({ x: point1.x, y: point1.y + thick / 2 + doorlength });
  1920. if (point2.x < point1.x) {
  1921. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
  1922. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
  1923. }
  1924. else {
  1925. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
  1926. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
  1927. }
  1928. arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
  1929. }
  1930. else {
  1931. arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
  1932. arcpoints.push({ x: point2.x, y: point2.y - thick / 2 - doorlength });
  1933. arcpoints.push({ x: point1.x, y: point1.y - thick / 2 - doorlength });
  1934. if (point2.x < point1.x) {
  1935. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
  1936. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
  1937. }
  1938. else {
  1939. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
  1940. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
  1941. }
  1942. arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
  1943. }
  1944. }
  1945. else {
  1946. var tl = {};
  1947. var a = Math.atan(line.a);
  1948. tl.a = -1 / line.a;
  1949. var temp_line2 = calculateLine.getLineForPoint(tl, point1);
  1950. var temp_line1 = calculateLine.getLineForPoint(tl, point2);
  1951. var p1, p2, p3, p4, p5, p6;
  1952. var temp_line3 = {};
  1953. var db = doorlength / Math.cos(a);
  1954. var drift = (thick / 2) / Math.cos(a);
  1955. var same_line1, same_line2;
  1956. if (toward == 1) {
  1957. same_line1 = { a: line.a, b: line.b + drift };
  1958. same_line2 = { a: line.a, b: line.b + drift + db };
  1959. p1 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
  1960. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
  1961. p3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
  1962. if (temp_line2.b < temp_line1.b) {
  1963. temp_line3.a = temp_line1.a;
  1964. temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  1965. p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  1966. p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  1967. }
  1968. else {
  1969. temp_line3.a = temp_line1.a;
  1970. temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  1971. p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  1972. p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  1973. }
  1974. p6 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
  1975. }
  1976. else {
  1977. same_line1 = { a: line.a, b: line.b - drift };
  1978. same_line2 = { a: line.a, b: line.b - drift - db };
  1979. p1 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
  1980. p2 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
  1981. p3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
  1982. if (temp_line2.b < temp_line1.b) {
  1983. temp_line3.a = temp_line1.a;
  1984. temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  1985. p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  1986. p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  1987. }
  1988. else {
  1989. temp_line3.a = temp_line1.a;
  1990. temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  1991. p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  1992. p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  1993. }
  1994. p6 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
  1995. }
  1996. arcpoints.push(p1);
  1997. arcpoints.push(p2);
  1998. arcpoints.push(p3);
  1999. arcpoints.push(p4);
  2000. arcpoints.push(p5);
  2001. arcpoints.push(p6);
  2002. }
  2003. return arcpoints;
  2004. };
  2005. CalculateElement.prototype.getBiFoldDoorPoints = function (point1, point2, toward, thick) {
  2006. var calculateLine = this.calculateLine;
  2007. var line = calculateLine.createLine(point1, point2);
  2008. var arcpoints = [];
  2009. var doorlength = BABYLON.Vector2.Distance(point1, point2) / 2;
  2010. var midpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
  2011. if (line.hasOwnProperty('x')) {
  2012. if (toward == 1) {
  2013. arcpoints.push({ x: midpoint.x + thick / 2, y: midpoint.y });
  2014. arcpoints.push({ x: midpoint.x + thick / 2 + doorlength, y: midpoint.y });
  2015. arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y });
  2016. arcpoints.push({ x: midpoint.x + thick / 2, y: midpoint.y });
  2017. arcpoints.push({ x: midpoint.x + thick / 2 + doorlength, y: midpoint.y });
  2018. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y });
  2019. if (point2.y < point1.y) {
  2020. arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y + this.layer.parameter.simpleDoorDrift });
  2021. arcpoints.push({ x: point2.x + thick / 2, y: point2.y + this.layer.parameter.simpleDoorDrift });
  2022. arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
  2023. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
  2024. arcpoints.push({ x: point1.x + thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
  2025. arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
  2026. }
  2027. else {
  2028. arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y - this.layer.parameter.simpleDoorDrift });
  2029. arcpoints.push({ x: point2.x + thick / 2, y: point2.y - this.layer.parameter.simpleDoorDrift });
  2030. arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
  2031. arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
  2032. arcpoints.push({ x: point1.x + thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
  2033. arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
  2034. }
  2035. }
  2036. else {
  2037. arcpoints.push({ x: midpoint.x - thick / 2, y: midpoint.y });
  2038. arcpoints.push({ x: midpoint.x - thick / 2 - doorlength, y: midpoint.y });
  2039. arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y });
  2040. arcpoints.push({ x: midpoint.x - thick / 2, y: midpoint.y });
  2041. arcpoints.push({ x: midpoint.x - thick / 2 - doorlength, y: midpoint.y });
  2042. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y });
  2043. if (point2.y < point1.y) {
  2044. arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y + this.layer.parameter.simpleDoorDrift });
  2045. arcpoints.push({ x: point2.x - thick / 2, y: point2.y + this.layer.parameter.simpleDoorDrift });
  2046. arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
  2047. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
  2048. arcpoints.push({ x: point1.x - thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
  2049. arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
  2050. }
  2051. else {
  2052. arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y - this.layer.parameter.simpleDoorDrift });
  2053. arcpoints.push({ x: point2.x - thick / 2, y: point2.y - this.layer.parameter.simpleDoorDrift });
  2054. arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
  2055. arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
  2056. arcpoints.push({ x: point1.x - thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
  2057. arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
  2058. }
  2059. }
  2060. }
  2061. else if (line.hasOwnProperty('y')) {
  2062. if (toward == 1) {
  2063. arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 });
  2064. arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 + doorlength });
  2065. arcpoints.push({ x: point2.x, y: point2.y + thick / 2 + doorlength });
  2066. arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 });
  2067. arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 + doorlength });
  2068. arcpoints.push({ x: point1.x, y: point1.y + thick / 2 + doorlength });
  2069. if (point2.x < point1.x) {
  2070. arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 + doorlength });
  2071. arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 });
  2072. arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
  2073. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
  2074. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
  2075. arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
  2076. }
  2077. else {
  2078. arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 + doorlength });
  2079. arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 });
  2080. arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
  2081. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
  2082. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
  2083. arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
  2084. }
  2085. }
  2086. else {
  2087. arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 });
  2088. arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 - doorlength });
  2089. arcpoints.push({ x: point2.x, y: point2.y - thick / 2 - doorlength });
  2090. arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 });
  2091. arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 - doorlength });
  2092. arcpoints.push({ x: point1.x, y: point1.y - thick / 2 - doorlength });
  2093. if (point2.y < point1.y) {
  2094. arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 - doorlength });
  2095. arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 });
  2096. arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
  2097. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
  2098. arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
  2099. arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
  2100. }
  2101. else {
  2102. arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 - doorlength });
  2103. arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 });
  2104. arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
  2105. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
  2106. arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
  2107. arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
  2108. }
  2109. }
  2110. }
  2111. else {
  2112. var tl = {};
  2113. var a = Math.atan(line.a);
  2114. tl.a = -1 / line.a;
  2115. var temp_line1 = calculateLine.getLineForPoint(tl, point1);
  2116. var temp_line2 = calculateLine.getLineForPoint(tl, point2);
  2117. var temp_midline = calculateLine.getLineForPoint(tl, midpoint);
  2118. var t1, t2, t3, t4, t5, t6;
  2119. var p1, p2, p3, p4, p5, p6;
  2120. var temp_line3 = {};
  2121. var temp_line4 = {};
  2122. var db = doorlength / Math.cos(a);
  2123. var drift = (thick / 2) / Math.cos(a);
  2124. var same_line1, same_line2;
  2125. if (toward == 1) {
  2126. same_line1 = { a: line.a, b: line.b + drift };
  2127. same_line2 = { a: line.a, b: line.b + drift + db };
  2128. t1 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
  2129. t2 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
  2130. t3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
  2131. t4 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
  2132. t5 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
  2133. t6 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
  2134. if (temp_line2.b < temp_line1.b) {
  2135. temp_line3.a = temp_line1.a;
  2136. temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2137. temp_line4.a = temp_line1.a;
  2138. temp_line4.b = temp_line1.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2139. }
  2140. else {
  2141. temp_line3.a = temp_line1.a;
  2142. temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2143. temp_line4.a = temp_line1.a;
  2144. temp_line4.b = temp_line1.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2145. }
  2146. p1 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  2147. p2 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  2148. p3 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
  2149. p4 = calculateLine.getIntersectionPoint(temp_line4, same_line2);
  2150. p5 = calculateLine.getIntersectionPoint(temp_line4, same_line1);
  2151. p6 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
  2152. }
  2153. else {
  2154. same_line1 = { a: line.a, b: line.b - drift };
  2155. same_line2 = { a: line.a, b: line.b - drift - db };
  2156. t1 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
  2157. t2 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
  2158. t3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
  2159. t4 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
  2160. t5 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
  2161. t6 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
  2162. if (temp_line2.b < temp_line1.b) {
  2163. temp_line3.a = temp_line1.a;
  2164. temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2165. temp_line4.a = temp_line1.a;
  2166. temp_line4.b = temp_line1.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2167. }
  2168. else {
  2169. temp_line3.a = temp_line1.a;
  2170. temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2171. temp_line4.a = temp_line1.a;
  2172. temp_line4.b = temp_line1.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
  2173. }
  2174. p1 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
  2175. p2 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
  2176. p3 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
  2177. p4 = calculateLine.getIntersectionPoint(temp_line4, same_line2);
  2178. p5 = calculateLine.getIntersectionPoint(temp_line4, same_line1);
  2179. p6 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
  2180. }
  2181. arcpoints.push(t1);
  2182. arcpoints.push(t2);
  2183. arcpoints.push(t3);
  2184. arcpoints.push(t4);
  2185. arcpoints.push(t5);
  2186. arcpoints.push(t6);
  2187. arcpoints.push(p1);
  2188. arcpoints.push(p2);
  2189. arcpoints.push(p3);
  2190. arcpoints.push(p4);
  2191. arcpoints.push(p5);
  2192. arcpoints.push(p6);
  2193. }
  2194. return arcpoints;
  2195. };
  2196. CalculateElement.prototype.getSlidingPoints = function (point1, point2, toward, thick) {
  2197. var calculateLine = this.layer.calculateLine;
  2198. var line = calculateLine.createLine(point1, point2);
  2199. var drawpoints = [];
  2200. var point3, point4, point5, point6;
  2201. var r = 10;
  2202. if (line.hasOwnProperty('x')) {
  2203. point3 = { x: point1.x - r, y: point1.y };
  2204. point4 = { x: point1.x - r, y: (point1.y + point2.y) / 2 };
  2205. point5 = { x: point1.x + r, y: (point1.y + point2.y) / 2 };
  2206. point6 = { x: point1.x + r, y: point2.y };
  2207. }
  2208. else if (line.hasOwnProperty('y')) {
  2209. point3 = { x: point1.x, y: point1.y - r };
  2210. point4 = { x: (point1.x + point2.x) / 2, y: point1.y - r };
  2211. point5 = { x: (point1.x + point2.x) / 2, y: point1.y + r };
  2212. point6 = { x: point2.x, y: point2.y + r };
  2213. }
  2214. else {
  2215. var tl = {};
  2216. var a = Math.atan(line.a);
  2217. tl.a = -1 / line.a;
  2218. var temp_line1 = calculateLine.createLine2(tl, point1);
  2219. var temp_line2 = calculateLine.createLine2(tl, point2);
  2220. var centerpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
  2221. var tempcenterline = calculateLine.createLine2(tl, centerpoint);
  2222. var db = r / Math.cos(a);
  2223. var like_line1 = { a: line.a, b: line.b + db };
  2224. var like_line2 = { a: line.a, b: line.b - db };
  2225. point3 = calculateLine.getIntersectionPoint(like_line1, temp_line1);
  2226. point4 = calculateLine.getIntersectionPoint(like_line1, tempcenterline);
  2227. point5 = calculateLine.getIntersectionPoint(like_line2, tempcenterline);
  2228. point6 = calculateLine.getIntersectionPoint(like_line2, temp_line2);
  2229. }
  2230. drawpoints.push(point1);
  2231. drawpoints.push(point2);
  2232. drawpoints.push(point3);
  2233. drawpoints.push(point4);
  2234. drawpoints.push(point5);
  2235. drawpoints.push(point6);
  2236. return drawpoints;
  2237. };
  2238. CalculateElement.prototype.getSymbolPoints = function (point1, point2, type, toward, thick) {
  2239. var points = [];
  2240. if (type == "OpenDoor" || type == "OpenWindow") {
  2241. points.push(point1);
  2242. points.push(point2);
  2243. }
  2244. else if (type == "SimpleDoor") {
  2245. points = this.getSimpleDoorPoints(point1, point2, toward, thick);
  2246. }
  2247. else if (type == "BiFoldDoor") {
  2248. points = this.getBiFoldDoorPoints(point1, point2, toward, thick);
  2249. }
  2250. else if (type == "SlidingDoor" || type == "SlidingWindow") {
  2251. points = this.getSlidingPoints(point1, point2, toward, thick);
  2252. }
  2253. else if (type == "SingleCasement") {
  2254. points = this.getSingleCasementPoints(point1, point2, toward, thick);
  2255. }
  2256. else if (type == "DoubleCasement") {
  2257. points = this.getDoubleCasementPoints(point1, point2, toward, thick);
  2258. }
  2259. return points;
  2260. };