Kaynağa Gözat

Update 'src/app/core/parser/parser-orchestrator.js'

Some fixes to allow the MidPoint creation through GEO file with the correct ID
(e.g. one with "1:3" was been created with ID=1)
In "orchestrate(vec_dynamic_obj)" added new list "listID[i] = id;" to help create object from GEO file with "correct" ID.
In "do(id, map, vecOD)" to ELEMENTS_CLASS.MIDDLE_POINT, introduced "object.id = id;" to fix ID (after object = MiddlePointModel.do(map, vecOD, this.list);"
leo 2 yıl önce
ebeveyn
işleme
450fb8415a
1 değiştirilmiş dosya ile 23 ekleme ve 6 silme
  1. 23 6
      src/app/core/parser/parser-orchestrator.js

+ 23 - 6
src/app/core/parser/parser-orchestrator.js

@@ -40,10 +40,11 @@ export class ParserOrchestrator {
   // @param vec_obj_dynamic_obj is Array() with { id : only_id, obj : parsed_object }
   // @calledby app/core/application/header-menu.js!onFileChanged(): orchestrator.orchestrate();
   orchestrate (vec_dynamic_obj) {
-    var auxEr = "", auxEr2 = ""; //D
-    var ii=0, result; //D
+    var auxEr = "", auxEr2 = "", aux3 = ""; //D
+    var tam, ii=0, result, listID = []; //D
     try {
-      console.log("parser-orchestrator.js: orchestrate(): #this.mapArr[]=" + this.mapArr.length);
+      console.log("parser-orchestrator.js: orchestrate(): #this.mapArr[]=" + this.mapArr.length + " / here, this.list[].id=[]");
+      aux3 = "";
       for (const i in this.mapArr) { // [id=1] [type=0] [param=357,-285.48333740234375] [deps=3] [label=A,4,-10,0] [defined=1] [color=[object Object]] [hidden=0] [position=NaN] [font=] [label_color=[object Object]]
         if (!this.mapArr[i] || this.mapArr[i]=="")
           continue; // avoid empty entry in "this.mapArr[]" and in "vec_dynamic_obj[]"
@@ -52,16 +53,31 @@ export class ParserOrchestrator {
         console.log("parser-orchestrator.js: orchestrate(): this.mapArr: ii=" + ii + ": this.mapArr[i].id=" + id + ", " + ParserOrchestrator.printMap_po(this.mapArr[i]));
 
         // This defines elements to be used by "static do (map, list)" of GeometricObject to create the objects
-        result = this.do(id, this.mapArr[i], vec_dynamic_obj); // create the GeometricObject
+        result = this.do(id, this.mapArr[i], vec_dynamic_obj); // create the GeometricObject, build this.list[]
+        // parser-orchestrator.js: orchestrate(): #this.mapArr[]=6, listID[]=listID[0]=1; listID[1]=2; listID[2]=3;, with ii=1, 3, 5 
+        listID[i] = id; // Security: PointIntersection ("intersection-model.js") usually create ID=1 when use "og1.getIntersection(og2);", bellow "do(id, map, vecOD)" must fix it - if it also fail...
+        aux3 += "listID[" + i + "]=" + id + "=" + this.list[i].id + "?; ";
+        ii++;
 
         if (result==-1) console.log("parser-orchestrator.js: orchestrate(): error 1: i=" + i + ", ii=" + ii + ", this.mapArr["+i+"]=" + ParserOrchestrator.printMap_po(this.mapArr[i]));
         // this.mapArr[i].entries(). JSON.stringify(Object.keys(this.mapArr[i]))
         }
-      console.log("parser-orchestrator.js: orchestrate(): #this.mapArr[]=" + ii); //D + ": " + auxEr); //D
+      tam = 0;
+      if (this.list) tam = tam = this.list.length; aux3 += " / this.list[].id=[";
+      for (ii=0; ii<tam; ii++) aux3 += this.list[ii].id + ", ";
+      aux3 += "]";
+      console.log("parser-orchestrator.js: orchestrate(): #this.mapArr[]=" + ii + ", listID[]=" + aux3); //D + ": " + auxEr); //D
       ii = 0;
       for (const i in this.list) { // to each geom. obj. (e.g. Point): ["id","label","labelIgeom","dependentsOnThis","definitions","labelColor","defined","color","visible","draggable","posX","posY","elementClass"]
         auxEr2 = "id=" + this.list[i].id + ", elementClass=" + this.list[i].elementClass + ", " + JSON.stringify(Object.keys(this.list[i])); // elementClass is int value to DEFINITION, e.g. Point is 0, since its DEFINITION is "2:0"
-        //D console.log("parser-orchestrator.js: orchestrate(): this.list: " + ii + ": " + auxEr2); //D
+	if (this.list[i].id!=listID[i]) try { // if "do(id, map, vecOD)" fail to fix PointIntersection.id...
+          console.log("parser-orchestrator.js: orchestrate(): error, ii=" + ii +", fix this.list[" + i + "].id=" + this.list[i].id + " <- " + listID[i]);
+          if (listID[i]) {
+            this.list[i].id = listID[i];
+            auxEr2 = "id=" + this.list[i].id + ", elementClass=" + this.list[i].elementClass + ", " + JSON.stringify(Object.keys(this.list[i]));
+            }
+          } catch (error) { console.log("parser-orchestrator.js!orchestrate(): error " + error + ", ii=" + ii + ", i=" + i); }
+        console.log("parser-orchestrator.js: orchestrate(): this.list: " + ii + ": " + auxEr2); //D
         auxEr += "(" + ii + "," + JSON.stringify(Object.keys(this.list[i])) + "); "; ii++; //D
         result = this.draw(this.list[i]);
         if (result==-1) console.log("parser-orchestrator.js: orchestrate(): error: ii=" + ii + ", this.list["+i+"]=" + JSON.stringify(Object.keys(this.list[i])));
@@ -102,6 +118,7 @@ export class ParserOrchestrator {
           auxEr = "5 [" + auxDef + "], "; //D
           // object = MiddlePointModel.do(map, this.list);
           object = MiddlePointModel.do(map, vecOD, this.list); // 2023/07
+	  object.id = id; // "intersection-model.js!static do(id, map, vecIdObj, list)" can generate an wrong ID, fix it!
           break;
         case ELEMENTS_CLASS.LINE_SEGMENT:
           auxEr = "6, "; //D