fl-web-component 2.0.19 → 2.1.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/fl-web-component.common.1.js.map +1 -1
  2. package/dist/fl-web-component.common.2.js.map +1 -1
  3. package/dist/fl-web-component.common.js +5871 -1872
  4. package/dist/fl-web-component.common.js.map +1 -1
  5. package/dist/fl-web-component.css +1 -1
  6. package/package.json +4 -3
  7. package/packages/components/com-flcanvas/components/entityFormatting.js +134 -1
  8. package/packages/components/com-flcanvas/index.vue +335 -239
  9. package/packages/components/com-graphics/index.vue +433 -35
  10. package/packages/components/com-graphics/mock.json +115 -0
  11. package/packages/utils/StreamLoader.js +250 -107
  12. package/packages/utils/StreamLoaderParser.worker.js +180 -72
  13. package/src/utils/dxf-parser/AutoCadColorIndex.js +265 -0
  14. package/src/utils/dxf-parser/DimStyleCodes.js +33 -0
  15. package/src/utils/dxf-parser/DxfArrayScanner.js +151 -0
  16. package/src/utils/dxf-parser/DxfParser.js +918 -0
  17. package/src/utils/dxf-parser/ExtendedDataParser.js +117 -0
  18. package/src/utils/dxf-parser/LICENSE +21 -0
  19. package/src/utils/dxf-parser/ParseHelpers.js +140 -0
  20. package/src/utils/dxf-parser/README.md +8 -0
  21. package/src/utils/dxf-parser/entities/3dface.js +83 -0
  22. package/src/utils/dxf-parser/entities/arc.js +38 -0
  23. package/src/utils/dxf-parser/entities/attdef.js +89 -0
  24. package/src/utils/dxf-parser/entities/attribute.js +109 -0
  25. package/src/utils/dxf-parser/entities/circle.js +43 -0
  26. package/src/utils/dxf-parser/entities/dimension.js +71 -0
  27. package/src/utils/dxf-parser/entities/ellipse.js +48 -0
  28. package/src/utils/dxf-parser/entities/hatch.js +348 -0
  29. package/src/utils/dxf-parser/entities/insert.js +57 -0
  30. package/src/utils/dxf-parser/entities/line.js +34 -0
  31. package/src/utils/dxf-parser/entities/lwpolyline.js +103 -0
  32. package/src/utils/dxf-parser/entities/mtext.js +57 -0
  33. package/src/utils/dxf-parser/entities/point.js +35 -0
  34. package/src/utils/dxf-parser/entities/polyline.js +92 -0
  35. package/src/utils/dxf-parser/entities/solid.js +40 -0
  36. package/src/utils/dxf-parser/entities/spline.js +70 -0
  37. package/src/utils/dxf-parser/entities/text.js +50 -0
  38. package/src/utils/dxf-parser/entities/vertex.js +62 -0
  39. package/src/utils/flgltf-parser.js +21 -9
  40. package/src/utils/instance-parser.js +59 -59
  41. package/src/utils/threejs/measure-clear-distance.js +149 -123
  42. package/packages/components/com-graphics/box.json +0 -77
@@ -0,0 +1,151 @@
1
+ /**
2
+ * DxfArrayScanner
3
+ *
4
+ * Based off the AutoCad 2012 DXF Reference
5
+ * http://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf
6
+ *
7
+ * Reads through an array representing lines of a dxf file. Takes an array and
8
+ * provides an easy interface to extract group code and value pairs.
9
+ * @param data - an array where each element represents a line in the dxf file
10
+ * @constructor
11
+ */
12
+ export default function DxfArrayScanner(data) {
13
+ this._pointer = 0;
14
+ this._data = data;
15
+ this._eof = false;
16
+ }
17
+
18
+ /**
19
+ * Gets the next group (code, value) from the array. A group is two consecutive elements
20
+ * in the array. The first is the code, the second is the value.
21
+ * @returns {{code: Number}|*}
22
+ */
23
+ DxfArrayScanner.prototype.next = function() {
24
+ var group;
25
+ if(!this.hasNext()) {
26
+ if(!this._eof)
27
+ throw new Error('Unexpected end of input: EOF group not read before end of file. Ended on code ' + this._data[this._pointer]);
28
+ else
29
+ throw new Error('Cannot call \'next\' after EOF group has been read');
30
+ }
31
+
32
+ group = {
33
+ code: parseInt(this._data[this._pointer])
34
+ };
35
+
36
+ if (isNaN(group.code)) {
37
+ throw new Error("Cannot parse group code: " + this._data[this._pointer])
38
+ }
39
+
40
+ this._pointer++;
41
+
42
+ group.value = parseGroupValue(group.code, this._data[this._pointer]);
43
+
44
+ this._pointer++;
45
+
46
+ if(group.code === 0 && group.value === 'EOF') this._eof = true;
47
+
48
+ this.lastReadGroup = group;
49
+
50
+ return group;
51
+ };
52
+
53
+ DxfArrayScanner.prototype.peek = function() {
54
+ if(!this.hasNext()) {
55
+ if(!this._eof)
56
+ throw new Error('Unexpected end of input: EOF group not read before end of file. Ended on code ' + this._data[this._pointer]);
57
+ else
58
+ throw new Error('Cannot call \'next\' after EOF group has been read');
59
+ }
60
+
61
+ var group = {
62
+ code: parseInt(this._data[this._pointer])
63
+ };
64
+
65
+ if (isNaN(group.code)) {
66
+ throw new Error("Cannot parse group code: " + this._data[this._pointer])
67
+ }
68
+
69
+ group.value = parseGroupValue(group.code, this._data[this._pointer + 1]);
70
+
71
+ return group;
72
+ };
73
+
74
+
75
+ DxfArrayScanner.prototype.rewind = function(numberOfGroups) {
76
+ numberOfGroups = numberOfGroups || 1;
77
+ this._pointer = this._pointer - numberOfGroups * 2;
78
+ };
79
+
80
+ /**
81
+ * Returns true if there is another code/value pair (2 elements in the array).
82
+ * @returns {boolean}
83
+ */
84
+ DxfArrayScanner.prototype.hasNext = function() {
85
+ // Check if we have read EOF group code
86
+ if(this._eof) {
87
+ return false;
88
+ }
89
+
90
+ // We need to be sure there are two lines available
91
+ if(this._pointer > this._data.length - 2) {
92
+ return false;
93
+ }
94
+ return true;
95
+ };
96
+
97
+ /**
98
+ * Returns true if the scanner is at the end of the array
99
+ * @returns {boolean}
100
+ */
101
+ DxfArrayScanner.prototype.isEOF = function() {
102
+ return this._eof;
103
+ };
104
+
105
+ /**
106
+ * Parse a value to its proper type.
107
+ * See pages 3 - 10 of the AutoCad DXF 2012 reference given at the top of this file
108
+ *
109
+ * @param code
110
+ * @param value
111
+ * @returns {*}
112
+ */
113
+ function parseGroupValue(code, value) {
114
+ if(code <= 9) return value;
115
+ if(code >= 10 && code <= 59) return parseFloat(value.trim());
116
+ if(code >= 60 && code <= 99) return parseInt(value.trim());
117
+ if(code >= 100 && code <= 109) return value;
118
+ if(code >= 110 && code <= 149) return parseFloat(value.trim());
119
+ if(code >= 160 && code <= 179) return parseInt(value.trim());
120
+ if(code >= 210 && code <= 239) return parseFloat(value.trim());
121
+ if(code >= 270 && code <= 289) return parseInt(value.trim());
122
+ if(code >= 290 && code <= 299) return parseBoolean(value.trim());
123
+ if(code >= 300 && code <= 369) return value;
124
+ if(code >= 370 && code <= 389) return parseInt(value.trim());
125
+ if(code >= 390 && code <= 399) return value;
126
+ if(code >= 400 && code <= 409) return parseInt(value.trim());
127
+ if(code >= 410 && code <= 419) return value;
128
+ if(code >= 420 && code <= 429) return parseInt(value.trim());
129
+ if(code >= 430 && code <= 439) return value;
130
+ if(code >= 440 && code <= 459) return parseInt(value.trim());
131
+ if(code >= 460 && code <= 469) return parseFloat(value.trim());
132
+ if(code >= 470 && code <= 481) return value;
133
+ if(code === 999) return value;
134
+ if(code >= 1000 && code <= 1009) return value;
135
+ if(code >= 1010 && code <= 1059) return parseFloat(value.trim());
136
+ if(code >= 1060 && code <= 1071) return parseInt(value.trim());
137
+
138
+ console.log('WARNING: Group code does not have a defined type: %j', { code: code, value: value });
139
+ return value;
140
+ }
141
+
142
+ /**
143
+ * Parse a boolean according to a 1 or 0 value
144
+ * @param str
145
+ * @returns {boolean}
146
+ */
147
+ function parseBoolean(str) {
148
+ if(str === '0') return false;
149
+ if(str === '1') return true;
150
+ throw TypeError('String \'' + str + '\' cannot be cast to Boolean type');
151
+ }