diff --git a/test/test.js b/test/test.js index 8eb1cdeaa6118b96bed8ec3093149bf09eea396f..9974151ac1ad9b6be3853f84fc0df26007f87799 100644 --- a/test/test.js +++ b/test/test.js @@ -1,14 +1,102 @@ -var step = "arr" - - - - - -console.log(getStepType(step)); +function getFeaturesSurface(arr) { + var surface_index = 1; + var surface = {}; + var tmp_array = arr + var surface_points = [] + for(var i=0; i<tmp_array.length;i++) { + if(/^#S\s+P/.test(tmp_array[i])){ + var tmp = tmp_array[i].split(/\,/) + if(!surface[surface_index]){surface[surface_index] = {}} + surface[surface_index]["attributes"] = tmp + } + if(/^#\d+\s+#S\s+P/.test(tmp_array[i])){ + var tmp = tmp_array[i].split(/\,/) + if(!surface[surface_index]){surface[surface_index] = {}} + surface[surface_index]["attributes"] = tmp + surface[surface_index]["serial"] = /#(\d+)/.exec(tmp_array[i])[1] + } + var tmp=tmp_array[i].split(/\s+/) + console.log(tmp); + if(tmp[0]==="#" || /^#\d+$/.test(tmp[0])){ + tmp = tmp.slice(1) + } + if (/^#OB|^#\s+#OB/.test(tmp_array[i]) || /^#OS|^#\s+#OS/.test(tmp_array[i])) { + if (/^#OB|^#\s+#OB/.test(tmp_array[i])) { + if(!surface[surface_index]){surface[surface_index] = {}} + surface[surface_index].type = tmp[3] + } + surface_points.push({x:tmp[1],y:tmp[2],arcx:undefined,arcy:undefined,arcdir:undefined}) + }else if (/^#OC|^#\s+#OC/.test(tmp_array[i])) { + surface_points.push({x:tmp[1],y:tmp[2],arcx:tmp[3],arcy:tmp[4],arcdir:tmp[5]}) + } + if (/^#OE|^#\s+#OE/.test(tmp_array[i])) { + if(!surface[surface_index]){surface[surface_index] = {}} + surface[surface_index].coordinates = surface_points + surface[surface_index].points_num = surface_points.length + surface_index++; + surface_points = [] + } + } + return surface +} +// #OB #OS #OE +console.log(getFeaturesSurface( + [ + "### Layer - tmp features data ###", + "#26 #S P 0", + "# #OB 5.687356102362 3.734867322835 I", + "# #OS 5.687356102362 4.881030511811", + "# #OS 6.477813484252 4.881030511811", + "# #OS 6.477813484252 3.734867322835", + "# #OS 5.687356102362 3.734867322835", + "# #OE", + "#27 #S P 0", + "# #OB 4.514844389764 4.459453248031 I", + "# #OS 4.64658730315 3.91930738189", + "# #OS 4.751981594488 3.418684350394", + "# #OS 4.264532874016 2.66774980315", + "# #OS 2.933929625984 3.892958759843", + "# #OS 4.514844389764 4.459453248031", + "# #OE", + ] +)) +/* +#28 #S P 0 +# #OB 1.063180511811 6.119413681102 I +# #OS 2.775838188976 5.236736318898 +# #OS 2.670443799213 4.354058858268 +# #OS 0.694300393701 5.104993405512 +# #OS 1.063180511811 6.119413681102 +# #OE +#29 #S P 0 +# #OB 1.695546456693 2.628226968504 I +# #OS 1.985380807087 1.468889468504 +# #OS 1.326666338583 1.626981003937 +# #OS 1.695546456693 2.628226968504 +# #OE +#30 #S P 0 +# #OB 5.357998917323 1.798246751969 I +# #OS 5.753227559055 1.205403740157 +# #OS 4.896898818898 1.086835137795 +# #OS 5.357998917323 1.798246751969 +# #OE +#31 #S P 0 +# #OB 7.966508267717 2.812667027559 I +# #OS 7.768893897638 2.24617253937 +# #OS 7.347316633858 2.746795570866 +# #OS 7.966508267717 2.812667027559 +# #OE +#32 #S P 0 +# #OB 7.729371062992 5.737359251969 I +# #OS 7.492233759843 5.289433464567 +# #OS 7.479059547244 5.671487893701 +# #OS 7.729371062992 5.737359251969 +# #OE +*/ \ No newline at end of file diff --git a/test/test2.js b/test/test2.js index 56dc41ddd1cd7a3229c049e9cebc24b01fe0b657..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/test/test2.js +++ b/test/test2.js @@ -1,26 +0,0 @@ -["GEN_TYPE", "ERROR_HANDLE", "GENESIS_DIR", "GENESIS_VER", "GENESIS_EDIR", "GENESIS_TMP", -"COMMS", "DIR_PREFIX", "STATUS", "INFO_RESULT", "sendCommand", "blankStatusResults", "sendCommandToPipe", -"COM", "getReply", "VON", "VOF", "SU_ON", "SU_OFF", "PAUSE", "MOUSE", "AUX", "DO_INFO", "INFO", "parse", -"clearInfoResult", "dbutil", "hooksSkip", "getJobPath", "shellwords", "hasError", "currentJob", "currentStep", -"getWorkLayer", "getAffectLayer", "getDispLayers", "getJobList", "getUserName", "getJobDbName", "isJobExists", -"isJobOpen", "createJob", "openJob", "closeJob", "deleteJob", "deleteStep", "importJob", "listOpenJobs", "isStepExists", -"createStep", "setGroup", "openStep", "closeStep", "getStepList", "getMatrix", "matrixAddLayer", "matrixMoveRow", "matrixAddStep", -"matrixDeleteStep", "matrixCopyStep", "matrixCopyLayer", "openMatrix", "matrixRefresh", "matrixLayerAttr", "matrixLayerDrill", -"getLayerCount", "getTool", "toolSet", "outputPostScript", "outputRs274x", "outputDxf", "isLayerExists", "createLayer", -"deleteLayer", "getLayerLimits", "getSymbolLimits", "getProfileLimits", "affectedLayer", "getSelectCount", "selCopyOther", -"selMoveOther", "clearLayers", "workLayer", "zoomArea", "units", "selectByFilter", "highlightByFilter", "selRefFeat", "filterSet", -"checkInout", "saveJob", "copyJob", "copyLayer", "getChecklist", "chklistFromLib", "createChklist", "isChklistExists", "chklistShow", -"chklistRun", "getCheckMeas", "runSingleDfm", "copperArea", "exposedArea", "selContourize", "zoomHome", "panelSize", "srFill", -"addPad", "addLine", "addArc", "transCoordinate", "addText", "getTextRect", "addRectangle", "addPolygon", "selFill", "selReverse", -"selDelete", "panelSR", "flattenLayer", "getSymbolFeatures", "getFeatures", "copyStep", "selChangeSym", "selBoardNetFeat", "displayLayer", -"getNcsetsList", "getNcsetReg", "selCreateStep", "selMoveRepeat", "createSymbol", "isSymbolExists", "openSymbol", "closeSymbol", "getCheckAttr", -"getProfile", "clearHighlight", "selBreak", "getUnits", "getLayerSymsHist", "getSymbolSymsHist", "netlistPageOpen", "netlistRecalc", "netlistCompare", -"netlistPageClose", "selClearFeature", "getSRLimits", "getSR", "getActiveArea", "chklistCupd", "getChklistRange", "chklistErfRange", "chklistErf", -"chklistRereadErf", "chklistSelectAct", "chklistSelectAll", "getChklistActCount", "chklistCreateLyrs", "getStepLimits", "selMove", "selSubstitute", -"selTransform", "getSR1", "getRepeat", "getSubSteps", "getDatum", "getStepAttr", "getJobAttr", "setJobAttr", "getLPD", "getLPM", "setCurrentAttribute", -"attributeReset", "selAddAttr", "setOrigin", "setDatum", "selNetFeat", "getOrigin", "origin", "chklistResShow", "chklistClose", "getDbList", -"getLayerAttr", "isJobChanged", "isStepChanged", "isLayerChanged", "getSymbolHistory", "selectRectangle", "renameLayer", "renameStep", -"setLayerAttr", "setStepAttr", "getToolUser", "getToolThick", "getToolSlots", "cadNetlistExists", "netlistExists", "isLayerEmpty", -"changeText", "getGenVersion", "getLayerFeatHist", "getSymbolList", "copySymbol", "clipArea", -"compareLayers", "von", "vof", -"dispOn", "dispOff", "errOn", "errOff", "selCreateProfile", "selAllFeat", "selResize", "breakStep", "delStepType"] \ No newline at end of file