12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657 |
- function CalculateElement(layer) {
- this.layer = layer
- this.calculateLine = this.layer.calculateLine;
- };
- CalculateElement.prototype.getSquarePointsFromStair = function (line1, line2, verticalLine1, verticalLine2) {
- var tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine1, line1);
- var tempjoin3 = this.calculateLine.getIntersectionPoint(verticalLine1, line2);
- var tempjoin2 = this.calculateLine.getIntersectionPoint(verticalLine2, line1);
- var tempjoin4 = this.calculateLine.getIntersectionPoint(verticalLine2, line2);
- var distance = BABYLON.Vector2.Distance(tempjoin1, tempjoin2);
- var num = parseInt(distance / this.layer.parameter.staircell);
- var count = 1;
- var linkedpoints = [];
- linkedpoints.push({ 1: tempjoin1, 2: tempjoin3 });
- while (count < num) {
- var verticalLine = null;
- if (verticalLine2.hasOwnProperty('x')) {
- diff = (verticalLine2.x - verticalLine1.x) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine2.x - diff * count) };
- }
- else if (verticalLine2.hasOwnProperty('y')) {
- diff = (verticalLine2.y - verticalLine1.y) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine2.y - diff * count) };
- }
- else {
- diff = (verticalLine2.b - verticalLine1.b) / num;
- verticalLine = { a: verticalLine2.a, b: (verticalLine2.b - diff * count) };
- }
- var join1 = this.calculateLine.getIntersectionPoint(verticalLine, line1);
- var join2 = this.calculateLine.getIntersectionPoint(verticalLine, line2);
- linkedpoints.push({ 1: join1, 2: join2 });
- ++count;
- }
- linkedpoints.push({ 1: tempjoin2, 2: tempjoin4 });
- return linkedpoints;
- };
- CalculateElement.prototype.GetSpiralpoints = function (point) {
- var line = {};
- var points = [];
- var verticalLine = {};
- var verticalLine1 = {};
- var verticalLine2 = {};
- points.push({ x: (point.x + this.layer.parameter.spiralR1), y: point.y });
- points.push({ x: (point.x - this.layer.parameter.spiralR1), y: point.y });
- for (var i = 1; i < 6; ++i) {
- line.a = Math.tan(i * 30 * Math.PI / 180);
- line.b = point.y - line.a * point.x;
- verticalLine.a = -1 / line.a;
- verticalLine1.a = -1 / line.a;
- verticalLine2.a = -1 / line.a;
- verticalLine.b = point.y + 1 / line.a * point.x;
- verticalLine1.b = verticalLine.b + this.layer.calculateLine.driftY3(verticalLine.a, this.layer.parameter.spiralR1);
- verticalLine2.b = verticalLine.b - this.layer.calculateLine.driftY3(verticalLine.a, this.layer.parameter.spiralR1);
- var join1 = this.layer.calculateLine.getIntersectionPoint(verticalLine1, line);
- points.push(join1);
- var join2 = this.layer.calculateLine.getIntersectionPoint(verticalLine2, line);
- points.push(join2);
- }
- return points;
- };
- //三个点的时候
- CalculateElement.prototype.getAllPointsFromStair = function (points) {
- var allpoints = {};
- var linkedpoints = [];
- //表示不是闭合的
- var state = 1;
- var interval1 = (this.layer.parameter.stairWidth + this.layer.parameter.stairMeasure);
- var interval2 = this.layer.parameter.stairWidth;
- //和墙没关系,只是使用了它的函数
- var lines = this.getWalllines(points, state, interval1, interval2);
- var edgepoints = this.getOutlineMeasureJoin(lines, points, state);
- var verticalLine_a = null;
- var verticalLine_b = null;
- for (var i = 0; i < edgepoints.border1.length - 1; ++i) {
- var point11 = edgepoints.border1[i];
- var point12 = edgepoints.border1[i + 1];
- var point21 = edgepoints.border2[i];
- var point22 = edgepoints.border2[i + 1];
- var line1 = this.calculateLine.createLine(point11, point12);
- var line2 = this.calculateLine.createLine(point21, point22);
- var num, extendnum, extenddiff, verticalLine1, verticalLine3;
- var join1, join2, join3, join4;
- var extendDistance = null;
- verticalLine1 = this.calculateLine.getVerticalLine(line2, point21);
- verticalLine3 = this.calculateLine.getVerticalLine(line2, point11);
- var tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine1, line1);
- var distance1 = BABYLON.Vector2.Distance(tempjoin1, point11);
- if (distance1 < this.layer.parameter.minInterval) {
- linkedpoints.push({ 1: point11, 2: point21 });
- verticalLine_a = verticalLine1;
- }
- else if (this.calculateLine.containPoint(point11, point12, tempjoin1)) {
- verticalLine_a = verticalLine1;
- num = parseInt(distance1 / this.layer.parameter.staircell);
- if (num == 0 && distance1 > this.layer.parameter.minInterval) {
- num = 1;
- }
- var count = 0;
- while (count < num) {
- var verticalLine = null;
- if (verticalLine3.hasOwnProperty('x')) {
- diff = (verticalLine3.x - verticalLine1.x) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine3.x - diff * count) };
- }
- else if (verticalLine3.hasOwnProperty('y')) {
- diff = (verticalLine3.y - verticalLine1.y) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine3.y - diff * count) };
- }
- else {
- diff = (verticalLine3.b - verticalLine1.b) / num;
- verticalLine = { a: verticalLine3.a, b: (verticalLine3.b - diff * count) };
- }
- var p = this.calculateLine.getIntersectionPoint(verticalLine, line1);
- linkedpoints.push({ 1: p, 2: point21 });
- ++count;
- }
- }
- else {
- verticalLine_a = verticalLine3;
- tempjoin1 = this.calculateLine.getIntersectionPoint(verticalLine3, line2);
- distance1 = BABYLON.Vector2.Distance(tempjoin1, point21);
- num = parseInt(distance1 / this.layer.parameter.staircell);
- if (num == 0 && distance1 > this.layer.parameter.minInterval) {
- num = 1;
- }
- var count = 0;
- while (count < num) {
- var verticalLine = null;
- if (verticalLine1.hasOwnProperty('x')) {
- diff = (verticalLine1.x - verticalLine3.x) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine1.x - diff * count) };
- }
- else if (verticalLine1.hasOwnProperty('y')) {
- diff = (verticalLine1.y - verticalLine3.y) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine1.y - diff * count) };
- }
- else {
- diff = (verticalLine1.b - verticalLine3.b) / num;
- verticalLine = { a: verticalLine1.a, b: (verticalLine1.b - diff * count) };
- }
- var p = this.calculateLine.getIntersectionPoint(verticalLine, line2);
- linkedpoints.push({ 1: point11, 2: p });
- ++count;
- }
- }
- var verticalLine2 = this.calculateLine.getVerticalLine(line2, point22);
- var verticalLine4 = this.calculateLine.getVerticalLine(line2, point12);
- if (i != edgepoints.border1.length - 2) {
- var tempjoin2 = this.calculateLine.getIntersectionPoint(verticalLine2, line1);
- var distance2 = BABYLON.Vector2.Distance(tempjoin2, point12);
- if (distance2 < this.layer.parameter.minInterval) {
- linkedpoints.push({ 1: point12, 2: point22 });
- verticalLine_b = verticalLine2;
- var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
- linkedpoints = linkedpoints.concat(linked);
- }
- else if (this.calculateLine.containPoint(point11, point12, tempjoin2)) {
- verticalLine_b = verticalLine2;
- var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
- linkedpoints = linkedpoints.concat(linked);
- verticalLine_a = null;
- verticalLine_b = null;
- num = parseInt(distance2 / this.layer.parameter.staircell);
- if (num == 0 && distance1 > this.layer.parameter.minInterval) {
- num = 1;
- }
- var count = 1;
- while (count < num) {
- var verticalLine = null;
- if (verticalLine4.hasOwnProperty('x')) {
- diff = (verticalLine4.x - verticalLine2.x) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine4.x - diff * count) };
- }
- else if (verticalLine4.hasOwnProperty('y')) {
- diff = (verticalLine4.y - verticalLine2.y) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine4.y - diff * count) };
- }
- else {
- diff = (verticalLine4.b - verticalLine2.b) / num;
- verticalLine = { a: verticalLine4.a, b: (verticalLine4.b - diff * count) };
- }
- var p = this.calculateLine.getIntersectionPoint(verticalLine, line1);
- linkedpoints.push({ 1: p, 2: point22 });
- ++count;
- }
- }
- else {
- verticalLine_b = verticalLine4;
- var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
- linkedpoints = linkedpoints.concat(linked);
- verticalLine_a = null;
- verticalLine_b = null;
- num = parseInt(distance2 / this.layer.parameter.staircell);
- if (num == 0 && distance1 > this.layer.parameter.minInterval) {
- num = 1;
- }
- var count = 1;
- while (count < num) {
- var verticalLine = null;
- if (verticalLine2.hasOwnProperty('x')) {
- diff = (verticalLine2.x - verticalLine4.x) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine2.x - diff * count) };
- }
- else if (verticalLine2.hasOwnProperty('y')) {
- diff = (verticalLine2.y - verticalLine4.y) / num;
- verticalLine = { a: 0, b: 0, x: (verticalLine2.y - diff * count) };
- }
- else {
- diff = (verticalLine2.b - verticalLine4.b) / num;
- verticalLine = { a: verticalLine2.a, b: (verticalLine2.b - diff * count) };
- }
- var p = this.calculateLine.getIntersectionPoint(verticalLine, line2);
- linkedpoints.push({ 1: point12, 2: p });
- ++count;
- }
- }
- }
- else {
- verticalLine_b = verticalLine2;
- var linked = this.getSquarePointsFromStair(line1, line2, verticalLine_a, verticalLine_b);
- linkedpoints = linkedpoints.concat(linked);
- verticalLine_a = null;
- verticalLine_b = null;
- }
- }
- allpoints.vertical = linkedpoints;
- allpoints.border1 = edgepoints.border1;
- allpoints.border2 = edgepoints.border2;
- allpoints.arrows1 = edgepoints.arrows1;
- allpoints.arrows2 = edgepoints.arrows2;
- return allpoints;
- };
- /*
- //两个点的时候
- CalculateElement.prototype.getAllPointsFromStair=function(point1,point2)
- {
- var line = this.calculateLine.createLine(point1,point2);
- var lines = this.calculateLine.getParallelLineForDistance(line,this.layer.parameter.stairWidth);
-
- var start1 = this.calculateLine.getJoinLinePoint(point1,lines.line1);
- var start2 = this.calculateLine.getJoinLinePoint(point1,lines.line2);
-
- var end1 = this.calculateLine.getJoinLinePoint(point2,lines.line1);
- var end2 = this.calculateLine.getJoinLinePoint(point2,lines.line2);
-
- var distance = BABYLON.Vector2.Distance(point1,point2);
- var num = parseInt(distance/this.layer.parameter.staircell);
-
- //针对直线的函数
- var divide=null;
-
- var verticalLine1 = this.calculateLine.getVerticalLine(line,point1);
- var verticalLine2 = this.calculateLine.getVerticalLine(line,point2);
-
- var diff=null;
- var count=1;
- var points=[];
- points.push({1:start1,2:start2});
-
- while(count<num)
- {
- var verticalLine=null;
- if(verticalLine1.hasOwnProperty('x'))
- {
- diff=(verticalLine1.x-verticalLine2.x)/num;
- verticalLine={a:0,b:0,x:(verticalLine1.x-diff*count)};
- }
- else if(verticalLine1.hasOwnProperty('y'))
- {
- diff=(verticalLine1.y-verticalLine2.y)/num;
- verticalLine={a:0,b:0,x:(verticalLine1.y-diff*count)};
- }
- else
- {
- diff=(verticalLine1.b-verticalLine2.b)/num;
- verticalLine={a:verticalLine1.a,b:(verticalLine1.b-diff*count)};
- }
- var p1 = this.calculateLine.getIntersectionPoint(verticalLine,lines.line1);
- var p2 = this.calculateLine.getIntersectionPoint(verticalLine,lines.line2);
- points.push({1:p1,2:p2});
- ++count;
- }
- points.push({1:end1,2:end2});
-
- return points;
- };
- */
- //点之间的距离小于r,就是包含
- CalculateElement.prototype.pointContain = function (point1, point2, r) {
- var distance = BABYLON.Vector2.Distance(point1, point2);
- if (distance < r) {
- return true;
- }
- else {
- return false;
- }
- };
- //point1到point2的直线,宽度是2*deep,是否包含point
- CalculateElement.prototype.lineContain = function (point1, point2, point, deep) {
- var line = this.calculateLine.createLine(point1, point2);
- var join = this.calculateLine.getJoinLinePoint(point, line);
- var flag = this.calculateLine.containPoint(point1, point2, join);
- if (!flag) {
- return false;
- }
- else if (BABYLON.Vector2.Distance(join, point) < deep) {
- return true;
- }
- else {
- return false;
- }
- };
- CalculateElement.prototype.singleSymbolContain = function (point, id) {
- if (this.layer.vectors[id].geometry.floor != this.layer.selectFloor) {
- return null;
- }
- var r;
- var points = this.layer.vectors[id].geometry.points;
- var result = {};
- //当是墙的时候
- if (this.layer.vectors[id].geometry.geoType == "Wall") {
- if (this.layer.vectors[id].geometry.wallType == 1) {
- r = wallThickness / 2;
- }
- else {
- r = partitionThickness / 2;
- }
- }
- //当是楼梯的时候
- else if (this.layer.vectors[id].geometry.geoType == "WinderStair") {
- r = this.layer.parameter.stairWidth;
- }
- else if (this.layer.vectors[id].geometry.geoType == "Spiral") {
- var distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point1);
- if (distance < this.layer.parameter.spiralR2) {
- result.id = id;
- result.type = 0;
- result.index = 1;
- result.geoType = "Spiral";
- return result;
- }
- distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point2);
- if (distance < this.layer.parameter.spiralR2) {
- result.id = id;
- result.type = 0;
- result.index = 2;
- result.geoType = "Spiral";
- return result;
- }
- distance = BABYLON.Vector2.Distance(point, this.layer.vectors[id].geometry.point);
- if (distance < this.layer.parameter.spiralR1) {
- result.id = id;
- result.type = 1;
- result.index = null;
- result.geoType = "Spiral";
- return result;
- }
- return null;
- }
- if (points.length < 2) {
- alert("CalculateElement:10");
- return null;
- }
- var endindex = null;
- //判断拐角
- for (var i = 0; i < points.length - 1; ++i) {
- var point1 = points[i];
- if (this.pointContain(point1, point, r)) {
- result.id = id;
- result.index = i;
- result.type = 0;
- return result;
- }
- var point2 = points[i + 1];
- if (this.pointContain(point2, point, r)) {
- result.id = id;
- result.index = i + 1;
- result.type = 0;
- return result;
- }
- }
- for (var i = 0; i < points.length; ++i) {
- var point1 = points[i];
- endindex = this.getNextIndex(points, i);
- var point2 = points[endindex];
- if (i == points.length - 1 && this.layer.vectors[id].geometry.state == 1) {
- break;
- }
- else if (i == points.length - 1 && this.layer.vectors[id].geometry.geoType == "WinderStair") {
- break;
- }
- var line = this.calculateLine.createLine(point1, point2);
- if (this.lineContain(point1, point2, point, r)) {
- result.id = id;
- result.index = i;
- result.type = 1;
- result.endindex = endindex;
- return result;
- }
- }
- return null;
- };
- //wallId的墙是否包含point,与singleWallContain不同的是当point离wallId的距离小于thick/2就算包含
- CalculateElement.prototype.singleWallContain2 = function (point, id, index, wallId) {
- var result = this.singleWallContain(point, wallId);
- if (result == null) {
- result = {};
- var d = this.layer.vectors[id].geometry.wallInfo[index].thick / 2;
- var points = this.layer.vectors[wallId].geometry.points;
- for (var i = 0; i < points.length; ++i) {
- var point1 = points[i];
- var endindex = this.getNextIndex(points, i);
- var point2 = points[endindex];
- if (i == points.length - 1 && this.layer.vectors[wallId].geometry.state == 1) {
- break;
- }
- var deep = this.layer.vectors[wallId].geometry.wallInfo[i].thick / 2 + d;
- var flag = lineContain(point1, point2, point, deep);
- if (flag) {
- result.id = wallId;
- result.index = Math.min(i, endindex);
- result.endindex = Math.max(i, endindex);
- result.thick = this.layer.vectors[wallId].geometry.wallInfo[i].thick;
- return result;
- }
- }
- return null;
- }
- }
- ///id是wallId的墙是否包含point
- CalculateElement.prototype.singleWallContain = function (point, wallId) {
- if (this.layer.vectors[wallId].geometry.floor != this.layer.selectFloor) {
- return null;
- }
- var points = this.layer.vectors[wallId].geometry.points;
- var type = this.layer.vectors[wallId].geometry.wallType;
- var r;
- if (type == 1) {
- r = wallThickness / 2;
- }
- else {
- r = partitionThickness / 2;
- }
- if (points.length < 2) {
- alert("CalculateElement:10");
- return null;
- }
- var result = {};
- var endindex = null;
- //判断拐角
- for (var i = 0; i < points.length - 1; ++i) {
- var point1 = points[i];
- if (this.pointContain(point1, point, r)) {
- result.id = wallId;
- result.index = i;
- result.type = 0;
- return result;
- }
- var point2 = points[i + 1];
- if (this.pointContain(point2, point, r)) {
- result.id = wallId;
- result.index = i + 1;
- result.type = 0;
- return result;
- }
- }
- for (var i = 0; i < points.length; ++i) {
- var point1 = points[i];
- endindex = this.getNextIndex(points, i);
- var point2 = points[endindex];
- if (i == points.length - 1 && this.layer.vectors[wallId].geometry.state == 1) {
- break;
- }
- var line = this.calculateLine.createLine(point1, point2);
- r = this.layer.vectors[wallId].geometry.wallInfo[i].thick / 2 + wallThickness / 2;
- if (this.lineContain(point1, point2, point, r)) {
- result.id = wallId;
- result.index = i;
- result.type = 1;
- result.endindex = endindex;
- return result;
- }
- }
- return null;
- };
- //有没有symbol包含point,如果有返回该symbol
- //r主要是可能是墙或隔断的宽度
- CalculateElement.prototype.symbolsContain = function (point) {
- //判断当前选择的有没有symbol
- for (var key in this.layer.vectors[this.layer.currentState.currentWallId].symbol2Ds) {
- var symbol2d = this.layer.vectors[this.layer.currentState.currentWallId].symbol2Ds[key];
- var r = this.layer.vectors[this.layer.currentState.currentWallId].geometry.wallInfo[Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex)].thick;
- if (this.lineContain(symbol2d.geometry.point1, symbol2d.geometry.point2, point, r)) {
- return symbol2d;
- }
- }
- return null;
- };
- CalculateElement.prototype.stairsContain = function (point, exceptid) {
- var len = this.layer.data2d.stairIds.length;
- var result = null;
- for (var i = 0; i < len; ++i) {
- var stairId = this.layer.data2d.stairIds[i];
- if (this.layer.vectors[stairId].geometry.floor != this.layer.selectFloor) {
- continue;
- }
- result = this.singleSymbolContain(point, stairId);
- if (result != null) {
- this.layer.currentState.currentendlinePointIndex = result.endindex;
- this.layer.currentState.currentStairId = stairId;
- this.layer.currentState.currentstartlinePointIndex = result.index;
- return result;
- }
- }
- return result;
- };
- //返回0表示当前鼠标指向的是某个点
- //返回1表示当前鼠标指向的是某条线
- //返回2表示当前鼠标指向的是空白
- CalculateElement.prototype.wallsContain = function (point, exceptid) {
- var len = this.layer.data2d.wallIds.length;
- var result = null;
- var result2 = null;
- for (var i = 0; i < len; ++i) {
- var wallId = this.layer.data2d.wallIds[i];
- if (exceptid != null && typeof (exceptid != "undefined")) {
- if (wallId == exceptid) {
- continue;
- }
- }
- if (this.layer.vectors[wallId].geometry.floor != this.layer.selectFloor) {
- continue;
- }
- result = this.singleWallContain(point, wallId);
- if (result != null) {
- this.layer.currentState.currentendlinePointIndex = result.endindex;
- this.layer.currentState.currentWallId = result.id;
- this.layer.currentState.currentstartlinePointIndex = result.index;
- if (result.type == 0) {
- return result;
- }
- else {
- result2 = result;
- }
- }
- }
- return result2;
- };
- //得到挨着index1,index2的墙的线段
- CalculateElement.prototype.getOrginLine = function (len, id, index1, index2) {
- var side1 = this.getSideIndex(len, index1);
- var side2 = this.getSideIndex(len, index2);
- var sideline1 = [];
- var sideline2 = [];
- var point1index = null;
- var point2index = null;
- if (side1.pre == index2) {
- sideline1.push(index1);
- sideline1.push(side1.next);
- point1index = side1.next;
- }
- else {
- sideline1.push(index1);
- sideline1.push(side1.pre);
- point1index = side1.pre;
- }
- if (side2.pre == index1) {
- sideline2.push(index2);
- sideline2.push(side2.next);
- point2index = side2.next;
- }
- else {
- sideline2.push(index2);
- sideline2.push(side2.pre);
- point2index = side2.pre;
- }
- return { line1: sideline1, point1: point1index, line2: sideline2, point2: point2index };
- };
- //index两旁
- CalculateElement.prototype.getSideIndex = function (len, index) {
- var pre = index - 1;
- var next = index + 1;
- if (pre < 0) {
- pre = len - 1;
- }
- if (next == len) {
- next = 0;
- }
- return { pre: pre, next: next };
- };
- //获取symbol两个端点离鼠标与symbol交点的距离
- CalculateElement.prototype.getSymbolDistance = function (line, point, symbol) {
- var join = this.calculateLine.getJoinLinePoint(line, point);
- var distance1 = BABYLON.Vector2.Distance(join, symbol.point1);
- var distance2 = BABYLON.Vector2.Distance(join, symbol.point2);
- return { dis1: distance1, dis2: distance2 };
- };
- //points数组里面,在index前面的点
- CalculateElement.prototype.getPrePoint = function (points, index) {
- var pre = index - 1;
- if (pre > -1) {
- return points[pre];
- }
- else {
- return points[points.length - 1];
- }
- };
- //points数组里面,在index前面的序号
- CalculateElement.prototype.getPreIndex = function (points, index) {
- var pre = index - 1;
- if (pre == -1) {
- pre = points.length - 1;
- }
- return pre;
- };
- //points数组里面,在index后面的点
- CalculateElement.prototype.getNextPoint = function (points, index) {
- var next = index + 1;
- if (next > points.length - 1) {
- return points[0];
- }
- else {
- return points[next];
- }
- };
- //points数组里面,在index后面的序号
- CalculateElement.prototype.getNextIndex = function (points, index, state) {
- var next = index + 1;
- if (next > points.length - 1 && (typeof (state) == "undefined" || state == 0)) {
- next = 0;
- }
- else if (next > points.length - 1) {
- next = index - 1;
- }
- return next;
- };
- //在长度是len的数组里,序号index和num是否相邻
- CalculateElement.prototype.isNeighbor = function (len, index, num) {
- if (Math.abs(index - num) == 1) {
- return true;
- }
- else if (index == 0 && (num == len - 1)) {
- return true;
- }
- else if ((index == len - 1) && num == 0) {
- return true;
- }
- else {
- return false;
- }
- };
- //计算墙的尺寸
- CalculateElement.prototype.computerMeasure = function (geometry) {
- var points = geometry.points;
- var state = geometry.state;
- var type = geometry.wallType;
- var lines, interval;
- /*
- if(type==2)
- {
- interval=partitionThickness;
- }
- else
- {
- interval=wallThickness;
- }
- */
- //lines=this.getWalllines(points,state,interval,interval/2);
- lines = this.getWalllines2(geometry);
- var wallpoint = this.getOutlineMeasureJoin(lines, points, state);
- //var wallpoint=this.getOutlineMeasureJoin2(lines,geometry);
- return wallpoint;
- };
- //从一组border里面挑选出合适的
- CalculateElement.prototype.getIndexFromLines = function (lines, point1, point2) {
- var seg = {};
- seg.point1 = point1;
- seg.point2 = point2;
- var joins = {};
- for (var i = 0; i < lines.length; ++i) {
- var seg1 = {};
- seg1.point1 = this.layer.vectors[lines[i].id].geometry.wallInfo[lines[i].index1][lines[i].border];
- seg1.point2 = this.layer.vectors[lines[i].id].geometry.wallInfo[lines[i].index2][lines[i].border];
- var join = this.calculateLine.isjoin(seg, seg1);
- if (join == null) {
- continue;
- }
- else {
- joins[i] = join;
- }
- }
- var index = null;
- for (var key in joins) {
- if (index == null) {
- index = key;
- }
- else {
- var d1 = BABYLON.Vector2.Distance(point2, joins[key]);
- var d2 = BABYLON.Vector2.Distance(point2, joins[index]);
- if (d1 < d2) {
- index = key;
- }
- }
- }
- if (index == null) {
- return null;
- }
- else {
- return { index: index, join: joins[key] };
- }
- };
- //调整不闭合墙的端点
- CalculateElement.prototype.changeEndPointMeasure = function (wallpoint, geometry) {
- if (typeof (geometry.firstLines) != "undefined" && geometry.firstLines.length > 0) {
- var result = this.singleWallContain(geometry.points[0], geometry.firstLines[0].id);
- if (result != null) {
- var jo = this.getIndexFromLines(geometry.firstLines, wallpoint.border1[0], wallpoint.border1[1]);
- if (jo != null) {
- wallpoint.border1[0] = jo["join"];
- var arrowjoin1 = this.calculateLine.getJoinLinePoint(jo["join"], this.calculateLine.createLine(wallpoint.arrows1[0], wallpoint.arrows1[1]));
- if (arrowjoin1 != null) {
- wallpoint.arrows1[0] = arrowjoin1;
- }
- var seg = {};
- seg.point1 = this.layer.vectors[geometry.firstLines[jo["index"]].id].geometry.wallInfo[geometry.firstLines[jo["index"]].index1][geometry.firstLines[jo["index"]].border];
- seg.point2 = this.layer.vectors[geometry.firstLines[jo["index"]].id].geometry.wallInfo[geometry.firstLines[jo["index"]].index2][geometry.firstLines[jo["index"]].border];
- var jn = this.calculateLine.isjoin(seg, { point1: wallpoint.border2[0], point2: wallpoint.border2[1] });
- if (jn != null) {
- wallpoint.border2[0] = jn;
- var arrowjoin2 = this.calculateLine.getJoinLinePoint(jn, this.calculateLine.createLine(wallpoint.arrows2[0], wallpoint.arrows2[1]));
- if (arrowjoin2 != null) {
- wallpoint.arrows2[0] = arrowjoin2;
- }
- }
- }
- }
- else {
- delete geometry.firstLines;
- }
- }
- if (typeof (geometry.endLines) != "undefined" && geometry.endLines.length > 0) {
- var len = wallpoint.border1.length;
- var result = this.singleWallContain(geometry.points[len - 1], geometry.endLines[0].id);
- if (result != null) {
- var jo = this.getIndexFromLines(geometry.endLines, wallpoint.border1[0], wallpoint.border1[1]);
- if (jo != null) {
- wallpoint.border1[len - 1] = jo["join"];
- var arrowjoin1 = this.calculateLine.getJoinLinePoint(jo["join"], this.calculateLine.createLine(wallpoint.arrows1[len - 1], wallpoint.arrows1[len - 2]));
- if (arrowjoin1 != null) {
- wallpoint.arrows1[len - 1] = arrowjoin1;
- }
- var seg = {};
- seg.point1 = this.layer.vectors[geometry.endLines[jo["index"]].id].geometry.wallInfo[geometry.endLines[jo["index"]].index1][geometry.endLines[jo["index"]].border];
- seg.point2 = this.layer.vectors[geometry.endLines[jo["index"]].id].geometry.wallInfo[geometry.endLines[jo["index"]].index2][geometry.endLines[jo["index"]].border];
- var jn = this.calculateLine.isjoin(seg, { point1: wallpoint.border2[len - 2], point2: wallpoint.border2[len - 1] });
- if (jn != null) {
- wallpoint.border2[len - 1] = jn;
- var arrowjoin2 = this.calculateLine.getJoinLinePoint(jn, this.calculateLine.createLine(wallpoint.arrows2[len - 1], wallpoint.arrows2[len - 2]));
- if (arrowjoin2 != null) {
- wallpoint.arrows2[len - 1] = arrowjoin2;
- }
- }
- }
- }
- else {
- delete geometry.endLines;
- }
- }
- return wallpoint;
- };
- //获得墙的内外侧
- CalculateElement.prototype.getOneWallOutline = function (line, interval1, interval2) {
- var border1 = {};
- var border2 = {};
- var measure1 = {};
- var measure2 = {};
- if (line.a == 0) {
- measure1.a = 0;
- measure1.b = 0
- measure2.a = 0;
- measure2.b = 0
- border1.a = 0;
- border1.b = 0
- border2.a = 0;
- border2.b = 0
- if (line.hasOwnProperty('x')) {
- measure1.x = line.x + interval1;
- border1.x = line.x + interval2;
- measure2.x = line.x - interval1;
- border2.x = line.x - interval2;
- }
- else if (line.hasOwnProperty('y')) {
- measure1.y = line.y + interval1;
- border1.y = line.y + interval2;
- measure2.y = line.y - interval1;
- border2.y = line.y - interval2;
- }
- }
- else {
- //测量
- measure1.a = line.a;
- //measure1.b= line.b+this.calculateLine.driftY(measure1.a,1,type);
- measure1.b = line.b + this.calculateLine.driftY3(measure1.a, interval1);
- measure2.a = line.a;
- //measure2.b= line.b-this.calculateLine.driftY(measure2.a,1,type);
- measure2.b = line.b - this.calculateLine.driftY3(measure2.a, interval1);
- //墙外侧
- border1.a = line.a;
- border1.b = line.b + this.calculateLine.driftY3(border1.a, interval2);
- border2.a = line.a;
- border2.b = line.b - this.calculateLine.driftY3(border2.a, interval2);
- }
- return { b1: border1, b2: border2, m1: measure1, m2: measure2 };
- };
- /*
- //删除墙后,border变了
- CalculateElement.prototype.changeWallEndpoint=function(point,line1,line2)
- {
- var verticalLine=this.calculateLine.getVerticalLine(line1,point);
- var join1=this.getIntersectionPoint(line1,verticalLine);
- return join;
- }
- */
- //墙的厚度可变
- CalculateElement.prototype.getWalllines2 = function (geometry) {
- var points = geometry.points;
- var wallInfo = geometry.wallInfo;
- var ringflag = geometry.state;
- var type = geometry.wallType;
- var d;
- if (type == 2) {
- d = partitionThickness / 2;
- }
- else {
- d = wallThickness / 2;
- }
- var result = { border1: [], border2: [], arrows1: [], arrows2: [] };
- var interval1 = wallInfo[0].thick / 2 + d;
- // var interval2 = wallInfo[0].thick / 2;
- var interval2 = 0.00001;
- var outlines = this.getOneWallOutline(this.calculateLine.createLine(points[0], points[1]), interval1, interval2);
- result.border1.push(outlines.b1);
- result.border2.push(outlines.b2);
- result.arrows1.push(outlines.m1);
- result.arrows2.push(outlines.m2);
- for (var i = 1; i < points.length; ++i) {
- var j = i - 1;
- var k = i + 1;
- if (i == points.length - 1) {
- k = 0;
- }
- if (ringflag == 1 && i == points.length - 1) //不闭合
- {
- return result;
- }
- var line = this.calculateLine.createLine(points[i], points[k]);
- var radial = { point1: points[i], point2: points[k] };
- 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] };
- interval1 = wallInfo[i].thick / 2 + d;
- // interval2 = wallInfo[i].thick / 2;
- interval2 = 0.00001;
- var outlines2 = this.getOneWallOutline(line, interval1, interval2);
- var join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b1);
- if (join1 == null) {
- join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
- }
- var join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b2);
- if (join2 == null) {
- join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
- }
- var _join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b2);
- if (_join1 == null) {
- _join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
- }
- var _join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b1);
- if (_join2 == null) {
- _join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
- }
- var line2 = this.calculateLine.createLine(points[i], points[j]);
- var radial2 = { point1: points[i], point2: points[j] };
- var nextseg1 = {};
- var nextseg3 = {};
- var nextseg2 = {};
- var nextseg4 = {};
- nextseg1.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b1);
- nextseg1.point2 = join1;
- nextseg3.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b2);
- nextseg3.point2 = join2;
- nextseg2.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b1);
- nextseg2.point2 = join1;
- nextseg4.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b2);
- nextseg4.point2 = join2;
- 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)) {
- result.border1.push(outlines2.b2);
- result.border2.push(outlines2.b1);
- result.arrows1.push(outlines2.m2);
- result.arrows2.push(outlines2.m1);
- }
- else {
- result.border1.push(outlines2.b1);
- result.border2.push(outlines2.b2);
- result.arrows1.push(outlines2.m1);
- result.arrows2.push(outlines2.m2);
- }
- }
- return result;
- };
- //获取墙的border和arrows
- CalculateElement.prototype.getWalllines = function (points, ringflag, interval1, interval2) {
- var result = { border1: [], border2: [], arrows1: [], arrows2: [] };
- var outlines = this.getOneWallOutline(this.calculateLine.createLine(points[0], points[1]), interval1, interval2);
- result.border1.push(outlines.b1);
- result.border2.push(outlines.b2);
- result.arrows1.push(outlines.m1);
- result.arrows2.push(outlines.m2);
- for (var i = 1; i < points.length; ++i) {
- var j = i - 1;
- var k = i + 1;
- if (i == points.length - 1) {
- k = 0;
- }
- if (ringflag == 1 && i == points.length - 1) //不闭合
- {
- return result;
- }
- var line = this.calculateLine.createLine(points[i], points[k]);
- var radial = { point1: points[i], point2: points[k] };
- 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] };
- var outlines2 = this.getOneWallOutline(line, interval1, interval2);
- var join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b1);
- if (join1 == null) {
- join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
- }
- var join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b2);
- if (join2 == null) {
- join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
- }
- var _join1 = this.calculateLine.getIntersectionPoint(outlines1.b1, outlines2.b2);
- if (_join1 == null) {
- _join1 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b1);
- }
- var _join2 = this.calculateLine.getIntersectionPoint(outlines1.b2, outlines2.b1);
- if (_join2 == null) {
- _join2 = this.calculateLine.getJoinLinePoint(points[i], outlines1.b2);
- }
- var line2 = this.calculateLine.createLine(points[i], points[j]);
- var radial2 = { point1: points[i], point2: points[j] };
- var nextseg1 = {};
- var nextseg3 = {};
- var nextseg2 = {};
- var nextseg4 = {};
- nextseg1.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b1);
- nextseg1.point2 = join1;
- nextseg3.point1 = this.calculateLine.getJoinLinePoint(points[k], outlines2.b2);
- nextseg3.point2 = join2;
- nextseg2.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b1);
- nextseg2.point2 = join1;
- nextseg4.point1 = this.calculateLine.getJoinLinePoint(points[j], outlines1.b2);
- nextseg4.point2 = join2;
- 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)) {
- result.border1.push(outlines2.b2);
- result.border2.push(outlines2.b1);
- result.arrows1.push(outlines2.m2);
- result.arrows2.push(outlines2.m1);
- }
- else {
- result.border1.push(outlines2.b1);
- result.border2.push(outlines2.b2);
- result.arrows1.push(outlines2.m1);
- result.arrows2.push(outlines2.m2);
- }
- }
- return result;
- }
- //获取交点
- CalculateElement.prototype.getOutlineMeasureJoin2 = function (walllines, geometry) {
- if (walllines == null) {
- return;
- }
- var state = geometry.state;
- var points = geometry.points;
- var border1 = geometry.wallInfo[0].border1;
- var border2 = geometry.wallInfo[0].border2;
- var _border1 = geometry.wallInfo[geometry.points.length - 1].border1;
- var _border2 = geometry.wallInfo[geometry.points.length - 1].border2;
- var len = walllines.arrows1.length;
- var wallpoint = { arrows1: [], arrows2: [], border1: [], border2: [] };
- if (len == 1) {
- //var joinpoint1=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows1[0]);
- var joinpoint1 = this.calculateLine.getJoinLinePoint(border1, walllines.arrows1[0]);
- wallpoint.arrows1.push(joinpoint1);
- //var joinpoint2=this.calculateLine.getJoinLinePoint(points[1],walllines.arrows1[0]);
- var joinpoint2 = this.calculateLine.getJoinLinePoint(_border1, walllines.arrows1[0]);
- wallpoint.arrows1.push(joinpoint2);
- //var joinpoint3=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows2[0]);
- var joinpoint3 = this.calculateLine.getJoinLinePoint(border2, walllines.arrows2[0]);
- wallpoint.arrows2.push(joinpoint3);
- //var joinpoint4=this.calculateLine.getJoinLinePoint(points[1],walllines.arrows2[0]);
- var joinpoint4 = this.calculateLine.getJoinLinePoint(_border2, walllines.arrows2[0]);
- wallpoint.arrows2.push(joinpoint4);
- //var joinpoint5=this.calculateLine.getJoinLinePoint(points[0],walllines.border1[0]);
- var joinpoint5 = this.calculateLine.getJoinLinePoint(border1, walllines.border1[0]);
- wallpoint.border1.push(joinpoint5);
- //var joinpoint6=this.calculateLine.getJoinLinePoint(points[1],walllines.border1[0]);
- var joinpoint6 = this.calculateLine.getJoinLinePoint(_border1, walllines.border1[0]);
- wallpoint.border1.push(joinpoint6);
- //var joinpoint7=this.calculateLine.getJoinLinePoint(points[0],walllines.border2[0]);
- var joinpoint7 = this.calculateLine.getJoinLinePoint(border2, walllines.border2[0]);
- wallpoint.border2.push(joinpoint7);
- //var joinpoint8=this.calculateLine.getJoinLinePoint(points[1],walllines.border2[0]);
- var joinpoint8 = this.calculateLine.getJoinLinePoint(_border2, walllines.border2[0]);
- wallpoint.border2.push(joinpoint8);
- return wallpoint;
- }
- for (var i = 0; i < len; ++i) {
- if (state == 1) {
- if (i == 0 || i == len - 1) {
- if (i == 0) {
- //var border1join1=this.calculateLine.getJoinLinePoint(points[0],walllines.border1[0]);
- var border1join1 = this.calculateLine.getJoinLinePoint(border1, walllines.border1[0]);
- wallpoint.border1.push(border1join1);
- //var border2join1=this.calculateLine.getJoinLinePoint(points[0],walllines.border2[0]);
- var border2join1 = this.calculateLine.getJoinLinePoint(border2, walllines.border2[0]);
- wallpoint.border2.push(border2join1);
- var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[0], walllines.border1[1]);
- if (border1join2 == null) {
- border1join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
- }
- wallpoint.border1.push(border1join2);
- var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[0], walllines.border2[1]);
- if (border2join2 == null) {
- border2join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
- }
- wallpoint.border2.push(border2join2);
- //var join1=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows1[0]);
- var join1 = this.calculateLine.getJoinLinePoint(border1, walllines.arrows1[0]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[0]);
- wallpoint.arrows1.push(join2);
- //var join3=this.calculateLine.getJoinLinePoint(points[0],walllines.arrows2[0]);
- var join3 = this.calculateLine.getJoinLinePoint(border2, walllines.arrows2[0]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[0]);
- wallpoint.arrows2.push(join4);
- }
- else {
- //var border1join1=this.calculateLine.getJoinLinePoint(points[i+1],walllines.border1[i]);
- var border1join1 = this.calculateLine.getJoinLinePoint(_border1, walllines.border1[i]);
- wallpoint.border1.push(border1join1);
- //var border2join1=this.calculateLine.getJoinLinePoint(points[i+1],walllines.border2[i]);
- var border2join1 = this.calculateLine.getJoinLinePoint(_border2, walllines.border2[i]);
- wallpoint.border2.push(border2join1);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[i], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- //var join2=this.calculateLine.getJoinLinePoint(points[i+1],walllines.arrows1[i]);
- var join2 = this.calculateLine.getJoinLinePoint(_border1, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[i], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- //var join4=this.calculateLine.getJoinLinePoint(points[i+1],walllines.arrows2[i]);
- var join4 = this.calculateLine.getJoinLinePoint(_border2, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- continue;
- }
- else {
- var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join == null) {
- border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join);
- var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join == null) {
- border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- continue;
- }
- }
- else if (state == 0) {
- if (i == 0) {
- var border1join1 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getPreIndex(walllines.border1, i)]);
- if (border1join1 == null) {
- border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join1);
- var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join2 == null) {
- border1join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join2);
- var border2join1 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getPreIndex(walllines.border2, i)]);
- if (border2join1 == null) {
- border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join1);
- var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join2 == null) {
- border2join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join2);
- var join1 = this.calculateLine.getJoinLinePoint(border1join1, walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(border2join1, walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- continue;
- }
- }
- if (i < len - 1) {
- var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join == null) {
- border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join);
- var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join == null) {
- border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- else {
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 1], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(wallpoint.border1[0], walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 1], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(wallpoint.border2[0], walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- }
- return wallpoint;
- };
- //获取交点
- CalculateElement.prototype.getOutlineMeasureJoin = function (walllines, points, state) {
- if (walllines == null) {
- return;
- }
- var len = walllines.arrows1.length;
- var wallpoint = { arrows1: [], arrows2: [], border1: [], border2: [] };
- if (len == 1) {
- var joinpoint1 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows1[0]);
- wallpoint.arrows1.push(joinpoint1);
- var joinpoint2 = this.calculateLine.getJoinLinePoint(points[1], walllines.arrows1[0]);
- wallpoint.arrows1.push(joinpoint2);
- var joinpoint3 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows2[0]);
- wallpoint.arrows2.push(joinpoint3);
- var joinpoint4 = this.calculateLine.getJoinLinePoint(points[1], walllines.arrows2[0]);
- wallpoint.arrows2.push(joinpoint4);
- var joinpoint5 = this.calculateLine.getJoinLinePoint(points[0], walllines.border1[0]);
- wallpoint.border1.push(joinpoint5);
- var joinpoint6 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
- wallpoint.border1.push(joinpoint6);
- var joinpoint7 = this.calculateLine.getJoinLinePoint(points[0], walllines.border2[0]);
- wallpoint.border2.push(joinpoint7);
- var joinpoint8 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
- wallpoint.border2.push(joinpoint8);
- return wallpoint;
- }
- for (var i = 0; i < len; ++i) {
- if (state == 1) {
- if (i == 0 || i == len - 1) {
- if (i == 0) {
- var border1join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.border1[0]);
- wallpoint.border1.push(border1join1);
- var border2join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.border2[0]);
- wallpoint.border2.push(border2join1);
- var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[0], walllines.border1[1]);
- if (border1join2 == null) {
- border1join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border1[0]);
- }
- wallpoint.border1.push(border1join2);
- var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[0], walllines.border2[1]);
- if (border2join2 == null) {
- border2join2 = this.calculateLine.getJoinLinePoint(points[1], walllines.border2[0]);
- }
- wallpoint.border2.push(border2join2);
- var join1 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows1[0]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[0]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(points[0], walllines.arrows2[0]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[0]);
- wallpoint.arrows2.push(join4);
- }
- else {
- var border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- wallpoint.border1.push(border1join1);
- var border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- wallpoint.border2.push(border2join1);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[i], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[i], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- continue;
- }
- else {
- var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join == null) {
- border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join);
- var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join == null) {
- border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- continue;
- }
- }
- else if (state == 0) {
- if (i == 0) {
- var border1join1 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getPreIndex(walllines.border1, i)]);
- if (border1join1 == null) {
- border1join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join1);
- var border1join2 = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join2 == null) {
- border1join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join2);
- var border2join1 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getPreIndex(walllines.border2, i)]);
- if (border2join1 == null) {
- border2join1 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join1);
- var border2join2 = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join2 == null) {
- border2join2 = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join2);
- var join1 = this.calculateLine.getJoinLinePoint(border1join1, walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join2, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(border2join1, walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join2, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- continue;
- }
- }
- if (i < len - 1) {
- var border1join = this.calculateLine.getIntersectionPoint(walllines.border1[i], walllines.border1[this.getNextIndex(walllines.border1, i)]);
- if (border1join == null) {
- border1join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border1[i]);
- }
- wallpoint.border1.push(border1join);
- var border2join = this.calculateLine.getIntersectionPoint(walllines.border2[i], walllines.border2[this.getNextIndex(walllines.border2, i)]);
- if (border2join == null) {
- border2join = this.calculateLine.getJoinLinePoint(points[i + 1], walllines.border2[i]);
- }
- wallpoint.border2.push(border2join);
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 2], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(border1join, walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 2], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(border2join, walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- else {
- var join1 = this.calculateLine.getJoinLinePoint(wallpoint.border1[wallpoint.border1.length - 1], walllines.arrows1[i]);
- wallpoint.arrows1.push(join1);
- var join2 = this.calculateLine.getJoinLinePoint(wallpoint.border1[0], walllines.arrows1[i]);
- wallpoint.arrows1.push(join2);
- var join3 = this.calculateLine.getJoinLinePoint(wallpoint.border2[wallpoint.border2.length - 1], walllines.arrows2[i]);
- wallpoint.arrows2.push(join3);
- var join4 = this.calculateLine.getJoinLinePoint(wallpoint.border2[0], walllines.arrows2[i]);
- wallpoint.arrows2.push(join4);
- }
- }
- wallpoint.arrows3 = []
- for (var i = 0; i < len; i++) {
- var start = wallpoint.arrows1[i]
- var end = wallpoint.arrows1[i + 1]
- // console.log(i, start.y - end.y)
- }
- return wallpoint;
- };
- //border1,border2是墙的边缘
- //arrow1,arrow2是墙的测量线
- CalculateElement.prototype.getWallMappingPoints = function (wallpoint, points, state) {
- if (wallpoint == null) {
- return;
- }
- var len = points.length;
- var resultLines = [];
- for (var i = 0; i < len; ++i) {
- if (state == 1) {
- if (i == len - 1) {
- break;
- }
- }
- var measureLine = {};
- measureLine.arrow1Line1 = wallpoint.arrows1[2 * i];
- measureLine.arrow1Line2 = wallpoint.arrows1[this.getNextIndex(wallpoint.arrows1, 2 * i)];
- measureLine.text1pt = { x: (measureLine.arrow1Line1.x + measureLine.arrow1Line2.x) / 2, y: (measureLine.arrow1Line1.y + measureLine.arrow1Line2.y) / 2 };
- measureLine.arrow2Line1 = wallpoint.arrows2[2 * i];
- measureLine.arrow2Line2 = wallpoint.arrows2[this.getNextIndex(wallpoint.arrows2, 2 * i)];
- measureLine.text2pt = { x: (measureLine.arrow2Line1.x + measureLine.arrow2Line2.x) / 2, y: (measureLine.arrow2Line1.y + measureLine.arrow2Line2.y) / 2 };
- if (wallpoint.border1 != null) {
- measureLine.border1Line1 = wallpoint.border1[i];
- measureLine.border1Line2 = wallpoint.border1[this.getNextIndex(wallpoint.border1, i)];
- measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.border1Line1, measureLine.border1Line2) / meter;
- } else {
- measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.arrow1Line1, measureLine.arrow1Line2) / meter;
- }
- if (wallpoint.border2 != null) {
- measureLine.border2Line1 = wallpoint.border2[i];
- measureLine.border2Line2 = wallpoint.border2[this.getNextIndex(wallpoint.border2, i)];
- measureLine.distance2 = BABYLON.Vector2.Distance(measureLine.border2Line1, measureLine.border2Line2) / meter;
- } else {
- measureLine.distance2 = BABYLON.Vector2.Distance(measureLine.arrow2Line1, measureLine.arrow2Line2) / meter;
- }
- measureLine.border1Line1 = wallpoint.border1[i];
- measureLine.border1Line2 = wallpoint.border1[this.getNextIndex(wallpoint.border1, i)];
- measureLine.distance1 = BABYLON.Vector2.Distance(measureLine.border1Line1, measureLine.border1Line2) / meter;
- resultLines.push(measureLine);
- }
- return resultLines;
- };
- //9.7
- CalculateElement.prototype.updateSelectWallLineIndex = function (wallId, wallindex1, wallindex2, mergeindex) {
- var len = this.layer.vectors[wallId].geometry.points.length;
- if (this.isNeighbor(len, wallindex1, mergeindex)) {
- this.updateSymbolsWallCornerIndexDelete(wallId, mergeindex, wallindex1);
- if (wallindex1 > mergeindex) {
- if (mergeindex == 0 && wallindex1 != 1) {
- wallindex1 = 0;
- }
- else {
- --wallindex1;
- --wallindex2;
- }
- }
- else if (wallindex1 < mergeindex) {
- if (wallindex1 == 0 && mergeindex == 1) {
- --wallindex2;
- }
- else if (wallindex1 == 0) {
- wallindex2 = mergeindex - 1;
- }
- }
- }
- else if (this.isNeighbor(len, wallindex2, mergeindex)) {
- this.updateSymbolsWallCornerIndexDelete(wallId, mergeindex, wallindex2);
- if (wallindex2 > mergeindex) {
- if (mergeindex == 0 && wallindex2 != 1) {
- wallindex2 = 0;
- }
- else {
- --wallindex1;
- --wallindex2;
- }
- }
- else if (wallindex2 < mergeindex) {
- if (wallindex2 == 0 && mergeindex == 1) {
- --wallindex1;
- }
- else if (wallindex2 == 0) {
- wallindex1 = mergeindex - 1;
- }
- }
- }
- if (wallindex1 < 0) {
- wallindex1 = 0;
- }
- if (wallindex2 < 0) {
- wallindex2 = 0;
- }
- return { wallindex1: wallindex1, wallindex2: wallindex2 };
- };
- CalculateElement.prototype.getIndexsFordeleteWall = function (wallId, index) {
- var result = {};
- var points = this.layer.vectors[wallId].geometry.points;
- for (var i = 0; i < points.length; ++i) {
- if (i == index) {
- continue;
- }
- if (i > index) {
- result[i] = i - 1;
- }
- else {
- result[i] = i;
- }
- }
- return result;
- };
- CalculateElement.prototype.updateIndexAdd = function (len, index, startindex, endindex, symbolpoint1, symbolpoint2, point, wallpoint1, wallpoint2) {
- var temp = null;
- if (startindex > endindex) {
- temp = endindex;
- endindex = startindex;
- startindex = temp;
- }
- if (Math.abs(startindex - endindex) == 1) {
- if (startindex > index && endindex > index) {
- ++startindex;
- ++endindex;
- }
- else if (startindex == index && endindex > index) {
- ++startindex;
- ++endindex;
- }
- else if (startindex < index && endindex == index) {
- //两种情况,双击点在哪一侧?
- if (this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint1) && this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint2)) {
- //什么也不变
- }
- else {
- ++startindex;
- ++endindex;
- }
- }
- }
- else if (index > endindex) {
- //两种情况,双击点在哪一侧?
- if (this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint1) && this.calculateLine.segmentContainPoint(wallpoint1, point, symbolpoint2)) {
- startindex = endindex;
- endindex = index;
- }
- else {
- startindex = index;
- endindex = 0;
- }
- }
- else {
- ++endindex;
- }
- if (temp == null) {
- return { start: startindex, end: endindex };
- }
- else {
- return { start: endindex, end: startindex };
- }
- };
- //双击墙面
- CalculateElement.prototype.updateSymbolsWallCornerIndexAdd = function (wallId, insertindex, point) {
- var len = this.layer.vectors[wallId].geometry.points.length;
- var wallindex1 = insertindex - 1;
- var wallindex2 = insertindex + 1;
- if (wallindex2 == len) {
- wallindex2 = 0;
- }
- var wallpoint1 = this.layer.vectors[wallId].geometry.points[wallindex1];
- var wallpoint2 = this.layer.vectors[wallId].geometry.points[wallindex2];
- for (var key in this.layer.vectors[wallId].symbol2Ds) {
- var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
- var indexs = this.updateIndexAdd(len, insertindex, symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex, symbol2d.geometry.points[0], symbol2d.geometry.points[1], point, wallpoint1, wallpoint2);
- symbol2d.attributes.wallstartindex = indexs.start;
- symbol2d.attributes.wallendindex = indexs.end;
- }
- }
- //9.7
- CalculateElement.prototype.updateSymbolsWallCornerIndexDelete = function (wallId, mergeindex, selectIndex) {
- var len = this.layer.vectors[wallId].geometry.points.length;
- if (!this.isNeighbor(len, mergeindex, selectIndex)) {
- return;
- }
- for (var key in this.layer.vectors[wallId].symbol2Ds) {
- var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
- var index1 = symbol2d.attributes.wallstartindex;
- var index2 = symbol2d.attributes.wallendindex;
- if (mergeindex != 0 && selectIndex != 0) {
- if (Math.min(index1, index2) > Math.max(mergeindex, selectIndex)) {
- --symbol2d.attributes.wallstartindex;
- --symbol2d.attributes.wallendindex;
- }
- else if (Math.min(index1, index2) == Math.max(mergeindex, selectIndex)) {
- symbol2d.attributes.wallstartindex = Math.min(mergeindex, selectIndex);
- --symbol2d.attributes.wallendindex;
- }
- else if (index1 == 0 && index2 != 1) {
- --symbol2d.attributes.wallendindex;
- }
- else if (index2 == 0 && index1 != 1) {
- --symbol2d.attributes.wallstartindex;
- }
- }
- else if (mergeindex == 1 || selectIndex == 1) {
- --symbol2d.attributes.wallstartindex;
- --symbol2d.attributes.wallendindex;
- if (symbol2d.attributes.wallstartindex < 0) {
- symbol2d.attributes.wallstartindex = 0;
- }
- if (symbol2d.attributes.wallendindex < 0) {
- symbol2d.attributes.wallendindex = 0;
- }
- }
- else if (mergeindex != 1 && selectIndex != 1) {
- if (selectIndex == 0) {
- if (Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex) > 0) {
- --symbol2d.attributes.wallstartindex;
- --symbol2d.attributes.wallendindex;
- }
- else {
- symbol2d.attributes.wallstartindex = 0;
- symbol2d.attributes.wallendindex = mergeindex - 1;
- }
- }
- else {
- if (symbol2d.attributes.wallstartindex == selectIndex) {
- symbol2d.attributes.wallstartindex = 0;
- }
- else if (symbol2d.attributes.wallendindex == selectIndex) {
- symbol2d.attributes.wallendindex = 0;
- }
- }
- }
- }
- };
- //9.7
- CalculateElement.prototype.updateSymbolsForDeleteOnePoint = function (wallId, index) {
- var len = this.layer.vectors[wallId].geometry.points.length;
- for (var key in this.layer.vectors[wallId].symbol2Ds) {
- var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
- var index1 = symbol2d.attributes.wallstartindex;
- var index2 = symbol2d.attributes.wallendindex;
- if (index1 != 0 && index2 != 0) {
- if (index < Math.min(index1, index2)) {
- --symbol2d.attributes.wallstartindex;
- --symbol2d.attributes.wallendindex;
- }
- else if (index == index1) {
- if (index2 > index) {
- index1 = index - 1;
- --index2;
- }
- }
- else if (index == index2) {
- if (index1 > index) {
- index2 = index - 1;
- --index1;
- }
- }
- }
- else if (index1 == 0) {
- if (index2 != 1) {
- if (index != 0) {
- --index2;
- }
- }
- else if (index == 0) {
- index2 = len - 2;
- }
- }
- else if (index2 == 0) {
- if (index1 != 1) {
- if (index != 0) {
- --index1;
- }
- }
- else if (index == 0) {
- index1 = len - 2;
- }
- }
- symbol2d.attributes.wallstartindex = index1;
- symbol2d.attributes.wallendindex = index2;
- }
- };
- CalculateElement.prototype.updateSelectWallCornerIndex = function (wallId, mergeindex, selectIndex) {
- if (!this.isNeighbor(len, mergeindex, selectIndex)) {
- return null;
- }
- if (selectIndex > mergeindex) {
- return mergeindex;
- }
- else if (selectIndex == 0) {
- if (mergeindex != 1) {
- --mergeindex;
- return mergeindex;
- }
- }
- return selectIndex;
- };
- CalculateElement.prototype.updateSymbolsIndexAdd = function (wallId, index, point) {
- var len = this.layer.vectors[wallId].geometry.points.length;
- var wallindex1 = index - 1;
- var wallindex2 = index + 1;
- if (wallindex2 == len) {
- wallindex2 = 0;
- }
- var wallpoint1 = this.layer.vectors[wallId].geometry.points[wallindex1];
- var wallpoint2 = this.layer.vectors[wallId].geometry.points[wallindex2];
- for (var key in this.layer.vectors[wallId].symbol2Ds) {
- var symbol2d = this.layer.vectors[wallId].symbol2Ds[key];
- var indexs = this.updateIndexAdd(len, index, symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex, symbol2d.geometry.points[0], symbol2d.geometry.points[1], point, wallpoint1, wallpoint2);
- symbol2d.attributes.wallstartindex = indexs.start;
- symbol2d.attributes.wallendindex = indexs.end;
- }
- };
- CalculateElement.prototype.updateSymbolEndPoint = function (symbol2d, point, wallid, startinidex, endindex) {
- if (wallid == null) {
- return;
- }
- var len = symbol2d.getSymbolLen();
- var point1, point2;
- //不能是墙角
- if (endindex != null && typeof (endindex) != undefined) {
- point1 = this.layer.vectors[wallid].geometry.points[startinidex];
- point2 = this.layer.vectors[wallid].geometry.points[endindex];
- }
- else if (symbol2d.geometry.points.length > 0) {
- point1 = symbol2d.geometry.points[0];
- point2 = symbol2d.geometry.points[1];
- }
- else {
- return;
- }
- var line = this.calculateLine.createLine(point1, point2);
- var endpoint = this.calculateLine.getDisPointsLine(line, point, len / 2, len / 2)
- if (symbol2d.attributes.wallId != wallid) {
- --this.layer.vectors[symbol2d.attributes.wallId].symbol2dsCount;
- delete this.layer.vectors[symbol2d.attributes.wallId].symbol2Ds[symbol2d.id];
- symbol2d.attributes.wallId = wallid;
- ++this.layer.vectors[wallid].symbol2dsCount;
- this.layer.vectors[wallid].symbol2Ds[symbol2d.id] = symbol2d;
- }
- symbol2d.attributes.wallstartindex = startinidex;
- symbol2d.attributes.wallendindex = endindex;
- symbol2d.geometry.point1 = endpoint.newpoint1;
- symbol2d.geometry.point2 = endpoint.newpoint2;
- var thick = this.layer.getThickness(symbol2d.attributes.wallId, symbol2d.attributes.wallstartindex);
- symbol2d.geometry.points = this.getSymbolPoints(endpoint.newpoint1, endpoint.newpoint2, symbol2d.geometry.geoType, symbol2d.attributes.toward, thick)
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[0]].geometry.points[0] = endpoint.newpoint1;
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[0]].geometry.points[1] = endpoint.newpoint2;
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[1]].geometry.x = endpoint.newpoint1.x;
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[1]].geometry.y = endpoint.newpoint1.y;
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[2]].geometry.x = endpoint.newpoint2.x;
- this.layer.vectors[symbol2d.attributes.selectSymbolIds[2]].geometry.y = endpoint.newpoint2.y;
- //symbol2d.select=true;
- //symbol2d.draw(this.layer);
- };
- //point在墙上
- CalculateElement.prototype.getSymbolEndPoint = function (point, wallid, startinidex, endindex, len) {
- var point1 = this.layer.vectors[wallid].geometry.points[startinidex];
- if (typeof (endindex) == "undefined") {
- return null;
- }
- var point2 = this.layer.vectors[wallid].geometry.points[endindex];
- var line = this.calculateLine.createLine(point1, point2);
- var endpoint = this.calculateLine.getDisPointsLine(line, point, len / 2, len / 2)
- return endpoint;
- };
- //point不在墙上
- CalculateElement.prototype.getSymbolEndPoint2 = function (point, wallid, startinidex, endindex, len) {
- if (typeof (endindex) == "undefined") {
- return null;
- }
- var point1 = this.layer.vectors[wallid].geometry.points[startinidex];
- var point2 = this.layer.vectors[wallid].geometry.points[endindex];
- var line = this.calculateLine.createLine(point1, point2);
- var p = this.calculateLine.getJoinLinePoint(point, line);
- if (!this.lineContain(point1, point2, p, 1)) {
- return null;
- }
- else if (BABYLON.Vector2.Distance(point1, p) < len / 2 || BABYLON.Vector2.Distance(point2, p) < len / 2) {
- return null;
- }
- else {
- var endpoint = this.calculateLine.getDisPointsLine(line, p, len / 2, len / 2)
- return endpoint;
- }
- };
- //points中,第1,2点表示与point1和point2构成矩形
- //扇形都是以point2为圆心
- CalculateElement.prototype.getSingleCasementPoints = function (point1, point2, toward, thick) {
- //singleCasementDrift
- var calculateLine = this.calculateLine;
- var line = calculateLine.createLine(point1, point2);
- var arcpoints = [];
- var len = BABYLON.Vector2.Distance(point1, point2);
- var startAngle2, endAngle2;
- var tempPoint = { x: point2.x + 1, y: point2.y };
- if (line.hasOwnProperty('x')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x - this.layer.parameter.singleCasementDrift, y: point2.y });
- arcpoints.push({ x: point1.x - this.layer.parameter.singleCasementDrift, y: point1.y });
- endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- startAngle2 = endAngle2 - Math.PI / 6;
- }
- else {
- arcpoints.push({ x: point2.x + this.layer.parameter.singleCasementDrift, y: point2.y });
- arcpoints.push({ x: point1.x + this.layer.parameter.singleCasementDrift, y: point1.y });
- startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- endAngle2 = startAngle2 + Math.PI / 6;
- }
- }
- else if (line.hasOwnProperty('y')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x, y: point2.y - this.layer.parameter.singleCasementDrift });
- arcpoints.push({ x: point1.x, y: point1.y - this.layer.parameter.singleCasementDrift });
- startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- endAngle2 = startAngle2 + Math.PI / 6;
- }
- else {
- arcpoints.push({ x: point2.x, y: point2.y + this.layer.parameter.singleCasementDrift });
- arcpoints.push({ x: point1.x, y: point1.y + this.layer.parameter.singleCasementDrift });
- endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- startAngle2 = endAngle2 - Math.PI / 6;
- }
- }
- else {
- var tl = {};
- var a = Math.atan(line.a);
- tl.a = -1 / line.a;
- var temp_line2 = calculateLine.getLineForPoint(tl, point1);
- var temp_line1 = calculateLine.getLineForPoint(tl, point2);
- var p1, p2;
- var drift = (this.layer.parameter.singleCasementDrift) / Math.cos(a);
- var same_line;
- if (toward == 1) {
- same_line = { a: line.a, b: line.b - drift };
- p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
- arcpoints.push(p2);
- arcpoints.push(p1);
- startAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- endAngle2 = startAngle2 + Math.PI / 6;
- }
- else {
- same_line = { a: line.a, b: line.b + drift };
- p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
- arcpoints.push(p2);
- arcpoints.push(p1);
- endAngle2 = calculateLine.Angle2(point2, point1, tempPoint) / 180 * Math.PI;
- startAngle2 = endAngle2 - Math.PI / 6;
- }
- }
- arcpoints.push(startAngle2);
- arcpoints.push(endAngle2);
- return arcpoints;
- };
- CalculateElement.prototype.getDoubleCasementPoints = function (point1, point2, toward, thick) {
- var calculateLine = this.calculateLine;
- var line = calculateLine.createLine(point1, point2);
- var arcpoints = [];
- var len = BABYLON.Vector2.Distance(point1, point2);
- var midpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
- var startAngle21, startAngle22, endAngle21, endAngle22;
- var tempPoint1 = { x: point1.x + 1, y: point1.y };
- var tempPoint2 = { x: point2.x + 1, y: point2.y };
- if (line.hasOwnProperty('x')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x - this.layer.parameter.singleCasementDrift, y: point2.y });
- arcpoints.push({ x: point1.x - this.layer.parameter.singleCasementDrift, y: point1.y });
- if (point1.y > point2.y) {
- endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- startAngle21 = endAngle21 - Math.PI / 6;
- startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- endAngle22 = startAngle22 + Math.PI / 6;
- }
- else {
- endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- startAngle21 = endAngle21 - Math.PI / 6;
- startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI + Math.PI;
- endAngle22 = startAngle22 + Math.PI / 6;
- }
- }
- else {
- arcpoints.push({ x: point2.x + this.layer.parameter.singleCasementDrift, y: point2.y });
- arcpoints.push({ x: point1.x + this.layer.parameter.singleCasementDrift, y: point1.y });
- if (point1.y > point2.y) {
- startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- endAngle21 = startAngle21 + Math.PI / 6;
- endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- startAngle22 = endAngle22 - Math.PI / 6;
- }
- else {
- startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- endAngle21 = startAngle21 + Math.PI / 6;
- endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI + Math.PI;
- startAngle22 = endAngle22 - Math.PI / 6;
- }
- }
- }
- else if (line.hasOwnProperty('y')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x, y: point2.y - this.layer.parameter.singleCasementDrift });
- arcpoints.push({ x: point1.x, y: point1.y - this.layer.parameter.singleCasementDrift });
- if (point1.x > point2.x) {
- endAngle21 = 2 * Math.PI;
- startAngle21 = endAngle21 - Math.PI / 6;
- startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- endAngle22 = startAngle22 + Math.PI / 6;
- }
- else {
- startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- endAngle21 = startAngle21 + Math.PI / 6;
- endAngle22 = 2 * Math.PI;
- startAngle22 = endAngle22 - Math.PI / 6;
- }
- }
- else {
- arcpoints.push({ x: point2.x, y: point2.y + this.layer.parameter.singleCasementDrift });
- arcpoints.push({ x: point1.x, y: point1.y + this.layer.parameter.singleCasementDrift });
- if (point1.x > point2.x) {
- startAngle21 = 0;
- endAngle21 = startAngle21 + Math.PI / 6;
- endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- startAngle22 = endAngle22 - Math.PI / 6;
- }
- else {
- endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- startAngle21 = endAngle21 - Math.PI / 6;
- startAngle22 = 0;
- endAngle22 = startAngle22 + Math.PI / 6;
- }
- }
- }
- else {
- var tl = {};
- var a = Math.atan(line.a);
- tl.a = -1 / line.a;
- var temp_line2 = calculateLine.getLineForPoint(tl, point1);
- var temp_line1 = calculateLine.getLineForPoint(tl, point2);
- var temp_midline = calculateLine.getLineForPoint(tl, midpoint);
- var p1, p2;
- var drift = (this.layer.parameter.singleCasementDrift) / Math.cos(a);
- var same_line;
- if (toward == 1) {
- same_line = { a: line.a, b: line.b - drift };
- p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
- arcpoints.push(p2);
- arcpoints.push(p1);
- startAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- endAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- endAngle21 = startAngle21 + Math.PI / 6;
- startAngle22 = endAngle22 - Math.PI / 6;
- }
- else {
- same_line = { a: line.a, b: line.b + drift };
- p1 = calculateLine.getIntersectionPoint(temp_line2, same_line);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line);
- arcpoints.push(p2);
- arcpoints.push(p1);
- endAngle21 = calculateLine.Angle2(point2, point1, tempPoint2) / 180 * Math.PI;
- startAngle22 = calculateLine.Angle2(point1, point2, tempPoint1) / 180 * Math.PI;
- startAngle21 = endAngle21 - Math.PI / 6;
- endAngle22 = startAngle22 + Math.PI / 6;
- }
- }
- arcpoints.push(startAngle21);
- arcpoints.push(endAngle21);
- arcpoints.push(startAngle22);
- arcpoints.push(endAngle22);
- return arcpoints;
- };
- CalculateElement.prototype.getSimpleDoorPoints = function (point1, point2, toward, thick) {
- var calculateLine = this.calculateLine;
- var line = calculateLine.createLine(point1, point2);
- var arcpoints = [];
- var doorlength = BABYLON.Vector2.Distance(point1, point2);
- if (line.hasOwnProperty('x')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
- arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y });
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y });
- if (point2.y < point1.y) {
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
- }
- else {
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
- }
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
- }
- else {
- arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
- arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y });
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y });
- if (point2.y < point1.y) {
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
- }
- else {
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
- }
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
- }
- }
- else if (line.hasOwnProperty('y')) {
- if (toward == 1) {
- arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x, y: point1.y + thick / 2 + doorlength });
- if (point2.x < point1.x) {
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
- }
- else {
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
- }
- arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
- }
- else {
- arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x, y: point1.y - thick / 2 - doorlength });
- if (point2.x < point1.x) {
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
- }
- else {
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
- }
- arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
- }
- }
- else {
- var tl = {};
- var a = Math.atan(line.a);
- tl.a = -1 / line.a;
- var temp_line2 = calculateLine.getLineForPoint(tl, point1);
- var temp_line1 = calculateLine.getLineForPoint(tl, point2);
- var p1, p2, p3, p4, p5, p6;
- var temp_line3 = {};
- var db = doorlength / Math.cos(a);
- var drift = (thick / 2) / Math.cos(a);
- var same_line1, same_line2;
- if (toward == 1) {
- same_line1 = { a: line.a, b: line.b + drift };
- same_line2 = { a: line.a, b: line.b + drift + db };
- p1 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
- p3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
- if (temp_line2.b < temp_line1.b) {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- }
- else {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- }
- p6 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
- }
- else {
- same_line1 = { a: line.a, b: line.b - drift };
- same_line2 = { a: line.a, b: line.b - drift - db };
- p1 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
- p2 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
- p3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
- if (temp_line2.b < temp_line1.b) {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- }
- else {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- p4 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- }
- p6 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
- }
- arcpoints.push(p1);
- arcpoints.push(p2);
- arcpoints.push(p3);
- arcpoints.push(p4);
- arcpoints.push(p5);
- arcpoints.push(p6);
- }
- return arcpoints;
- };
- CalculateElement.prototype.getBiFoldDoorPoints = function (point1, point2, toward, thick) {
- var calculateLine = this.calculateLine;
- var line = calculateLine.createLine(point1, point2);
- var arcpoints = [];
- var doorlength = BABYLON.Vector2.Distance(point1, point2) / 2;
- var midpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
- if (line.hasOwnProperty('x')) {
- if (toward == 1) {
- arcpoints.push({ x: midpoint.x + thick / 2, y: midpoint.y });
- arcpoints.push({ x: midpoint.x + thick / 2 + doorlength, y: midpoint.y });
- arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y });
- arcpoints.push({ x: midpoint.x + thick / 2, y: midpoint.y });
- arcpoints.push({ x: midpoint.x + thick / 2 + doorlength, y: midpoint.y });
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y });
- if (point2.y < point1.y) {
- arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x + thick / 2, y: point2.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
- }
- else {
- arcpoints.push({ x: point2.x + thick / 2 + doorlength, y: point2.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x + thick / 2, y: point2.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x + thick / 2, y: point2.y });
- arcpoints.push({ x: point1.x + thick / 2 + doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x + thick / 2, y: point1.y });
- }
- }
- else {
- arcpoints.push({ x: midpoint.x - thick / 2, y: midpoint.y });
- arcpoints.push({ x: midpoint.x - thick / 2 - doorlength, y: midpoint.y });
- arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y });
- arcpoints.push({ x: midpoint.x - thick / 2, y: midpoint.y });
- arcpoints.push({ x: midpoint.x - thick / 2 - doorlength, y: midpoint.y });
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y });
- if (point2.y < point1.y) {
- arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x - thick / 2, y: point2.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
- }
- else {
- arcpoints.push({ x: point2.x - thick / 2 - doorlength, y: point2.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x - thick / 2, y: point2.y - this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point2.x - thick / 2, y: point2.y });
- arcpoints.push({ x: point1.x - thick / 2 - doorlength, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y + this.layer.parameter.simpleDoorDrift });
- arcpoints.push({ x: point1.x - thick / 2, y: point1.y });
- }
- }
- }
- else if (line.hasOwnProperty('y')) {
- if (toward == 1) {
- arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 });
- arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 + doorlength });
- arcpoints.push({ x: point2.x, y: point2.y + thick / 2 + doorlength });
- arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 });
- arcpoints.push({ x: midpoint.x, y: midpoint.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x, y: point1.y + thick / 2 + doorlength });
- if (point2.x < point1.x) {
- arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 + doorlength });
- arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
- arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
- }
- else {
- arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 + doorlength });
- arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y + thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y + thick / 2 });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 + doorlength });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y + thick / 2 });
- arcpoints.push({ x: point1.x, y: point1.y + thick / 2 });
- }
- }
- else {
- arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 });
- arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 - doorlength });
- arcpoints.push({ x: point2.x, y: point2.y - thick / 2 - doorlength });
- arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 });
- arcpoints.push({ x: midpoint.x, y: midpoint.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x, y: point1.y - thick / 2 - doorlength });
- if (point2.y < point1.y) {
- arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 - doorlength });
- arcpoints.push({ x: point2.x + this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x - this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
- arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
- }
- else {
- arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 - doorlength });
- arcpoints.push({ x: point2.x - this.layer.parameter.simpleDoorDrift, y: point2.y - thick / 2 });
- arcpoints.push({ x: point2.x, y: point2.y - thick / 2 });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 - doorlength });
- arcpoints.push({ x: point1.x + this.layer.parameter.simpleDoorDrift, y: point1.y - thick / 2 });
- arcpoints.push({ x: point1.x, y: point1.y - thick / 2 });
- }
- }
- }
- else {
- var tl = {};
- var a = Math.atan(line.a);
- tl.a = -1 / line.a;
- var temp_line1 = calculateLine.getLineForPoint(tl, point1);
- var temp_line2 = calculateLine.getLineForPoint(tl, point2);
- var temp_midline = calculateLine.getLineForPoint(tl, midpoint);
- var t1, t2, t3, t4, t5, t6;
- var p1, p2, p3, p4, p5, p6;
- var temp_line3 = {};
- var temp_line4 = {};
- var db = doorlength / Math.cos(a);
- var drift = (thick / 2) / Math.cos(a);
- var same_line1, same_line2;
- if (toward == 1) {
- same_line1 = { a: line.a, b: line.b + drift };
- same_line2 = { a: line.a, b: line.b + drift + db };
- t1 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
- t2 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
- t3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
- t4 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
- t5 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
- t6 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
- if (temp_line2.b < temp_line1.b) {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- temp_line4.a = temp_line1.a;
- temp_line4.b = temp_line1.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- }
- else {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- temp_line4.a = temp_line1.a;
- temp_line4.b = temp_line1.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- }
- p1 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p2 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- p3 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
- p4 = calculateLine.getIntersectionPoint(temp_line4, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line4, same_line1);
- p6 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
- }
- else {
- same_line1 = { a: line.a, b: line.b - drift };
- same_line2 = { a: line.a, b: line.b - drift - db };
- t1 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
- t2 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
- t3 = calculateLine.getIntersectionPoint(temp_line2, same_line2);
- t4 = calculateLine.getIntersectionPoint(temp_midline, same_line1);
- t5 = calculateLine.getIntersectionPoint(temp_midline, same_line2);
- t6 = calculateLine.getIntersectionPoint(temp_line1, same_line2);
- if (temp_line2.b < temp_line1.b) {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- temp_line4.a = temp_line1.a;
- temp_line4.b = temp_line1.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- }
- else {
- temp_line3.a = temp_line1.a;
- temp_line3.b = temp_line2.b - Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- temp_line4.a = temp_line1.a;
- temp_line4.b = temp_line1.b + Math.abs(this.layer.parameter.simpleDoorDrift / Math.sin(a));
- }
- p1 = calculateLine.getIntersectionPoint(temp_line3, same_line2);
- p2 = calculateLine.getIntersectionPoint(temp_line3, same_line1);
- p3 = calculateLine.getIntersectionPoint(temp_line2, same_line1);
- p4 = calculateLine.getIntersectionPoint(temp_line4, same_line2);
- p5 = calculateLine.getIntersectionPoint(temp_line4, same_line1);
- p6 = calculateLine.getIntersectionPoint(temp_line1, same_line1);
- }
- arcpoints.push(t1);
- arcpoints.push(t2);
- arcpoints.push(t3);
- arcpoints.push(t4);
- arcpoints.push(t5);
- arcpoints.push(t6);
- arcpoints.push(p1);
- arcpoints.push(p2);
- arcpoints.push(p3);
- arcpoints.push(p4);
- arcpoints.push(p5);
- arcpoints.push(p6);
- }
- return arcpoints;
- };
- CalculateElement.prototype.getSlidingPoints = function (point1, point2, toward, thick) {
- var calculateLine = this.layer.calculateLine;
- var line = calculateLine.createLine(point1, point2);
- var drawpoints = [];
- var point3, point4, point5, point6;
- var r = 10;
- if (line.hasOwnProperty('x')) {
- point3 = { x: point1.x - r, y: point1.y };
- point4 = { x: point1.x - r, y: (point1.y + point2.y) / 2 };
- point5 = { x: point1.x + r, y: (point1.y + point2.y) / 2 };
- point6 = { x: point1.x + r, y: point2.y };
- }
- else if (line.hasOwnProperty('y')) {
- point3 = { x: point1.x, y: point1.y - r };
- point4 = { x: (point1.x + point2.x) / 2, y: point1.y - r };
- point5 = { x: (point1.x + point2.x) / 2, y: point1.y + r };
- point6 = { x: point2.x, y: point2.y + r };
- }
- else {
- var tl = {};
- var a = Math.atan(line.a);
- tl.a = -1 / line.a;
- var temp_line1 = calculateLine.createLine2(tl, point1);
- var temp_line2 = calculateLine.createLine2(tl, point2);
- var centerpoint = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
- var tempcenterline = calculateLine.createLine2(tl, centerpoint);
- var db = r / Math.cos(a);
- var like_line1 = { a: line.a, b: line.b + db };
- var like_line2 = { a: line.a, b: line.b - db };
- point3 = calculateLine.getIntersectionPoint(like_line1, temp_line1);
- point4 = calculateLine.getIntersectionPoint(like_line1, tempcenterline);
- point5 = calculateLine.getIntersectionPoint(like_line2, tempcenterline);
- point6 = calculateLine.getIntersectionPoint(like_line2, temp_line2);
- }
- drawpoints.push(point1);
- drawpoints.push(point2);
- drawpoints.push(point3);
- drawpoints.push(point4);
- drawpoints.push(point5);
- drawpoints.push(point6);
- return drawpoints;
- };
- CalculateElement.prototype.getSymbolPoints = function (point1, point2, type, toward, thick) {
- var points = [];
- if (type == "OpenDoor" || type == "OpenWindow") {
- points.push(point1);
- points.push(point2);
- }
- else if (type == "SimpleDoor") {
- points = this.getSimpleDoorPoints(point1, point2, toward, thick);
- }
- else if (type == "BiFoldDoor") {
- points = this.getBiFoldDoorPoints(point1, point2, toward, thick);
- }
- else if (type == "SlidingDoor" || type == "SlidingWindow") {
- points = this.getSlidingPoints(point1, point2, toward, thick);
- }
- else if (type == "SingleCasement") {
- points = this.getSingleCasementPoints(point1, point2, toward, thick);
- }
- else if (type == "DoubleCasement") {
- points = this.getDoubleCasementPoints(point1, point2, toward, thick);
- }
- return points;
- };
|