PageSourceSearch

https://www.vzome.com/modules/exporters-QN2V3JA4.js

js vzome.com collected 2026-10-02 07:05:05 UTC 127,030 bytes, 3,512 lines download raw bytes

1import {
2  AntiprismSymmetry,
3  Color,
4  Command,
5  File,
6  Manifestations,
7  Polygon,
8  PolygonField,
9  PropertyChangeSupport,
10  ResourceLoader
11} from "./chunk-CQATDKLG.js";
12import {
13  AlgebraicVector,
14  ArrayComparator,
15  DomUtils,
16  NumberFormat,
17  Point,
18  PrintWriter,
19  RealVector,
20  StringWriter,
21  VefVectorExporter,
22  java,
23  javaemul
24} from "./chunk-5PFIPZES.js";
25import "./chunk-JSBRDJBE.js";
26
27// src/worker/legacy/from-java/com/vzome/core/viewing/Lights.ts
28var Lights = class _Lights {
29  addPropertyListener(listener) {
30    this.pcs.addPropertyChangeListener$java_beans_PropertyChangeListener(listener);
31  }
32  removePropertyListener(listener) {
33    this.pcs.removePropertyChangeListener$java_beans_PropertyChangeListener(listener);
34  }
35  setProperty(cmd, value) {
36    if ("backgroundColor" === cmd) {
37      this.backgroundColor = new Color(javaemul.internal.IntegerHelper.parseInt(value, 16));
38      this.pcs.firePropertyChange$java_lang_String$java_lang_Object$java_lang_Object(cmd, null, value);
39    }
40  }
41  constructor(prototype) {
42    if (prototype != null && prototype instanceof _Lights || prototype === null) {
43      let __args = arguments;
44      {
45        let __args2 = arguments;
46        if (this.mAmbientLightColor === void 0) {
47          this.mAmbientLightColor = null;
48        }
49        if (this.backgroundColor === void 0) {
50          this.backgroundColor = null;
51        }
52        this.pcs = new PropertyChangeSupport(this);
53        this.directionalLights = new java.util.ArrayList(3);
54      }
55      (() => {
56        this.backgroundColor = prototype.backgroundColor;
57        this.mAmbientLightColor = prototype.mAmbientLightColor;
58        for (let i = 0; i < prototype.directionalLights.size(); i++) {
59          {
60            this.addDirectionLight$com_vzome_core_viewing_Lights_DirectionalLight(prototype.directionalLights.get(i));
61          }
62          ;
63        }
64      })();
65    } else if (prototype != null && (prototype.constructor != null && prototype.constructor["__interfaces"] != null && prototype.constructor["__interfaces"].indexOf("org.w3c.dom.Element") >= 0) || prototype === null) {
66      let __args = arguments;
67      let element = __args[0];
68      {
69        let __args2 = arguments;
70        if (this.mAmbientLightColor === void 0) {
71          this.mAmbientLightColor = null;
72        }
73        if (this.backgroundColor === void 0) {
74          this.backgroundColor = null;
75        }
76        this.pcs = new PropertyChangeSupport(this);
77        this.directionalLights = new java.util.ArrayList(3);
78      }
79      (() => {
80        let str = element.getAttribute("background");
81        this.backgroundColor = Color.parseColor(str);
82        str = element.getAttribute("ambientLight");
83        this.mAmbientLightColor = Color.parseColor(str);
84        const nodes = element.getChildNodes();
85        for (let i = 0; i < nodes.getLength(); i++) {
86          {
87            const node = nodes.item(i);
88            if (node != null && (node.constructor != null && node.constructor["__interfaces"] != null && node.constructor["__interfaces"].indexOf("org.w3c.dom.Element") >= 0)) {
89              const viewElem = node;
90              str = viewElem.getAttribute("color");
91              const color = Color.parseColor(str);
92              const pos = new RealVector(javaemul.internal.FloatHelper.parseFloat(viewElem.getAttribute("x")), javaemul.internal.FloatHelper.parseFloat(viewElem.getAttribute("y")), javaemul.internal.FloatHelper.parseFloat(viewElem.getAttribute("z")));
93              this.addDirectionLight$com_vzome_core_viewing_Lights_DirectionalLight(new _Lights.DirectionalLight(pos, color));
94            }
95          }
96          ;
97        }
98      })();
99    } else if (prototype === void 0) {
100      let __args = arguments;
101      if (this.mAmbientLightColor === void 0) {
102        this.mAmbientLightColor = null;
103      }
104      if (this.backgroundColor === void 0) {
105        this.backgroundColor = null;
106      }
107      this.pcs = new PropertyChangeSupport(this);
108      this.directionalLights = new java.util.ArrayList(3);
109    } else throw new Error("invalid overload");
110  }
111  size() {
112    return this.directionalLights.size();
113  }
114  addDirectionLight$com_vzome_core_viewing_Lights_DirectionalLight(light) {
115    this.directionalLights.add(light);
116  }
117  setAmbientColor(color) {
118    this.mAmbientLightColor = color;
119  }
120  getAmbientColor() {
121    return this.mAmbientLightColor;
122  }
123  getAmbientColorWeb() {
124    return this.mAmbientLightColor.toWebString();
125  }
126  getDirectionalLights() {
127  }
128  getBackgroundColor() {
129    return this.backgroundColor;
130  }
131  getBackgroundColorWeb() {
132    return this.backgroundColor.toWebString();
133  }
134  setBackgroundColor(color) {
135    this.backgroundColor = color;
136  }
137  getXml(doc) {
138    const result = doc.createElement("sceneModel");
139    DomUtils.addAttribute(result, "ambientLight", this.mAmbientLightColor.toString());
140    DomUtils.addAttribute(result, "background", this.backgroundColor.toString());
141    for (let i = 0; i < this.directionalLights.size(); i++) {
142      {
143        const light = this.directionalLights.get(i);
144        const child = doc.createElement("directionalLight");
145        DomUtils.addAttribute(
146          child,
147          "x",
148          /* toString */
149          "" + light.direction.x
150        );
151        DomUtils.addAttribute(
152          child,
153          "y",
154          /* toString */
155          "" + light.direction.y
156        );
157        DomUtils.addAttribute(
158          child,
159          "z",
160          /* toString */
161          "" + light.direction.z
162        );
163        DomUtils.addAttribute(child, "color", light.color.toString());
164        result.appendChild(child);
165      }
166      ;
167    }
168    return result;
169  }
170  /**
171   * 
172   * @return {*}
173   */
174  iterator() {
175    return this.directionalLights.iterator();
176  }
177  addDirectionLight$com_vzome_core_construction_Color$com_vzome_core_math_RealVector(color, dir) {
178    this.addDirectionLight$com_vzome_core_viewing_Lights_DirectionalLight(new _Lights.DirectionalLight(dir, color));
179  }
180  addDirectionLight(color, dir) {
181    if ((color != null && color instanceof Color || color === null) && (dir != null && dir instanceof RealVector || dir === null)) {
182      return this.addDirectionLight$com_vzome_core_construction_Color$com_vzome_core_math_RealVector(color, dir);
183    } else if ((color != null && color instanceof _Lights.DirectionalLight || color === null) && dir === void 0) {
184      return this.addDirectionLight$com_vzome_core_viewing_Lights_DirectionalLight(color);
185    } else throw new Error("invalid overload");
186  }
187  getDirectionalLightVector(i) {
188    const light = this.directionalLights.get(i);
189    return new RealVector(light.direction.x, light.direction.y, light.direction.z);
190  }
191  getDirectionalLightColor(i) {
192    const light = this.directionalLights.get(i);
193    return light.color;
194  }
195};
196Lights["__class"] = "com.vzome.core.viewing.Lights";
197Lights["__interfaces"] = ["java.lang.Iterable"];
198((Lights2) => {
199  class DirectionalLight {
200    constructor(direction, color) {
201      if (this.direction === void 0) {
202        this.direction = null;
203      }
204      if (this.color === void 0) {
205        this.color = null;
206      }
207      this.direction = direction;
208      this.color = color;
209    }
210    getColor() {
211      return this.color.toWebString();
212    }
213    getDirection() {
214      return [this.direction.x, this.direction.y, this.direction.z];
215    }
216  }
217  Lights2.DirectionalLight = DirectionalLight;
218  DirectionalLight["__class"] = "com.vzome.core.viewing.Lights.DirectionalLight";
219})(Lights || (Lights = {}));
220
221// src/worker/legacy/from-java/com/vzome/core/math/RealMatrix4.ts
222var RealMatrix4 = class _RealMatrix4 {
223  constructor(m, transpose) {
224    if ((m != null && m instanceof Array && (m.length == 0 || m[0] == null || typeof m[0] === "number") || m === null) && (typeof transpose === "boolean" || transpose === null)) {
225      let __args = arguments;
226      if (this.m00 === void 0) {
227        this.m00 = 0;
228      }
229      if (this.m01 === void 0) {
230        this.m01 = 0;
231      }
232      if (this.m02 === void 0) {
233        this.m02 = 0;
234      }
235      if (this.m03 === void 0) {
236        this.m03 = 0;
237      }
238      if (this.m10 === void 0) {
239        this.m10 = 0;
240      }
241      if (this.m11 === void 0) {
242        this.m11 = 0;
243      }
244      if (this.m12 === void 0) {
245        this.m12 = 0;
246      }
247      if (this.m13 === void 0) {
248        this.m13 = 0;
249      }
250      if (this.m20 === void 0) {
251        this.m20 = 0;
252      }
253      if (this.m21 === void 0) {
254        this.m21 = 0;
255      }
256      if (this.m22 === void 0) {
257        this.m22 = 0;
258      }
259      if (this.m23 === void 0) {
260        this.m23 = 0;
261      }
262      if (this.m30 === void 0) {
263        this.m30 = 0;
264      }
265      if (this.m31 === void 0) {
266        this.m31 = 0;
267      }
268      if (this.m32 === void 0) {
269        this.m32 = 0;
270      }
271      if (this.m33 === void 0) {
272        this.m33 = 0;
273      }
274      this.m00 = m[0];
275      this.m01 = m[4];
276      this.m02 = m[8];
277      this.m03 = m[12];
278      this.m10 = m[1];
279      this.m11 = m[5];
280      this.m12 = m[9];
281      this.m13 = m[13];
282      this.m20 = m[2];
283      this.m21 = m[6];
284      this.m22 = m[10];
285      this.m23 = m[14];
286      this.m30 = m[3];
287      this.m31 = m[7];
288      this.m32 = m[11];
289      this.m33 = m[15];
290    } else if ((m != null && m instanceof Array && (m.length == 0 || m[0] == null || typeof m[0] === "
290number") || m === null) && transpose === void 0) {
291      let __args = arguments;
292      if (this.m00 === void 0) {
293        this.m00 = 0;
294      }
295      if (this.m01 === void 0) {
296        this.m01 = 0;
297      }
298      if (this.m02 === void 0) {
299        this.m02 = 0;
300      }
301      if (this.m03 === void 0) {
302        this.m03 = 0;
303      }
304      if (this.m10 === void 0) {
305        this.m10 = 0;
306      }
307      if (this.m11 === void 0) {
308        this.m11 = 0;
309      }
310      if (this.m12 === void 0) {
311        this.m12 = 0;
312      }
313      if (this.m13 === void 0) {
314        this.m13 = 0;
315      }
316      if (this.m20 === void 0) {
317        this.m20 = 0;
318      }
319      if (this.m21 === void 0) {
320        this.m21 = 0;
321      }
322      if (this.m22 === void 0) {
323        this.m22 = 0;
324      }
325      if (this.m23 === void 0) {
326        this.m23 = 0;
327      }
328      if (this.m30 === void 0) {
329        this.m30 = 0;
330      }
331      if (this.m31 === void 0) {
332        this.m31 = 0;
333      }
334      if (this.m32 === void 0) {
335        this.m32 = 0;
336      }
337      if (this.m33 === void 0) {
338        this.m33 = 0;
339      }
340      this.m00 = m[0];
341      this.m01 = m[1];
342      this.m02 = m[2];
343      this.m03 = m[3];
344      this.m10 = m[4];
345      this.m11 = m[5];
346      this.m12 = m[6];
347      this.m13 = m[7];
348      this.m20 = m[8];
349      this.m21 = m[9];
350      this.m22 = m[10];
351      this.m23 = m[11];
352      this.m30 = m[12];
353      this.m31 = m[13];
354      this.m32 = m[14];
355      this.m33 = m[15];
356    } else throw new Error("invalid overload");
357  }
358  /**
359   * 
360   * @param {RealVector} v 4th component treated as 1
361   * @return
362   * @return {RealVector}
363   */
364  transform3dPt(v) {
365    return new RealVector(Math.fround(Math.fround(Math.fround(Math.fround(this.m00 * v.x) + Math.fround(this.m01 * v.y)) + Math.fround(this.m02 * v.z)) + this.m03), Math.fround(Math.fround(Math.fround(Math.fround(this.m10 * v.x) + Math.fround(this.m11 * v.y)) + Math.fround(this.m12 * v.z)) + this.m13), Math.fround(Math.fround(Math.fround(Math.fround(this.m20 * v.x) + Math.fround(this.m21 * v.y)) + Math.fround(this.m22 * v.z)) + this.m23));
366  }
367  /**
368   * 
369   * @param {RealVector} v 4th component treated as 0
370   * @return
371   * @return {RealVector}
372   */
373  transform3dVec(v) {
374    return new RealVector(Math.fround(Math.fround(Math.fround(this.m00 * v.x) + Math.fround(this.m01 * v.y)) + Math.fround(this.m02 * v.z)), Math.fround(Math.fround(Math.fround(this.m10 * v.x) + Math.fround(this.m11 * v.y)) + Math.fround(this.m12 * v.z)), Math.fround(Math.fround(Math.fround(this.m20 * v.x) + Math.fround(this.m21 * v.y)) + Math.fround(this.m22 * v.z)));
375  }
376  transform4d(v) {
377    const x = Math.fround(Math.fround(Math.fround(Math.fround(this.m00 * v[0]) + Math.fround(this.m01 * v[1])) + Math.fround(this.m02 * v[2])) + Math.fround(this.m03 * v[3]));
378    const y = Math.fround(Math.fround(Math.fround(Math.fround(this.m10 * v[0]) + Math.fround(this.m11 * v[1])) + Math.fround(this.m12 * v[2])) + Math.fround(this.m13 * v[3]));
379    const z = Math.fround(Math.fround(Math.fround(Math.fround(this.m20 * v[0]) + Math.fround(this.m21 * v[1])) + Math.fround(this.m22 * v[2])) + Math.fround(this.m23 * v[3]));
380    const w = Math.fround(Math.fround(Math.fround(Math.fround(this.m30 * v[0]) + Math.fround(this.m31 * v[1])) + Math.fround(this.m32 * v[2])) + Math.fround(this.m33 * v[3]));
381    return [x, y, z, w];
382  }
383  /**
384   * Helping function that specifies the position and orientation of a
385   * view matrix. The inverse of this transform can be used to control
386   * the ViewPlatform object within the scene graph.
387   * @param {RealVector} eye the location of the eye
388   * @param {RealVector} center a point in the virtual world where the eye is looking
389   * @param {RealVector} up an up vector specifying the frustum's up direction
390   * @return {RealMatrix4}
391   */
392  static lookAt(eye, center, up) {
393    let forwardx;
394    let forwardy;
395    let forwardz;
396    let invMag;
397    let upx;
398    let upy;
399    let upz;
400    let sidex;
401    let sidey;
402    let sidez;
403    forwardx = Math.fround(eye.x - center.x);
404    forwardy = Math.fround(eye.y - center.y);
405    forwardz = Math.fround(eye.z - center.z);
406    invMag = Math.fround(1 / Math.sqrt(Math.fround(Math.fround(Math.fround(forwardx * forwardx) + Math.fround(forwardy * forwardy)) + Math.fround(forwardz * forwardz))));
407    forwardx = Math.fround(forwardx * invMag);
408    forwardy = Math.fround(forwardy * invMag);
409    forwardz = Math.fround(forwardz * invMag);
410    invMag = Math.fround(1 / Math.sqrt(Math.fround(Math.fround(Math.fround(up.x * up.x) + Math.fround(up.y * up.y)) + Math.fround(up.z * up.z))));
411    upx = Math.fround(up.x * invMag);
412    upy = Math.fround(up.y * invMag);
413    upz = Math.fround(up.z * invMag);
414    sidex = Math.fround(Math.fround(upy * forwardz) - Math.fround(forwardy * upz));
415    sidey = Math.fround(Math.fround(upz * forwardx) - Math.fround(upx * forwardz));
416    sidez = Math.fround(Math.fround(upx * forwardy) - Math.fround(upy * forwardx));
417    invMag = Math.fround(1 / Math.sqrt(Math.fround(Math.fround(Math.fround(sidex * sidex) + Math.fround(sidey * sidey)) + Math.fround(sidez * sidez))));
418    sidex *= invMag;
419    sidey *= invMag;
420    sidez *= invMag;
421    upx = Math.fround(Math.fround(forwardy * sidez) - Math.fround(sidey * forwardz));
422    upy = Math.fround(Math.fround(forwardz * sidex) - Math.fround(forwardx * sidez));
423    upz = Math.fround(Math.fround(forwardx * sidey) - Math.fround(forwardy * sidex));
424    const m00 = sidex;
425    const m01 = sidey;
426    const m02 = sidez;
427    const m10 = upx;
428    const m11 = upy;
429    const m12 = upz;
430    const m20 = forwardx;
431    const m21 = forwardy;
432    const m22 = forwardz;
433    const m03 = Math.fround(Math.fround(Math.fround(-eye.x * m00) + Math.fround(-eye.y * m01)) + Math.fround(-eye.z * m02));
434    const m13 = Math.fround(Math.fround(Math.fround(-eye.x * m10) + Math.fround(-eye.y * m11)) + Math.fround(-eye.z * m12));
435    const m23 = Math.fround(Math.fround(Math.fround(-eye.x * m20) + Math.fround(-eye.y * m21)) + Math.fround(-eye.z * m22));
436    return new _RealMatrix4([m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, 0, 0, 0, 1]);
437  }
438  /**
439   * Creates a perspective projection transform that mimics a standard,
440   * camera-based,
441   * view-model.
442   * (From javax.media.j3d.Transform3d.java)
443   * This transform maps coordinates from Eye Coordinates (EC)
444   * to Clipping Coordinates (CC).  Note that unlike the similar function
445   * in OpenGL, the clipping coordinates generated by the resulting
446   * transform are in a right-handed coordinate system
447   * (as are all other coordinate systems in Java 3D). Also note that the
448   * field of view is specified in radians.
449   * @param {number} fovx specifies the field of view in the x direction, in radians
450   * @param {number} aspect specifies the aspect ratio and thus the field of
451   * view in the x direction. The aspect ratio is the ratio of x to y,
452   * or width to height.
453   * @param {number} zNear the distance to the frustum's near clipping plane.
454   * This value must be positive, (the value -zNear is the location of the
455   * near clip plane).
456   * @param {number} zFar the distance to the frustum's far clipping plane
457   * @return {RealMatrix4}
458   */
459  static perspective(fovx, aspect, zNear, zFar) {
460    let sine;
461    let cotangent;
462    let deltaZ;
463    const half_fov = Math.fround(fovx * 0.5);
464    deltaZ = Math.fround(zFar - zNear);
465    sine = Math.fround(Math.sin(half_fov));
466    cotangent = Math.fround(Math.cos(half_fov) / sine);
467    const m00 = cotangent;
468    const m11 = Math.fround(cotangent * aspect);
469    const m22 = Math.fround(Math.fround(zFar + zNear) / deltaZ);
470    const m23 = Math.fround(Math.fround(Math.fround(2 * zNear) * zFar) / deltaZ);
471    const m32 = -1;
472    return new _RealMatrix4([m00, 0, 0, 0, 0, m11, 0, 0, 0, 0, m22, m23, 0, 0, m32, 0]);
473  }
474  /**
475   * Creates an orthographic projection transform that mimics a standard,
476   * camera-based,
477   * view-model.
478   * (From javax.media.j3d.Transform3d.java)
479   * This transform maps coordinates from Eye Coordinates (EC)
480   * to Clipping Coordinates (CC).  Note that unlike the similar function
481   * in OpenGL, the clipping coordinates generated by the resulting
482   * transform are in a right-handed coordinate system
483   * (as are all other coordinate systems in Java 3D).
484   * @param {number} left the vertical line on the left edge of the near
485   * clipping plane mapped to the left edge of the graphics window
486   * @param {number} right the vertical line on the right edge of the near
487   * clipping plane mapped to the right edge of the graphics window
488   * @param {number} bottom the horizontal line on the bottom edge of the near
489   * clipping plane mapped to the bottom edge of the graphics window
490   * @param {number} top the horizontal line on the top edge of the near
491   * clipping plane mapped to the top edge of the graphics window
492   * @param {number} near the distance to the frustum's near clipping plane
493   * (the value -near is the location of the near clip plane)
494   * @param {number} far the distance to the frustum's far clipping plane
495   * @return {RealMatrix4}
496   */
497  static ortho(left, right, bottom, top, near, far) {
498    const deltax = Math.fround(1 / Math.fround(right - left));
499    const deltay = Math.fround(1 / Math.fround(top - bottom));
500    const deltaz = Math.fround(1 / Math.fround(far - near));
501    const m00 = Math.fround(2 * deltax);
502    const m03 = Math.fround(-Math.fround(right + left) * deltax);
503    const m11 = Math.fround(2 * deltay);
504    const m13 = Math.fround(-Math.fround(top + bottom) * deltay);
505    const m22 = Math.fround(2 * deltaz);
506    const m23 = Math.fround(Math.fround(far + near) * deltaz);
507    const m33 = 1;
508    return new _RealMatrix4([m00, 0, 0, m03, 0, m11, 0, m13, 0, 0, m22, m23, 0, 0, 0, m33]);
509  }
510  toArray() {
511    return [this.m00, this.m01, this.m02, this.m03, this.m10, this.m11, this.m12, this.m13, this.m20, this.m21, this.m22, this.m23, this.m30, this.m31, this.m32, this.m33];
512  }
513};
514RealMatrix4["__class"] = "com.vzome.core.math.RealMatrix4";
515
516// src/worker/legacy/from-java/java/awt/Color.ts
517var Color2 = class _Color {
518  static WHITE_$LI$() {
519    if (_Color.WHITE == null) {
520      _Color.WHITE = new _Color(255, 255, 255);
521    }
522    return _Color.WHITE;
523  }
524  static BLACK_$LI$() {
525    if (_Color.BLACK == null) {
526      _Color.BLACK = new _Color(0, 0, 0);
527    }
528    return _Color.BLACK;
529  }
530  constructor(r, g, b, a) {
531    if ((typeof r === "number" || r === null) && (typeof g === "number" || g === null) && (typeof b === "number" || b === null) && (typeof a === "number" || a === null)) {
532      let __args = arguments;
533      if (this.value === void 0) {
534        this.value = 0;
535      }
536      this.value = (a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | (b & 255) << 0;
537    } else if ((typeof r === "number" || r === null) && (typeof g === "number" || g === null) && (typeof b === "number" || b === null) && a === void 0) {
538      let __args = arguments;
539      {
540        let __args2 = arguments;
541        let a2 = 255;
542        if (this.value === void 0) {
543          this.value = 0;
544        }
545        this.value = (a2 & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | (b & 255) << 0;
546      }
547    } else if ((typeof r === "number" || r === null) && g === void 0 && b === void 0 && a === void 0) {
548      let __args = arguments;
549      let rgb = __args[0];
550      if (this.value === void 0) {
551        this.value = 0;
552      }
553      this.value = -16777216 | rgb;
554    } else throw new Error("invalid overload");
555  }
556  getRed() {
557    return this.value >> 16 & 255;
558  }
559  getGreen() {
560    return this.value >> 8 & 255;
561  }
562  getBlue() {
563    return this.value >> 0 & 255;
564  }
565  getRGB() {
566    return this.value;
567  }
568  getRGBColorComponents(compArray) {
569    const f = [0, 0, 0];
570    f[0] = Math.fround(this.getRed() / 255);
571    f[1] = Math.fround(this.getGreen() / 255);
572    f[2] = Math.fround(this.getBlue() / 255);
573    return f;
574  }
575};
576Color2["__class"] = "java.awt.Color";
577
578// src/worker/legacy/from-java/java/awt/Dimension.ts
579var Dimension = class {
580  constructor(width, height) {
581    if (this.width === void 0) {
582      this.width = 0;
583    }
584    if (this.height === void 0) {
585      this.height = 0;
586    }
587    this.width = width;
588    this.height = height;
589  }
590};
591Dimension["__class"] = "java.awt.Dimension";
592
593// src/worker/legacy/from-java/java/awt/geom/PathIterator.ts
594var PathIterator;
595((PathIterator2) => {
596  PathIterator2.SEG_MOVETO = 0;
597  PathIterator2.SEG_LINETO = 1;
598  PathIterator2.SEG_CLOSE = 4;
599})(PathIterator || (PathIterator = {}));
600
601// src/worker/legacy/from-java/java/awt/geom/GeneralPath.ts
602var GeneralPath = class _GeneralPath {
603  moveTo(x, y) {
604    this.xs.add(x);
605    this.ys.add(y);
606    this.actions.add(PathIterator.SEG_MOVETO);
607  }
608  lineTo(x, y) {
609    this.xs.add(x);
610    this.ys.add(y);
611    this.actions.add(PathIterator.SEG_LINETO);
612  }
613  closePath() {
614    this.xs.add(0);
615    this.ys.add(0);
616    this.actions.add(PathIterator.SEG_CLOSE);
617  }
618  getPathIterator(at) {
619    return new _GeneralPath.GeneralPath$0(this);
620  }
621  constructor() {
622    this.xs = new java.util.ArrayList();
623    this.ys = new java.util.ArrayList();
624    this.actions = new java.util.ArrayList();
625  }
626};
627GeneralPath["__class"] = "java.awt.geom.GeneralPath";
628((GeneralPath2) => {
629  class GeneralPath$0 {
630    isDone() {
631      return this.index === this.__parent.actions.size();
632    }
633    currentSegment(coords) {
634      coords[0] = this.__parent.xs.get(this.index);
635      coords[1] = this.__parent.ys.get(this.index);
636      return this.__parent.actions.get(this.index) | 0;
637    }
638    next() {
639      ++this.index;
640    }
641    constructor(__parent) {
642      this.__parent = __parent;
643      this.index = 0;
644    }
645  }
646  GeneralPath2.GeneralPath$0 = GeneralPath$0;
647  GeneralPath$0["__interfaces"] = ["java.awt.geom.PathIterator"];
648})(GeneralPath || (GeneralPath = {}));
649
650// src/worker/legacy/from-java/com/vzome/core/exporters2d/Java2dSnapshot.ts
651var Java2dSnapshot = class _Java2dSnapshot {
652  getBackgroundColor() {
653    return this.backgroundColor;
654  }
655  isLineDrawing() {
656    return !this.lines.isEmpty();
657  }
658  addPolygon(polygon) {
659    this.polygons.add(polygon);
660  }
661  addLineSegment(color, start, end) {
662    this.lines.add(new _Java2dSnapshot.LineSegment(color, start, end));
663  }
664  depthSort() {
665    if (this.isLineDrawing()) java.util.Collections.sort(this.lines);
666    else java.util.Collections.sort(this.polygons);
667  }
668  setRect(rect) {
669    this.mRect = rect;
670  }
671  setStrokeWidth(strokeWidth) {
672    this.strokeWidth = strokeWidth;
673  }
674  getRect() {
675    return this.mRect;
676  }
677  getStrokeWidth() {
678    return this.strokeWidth;
679  }
680  getDimension() {
681    return new Dimension(this.mRect.getWidth() | 0, this.mRect.getHeight() | 0);
682  }
683  getLines() {
684    return this.lines;
685  }
686  getPolygons() {
687    return this.polygons;
688  }
689  clear() {
690    this.lines.clear();
691    this.polygons.clear();
692  }
693  setBackgroundColor(backgroundColor) {
694    this.backgroundColor = backgroundColor;
695  }
696  constructor() {
697    this.polygons = new java.util.ArrayList();
698    this.lines = new java.util.ArrayList();
699    if (this.mRect === void 0) {
700      this.mRect = null;
701    }
702    if (this.strokeWidth === void 0) {
703      this.strokeWidth = 0;
704    }
705    if (this.backgroundColor === void 0) {
706      this.backgroundColor = null;
707    }
708  }
709};
710Java2dSnapshot["__class"] = "com.vzome.core.exporters2d.Java2dSnapshot";
711((Java2dSnapshot2) => {
712  class LineSegment {
713    getPath() {
714      return this.mPath;
715    }
716    constructor(color, start, end) {
717      if (this.mPath === void 0) {
718        this.mPath = null;
719      }
720      if (this.mDepth === void 0) {
721        this.mDepth = 0;
722      }
723      if (this.mPolyColor === void 0) {
724        this.mPolyColor = null;
725      }
726      this.mPolyColor = color;
727      this.mPath = new GeneralPath();
728      this.mPath.moveTo(start.x, start.y);
729      this.mPath.lineTo(end.x, end.y);
730      this.mDepth = Math.fround(Math.fround(start.z + end.z) / 2);
731    }
732    getColor() {
733      return this.mPolyColor;
734    }
735    /**
736     * 
737     * @param {Java2dSnapshot.LineSegment} other
738     * @return {number}
739     */
740    compareTo(other) {
741      const otherZ = other.mDepth;
742      if (this.mDepth > otherZ) return 1;
743      if (this.mDepth < otherZ) return -1;
744      return 0;
745    }
746  }
747  Java2dSnapshot2.LineSegment = LineSegment;
748  LineSegment["__class"] = "com.vzome.core.exporters2d.Java2dSnapshot.LineSegment";
749  LineSegment["__interfaces"] = ["java.lang.Comparable"];
750  class Polygon2 {
751    getPath() {
752      return this.mPath;
753    }
754    size() {
755      return this.mSize;
756    }
757    addVertex(vertex) {
758      ++this.mSize;
759      if (this.mSize === 1) {
760        this.mPath.moveTo(vertex.x, vertex.y);
761        this.mDepth = vertex.z;
762      } else {
763        this.mPath.lineTo(vertex.x, vertex.y);
764        this.mDepth += vertex.z;
765      }
766    }
767    close() {
768      this.mDepth /= this.mSize;
769      this.mPath.closePath();
770    }
771    constructor(color) {
772      if (this.mPath === void 0) {
773        this.mPath = null;
774      }
775      if (this.mDepth === void 0) {
776        this.mDepth = 0;
777      }
778      this.mSize = 0;
779      if (this.mPolyColor === void 0) {
780        this.mPolyColor = null;
781      }
782      this.mPolyColor = color;
783      this.mPath = new GeneralPath();
784    }
785    getColor() {
786      return this.mPolyColor;
787    }
788    /**
789     * 
790     * @param {Java2dSnapshot.Polygon} other
791     * @return {number}
792     */
793    compareTo(other) {
794      const otherZ = other.mDepth;
795      if (this.mDepth > otherZ) return 1;
796      if (this.mDepth < otherZ) return -1;
797      return 0;
798    }
799    applyLighting(normal, lightDirs, lightColors, ambient) {
800      let redIntensity = Math.fround(ambient.getRed() / 255);
801      let greenIntensity = Math.fround(ambient.getGreen() / 255);
802      let blueIntensity = Math.fround(ambient.getBlue() / 255);
803      for (let i = 0; i < lightColors.length; i++) {
804        {
805          const intensity = Math.fround(Math.max(normal.dot(lightDirs[i]), 0));
806          redIntensity += Math.fround(intensity * Math.fround(lightColors[i].getRed() / 255));
807          greenIntensity += Math.fround(intensity * Math.fround(lightColors[i].getGreen() / 25
8075));
808          blueIntensity += Math.fround(intensity * Math.fround(lightColors[i].getBlue() / 255));
809        }
810        ;
811      }
812      const red = Math.fround(this.mPolyColor.getRed() * Math.min(redIntensity, 1)) | 0;
813      const green = Math.fround(this.mPolyColor.getGreen() * Math.min(greenIntensity, 1)) | 0;
814      const blue = Math.fround(this.mPolyColor.getBlue() * Math.min(blueIntensity, 1)) | 0;
815      this.mPolyColor = new Color2(red, green, blue);
816    }
817  }
818  Java2dSnapshot2.Polygon = Polygon2;
819  Polygon2["__class"] = "com.vzome.core.exporters2d.Java2dSnapshot.Polygon";
820  Polygon2["__interfaces"] = ["java.lang.Comparable"];
821})(Java2dSnapshot || (Java2dSnapshot = {}));
822
823// src/worker/legacy/from-java/java/awt/geom/Rectangle2D.ts
824var Rectangle2D = class {
825};
826Rectangle2D["__class"] = "java.awt.geom.Rectangle2D";
827((Rectangle2D2) => {
828  class Float extends Rectangle2D2 {
829    constructor(x, y, w, h) {
830      super();
831      if (this.width === void 0) {
832        this.width = 0;
833      }
834      if (this.height === void 0) {
835        this.height = 0;
836      }
837      this.width = w;
838      this.height = h;
839    }
840    getWidth() {
841      return this.width;
842    }
843    getHeight() {
844      return this.height;
845    }
846  }
847  Rectangle2D2.Float = Float;
848  Float["__class"] = "java.awt.geom.Rectangle2D.Float";
849})(Rectangle2D || (Rectangle2D = {}));
850
851// src/worker/legacy/from-java/com/vzome/core/exporters2d/Java2dExporter.ts
852var Java2dExporter = class {
853  render2d(model, viewTransform, eyeTransform, lights, height, width, drawLines, doLighting) {
854    this.viewTransform = viewTransform;
855    this.eyeTrans = eyeTransform;
856    const lightDirs = ((s) => {
857      let a = [];
858      while (s-- > 0) a.push(null);
859      return a;
860    })(lights.size());
861    const lightColors = ((s) => {
862      let a = [];
863      while (s-- > 0) a.push(null);
864      return a;
865    })(lights.size());
866    let ambientLight;
867    let background;
868    const snapshot = new Java2dSnapshot();
869    for (let i = 0; i < lightDirs.length; i++) {
870      {
871        lightDirs[i] = lights.getDirectionalLightVector(i).normalize().negate();
872        lightColors[i] = new Color2(lights.getDirectionalLightColor(i).getRGB());
873      }
874      ;
875    }
876    ambientLight = new Color2(lights.getAmbientColor().getRGB());
877    background = new Color2(lights.getBackgroundColor().getRGB());
878    snapshot.setStrokeWidth(0.5);
879    snapshot.setRect(new Rectangle2D.Float(0, 0, width, height));
880    snapshot.setBackgroundColor(background);
881    const mappedVertices = new java.util.ArrayList(60);
882    for (let index = model.iterator(); index.hasNext(); ) {
883      let rm = index.next();
884      {
885        const shape = rm.getShape();
886        const c = rm.getColor();
887        const color = c == null ? Color2.WHITE_$LI$() : new Color2(c.getRGB());
888        if (drawLines) {
889          const m = rm.getManifestation();
890          if (m != null && (m.constructor != null && m.constructor["__interfaces"] != null && m.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
891            const start = m.getLocation();
892            const end = m.getEnd();
893            const v0 = this.mapCoordinates(model.renderVector(start), height, width);
894            const v1 = this.mapCoordinates(model.renderVector(end), height, width);
895            snapshot.addLineSegment(color, v0, v1);
896          }
897          continue;
898        }
899        const vertices = shape.getVertexList();
900        const partOrientation = rm.getOrientation();
901        const location = rm.getLocation();
902        if (location == null) continue;
903        mappedVertices.clear();
904        for (let i = 0; i < vertices.size(); i++) {
905          {
906            let gv = vertices.get(i);
907            gv = partOrientation.timesColumn(gv);
908            const rv = location.plus(model.renderVector(gv));
909            const v = this.mapCoordinates(rv, height, width);
910            mappedVertices.add(v);
911          }
912          ;
913        }
914        for (let index2 = shape.getFaceSet().iterator(); index2.hasNext(); ) {
915          let face = index2.next();
916          {
917            const arity = face.size();
918            const path = new Java2dSnapshot.Polygon(color);
919            let backFacing = false;
920            let v1 = null;
921            let v2 = null;
922            for (let j = 0; j < arity; j++) {
923              {
924                const index3 = face.get(j);
925                const v = mappedVertices.get(index3);
926                path.addVertex(v);
927                switch (path.size()) {
928                  case 1:
929                    v1 = ((o) => {
930                      if (o.clone != void 0) {
931                        return o.clone();
932                      } else {
933                        let clone = Object.create(o);
934                        for (let p in o) {
935                          if (o.hasOwnProperty(p)) clone[p] = o[p];
936                        }
937                        return clone;
938                      }
939                    })(v);
940                    break;
941                  case 2:
942                    v2 = ((o) => {
943                      if (o.clone != void 0) {
944                        return o.clone();
945                      } else {
946                        let clone = Object.create(o);
947                        for (let p in o) {
948                          if (o.hasOwnProperty(p)) clone[p] = o[p];
949                        }
950                        return clone;
951                      }
952                    })(v);
953                    break;
954                  case 3:
955                    let v3 = ((o) => {
956                      if (o.clone != void 0) {
957                        return o.clone();
958                      } else {
959                        let clone = Object.create(o);
960                        for (let p in o) {
961                          if (o.hasOwnProperty(p)) clone[p] = o[p];
962                        }
963                        return clone;
964                      }
965                    })(v);
966                    v3 = v3.minus(v2);
967                    v2 = v2.minus(v1);
968                    const normal = v2.cross(v3);
969                    backFacing = normal.z > 0;
970                    break;
971                  default:
972                    break;
973                }
974              }
975              ;
976            }
977            path.close();
978            if (!backFacing) {
979              if (doLighting) {
980                const faceNormal = partOrientation.timesColumn(face.getNormal(vertices));
981                const normal = model.renderVector(faceNormal).normalize();
982                let normalV = new RealVector(normal.x, normal.y, normal.z);
983                normalV = this.viewTransform.transform3dVec(normalV);
984                path.applyLighting(normalV, lightDirs, lightColors, ambientLight);
985              }
986              snapshot.addPolygon(path);
987            }
988          }
989        }
990      }
991    }
992    snapshot.depthSort();
993    return snapshot;
994  }
995  /*private*/
996  mapCoordinates(rv, height, width) {
997    const xscale = Math.fround(width / 2);
998    rv = this.viewTransform.transform3dPt(rv);
999    let p4 = [rv.x, rv.y, rv.z, 1];
1000    p4 = this.eyeTrans.transform4d(p4);
1001    let x = Math.fround(p4[0] / p4[3]);
1002    let y = Math.fround(p4[1] / p4[3]);
1003    const z = Math.fround(p4[2] / p4[3]);
1004    x = Math.fround(xscale * Math.fround(x + 1));
1005    y = Math.fround(Math.fround(height - Math.fround(width * y)) / 2);
1006    return new RealVector(x, y, z);
1007  }
1008  constructor() {
1009    if (this.viewTransform === void 0) {
1010      this.viewTransform = null;
1011    }
1012    if (this.eyeTrans === void 0) {
1013      this.eyeTrans = null;
1014    }
1015  }
1016};
1017Java2dExporter["__class"] = "com.vzome.core.exporters2d.Java2dExporter";
1018
1019// src/worker/legacy/from-java/com/vzome/core/exporters2d/SnapshotExporter.ts
1020var SnapshotExporter = class _SnapshotExporter {
1021  includeFile(rsrcName) {
1022    const boilerplate = ResourceLoader.loadStringResource(rsrcName);
1023    this.output.write$java_lang_String(boilerplate);
1024  }
1025  export(snapshot, writer, doOutlines, monochrome, showBackground) {
1026    this.XY_FORMAT.setGroupingUsed(false);
1027    this.XY_FORMAT.setMaximumFractionDigits(2);
1028    this.RGB_FORMAT.setMaximumFractionDigits(3);
1029    this.output = new _SnapshotExporter.CountingPrintWriter(writer);
1030    const rect = snapshot.getRect();
1031    this.height = Math.fround(rect.getHeight());
1032    this.width = Math.fround(rect.getWidth());
1033    const lines = snapshot.getLines();
1034    let strokeWidth = snapshot.getStrokeWidth();
1035    if (!snapshot.isLineDrawing() && !doOutlines) strokeWidth = -1;
1036    this.outputPrologue(snapshot.getRect(), strokeWidth);
1037    const bgColor = snapshot.getBackgroundColor();
1038    if (bgColor != null && showBackground) this.outputBackground(bgColor);
1039    if (!lines.isEmpty()) for (let index = lines.iterator(); index.hasNext(); ) {
1040      let line = index.next();
1041      {
1042        this.outputLine(line, monochrome);
1043      }
1044    }
1045    else for (let index = snapshot.getPolygons().iterator(); index.hasNext(); ) {
1046      let polygon = index.next();
1047      {
1048        this.outputPolygon(polygon, strokeWidth > 0);
1049      }
1050    }
1051    this.outputPostlogue();
1052    this.output.flush();
1053    this.output.close();
1054  }
1055  outputLine(line, monochrome) {
1056    this.renderPath(line.getPath());
1057    const rgb = line.getColor().getRGBColorComponents(null);
1058    if (!monochrome) this.setRGBStrokeColor(rgb[0], rgb[1], rgb[2]);
1059    this.strokePath();
1060  }
1061  outputPolygon(polygon, doOutline) {
1062    this.renderPath(polygon.getPath());
1063    const rgb = polygon.getColor().getRGBColorComponents(null);
1064    this.setRGBFillColor(rgb[0], rgb[1], rgb[2]);
1065    this.fillPath();
1066    if (doOutline) {
1067      this.renderPath(polygon.getPath());
1068      this.setBlackStrokeColor();
1069      this.strokePath();
1070    }
1071  }
1072  renderPath(path) {
1073    this.beginPath();
1074    const segments = path.getPathIterator(null);
1075    while (!segments.isDone()) {
1076      {
1077        const coords = [0, 0, 0, 0, 0, 0];
1078        const step = segments.currentSegment(coords);
1079        switch (step) {
1080          case PathIterator.SEG_MOVETO:
1081            this.moveToPoint(coords[0], Math.fround(this.height - coords[1]));
1082            break;
1083          case PathIterator.SEG_LINETO:
1084            this.addLineToPoint(coords[0], Math.fround(this.height - coords[1]));
1085            break;
1086          case PathIterator.SEG_CLOSE:
1087            this.closePath();
1088            break;
1089          default:
1090            break;
1091        }
1092        segments.next();
1093      }
1094    }
1095    ;
1096  }
1097  setBlackStrokeColor() {
1098  }
1099  constructor() {
1100    if (this.output === void 0) {
1101      this.output = null;
1102    }
1103    if (this.height === void 0) {
1104      this.height = 0;
1105    }
1106    if (this.width === void 0) {
1107      this.width = 0;
1108    }
1109    this.RGB_FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1110    this.XY_FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1111  }
1112};
1113SnapshotExporter["__class"] = "com.vzome.core.exporters2d.SnapshotExporter";
1114((SnapshotExporter2) => {
1115  class CountingPrintWriter extends PrintWriter {
1116    constructor(writer) {
1117      super(writer);
1118      this.mTotal = 0;
1119    }
1120    write$char_A$int$int(buf, offset, len) {
1121      super.write$char_A$int$int(buf, offset, len);
1122      this.mTotal += len;
1123    }
1124    /**
1125     * 
1126     * @param {char[]} buf
1127     * @param {number} offset
1128     * @param {number} len
1129     */
1130    write(buf, offset, len) {
1131      if ((buf != null && buf instanceof Array && (buf.length == 0 || buf[0] == null || typeof buf[0] === "string") || buf === null) && (typeof offset === "number" || offset === null) && (typeof len === "
1131number" || len === null)) {
1132        return this.write$char_A$int$int(buf, offset, len);
1133      } else if ((typeof buf === "string" || buf === null) && offset === void 0 && len === void 0) {
1134        return this.write$java_lang_String(buf);
1135      } else throw new Error("invalid overload");
1136    }
1137    write$java_lang_String(str) {
1138      super.write$java_lang_String(str);
1139      this.mTotal += str.length;
1140    }
1141    getBytesTotal() {
1142      return this.mTotal;
1143    }
1144  }
1145  SnapshotExporter2.CountingPrintWriter = CountingPrintWriter;
1146  CountingPrintWriter["__class"] = "com.vzome.core.exporters2d.SnapshotExporter.CountingPrintWriter";
1147  CountingPrintWriter["__interfaces"] = ["java.lang.Appendable", "java.io.Closeable", "java.lang.AutoCloseable", "java.io.Flushable"];
1148})(SnapshotExporter || (SnapshotExporter = {}));
1149
1150// src/worker/legacy/from-java/com/vzome/core/exporters2d/PDFExporter.ts
1151var PDFExporter = class extends SnapshotExporter {
1152  /**
1153   * 
1154   * @param {number} r
1155   * @param {number} g
1156   * @param {number} b
1157   */
1158  setRGBStrokeColor(r, g, b) {
1159    this.output.print(" " + this.RGB_FORMAT.format(r) + " " + this.RGB_FORMAT.format(g) + " " + this.RGB_FORMAT.format(b) + " RG");
1160  }
1161  /**
1162   * 
1163   * @param {number} r
1164   * @param {number} g
1165   * @param {number} b
1166   */
1167  setRGBFillColor(r, g, b) {
1168    this.output.print(" " + this.RGB_FORMAT.format(r) + " " + this.RGB_FORMAT.format(g) + " " + this.RGB_FORMAT.format(b) + " rg");
1169  }
1170  /**
1171   * 
1172   */
1173  beginPath() {
1174  }
1175  /**
1176   * 
1177   * @param {number} x
1178   * @param {number} y
1179   */
1180  moveToPoint(x, y) {
1181    this.output.print(" " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(y) + " m");
1182  }
1183  /**
1184   * 
1185   * @param {number} x
1186   * @param {number} y
1187   */
1188  addLineToPoint(x, y) {
1189    this.output.print(" " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(y) + " l");
1190  }
1191  /**
1192   * 
1193   */
1194  closePath() {
1195    this.output.print(" h");
1196  }
1197  /**
1198   * 
1199   */
1200  fillPath() {
1201    this.output.print(" f");
1202  }
1203  /**
1204   * 
1205   */
1206  strokePath() {
1207    this.output.print(" S\n");
1208  }
1209  /**
1210   * 
1211   * @param {Rectangle2D} rect
1212   * @param {number} strokeWidth
1213   */
1214  outputPrologue(rect, strokeWidth) {
1215    this.includeFile("com/vzome/core/exporters/prologue.pdf");
1216    this.streamStart = this.output.getBytesTotal();
1217    if (strokeWidth > 0) this.output.print(strokeWidth + " w 1 j\n");
1218    this.RGB_FORMAT.setMaximumFractionDigits(3);
1219    this.XY_FORMAT.setMaximumFractionDigits(2);
1220  }
1221  /**
1222   * 
1223   * @param {Color} bgColor
1224   */
1225  outputBackground(bgColor) {
1226    const rgb = bgColor.getRGBColorComponents(null);
1227    this.setRGBFillColor(rgb[0], rgb[1], rgb[2]);
1228    this.beginPath();
1229    this.output.print(" 0 0 " + this.width + " " + this.height + " re\n");
1230    this.closePath();
1231    this.fillPath();
1232  }
1233  /**
1234   * 
1235   */
1236  outputPostlogue() {
1237    const streamLen = this.output.getBytesTotal() - this.streamStart;
1238    this.output.print("endstream\n");
1239    this.output.print("endobj\n");
1240    const sizeOffset = this.output.getBytesTotal();
1241    this.output.print("5 0 obj " + streamLen + " endobj\n");
1242    const boxOffset = this.output.getBytesTotal();
1243    this.output.print("6 0 obj [0 0 " + this.width + " " + this.height + "] endobj\n");
1244    const startXref = this.output.getBytesTotal();
1245    this.includeFile("com/vzome/core/exporters/postlogue.pdf");
1246    let num = (
1247      /* toString */
1248      "" + sizeOffset
1249    );
1250    for (let i = 0; i + num.length < 10; i++) {
1251      this.output.print("0");
1252    }
1253    this.output.print(num + " 00000 n \n");
1254    num = /* toString */
1255    "" + boxOffset;
1256    for (let i = 0; i + num.length < 10; i++) {
1257      this.output.print("0");
1258    }
1259    this.output.print(num + " 00000 n \n");
1260    this.output.print("trailer\n");
1261    this.output.print("<< /Size 7 /Root 1 0 R >>\n");
1262    this.output.print("startxref\n");
1263    this.output.print(startXref + "\n");
1264    this.output.print("%%EOF\n");
1265  }
1266  constructor() {
1267    super();
1268    if (this.streamStart === void 0) {
1269      this.streamStart = 0;
1270    }
1271  }
1272};
1273PDFExporter["__class"] = "com.vzome.core.exporters2d.PDFExporter";
1274
1275// src/worker/legacy/from-java/com/vzome/core/exporters2d/PostScriptExporter.ts
1276var PostScriptExporter = class extends SnapshotExporter {
1277  /**
1278   * 
1279   */
1280  setBlackStrokeColor() {
1281    this.output.print(" 0 setgray");
1282  }
1283  /**
1284   * 
1285   * @param {number} r
1286   * @param {number} g
1287   * @param {number} b
1288   */
1289  setRGBStrokeColor(r, g, b) {
1290    this.output.print(" " + this.RGB_FORMAT.format(r) + " " + this.RGB_FORMAT.format(g) + " " + this.RGB_FORMAT.format(b) + " setrgbcolor");
1291  }
1292  /**
1293   * 
1294   * @param {number} r
1295   * @param {number} g
1296   * @param {number} b
1297   */
1298  setRGBFillColor(r, g, b) {
1299    this.output.print(" " + this.RGB_FORMAT.format(r) + " " + this.RGB_FORMAT.format(g) + " " + this.RGB_FORMAT.format(b) + " setrgbcolor");
1300  }
1301  /**
1302   * 
1303   */
1304  beginPath() {
1305    this.output.print(" newpath");
1306  }
1307  /**
1308   * 
1309   * @param {number} x
1310   * @param {number} y
1311   */
1312  moveToPoint(x, y) {
1313    this.output.print(" " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(y) + " moveto");
1314  }
1315  /**
1316   * 
1317   * @param {number} x
1318   * @param {number} y
1319   */
1320  addLineToPoint(x, y) {
1321    this.output.print(" " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(y) + " lineto");
1322  }
1323  /**
1324   * 
1325   */
1326  closePath() {
1327    this.output.print(" closepath");
1328  }
1329  /**
1330   * 
1331   */
1332  fillPath() {
1333    this.output.print(" fill");
1334  }
1335  /**
1336   * 
1337   */
1338  strokePath() {
1339    this.output.print(" stroke\n");
1340  }
1341  /**
1342   * 
1343   * @param {Rectangle2D} rect
1344   * @param {number} strokeWidth
1345   */
1346  outputPrologue(rect, strokeWidth) {
1347    if (strokeWidth > 0) this.output.print(strokeWidth + " setlinewidth 1 setlinejoin\n");
1348    this.RGB_FORMAT.setMaximumFractionDigits(3);
1349    this.XY_FORMAT.setMaximumFractionDigits(3);
1350  }
1351  /**
1352   * 
1353   * @param {Color} bgColor
1354   */
1355  outputBackground(bgColor) {
1356    const rgb = bgColor.getRGBColorComponents(null);
1357    this.setRGBFillColor(rgb[0], rgb[1], rgb[2]);
1358    this.beginPath();
1359    this.moveToPoint(0, 0);
1360    this.addLineToPoint(0, this.height);
1361    this.addLineToPoint(this.width, this.height);
1362    this.addLineToPoint(this.width, 0);
1363    this.addLineToPoint(0, 0);
1364    this.closePath();
1365    this.fillPath();
1366  }
1367  /**
1368   * 
1369   */
1370  outputPostlogue() {
1371  }
1372};
1373PostScriptExporter["__class"] = "com.vzome.core.exporters2d.PostScriptExporter";
1374
1375// src/worker/legacy/from-java/com/vzome/core/exporters2d/SVGExporter.ts
1376var SVGExporter = class extends SnapshotExporter {
1377  /**
1378   * 
1379   * @param {Color} bgColor
1380   */
1381  outputBackground(bgColor) {
1382    this.output.print("<rect fill='#");
1383    const color = bgColor.getRGB() & 16777215;
1384    this.output.print(javaemul.internal.IntegerHelper.toHexString(color));
1385    this.output.println$java_lang_Object("' x='1' y='1' width='" + this.width + "' height='" + this.height + "'/>");
1386  }
1387  /**
1388   * 
1389   * @param {Rectangle2D} rect
1390   * @param {number} strokeWidth
1391   */
1392  outputPrologue(rect, strokeWidth) {
1393    this.output.println$java_lang_Object("<?xml version='1.0'?>");
1394    this.output.println$java_lang_Object("<svg version='1.1' xmlns='http://www.w3.org/2000/svg'");
1395    if (strokeWidth > 0) this.output.println$java_lang_Object("   stroke='black' stroke-linejoin='round' stroke-width='" + strokeWidth + "' ");
1396    this.output.println$java_lang_Object("   viewBox='0 0 " + this.width + " " + this.height + "' >");
1397    this.XY_FORMAT.setMaximumFractionDigits(2);
1398  }
1399  /**
1400   * 
1401   * @param {Java2dSnapshot.LineSegment} line
1402   * @param {boolean} monochrome
1403   */
1404  outputLine(line, monochrome) {
1405    this.output.print("<path stroke='#");
1406    let color = line.getColor().getRGB() & 16777215;
1407    if (monochrome) color = Color2.BLACK_$LI$().getRGB() & 16777215;
1408    const hex = javaemul.internal.IntegerHelper.toHexString(color);
1409    for (let i = 0; i < 6 - hex.length; i++) {
1410      this.output.print("0");
1411    }
1412    this.output.print(hex);
1413    this.output.print("' d='");
1414    this.renderPath(line.getPath());
1415    this.output.println$java_lang_Object("'/>");
1416  }
1417  /**
1418   * 
1419   * @param {Java2dSnapshot.Polygon} polygon
1420   * @param {boolean} doOutline
1421   */
1422  outputPolygon(polygon, doOutline) {
1423    this.output.print("<path fill='#");
1424    const color = polygon.getColor().getRGB() & 16777215;
1425    const hex = javaemul.internal.IntegerHelper.toHexString(color);
1426    for (let i = 0; i < 6 - hex.length; i++) {
1427      this.output.print("0");
1428    }
1429    this.output.print(hex);
1430    this.output.print("' d='");
1431    this.renderPath(polygon.getPath());
1432    this.output.println$java_lang_Object("'/>");
1433  }
1434  /**
1435   * 
1436   */
1437  outputPostlogue() {
1438    this.output.println$();
1439    this.output.println$java_lang_Object("</svg>");
1440  }
1441  /**
1442   * 
1443   * @param {number} r
1444   * @param {number} g
1445   * @param {number} b
1446   */
1447  setRGBStrokeColor(r, g, b) {
1448  }
1449  /**
1450   * 
1451   * @param {number} r
1452   * @param {number} g
1453   * @param {number} b
1454   */
1455  setRGBFillColor(r, g, b) {
1456  }
1457  /**
1458   * 
1459   */
1460  beginPath() {
1461  }
1462  /**
1463   * 
1464   * @param {number} x
1465   * @param {number} y
1466   */
1467  moveToPoint(x, y) {
1468    this.output.print("M " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(Math.fround(this.height - y)) + " ");
1469  }
1470  /**
1471   * 
1472   * @param {number} x
1473   * @param {number} y
1474   */
1475  addLineToPoint(x, y) {
1476    this.output.print("L " + this.XY_FORMAT.format(x) + " " + this.XY_FORMAT.format(Math.fround(this.height - y)) + " ");
1477  }
1478  /**
1479   * 
1480   */
1481  closePath() {
1482    this.output.print(" z");
1483  }
1484  /**
1485   * 
1486   */
1487  fillPath() {
1488  }
1489  /**
1490   * 
1491   */
1492  strokePath() {
1493  }
1494};
1495SVGExporter["__class"] = "com.vzome.core.exporters2d.SVGExporter";
1496
1497// src/worker/legacy/from-java/com/vzome/core/exporters/GeometryExporter.ts
1498var GeometryExporter = class {
1499  constructor() {
1500    if (this.output === void 0) {
1501      this.output = null;
1502    }
1503    if (this.mColors === void 0) {
1504      this.mColors = null;
1505    }
1506    if (this.mModel === void 0) {
1507      this.mModel = null;
1508    }
1509  }
1510  getContentType() {
1511    return "text/plain";
1512  }
1513  /**
1514   * Subclasses can override this if they don't rely on Manifestations and therefore can operate on article pages
1515   * See the comments below DocumentModel.getNaiveExporter() for a more complete explanation.
1516   * @return {boolean}
1517   */
1518  needsManifestations() {
1519    return true;
1520  }
1521  getBoilerplate(resourcePath) {
1522    return ResourceLoader.loadStringResource(resourcePath);
1523  }
1524  exportGeometry(model, file, writer, height, width) {
1525    this.mModel = model;
1526    this.doExport(file, writer, height, width);
1527    this.mModel = null;
1528  }
1529};
1530GeometryExporter["__class"] = "com.vzome.core.exporters.GeometryExporter";
1531
1532// src/worker/legacy/from-java/java/text/DecimalFormat.ts
1533var DecimalFormat = class extends NumberFormat {
1534  applyPattern(pattern) {
1535  }
1536};
1537DecimalFormat["__class"] = "java.text.DecimalFormat";
1538
1539// src/worker/legacy/from-java/com/vzome/core/exporters/StlExporter.ts
1540var StlExporter = class _StlExporter extends GeometryExporter {
1541  static FORMAT_$LI$() {
1542    if (_StlExporter.FORMAT == null) {
1543      _StlExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1544    }
1545    return _StlExporter.FORMAT;
1546  }
1547  /**
1548   * 
1549   * @param {File} directory
1550   * @param {java.io.Writer} writer
1551   * @param {number} height
1552   * @param {number} width
1553   */
1554  doExport(directory, writer, height, width) {
1555    if (_StlExporter.FORMAT_$LI$() != null && _StlExporter.FORMAT_$LI$() instanceof DecimalFormat) {
1556      _StlExporter.FORMAT_$LI$().applyPattern("0.000000E00");
1557    }
1558    const mmScaling = this.mModel.getCmScaling() * 10;
1559    this.output = new PrintWriter(writer);
1560    this.output.println$java_lang_Object("solid vcg");
1561    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1562      let rm = index.next();
1563      {
1564        const man = rm.getManifestation();
1565        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
1566          const panel = man;
1567          const norm = this.mModel.renderVector(panel["getNormal$"]()).normalize();
1568          let v0 = null;
1569          let v1 = null;
1570          for (let index2 = panel.iterator(); index2.hasNext(); ) {
1571            let vert = index2.next();
1572            {
1573              let vertex = this.mModel.renderVector(vert);
1574              vertex = vertex.scale(mmScaling);
1575              if (v0 == null) v0 = vertex;
1576              else if (v1 == null) v1 = vertex;
1577              else {
1578                this.output.print("  facet normal ");
1579                this.output.println$java_lang_Object(_StlExporter.FORMAT_$LI$().format(norm.x) + " " + _StlExporter.FORMAT_$LI$().format(norm.y) + " " + _StlExporter.FORMAT_$LI$().format(norm.z));
1580                this.output.println$java_lang_Object("    outer loop");
1581                this.output.println$java_lang_Object("      vertex " + _StlExporter.FORMAT_$LI$().format(v0.x) + " " + _StlExporter.FORMAT_$LI$().format(v0.y) + " " + _StlExporter.FORMAT_$LI$().format(v0.z));
1582                this.output.println$java_lang_Object("      vertex " + _StlExporter.FORMAT_$LI$().format(v1.x) + " " + _StlExporter.FORMAT_$LI$().format(v1.y) + " " + _StlExporter.FORMAT_$LI$().format(v1.z));
1583                this.output.println$java_lang_Object("      vertex " + _StlExporter.FORMAT_$LI$().format(vertex.x) + " " + _StlExporter.FORMAT_$LI$().format(vertex.y) + " " + _StlExporter.FORMAT_$LI$().format(vertex.z));
1584                this.output.println$java_lang_Object("    endloop");
1585                this.output.println$java_lang_Object("  endfacet");
1586                v1 = vertex;
1587              }
1588            }
1589          }
1590        }
1591      }
1592    }
1593    this.output.println$java_lang_Object("endsolid vcg");
1594    this.output.flush();
1595  }
1596  /**
1597   * 
1598   * @return {string}
1599   */
1600  getFileExtension() {
1601    return "stl";
1602  }
1603};
1604StlExporter["__class"] = "com.vzome.core.exporters.StlExporter";
1605
1606// src/worker/legacy/from-java/com/vzome/core/exporters/STEPExporter.ts
1607var STEPExporter = class _STEPExporter extends GeometryExporter {
1608  static {
1609    this.PREAMBLE_FILE = "com/vzome/core/exporters/step/preamble.step";
1610  }
1611  static {
1612    this.POSTLUDE = "ENDSEC;\nEND-ISO-10303-21;";
1613  }
1614  static {
1615    this.START_INDEX = 300;
1616  }
1617  /**
1618   * 
1619   * @param {File} file
1620   * @param {java.io.Writer} writer
1621   * @param {number} height
1622   * @param {number} width
1623   */
1624  doExport(file, writer, height, width) {
1625    this.output = new PrintWriter(writer);
1626    const preamble = ResourceLoader.loadStringResource(_STEPExporter.PREAMBLE_FILE);
1627    this.output.println$java_lang_Object(preamble);
1628    this.output.println$();
1629    const FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1630    FORMAT.setMaximumFractionDigits(19);
1631    let vertices = new java.util.TreeSet();
1632    Manifestations.sortVertices(this.mModel.getManifestations(), vertices);
1633    const sortedVertexList = new java.util.ArrayList(vertices);
1634    vertices = null;
1635    const inchScaling = this.mModel.getCmScaling() / 2.54;
1636    let index = _STEPExporter.START_INDEX - 1;
1637    const realVectors = new java.util.ArrayList();
1638    for (let index1 = sortedVertexList.iterator(); index1.hasNext(); ) {
1639      let gv = index1.next();
1640      {
1641        const v = this.mModel.renderVector(gv).scale(inchScaling);
1642        realVectors.add(v);
1643        const cpIndex = ++index;
1644        this.output.println$java_lang_Object("#" + cpIndex + " = CARTESIAN_POINT ( 'NONE',  ( " + v.toString$java_text_NumberFormat(FORMAT) + " ) ) ;");
1645        this.output.println$java_lang_Object("#" + ++index + " = VERTEX_POINT ( 'NONE', #" + cpIndex + " ) ;");
1646        this.output.println$();
1647      }
1648    }
1649    this.output.println$();
1650    const faceIndices = new java.util.ArrayList();
1651    for (let index1 = this.mModel.getManifestations().iterator(); index1.hasNext(); ) {
1652      let man = index1.next();
1653      {
1654        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
1655          const panel = man;
1656          const arity = panel.getVertexCount();
1657          const vIndices = ((s) => {
1658            let a = [];
1659            while (s-- > 0) a.push(0);
1660            return a;
1661          })(arity);
1662          let k = 0;
1663          for (let index12 = panel.iterator(); index12.hasNext(); ) {
1664            let av = index12.next();
1665            {
1666              const vIndex = sortedVertexList.indexOf(av);
1667              vIndices[k++] = vIndex;
1668            }
1669          }
1670          const edgeIndices = new java.util.ArrayList();
1671          let point1 = 0;
1672          let dir1 = null;
1673          let dir2 = null;
1674          for (let j = 0; j < arity; j++) {
1675            {
1676              let vindex = vIndices[j];
1677              const rv1index = vindex;
1678              let rv1 = realVectors.get(rv1index);
1679              point1 = rv1index * 2 + _STEPExporter.START_INDEX;
1680              const vertex1 = point1 + 1;
1681              vindex = vIndices[(j + 1) % arity];
1682              const rv2index = vindex;
1683              let rv2 = realVectors.get(rv2index);
1684              const vertex2 = rv2index * 2 + _STEPExporter.START_INDEX + 1;
1685              const direction12 = ++index;
1686              rv1 = rv2.minus(rv1);
1687              rv2 = rv1.normalize();
1688              if (dir2 == null) {
1689                if (dir1 == null) dir1 = rv2;
1690                else {
1691                  dir2 = dir1.cross(rv2).normalize();
1692                  dir1 = dir2.cross(dir1);
1693                }
1694              }
1695              this.output.println$java_lang_Object("#" + direction12 + " = DIRECTION ( 'NONE',  ( " + rv2.toString$java_text_NumberFormat(FORMAT) + " ) ) ;");
1696              const vector = ++index;
1697              this.output.println$java_lang_Object("#" + vector + " = VECTOR ( 'NONE', #" + direction12 + ", 39.37 ) ;");
1698              const line = ++index;
1699              this.output.println$java_lang_Object("#" + line + " = LINE ( 'NONE', #" + point1 + ", #" + vector + " ) ;");
1700              const edgeCurve = ++index;
1701              this.output.println$java_lang_Object("#" + edgeCurve + " = EDGE_CURVE ( 'NONE', #" + vertex1 + ", #" + vertex2 + ", #" + line + ", .T. ) ;");
1702              const orientedEdge = ++index;
1703              edgeIndices.add(orientedEdge);
1704              this.output.println$java_lang_Object("#" + orientedEdge + " = ORIENTED_EDGE ( 'NONE', *, *, #" + edgeCurve + ", ." + (j === 0 ? "T" : "T") + ". ) ;");
1705            }
1706            ;
1707          }
1708          const edgeLoop = ++index;
1709          this.output.print("#" + edgeLoop + " = EDGE_LOOP ( 'NONE', ( ");
1710          let delim2 = "";
1711          for (let index12 = edgeIndices.iterator(); index12.hasNext(); ) {
1712            let i = index12.next();
1713            {
1714              this.output.print(delim2 + "#" + i);
1715              delim2 = ", ";
1716            }
1717          }
1718          this.output.println$java_lang_Object(" ) ) ;");
1719          const direction1 = ++index;
1720          this.output.println$java_lang_Object("#" + direction1 + " = DIRECTION ( 'NONE',  ( " + dir2.toString$java_text_NumberFormat(FORMAT) + " ) ) ;");
1721          const direction2 = ++index;
1722          this.output.println$java_lang_Object("#" + direction2 + " = DIRECTION ( 'NONE',  ( " + dir1.toString$java_text_NumberFormat(FORMAT) + " ) ) ;");
1723          const axisPlacement3d = ++index;
1724          this.output.println$java_lang_Object("#" + axisPlacement3d + " = AXIS2_PLACEMENT_3D ( 'NONE', #" + point1 + ", #" + direction1 + ", #" + direction2 + " ) ;");
1725          const plane = ++index;
1726          this.output.println$java_lang_Object("#" + plane + " = PLANE ( 'NONE', #" + axisPlacement3d + " ) ;");
1727          const faceOuterBound = ++index;
1728          this.output.println$java_lang_Object("#" + faceOuterBound + " = FACE_OUTER_BOUND ( 'NONE', #" + edgeLoop + ", .T. ) ;");
1729          const advancedFace = ++index;
1730          this.output.println$java_lang_Object("#" + advancedFace + " = ADVANCED_FACE ( 'NONE', ( #" + faceOuterBound + " ), #" + plane + ", .T. ) ;");
1731          this.output.println$();
1732          faceIndices.add(advancedFace);
1733        }
1734      }
1735    }
1736    this.output.print("#299 = CLOSED_SHELL ( 'NONE', ( ");
1737    let delim = "";
1738    for (let index1 = faceIndices.iterator(); index1.hasNext(); ) {
1739      let i = index1.next();
1740      {
1741        this.output.print(delim + "#" + i);
1742        delim = ", ";
1743      }
1744    }
1745    this.output.println$java_lang_Object(" ) ) ;");
1746    this.output.println$java_lang_Object(_STEPExporter.POSTLUDE);
1747    this.output.flush();
1748    this.output.close();
1749  }
1750  /**
1751   * 
1752   * @return {string}
1753   */
1754  getFileExtension() {
1755    return "step";
1756  }
1757};
1758STEPExporter["__class"] = "com.vzome.core.exporters.STEPExporter";
1759
1760// src/worker/legacy/from-java/com/vzome/core/exporters/OpenScadMeshExporter.ts
1761var OpenScadMeshExporter = class _OpenScadMeshExporter extends GeometryExporter {
1762  static {
1763    this.__static_initialized = false;
1764  }
1765  static __static_initialize() {
1766    if (!_OpenScadMeshExporter.__static_initialized) {
1767      _OpenScadMeshExporter.__static_initialized = true;
1768      _OpenScadMeshExporter.__static_initializer_0();
1769    }
1770  }
1771  static FORMAT_$LI$() {
1772    _OpenScadMeshExporter.__static_initialize();
1773    if (_OpenScadMeshExporter.FORMAT == null) {
1774      _OpenScadMeshExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1775    }
1776    return _OpenScadMeshExporter.FORMAT;
1777  }
1778  static __static_initializer_0() {
1779    _OpenScadMeshExporter.FORMAT_$LI$().setMinimumFractionDigits(6);
1780    _OpenScadMeshExporter.FORMAT_$LI$().setMaximumFractionDigits(6);
1781  }
1782  /**
1783   * 
1784   * @param {File} directory
1785   * @param {java.io.Writer} writer
1786   * @param {number} height
1787   * @param {number} width
1788   */
1789  doExport(directory, writer, height, width) {
1790    let vertices = new java.util.TreeSet();
1791    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1792      let rm = index.next();
1793      {
1794        const man = rm.getManifestation();
1795        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1796          const strut = man;
1797          let loc = strut.getLocation();
1798          vertices.add(loc);
1799          loc = strut.getEnd();
1800          vertices.add(loc);
1801        }
1802      }
1803    }
1804    const sortedVertexList = new java.util.ArrayList(vertices);
1805    vertices = null;
1806    this.output = new PrintWriter(writer);
1807    const prelude = this.getBoilerplate("com/vzome/core/exporters/mesh-prelude.scad");
1808    this.output.print(prelude);
1809    this.output.println$java_lang_Object("vertices = [");
1810    for (let index = sortedVertexList.iterator(); index.hasNext(); ) {
1811      let vector = index.next();
1812      {
1813        const dv = this.mModel.renderVectorDouble(vector);
1814        this.output.print("[ ");
1815        this.output.print(_OpenScadMeshExporter.FORMAT_$LI$().format(dv[0]) + ", ");
1816        this.output.print(_OpenScadMeshExporter.FORMAT_$LI$().format(dv[1]) + ", ");
1817        this.output.println$java_lang_Object(_OpenScadMeshExporter.FORMAT_$LI$().format(dv[2]) + " ],");
1818      }
1819    }
1820    this.output.println$java_lang_Object("];");
1821    this.output.println$();
1822    this.output.println$java_lang_Object("edges = [");
1823    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1824      let rm = index.next();
1825      {
1826        const man = rm.getManifestation();
1827        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1828          const strut = man;
1829          this.output.println$java_lang_Object("[ " + sortedVertexList.indexOf(strut.getLocation()) + ", " + sortedVertexList.indexOf(strut.getEnd()) + " ],");
1830        }
1831      }
1832    }
1833    this.output.println$java_lang_Object("];");
1834    const postlude = this.getBoilerplate("com/vzome/core/exporters/mesh-postlude.scad");
1835    this.output.print(postlude);
1836    this.output.flush();
1837  }
1838  /**
1839   * 
1840   * @return {string}
1841   */
1842  getFileExtension() {
1843    return "scad";
1844  }
1845};
1846OpenScadMeshExporter["__class"] = "com.vzome.core.exporters.OpenScadMeshExporter";
1847OpenScadMeshExporter.__static_initialize();
1848
1849// src/worker/legacy/from-java/com/vzome/core/exporters/PythonBuild123dExporter.ts
1850var PythonBuild123dExporter = class _PythonBuild123dExporter extends GeometryExporter {
1851  static {
1852    this.__static_initialized = false;
1853  }
1854  static __static_initialize() {
1855    if (!_PythonBuild123dExporter.__static_initialized) {
1856      _PythonBuild123dExporter.__static_initialized = true;
1857      _PythonBuild123dExporter.__static_initializer_0();
1858    }
1859  }
1860  static FORMAT_$LI$() {
1861    _PythonBuild123dExporter.__static_initialize();
1862    if (_PythonBuild123dExporter.FORMAT == null) {
1863      _PythonBuild123dExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
1864    }
1865    return _PythonBuild123dExporter.FORMAT;
1866  }
1867  static __static_initializer_0() {
1868    _PythonBuild123dExporter.FORMAT_$LI$().setMinimumFractionDigits(6);
1869    _PythonBuild123dExporter.FORMAT_$LI$().setMaximumFractionDigits(6);
1870  }
1871  /**
1872   * 
1873   * @param {File} directory
1874   * @param {java.io.Writer} writer
1875   * @param {number} height
1876   * @param {number} width
1877   */
1878  doExport(directory, writer, height, width) {
1879    let vertices = new java.util.TreeSet();
1880    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1881      let rm = index.next();
1882      {
1883        const man = rm.getManifestation();
1884        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1885          const strut = man;
1886          let loc = strut.getLocation();
1887          vertices.add(loc);
1888          loc = strut.getEnd();
1889          vertices.add(loc);
1890        }
1891      }
1892    }
1893    const sortedVertexList = new java.util.ArrayList(vertices);
1894    vertices = null;
1895    this.output = new PrintWriter(writer);
1896    const prelude = this.getBoilerplate("com/vzome/core/exporters/mesh-prelude.py");
1897    this.output.print(prelude);
1898    this.output.println$java_lang_Object("vertices = [");
1899    for (let index = sortedVertexList.iterator(); index.hasNext(); ) {
1900      let vector = index.next();
1901      {
1902        const dv = this.mModel.renderVectorDouble(vector);
1903        this.output.print("( ");
1904        this.output.print(_PythonBuild123dExporter.FORMAT_$LI$().format(dv[0]) + ", ");
1905        this.output.print(_PythonBuild123dExporter.FORMAT_$LI$().format(dv[1]) + ", ");
1906        this.output.println$java_lang_Object(_PythonBuild123dExporter.FORMAT_$LI$().format(dv[2]) + " ),");
1907      }
1908    }
1909    this.output.println$java_lang_Object("]");
1910    this.output.println$();
1911    this.output.println$java_lang_Object("edges = [");
1912    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1913      let rm = index.next();
1914      {
1915        const man = rm.getManifestation();
1916        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1917          const strut = man;
1918          this.output.println$java_lang_Object("[ " + sortedVertexList.indexOf(strut.getLocation()) + ", " + sortedVertexList.indexOf(strut.getEnd()) + " ],");
1919        }
1920      }
1921    }
1922    this.output.println$java_lang_Object("]");
1923    const postlude = this.getBoilerplate("com/vzome/core/exporters/mesh-postlude.py");
1924    this.output.print(postlude);
1925    this.output.flush();
1926  }
1927  /**
1928   * 
1929   * @return {string}
1930   */
1931  getFileExtension() {
1932    return "py";
1933  }
1934};
1935PythonBuild123dExporter["__class"] = "com.vzome.core.exporters.PythonBuild123dExporter";
1936PythonBuild123dExporter.__static_initialize();
1937
1938// src/worker/legacy/from-java/com/vzome/core/exporters/DxfExporter.ts
1939var DxfExporter = class extends GeometryExporter {
1940  /**
1941   * 
1942   * @param {File} directory
1943   * @param {java.io.Writer} writer
1944   * @param {number} height
1945   * @param {number} width
1946   */
1947  doExport(directory, writer, height, width) {
1948    this.output = new PrintWriter(writer);
1949    this.output.println$java_lang_Object("0");
1950    this.output.println$java_lang_Object("SECTION");
1951    this.output.println$java_lang_Object("2");
1952    this.output.println$java_lang_Object("ENTITIES");
1953    const format = NumberFormat.getNumberInstance(java.util.Locale.US);
1954    format.setMaximumFractionDigits(6);
1955    const inchScaling = this.mModel.getCmScaling() / 2.54;
1956    for (let index = this.mModel.iterator(); index.hasNext(); ) {
1957      let rm = index.next();
1958      {
1959        const man = rm.getManifestation();
1960        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1961          this.output.println$java_lang_Object("0");
1962          this.output.println$java_lang_Object("LINE");
1963          this.output.println$java_lang_Object("8");
1964          this.output.println$java_lang_Object("vZome");
1965          const start = man.getLocation();
1966          const end = man.getEnd();
1967          let rv = this.mModel.renderVector(start);
1968          rv = rv.scale(inchScaling);
1969          this.output.println$java_lang_Object("10");
1970          this.output.println$java_lang_Object(format.format(rv.x));
1971          this.output.println$java_lang_Object("20");
1972          this.output.println$java_lang_Object(format.format(rv.y));
1973          this.output.println$java_lang_Object("30");
1974          this.output.println$java_lang_Object(format.format(rv.z));
1975          rv = this.mModel.renderVector(end);
1976          rv = rv.scale(inchScaling);
1977          this.output.println$java_lang_Object("11");
1978          this.output.println$java_lang_Object(format.format(rv.x));
1979          this.output.println$java_lang_Object("21");
1980          this.output.println$java_lang_Object(format.format(rv.y));
1981          this.output.println$java_lang_Object("31");
1982          this.output.println$java_lang_Object(format.format(rv.z));
1983        }
1984      }
1985    }
1986    this.output.println$java_lang_Object("0");
1987    this.output.println$java_lang_Object("ENDSEC");
1988    this.output.println$java_lang_Object("0");
1989    this.output.println$java_lang_Object("EOF");
1990    this.output.flush();
1991  }
1992  /**
1993   * 
1994   * @return {string}
1995   */
1996  getFileExtension() {
1997    return "dxf";
1998  }
1999};
2000DxfExporter["__class"] = "com.vzome.core.exporters.DxfExporter";
2001
2002// src/worker/legacy/from-java/com/vzome/core/exporters/OffExporter.ts
2003var OffExporter = class _OffExporter extends GeometryExporter {
2004  static {
2005    this.__static_initialized = false;
2006  }
2007  static __static_initialize() {
2008    if (!_OffExporter.__static_initialized) {
2009      _OffExporter.__static_initialized = true;
2010      _OffExporter.__static_initializer_0();
2011    }
2012  }
2013  static FORMAT_$LI$() {
2014    _OffExporter.__static_initialize();
2015    if (_OffExporter.FORMAT == null) {
2016      _OffExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
2017    }
2018    return _OffExporter.FORMAT;
2019  }
2020  static __static_initializer_0() {
2021    _OffExporter.FORMAT_$LI$().setMinimumFractionDigits(16);
2022  }
2023  /**
2024   * 
2025   * @param {File} directory
2026   * @param {java.io.Writer} writer
2027   * @param {number} height
2028   * @param {number} width
2029   */
2030  doExport(directory, writer, height, width) {
2031    let vertices = new java.util.TreeSet();
2032    let numStruts = 0;
2033    const arrayComparator = new ArrayComparator();
2034    const panelVertices = new java.util.TreeSet(((funcInst) => {
2035      if (funcInst == null || typeof funcInst == "function") {
2036        return funcInst;
2037      }
2038      return (arg0, arg1) => (funcInst["compare"] ? funcInst["compare"] : funcInst).call(funcInst, arg0, arg1);
2039    })(arrayComparator.getLengthFirstArrayComparator()));
2040    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2041      let rm = index.next();
2042      {
2043        const man = rm.getManifestation();
2044        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) {
2045          const loc = man.getLocation();
2046          vertices.add(loc);
2047        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
2048          ++numStruts;
2049        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2050          const panel = man;
2051          const corners = new java.util.ArrayList(panel.getVertexCount());
2052          for (let index2 = panel.iterator(); index2.hasNext(); ) {
2053            let vertex = index2.next();
2054            {
2055              corners.add(vertex);
2056            }
2057          }
2058          vertices.addAll(corners);
2059          const cornerArray = ((s) => {
2060            let a = [];
2061            while (s-- > 0) a.push(null);
2062            return a;
2063          })(corners.size());
2064          corners.toArray(cornerArray);
2065          panelVertices.add(cornerArray);
2066        }
2067      }
2068    }
2069    const sortedVertexList = new java.util.ArrayList(vertices);
2070    vertices = null;
2071    this.output = new PrintWriter(writer);
2072    this.output.println$java_lang_Object("OFF");
2073    this.output.println$java_lang_Object("# numVertices numFaces numEdges (numEdges is ignored)");
2074    this.output.println$java_lang_Object(sortedVertexList.size() + " " + panelVertices.size() + " " + numStruts + "\n");
2075    this.output.println$java_lang_Object("# Vertices.  Each line is the XYZ coordinates of one vertex.");
2076    for (let index = sortedVertexList.iterator(); index.hasNext(); ) {
2077      let vector = index.next();
2078      {
2079        const dv = this.mModel.renderVectorDouble(vector);
2080        this.output.print(_OffExporter.FORMAT_$LI$().format(dv[0]) + " ");
2081        this.output.print(_OffExporter.FORMAT_$LI$().format(dv[1]) + " ");
2082        this.output.print(_OffExporter.FORMAT_$LI$().format(dv[2]) + "\n");
2083      }
2084    }
2085    this.output.println$();
2086    this.output.println$java_lang_Object("# Faces.  numCorners vertexIndex[0] ... vertexIndex[numCorners-1]");
2087    for (let index = panelVertices.iterator(); index.hasNext(); ) {
2088      let corners = index.next();
2089      {
2090        this.output.print(corners.length);
2091        for (let index2 = 0; index2 < corners.length; index2++) {
2092          let corner = corners[index2];
2093          {
2094            this.output.print(" " + sortedVertexList.indexOf(corner));
2095          }
2096        }
2097        this.output.println$();
2098      }
2099    }
2100    this.output.flush();
2101  }
2102  /**
2103   * 
2104   * @return {string}
2105   */
2106  getFileExtension() {
2107    return "off";
2108  }
2109};
2110OffExporter["__class"] = "com.vzome.core.exporters.OffExporter";
2111OffExporter.__static_initialize();
2112
2113// src/worker/legacy/from-java/com/vzome/core/exporters/PlyExporter.ts
2114var PlyExporter = class _PlyExporter extends GeometryExporter {
2115  static {
2116    this.__static_initialized = false;
2117  }
2118  static __static_initialize() {
2119    if (!_PlyExporter.__static_initialized) {
2120      _PlyExporter.__static_initialized = true;
2121      _PlyExporter.__static_initializer_0();
2122    }
2123  }
2124  static FORMAT_$LI$() {
2125    _PlyExporter.__static_initialize();
2126    if (_PlyExporter.FORMAT == null) {
2127      _PlyExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
2128    }
2129    return _PlyExporter.FORMAT;
2130  }
2131  static __static_initializer_0() {
2132    if (_PlyExporter.FORMAT_$LI$() != null && _PlyExporter.FORMAT_$LI$() instanceof DecimalFormat) {
2133      _PlyExporter.FORMAT_$LI$().applyPattern("0.000000E00");
2134    }
2135  }
2136  /**
2137   * 
2138   * @param {File} directory
2139   * @param {java.io.Writer} writer
2140   * @param {number} height
2141   * @param {number} width
2142   */
2143  doExport(directory, writer, height, width) {
2144    let numPanels = 0;
2145    const panels = new java.lang.StringBuffer();
2146    this.vertexData = new java.util.LinkedHashMap();
2147    this.vertices = new java.lang.StringBuffer();
2148    const output = new PrintWriter(writer);
2149    output.println$java_lang_Object("ply");
2150    output.println$java_lang_Object("format ascii 1.0");
2151    output.println$java_lang_Object("comment   Exported by vZome, http://vzome.com");
2152    output.println$java_lang_Object("comment     All vertex data is in inches");
2153    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2154      let rm = index.next();
2155      {
2156        const man = rm.getManifestation();
2157        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2158          ++numPanels;
2159          const vs = new java.util.ArrayList();
2160          for (let index2 = man.iterator(); index2.hasNext(); ) {
2161            let vertex = index2.next();
2162            {
2163              vs.add(this.getVertexIndex(vertex));
2164            }
2165          }
2166          panels.append(vs.size());
2167          for (let index2 = vs.iterator(); index2.hasNext(); ) {
2168            let v = index2.next();
2169            {
2170              panels.append(" ");
2171              panels.append(v);
2172            }
2173          }
2174          panels.append("\n");
2175        }
2176      }
2177    }
2178    output.println$java_lang_Object("element vertex " + this.vertexData.size());
2179    output.println$java_lang_Object("property float x");
2180    output.println$java_lang_Object("property float y");
2181    output.println$java_lang_Object("property float z");
2182    output.println$java_lang_Object("element face " + numPanels);
2183    output.println$java_lang_Object("property list uchar int vertex_indices");
2184    output.println$java_lang_Object("end_header");
2185    output.print(this.vertices);
2186    output.print(panels);
2187    output.flush();
2188  }
2189  getVertexIndex(vertexVector) {
2190    let obj = this.vertexData.get(vertexVector);
2191    if (obj == null) {
2192      const key = vertexVector;
2193      const index = this.vertexData.size();
2194      obj = index;
2195      this.vertexData.put(key, obj);
2196      this.vertices.append(this.mModel.renderVector(vertexVector).spacedString() + "\n");
2197    }
2198    return obj;
2199  }
2200  /**
2201   * 
2202   * @return {string}
2203   */
2204  getFileExtension() {
2205    return "ply";
2206  }
2207  constructor() {
2208    super();
2209    if (this.vertexData === void 0) {
2210      this.vertexData = null;
2211    }
2212    if (this.vertices === void 0) {
2213      this.vertices = null;
2214    }
2215  }
2216};
2217PlyExporter["__class"] = "com.vzome.core.exporters.PlyExporter";
2218PlyExporter.__static_initialize();
2219
2220// src/worker/legacy/from-java/com/vzome/core/exporters/VRMLExporter.ts
2221var VRMLExporter = class _VRMLExporter extends GeometryExporter {
2222  static {
2223    this.PREAMBLE_FILE = "com/vzome/core/exporters/vrml/preamble.wrl";
2224  }
2225  static {
2226    this.SCALE = 0.35;
2227  }
2228  /*private*/
2229  exportColor(name, color) {
2230    this.output.println$java_lang_Object("PROTO " + name + " [] {");
2231    this.output.print("    Appearance { material Material { diffuseColor ");
2232    const rgb = color.getRGBColorComponents([0, 0, 0]);
2233    this.output.print(rgb[0] + " ");
2234    this.output.print(rgb[1] + " ");
2235    this.output.print(rgb[2]);
2236    this.output.println$java_lang_Object(" }}}");
2237  }
2238  /**
2239   * 
2240   * @param {File} directory
2241   * @param {java.io.Writer} writer
2242   * @param {number} height
2243   * @param {number} width
2244   */
2245  doExport(directory, writer, height, width) {
2246    this.output = new PrintWriter(writer);
2247    this.output.println$java_lang_Object(this.getBoilerplate(_VRMLExporter.PREAMBLE_FILE));
2248    this.output.println$();
2249    let field = null;
2250    const instances = new java.lang.StringBuffer();
2251    let numShapes = 0;
2252    const shapes = new java.util.HashMap();
2253    const colors = new java.util.HashMap();
2254    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2255      let rm = index.next();
2256      {
2257        const shape = rm.getShape();
2258        if (field == null) field = shape.getField();
2259        let shapeName = shapes.get(shape);
2260        if (shapeName == null) {
2261          shapeName = "shape" + numShapes++;
2262          shapes.put(shape, shapeName);
2263          this.exportShape(shapeName, shape);
2264        }
2265        const transform = rm.getOrientation();
2266        const mx = this.mModel.renderVector(transform.timesRow(field.basisVector(3, AlgebraicVector.X)));
2267        const my = this.mModel.renderVector(transform.timesRow(field.basisVector(3, AlgebraicVector.Y)));
2268        const mz = this.mModel.renderVector(transform.timesRow(field.basisVector(3, AlgebraicVector.Z)));
2269        let x = Math.fround(mz.y - my.z);
2270        let y = Math.fround(mx.z - mz.x);
2271        let z = Math.fround(my.x - mx.y);
2272        const cos = (Math.fround(Math.fround(mx.x + my.y) + mz.z) - 1) * 0.5;
2273        const sin = 0.5 * Math.sqrt(x * x + y * y + z * z);
2274        const angle = Math.fround(Math.atan2(sin, cos));
2275        if (Math.abs(angle - Math.PI) < 1e-5) {
2276          if (mx.x >= my.y && mx.x >= mz.z) {
2277            x = Math.sqrt(Math.fround(Math.fround(mx.x - my.y) - mz.z) + 1) * 0.5;
2278            y = mx.y / (2 * x);
2279            z = mx.z / (2 * x);
2280          } else if (my.y >= mz.z && my.y >= mx.x) {
2281            y = Math.sqrt(Math.fround(Math.fround(my.y - mx.x) - mz.z) + 1) * 0.5;
2282            x = mx.y / (2 * y);
2283            z = my.z / (2 * y);
2284          } else {
2285            z = Math.sqrt(Math.fround(Math.fround(mz.z - my.y) - mx.x) + 1) * 0.5;
2286            x = mx.z / (2 * z);
2287            y = my.z / (2 * z);
2288          }
2289        }
2290        let color = rm.getColor();
2291        if (color == null) {
2292          color = Color.WHITE_$LI$();
2293        }
2294        let colorName = colors.get(color);
2295        if (colorName == null) {
2296          colorName = "color_" + /* replace */
2297          color.toString().split(",").join("_");
2298          colors.put(color, colorName);
2299          this.exportColor(colorName, color);
2300        }
2301        instances.append("Transform { translation ");
2302        instances.append(rm.getLocation().scale(_VRMLExporter.SCALE).spacedString());
2303        instances.append(" rotation " + x + " " + y + " " + z + " " + angle);
2304        instances.append(" children[ Shape{ geometry " + shapeName + "{} appearance " + colorName + "{}}]}\n");
2305      }
2306    }
2307    this.output.println$java_lang_Object(instances.toString());
2308    this.output.flush();
2309    this.output.close();
2310  }
2311  /*private*/
2312  exportShape(shapeName, poly) {
2313    this.output.println$java_lang_Object("PROTO " + shapeName + " [] { IndexedFaceSet{ solid FALSE convex FALSE colorPerVertex FALSE");
2314    this.output.println$java_lang_Object("   coord Coordinate{ point [");
2315    for (let index = poly.getVertexList().iterator(); index.hasNext(); ) {
2316      let gv = index.next();
2317      {
2318        const v = this.mModel.renderVector(gv);
2319        this.output.println$java_lang_Object(v.scale(_VRMLExporter.SCALE).spacedString() + ",");
2320      }
2321    }
2322    this.output.println$java_lang_Object("] } coordIndex [");
2323    for (let index = poly.getFaceSet().iterator(); index.hasNext(); ) {
2324      let face = index.next();
2325      {
2326        const arity = face.size();
2327        for (let j = 0; j < arity; j++) {
2328          {
2329            const index2 = face.get(j);
2330            this.output.print(index2 + ", ");
2331          }
2332          ;
2333        }
2334        this.output.println$java_lang_Object("-1,");
2335      }
2336    }
2337    this.output.println$java_lang_Object("]}}");
2338    this.output.flush();
2339  }
2340  /**
2341   * 
2342   * @return {string}
2343   */
2344  getFileExtension() {
2345    return "wrl";
2346  }
2347};
2348VRMLExporter["__class"] = "com.vzome.core.exporters.VRMLExporter";
2349
2350// src/worker/legacy/from-java/com/vzome/core/exporters/DocumentExporter.ts
2351var DocumentExporter = class extends GeometryExporter {
2352  /**
2353   * Subclasses can override this if they need to export history, the lesson model, or the selection.
2354   * @param {*} doc
2355   * @param {File} file
2356   * @param {java.io.Writer} writer
2357   * @param {number} height
2358   * @param {number} width
2359   */
2360  exportDocument(doc, file, writer, height, width) {
2361    this.mScene = doc.getCameraModel();
2362    this.mLights = doc.getSceneLighting();
2363    this.exportGeometry(doc.getRenderedModel(), file, writer, height, width);
2364    this.mScene = null;
2365    this.mLights = null;
2366  }
2367  constructor() {
2368    super();
2369    if (this.mLights === void 0) {
2370      this.mLights = null;
2371    }
2372    if (this.mScene === void 0) {
2373      this.mScene = null;
2374    }
2375  }
2376};
2377DocumentExporter["__class"] = "com.vzome.core.exporters.DocumentExporter";
2378DocumentExporter["__interfaces"] = ["com.vzome.core.exporters.DocumentExporterIntf"];
2379
2380// src/worker/legacy/from-java/com/vzome/core/exporters/POVRayExporter.ts
2381var POVRayExporter = class _POVRayExporter extends DocumentExporter {
2382  static FORMAT_$LI$() {
2383    if (_POVRayExporter.FORMAT == null) {
2384      _POVRayExporter.FORMAT = NumberFormat.getNumberInstance(java.util.Locale.US);
2385    }
2386    return _POVRayExporter.FORMAT;
2387  }
2388  static {
2389    this.PREAMBLE_FILE = "com/vzome/core/exporters/povray/preamble.pov";
2390  }
2391  mapViewToWorld(view, vector) {
2392  }
2393  /**
2394   * 
2395   * @return {boolean}
2396   */
2397  needsManifestations() {
2398    return false;
2399  }
2400  /**
2401   * 
2402   * @param {File} povFile
2403   * @param {java.io.Writer} writer
2404   * @param {number} height
2405   * @param {number} width
2406   */
2407  doExport(povFile, writer, height, width) {
2408    this.output = new PrintWriter(writer);
2409    const lookDir = this.mScene.getLookDirectionRV();
2410    const upDir = this.mScene.getUpDirectionRV();
2411    _POVRayExporter.FORMAT_$LI$().setMaximumFractionDigits(8);
2412    this.output.println$();
2413    this.output.println$();
2414    this.output.println$java_lang_Object("#declare           look_dir = " + this.printTuple3d(lookDir) + ";");
2415    this.output.println$();
2416    this.output.println$java_lang_Object("#declare             up_dir = " + this.printTuple3d(upDir) + ";");
2417    this.output.println$();
2418    this.output.println$java_lang_Object("#declare viewpoint_distance = " + this.mScene.getViewDistance() + ";");
2419    this.output.println$();
2420    this.output.println$java_lang_Object("#declare      look_at_point = " + this.printTuple3d(this.mScene.getLookAtPointRV()) + ";");
2421    this.output.println$();
2422    this.output.println$java_lang_Object("#declare      field_of_view = " + this.mScene.getFieldOfView() + ";");
2423    this.output.println$();
2424    this.output.println$java_lang_Object("#declare      parallel_proj = " + (this.mScene.isPerspective() ? 0 : 1) + ";");
2425    this.output.println$();
2426    const preamble = ResourceLoader.loadStringResource(_POVRayExporter.PREAMBLE_FILE);
2427    this.output.println$java_lang_Object(preamble);
2428    this.output.println$();
2429    for (let i = 0; i < 3; i++) {
2430      {
2431        const color = this.mLights.getDirectionalLightColor(i);
2432        let rv = this.mLights.getDirectionalLightVector(i);
2433        rv = this.mScene.mapViewToWorld(rv);
2434        this.output.print("light_source { -light_distance * " + this.printTuple3d(rv));
2435        this.output.print(" ");
2436        this.printColor(color);
2437        this.output.println$java_lang_Object(" * multiplier_light_" + (i + 1) + " }");
2438        this.output.println$();
2439      }
2440      ;
2441    }
2442    this.output.print("#declare ambient_color = ");
2443    this.printColor(this.mLights.getAmbientColor());
2444    this.output.println$java_lang_Object(";");
2445    this.output.println$();
2446    this.output.println$java_lang_Object("#default { texture { finish { phong 0.3 ambient multiplier_ambient * ambient_color diffuse 0.6 } } }");
2447    this.output.println$();
2448    this.output.print("background { ");
2449    this.printColor(this.mLights.getBackgroundColor());
2450    this.output.println$java_lang_Object(" }");
2451    this.output.println$();
2452    const instances = new java.lang.StringBuffer();
2453    const field = this.mModel.getField();
2454    const embedding = this.mModel.getEmbedding();
2455    let embeddingTransform = " ";
2456    if (!embedding.isTrivial()) {
2457      embeddingTransform = " transform embedding ";
2458      this.output.print("#declare embedding = transform { matrix < ");
2459      for (let i = 0; i < 3; i++) {
2460        {
2461          const columnSelect = field.basisVector(3, i);
2462          const columnI = embedding.embedInR3(columnSelect);
2463          this.output.print(_POVRayExporter.FORMAT_$LI$().format(columnI.x));
2464          this.output.print(", ");
2465          this.output.print(_POVRayExporter.FORMAT_$LI$().format(columnI.y));
2466          this.output.print(", ");
2467          this.output.print(_POVRayExporter.FORMAT_$LI$().format(columnI.z));
2468          this.output.print(", ");
2469        }
2470        ;
2471      }
2472      this.output.println$java_lang_Object(" 0, 0, 0 > }");
2473      this.output.flush();
2474    }
2475    let numTransforms = 0;
2476    const shapes = new java.util.HashSet();
2477    const transforms = new java.util.HashMap();
2478    const colors = new java.util.HashMap();
2479    const sorted = [];
2480    for (let index2 = this.mModel.iterator(); index2.hasNext(); ) {
2481      sorted.push(index2.next());
2482    }
2483    sorted.sort(_POVRayExporter.compareForExport);
2484    for (let sortedIndex = 0; sortedIndex < sorted.length; sortedIndex++) {
2485      let rm = sorted[sortedIndex];
2486      {
2487        const shapeName = "S" + /* replaceAll */
2488        rm.getShapeKey().replace(new RegExp("[^A-Za-z0-9_]", "g"), "_");
2489        if (!shapes.contains(shapeName)) {
2490          shapes.add(shapeName);
2491          this.exportShape(shapeName, rm.getShape());
2492        }
2493        const transform = rm.getOrientation();
2494        const transformKey = "" + transform;
2495        let transformName = transforms.get(transformKey);
2496        if (transformName == null) {
2497          transformName = "trans" + numTransforms++;
2498          transforms.put(transformKey, transformName);
2499          this.exportTransform(transformName, transform);
2500        }
2501        let color = rm.getColor();
2502        if (color == null) color = Color.WHITE_$LI$();
2503        const colorKey = "" + color;
2504        let colorName = colors.get(colorKey);
2505        if (colorName == null) {
2506          colorName = this.nameColor(color);
2507          colors.put(colorKey, colorName);
2508          this.exportColor(colorName, color);
2509        }
2510        instances.append("object { " + shapeName + " transform " + transformName + " translate ");
2511        instances.append("(<");
2512        let loc = rm.getLocationAV();
2513        if (loc == null) loc = rm.getShape().getField().origin(3);
2514        this.appendVector(loc, instances);
2515        instances.append(">)");
2516        instances.append(embeddingTransform + "transform anim texture { " + colorName + " } }");
2517        instances.append(java.lang.System.getProperty("line.separator"));
2518      }
2519    }
2520    this.output.println$java_lang_Object(instances.toString());
2521    this.output.flush();
2522    if (povFile == null) return;
2523    let filename = povFile.getName();
2524    const index = filename.lastIndexOf(".pov");
2525    if (index > 0) {
2526      filename = filename.substring(0, index);
2527    }
2528    const file = new File(povFile.getParentFile(), filename + ".ini");
2529    this.output = new PrintWriter(new java.io.FileWriter(file));
2530    this.output.println$java_lang_Object("+W600");
2531    this.output.println$java_lang_Object("+H600");
2532    this.output.println$java_lang_Object("+A");
2533    this.output.println$java_lang_Object("Input_File_Name=" + filename + ".pov");
2534    this.output.println$java_lang_Object("Output_File_Name=" + filename + ".png");
2535    this.output.close();
2536  }
2537  nameColor(color) {
2538    return "color_" + /* replace */
2539    color.toString().split(",").join("_");
2540  }
2541  /*private*/
2542  printTuple3d(t) {
2543    const buf = new java.lang.StringBuilder("<");
2544    buf.append(_POVRayExporter.FORMAT_$LI$().format(t.x));
2545    buf.append(",");
2546    buf.append(_POVRayExporter.FORMAT_$LI$().format(t.y));
2547    buf.append(",");
2548    buf.append(_POVRayExporter.FORMAT_$LI$().format(t.z));
2549    buf.append(">");
2550    return buf.toString();
2551  }
2552  exportColor(name, color) {
2553    this.output.print("#declare " + /* replace */
2554    name.split(".").join("_") + " = texture { pigment { ");
2555    this.printColor(color);
2556    this.output.println$java_lang_Object(" } };");
2557  }
2558  /*private*/
2559  printColor(color) {
2560    const doAlpha = color.getAlpha() < 255;
2561    if (doAlpha) this.output.print("color rgbf <");
2562    else this.output.print("color rgb <");
2563    const rgb = color.getRGBColorComponents([0, 0, 0, 0]);
2564    this.output.print(_POVRayExporter.FORMAT_$LI$().format(rgb[0]) + ",");
2565    this.output.print(_POVRayExporter.FORMAT_$LI$().format(rgb[1]) + ",");
2566    if (doAlpha) {
2567      this.output.print(_POVRayExporter.FORMAT_$LI$().format(rgb[2]) + ",");
2568      this.output.print(_POVRayExporter.FORMAT_$LI$().format(rgb[3]));
2569    } else {
2570      this.output.print(_POVRayExporter.FORMAT_$LI$().format(rgb[2]));
2571    }
2572    this.output.print(">");
2573  }
2574  appendVector(loc, buf) {
2575    const vector = loc.toRealVector();
2576    buf.append(_POVRayExporter.FORMAT_$LI$().format(vector.x));
2577    buf.append(", ");
2578    buf.append(_POVRayExporter.FORMAT_$LI$().format(vector.y));
2579    buf.append(", ");
2580    buf.append(_POVRayExporter.FORMAT_$LI$().format(vector.z));
2581  }
2582  //  The four keys together are exactly what the exporter emits per instance, so ties
2583  //  are only possible between manifestations that would emit identical lines anyway.
2584  /*private*/
2585  static compareForExport(a, b) {
2586    let comparison = _POVRayExporter.nullSafeCompare(a.getShapeKey(), b.getShapeKey());
2587    if (comparison !== 0) return comparison;
2588    const aOrientation = a.getOrientation();
2589    const bOrientation = b.getOrientation();
2590    comparison = _POVRayExporter.nullSafeCompare(
2591      aOrientation == null ? null : aOrientation.toString(),
2592      bOrientation == null ? null : bOrientation.toString()
2593    );
2594    if (comparison !== 0) return comparison;
2595    const aLocation = a.getLocationAV();
2596    const bLocation = b.getLocationAV();
2597    if (aLocation != null && bLocation != null) {
2598      comparison = aLocation.compareTo(bLocation);
2599      if (comparison !== 0) return comparison;
2600    } else if (aLocation !== bLocation) {
2601      return aLocation == null ? -1 : 1;
2602    }
2603    const aColor = a.getColor();
2604    const bColor = b.getColor();
2605    return _POVRayExporter.nullSafeCompare(
2606      aColor == null ? null : aColor.toString(),
2607      bColor == null ? null : bColor.toString()
2608    );
2609  }
2610  /*private*/
2611  static nullSafeCompare(a, b) {
2612    if (a == null) return b == null ? 0 : -1;
2613    if (b == null) return 1;
2614    return a < b ? -1 : a > b ? 1 : 0;
2615  }
2616  /*private*/
2617  exportShape(shapeName, poly) {
2618    this.output.print("#declare " + shapeName + " = ");
2619    const vertices = poly.getVertexList();
2620    this.output.println$java_lang_Object("mesh {");
2621    const triangles = [];
2622    for (let index = poly.getTriangleFaces().iterator(); index.hasNext(); ) {
2623      let face = index.next();
2624      {
2625        const buf = new java.lang.StringBuffer("triangle {");
2626        for (let loopIndex = 0; loopIndex < face.vertices.length; loopIndex++) {
2627          let index2 = face.vertices[loopIndex];
2628          {
2629            const loc = vertices.get(index2);
2630            buf.append("<");
2631            this.appendVector(loc, buf);
2632            buf.append(">");
2633          }
2634        }
2635        buf.append("}");
2636        triangles.push(buf.toString());
2637      }
2638    }
2639    triangles.sort();
2640    for (let t = 0; t < triangles.length; t++) {
2641      this.output.println$java_lang_Object(triangles[t]);
2642    }
2643    this.output.println$java_lang_Object("}");
2644    this.output.flush();
2645  }
2646  /*private*/
2647  exportTransform(name, transform) {
2648    const field = this.mModel.getField();
2649    this.output.print("#declare " + name + " = transform { matrix < ");
2650    const buf = new java.lang.StringBuffer();
2651    for (let i = 0; i < 3; i++) {
2652      {
2653        const columnSelect = field.basisVector(3, i);
2654        const columnI = transform.timesColumn(columnSelect);
2655        this.appendVector(columnI, buf);
2656        buf.append(", ");
2657      }
2658      ;
2659    }
2660    this.output.print(buf);
2661    this.output.println$java_lang_Object(" 0, 0, 0 > }");
2662    this.output.flush();
2663  }
2664  /**
2665   * 
2666   * @return {string}
2667   */
2668  getFileExtension() {
2669    return "pov";
2670  }
2671  constructor() {
2672    super();
2673  }
2674};
2675POVRayExporter["__class"] = "com.vzome.core.exporters.POVRayExporter";
2676POVRayExporter["__interfaces"] = ["com.vzome.core.exporters.DocumentExporterIntf"];
2677
2678// src/worker/legacy/from-java/com/vzome/core/model/VefModelExporter.ts
2679var VefModelExporter = class extends VefVectorExporter {
2680  constructor(writer, field, scale = null, withOffset = false) {
2681    super(writer, field, scale, withOffset);
2682  }
2683  /**
2684   * 
2685   * @param {*} man
2686   */
2687  exportManifestation(man) {
2688    if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) {
2689      this.exportPoint(man.getLocation());
2690    } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
2691      const strut = man;
2692      this.exportSegment(strut.getLocation(), strut.getEnd());
2693    } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2694      const panel = man;
2695      const corners = new java.util.ArrayList(panel.getVertexCount());
2696      for (let index = panel.iterator(); index.hasNext(); ) {
2697        let vertex = index.next();
2698        {
2699          corners.add(vertex);
2700        }
2701      }
2702      this.exportPolygon(corners);
2703    }
2704  }
2705  /**
2706   * This is used only for vZome part geometry export
2707   * @param {*} man
2708   */
2709  exportSelectedManifestation(man) {
2710    if (man == null) {
2711      this.output.println$();
2712      this.output.flush();
2713    } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) {
2714      if (this.strTip != null) {
2715        this.output.print(this.strTip);
2716        this.strTip = null;
2717      }
2718      const loc = man.getLocation();
2719      this.output.println$java_lang_Object(" " + this.sortedVertexList.indexOf(loc));
2720    } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2721      if (this.strMiddle != null) {
2722        this.output.println$java_lang_Object(this.strMiddle);
2723        this.strMiddle = null;
2724      }
2725      const panel = man;
2726      for (let index = panel.iterator(); index.hasNext(); ) {
2727        let corner = index.next();
2728        {
2729          this.output.print(this.sortedVertexList.indexOf(corner) + " ");
2730        }
2731      }
2732      this.output.println$();
2733    }
2734  }
2735  /**
2736   * 
2737   */
2738  finish() {
2739    super.finishExport();
2740  }
2741};
2742VefModelExporter["__class"] = "com.vzome.core.model.VefModelExporter";
2743VefModelExporter["__interfaces"] = ["com.vzome.core.model.Exporter"];
2744
2745// src/worker/legacy/from-java/com/vzome/core/exporters/VefExporter.ts
2746var VefExporter = class extends GeometryExporter {
2747  /**
2748   * 
2749   * @param {File} directory
2750   * @param {java.io.Writer} writer
2751   * @param {number} height
2752   * @param {number} width
2753   */
2754  doExport(directory, writer, height, width) {
2755    const field = this.mModel.getField();
2756    const exporter = new VefModelExporter(writer, field);
2757    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2758      let rm = index.next();
2759      {
2760        const man = rm.getManifestation();
2761        exporter.exportManifestation(man);
2762      }
2763    }
2764    exporter.finish();
2765  }
2766  /**
2767   * 
2768   * @return {string}
2769   */
2770  getFileExtension() {
2771    return "vef";
2772  }
2773};
2774VefExporter["__class"] = "com.vzome.core.exporters.VefExporter";
2775
2776// src/worker/legacy/from-java/com/vzome/core/exporters/PartGeometryExporter.ts
2777var PartGeometryExporter = class extends VefExporter {
2778  exportDocument(doc, file, writer, height, width) {
2779    this.mModel = doc.getRenderedModel();
2780    this.selection = doc.getEditorModel().getSelection();
2781    this.doExport(file, writer, height, width);
2782    this.selection = null;
2783    this.mModel = null;
2784  }
2785  /**
2786   * 
2787   * @param {File} directory
2788   * @param {java.io.Writer} writer
2789   * @param {number} height
2790   * @param {number} width
2791   */
2792  doExport(directory, writer, height, width) {
2793    const field = this.mModel.getField();
2794    const exporter = new VefModelExporter(writer, field);
2795    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2796      let rm = index.next();
2797      {
2798        exporter.exportManifestation(rm.getManifestation());
2799      }
2800    }
2801    exporter.finish();
2802    this.exportSelection(exporter);
2803  }
2804  /*private*/
2805  exportSelection(exporter) {
2806    let tip = null;
2807    const arrayComparator = new ArrayComparator();
2808    const panelVertices = new java.util.TreeSet(((funcInst) => {
2809      if (funcInst == null || typeof funcInst == "function") {
2810        return funcInst;
2811      }
2812      return (arg0, arg1) => (funcInst["compare"] ? funcInst["compare"] : funcInst).call(funcInst, arg0, arg1);
2813    })(arrayComparator.getLengthFirstArrayComparator()));
2814    const vertexArrayPanelMap = new java.util.HashMap();
2815    for (let index = this.selection.iterator(); index.hasNext(); ) {
2816      let man = index.next();
2817      {
2818        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) {
2819          if (tip == null) {
2820            tip = man;
2821          }
2822        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2823          const panel = man;
2824          const corners = new java.util.ArrayList(panel.getVertexCount());
2825          for (let index2 = panel.iterator(); index2.hasNext(); ) {
2826            let vertex = index2.next();
2827            {
2828              corners.add(vertex);
2829            }
2830          }
2831          const cornerArray = ((s) => {
2832            let a = [];
2833            while (s-- > 0) a.push(null);
2834            return a;
2835          })(corners.size());
2836          corners.toArray(cornerArray);
2837          panelVertices.add(cornerArray);
2838          vertexArrayPanelMap.put(cornerArray, panel);
2839        }
2840      }
2841    }
2842    if (tip != null) {
2843      exporter.exportSelectedManifestation(null);
2844      exporter.exportSelectedManifestation(tip);
2845      if (!panelVertices.isEmpty()) {
2846        exporter.exportSelectedManifestation(null);
2847        for (let index = panelVertices.iterator(); index.hasNext(); ) {
2848          let vertexArray = index.next();
2849          {
2850            const panel = vertexArrayPanelMap.get(vertexArray);
2851            exporter.exportSelectedManifestation(panel);
2852          }
2853        }
2854      }
2855      exporter.exportSelectedManifestation(null);
2856    }
2857  }
2858  constructor() {
2859    super();
2860    if (this.selection === void 0) {
2861      this.selection = null;
2862    }
2863  }
2864};
2865PartGeometryExporter["__class"] = "com.vzome.core.exporters.PartGeometryExporter";
2866PartGeometryExporter["__interfaces"] = ["com.vzome.core.exporters.DocumentExporterIntf"];
2867
2868// src/worker/legacy/from-java/com/vzome/core/exporters/OpenScadExporter.ts
2869var OpenScadExporter = class extends DocumentExporter {
2870  /**
2871   * 
2872   * @param {*} doc
2873   * @param {File} file
2874   * @param {java.io.Writer} writer
2875   * @param {number} height
2876   * @param {number} width
2877   */
2878  exportDocument(doc, file, writer, height, width) {
2879    const toolsModel = doc.getToolsModel();
2880    this.mModel = doc.getRenderedModel();
2881    const field = this.mModel.getField();
2882    const tipBookmark = toolsModel.values().stream().filter((tool) => "tip vertex" === tool.getLabel()).findAny();
2883    if (!tipBookmark.isPresent()) throw new Command.Failure('You must have a bookmark named "tip vertex" for the strut endpoint.');
2884    const tipItems = tipBookmark.get().getParameters();
2885    const tipPoint = tipItems.get(0);
2886    if (tipItems.size() > 1 || !(tipPoint != null && tipPoint instanceof Point)) throw new Command.Failure('The "tip vertex" bookmark must select a single ball.');
2887    const tipVertex = tipPoint.getLocation();
2888    const floatingBookmark = toolsModel.values().stream().filter((tool) => "floating panels" === tool.getLabel()).findAny();
2889    let floatingVerticesSet = new java.util.TreeSet();
2890    if (!floatingBookmark.isPresent()) throw new Command.Failure('You must have a bookmark named "floating panels".');
2891    for (let index = floatingBookmark.get().getParameters().iterator(); index.hasNext(); ) {
2892      let polygon = index.next();
2893      {
2894        if (!(polygon != null && polygon instanceof Polygon)) throw new Command.Failure('The "floating panels" bookmark must select only panels.');
2895        {
2896          let array = polygon.getVertices();
2897          for (let index2 = 0; index2 < array.length; index2++) {
2898            let vertex = array[index2];
2899            {
2900              floatingVerticesSet.add(vertex);
2901            }
2902          }
2903        }
2904      }
2905    }
2906    let bottomFaceNormal = null;
2907    const bottomFaceBookmark = toolsModel.values().stream().filter((tool) => "bottom face" === tool.getLabel()).findAny();
2908    if (bottomFaceBookmark.isPresent()) {
2909      const bottomFaceItems = bottomFaceBookmark.get().getParameters();
2910      const bottomFacePanel = bottomFaceItems.get(0);
2911      if (bottomFaceItems.size() > 1 || !(bottomFacePanel != null && bottomFacePanel instanceof Polygon)) throw new Command.Failure('The "bottom face" bookmark must select a single panel.');
2912      bottomFaceNormal = bottomFacePanel.getNormal();
2913    }
2914    let fixedVerticesSet = new java.util.TreeSet();
2915    let orbitName = null;
2916    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2917      let rm = index.next();
2918      {
2919        const man = rm.getManifestation();
2920        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2921          const panel = man;
2922          for (let index2 = panel.iterator(); index2.hasNext(); ) {
2923            let vertex = index2.next();
2924            {
2925              if (!floatingVerticesSet.contains(vertex)) fixedVerticesSet.add(vertex);
2926            }
2927          }
2928        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
2929          if (orbitName != null) throw new Command.Failure("The model must contain a single prototype strut.");
2930          orbitName = rm.getStrutOrbit().getName();
2931        }
2932      }
2933    }
2934    if (orbitName == null) throw new Command.Failure("The model must contain a single prototype strut.");
2935    const sortedFixedVertexList = new java.util.ArrayList(fixedVerticesSet);
2936    const sortedFloatingVertexList = new java.util.ArrayList(floatingVerticesSet);
2937    fixedVerticesSet = null;
2938    floatingVerticesSet = null;
2939    this.output = new PrintWriter(writer);
2940    let prelude = super.getBoilerplate("com/vzome/core/exporters/zome-strut-prelude.scad");
2941    prelude = /* replaceAll */
2942    prelude.replace(new RegExp("%%ORBIT%%", "g"), orbitName);
2943    this.output.println$java_lang_Object(prelude);
2944    this.output.println$java_lang_Object("  irrational = " + field.getCoefficients()[1] + ";");
2945    this.output.println$();
2946    this.output.println$java_lang_Object("module " + orbitName + "_strut( size, scalar=1.0, offsets=0 ) {");
2947    this.output.println$();
2948    if (bottomFaceNormal == null) {
2949      this.output.println$java_lang_Object('  // WARNING: The vZome design contained no "bottom face" bookmark.');
2950      this.output.println$java_lang_Object("  bottom_face_normal = [ 0, 0, -1 ];");
2951    } else {
2952      const bottomFaceDirection = this.mModel.renderVector(bottomFaceNormal).normalize();
2953      this.output.println$java_lang_Object("  bottom_face_normal = [ " + bottomFaceDirection.toString$() + " ];");
2954    }
2955    this.output.println$();
2956    const mmScaling = this.mModel.getCmScaling() * 10;
2957    const tipVertexString = this.mModel.renderVector(tipVertex).scale(mmScaling).toString$();
2958    this.output.println$java_lang_Object("  tip_vertex = [ " + tipVertexString + " ];");
2959    this.output.println$();
2960    this.output.println$java_lang_Object("  fixed_vertices = [ ");
2961    for (let index = sortedFixedVertexList.iterator(); index.hasNext(); ) {
2962      let vertex = index.next();
2963      {
2964        this.output.print("[ ");
2965        this.output.print(this.mModel.renderVector(vertex).scale(mmScaling).toString$());
2966        this.output.print(" ], ");
2967      }
2968    }
2969    this.output.println$java_lang_Object(" ];");
2970    this.output.println$java_lang_Object("  floating_vertices = [ ");
2971    for (let index = sortedFloatingVertexList.iterator(); index.hasNext(); ) {
2972      let vertex = index.next();
2973      {
2974        this.output.print("[ ");
2975        this.output.print(this.mModel.renderVector(vertex).scale(mmScaling).toString$());
2976        this.output.print(" ], ");
2977      }
2978    }
2979    this.output.println$java_lang_Object(" ];");
2980    this.output.println$java_lang_Object("  faces = [ ");
2981    for (let index = this.mModel.iterator(); index.hasNext(); ) {
2982      let rm = index.next();
2983      {
2984        const man = rm.getManifestation();
2985        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
2986          this.output.print("[ ");
2987          const panel = man;
2988          const stack = new java.util.Stack();
2989          for (let index2 = panel.iterator(); index2.hasNext(); ) {
2990            let vertex = index2.next();
2991            {
2992              stack.push(vertex);
2993            }
2994          }
2995          while (!stack.isEmpty()) {
2996            {
2997              const vertex = stack.pop();
2998              let index2 = sortedFixedVertexList.indexOf(vertex);
2999              if (index2 < 0) {
3000                index2 = sortedFixedVertexList.size() + sortedFloatingVertexList.indexOf(vertex);
3001              }
3002              this.output.print(index2 + ", ");
3003            }
3004          }
3005          ;
3006          this.output.print("], ");
3007        }
3008      }
3009    }
3010    this.output.println$java_lang_Object(" ];");
3011    this.output.println$java_lang_Object("  zome_strut( tip_vertex, fixed_vertices, floating_vertices, faces, bottom_face_normal, size, scalar, offsets );");
3012    this.output.println$java_lang_Object("}");
3013    this.output.flush();
3014  }
3015  /**
3016   * 
3017   * @return {string}
3018   */
3019  getFileExtension() {
3020    return "scad";
3021  }
3022  /**
3023   * 
3024   * @param {File} file
3025   * @param {java.io.Writer} writer
3026   * @param {number} height
3027   * @param {number} width
3028   */
3029  doExport(file, writer, height, width) {
3030  }
3031  constructor() {
3032    super();
3033  }
3034};
3035OpenScadExporter["__class"] = "com.vzome.core.exporters.OpenScadExporter";
3036OpenScadExporter["__interfaces"] = ["com.vzome.core.exporters.DocumentExporterIntf"];
3037
3038// src/worker/legacy/from-java/com/vzome/core/exporters/MathTableExporter.ts
3039var MathTableExporter = class _MathTableExporter extends GeometryExporter {
3040  static X_$LI$() {
3041    if (_MathTableExporter.X == null) {
3042      _MathTableExporter.X = AlgebraicVector.X;
3043    }
3044    return _MathTableExporter.X;
3045  }
3046  static Y_$LI$() {
3047    if (_MathTableExporter.Y == null) {
3048      _MathTableExporter.Y = AlgebraicVector.Y;
3049    }
3050    return _MathTableExporter.Y;
3051  }
3052  /**
3053   * 
3054   * @param {File} file
3055   * @param {java.io.Writer} writer
3056   * @param {number} height
3057   * @param {number} width
3058   */
3059  doExport(file, writer, height, width) {
3060    const field = this.mModel.getField();
3061    const buf = new java.lang.StringBuilder();
3062    buf.append("{\n");
3063    _MathTableExporter.writeFieldData(field, buf);
3064    _MathTableExporter.writeUnitTermsOrDiagonals(field, buf);
3065    _MathTableExporter.writeMultiplicationTable(field, buf);
3066    _MathTableExporter.writeDivisionTable(field, buf);
3067    _MathTableExporter.writeExponentsTable(field, buf);
3068    if (field != null && field instanceof PolygonField) {
3069      _MathTableExporter.writeNamedNumbers(field, buf);
3070      _MathTableExporter.writeEmbedding(field, buf);
3071      _MathTableExporter.writeTrigTable(field, buf);
3072    }
3073    buf.setLength(buf.length() - 2);
3074    buf.append("\n}\n");
3075    this.output = new PrintWriter(writer);
3076    this.output.println$java_lang_Object(
3077      /* replace */
3078      buf.toString().split("'").join('"')
3079    );
3080    this.output.flush();
3081  }
3082  /*private*/
3083  static getUnitTermOrDiagonal(field, i) {
3084    return field != null && field instanceof PolygonField ? field.getUnitDiagonal(i) : field.getUnitTerm(i);
3085  }
3086  /*private*/
3087  static getFieldOrderOrDiagonalCount(field) {
3088    return field != null && field instanceof PolygonField ? field.diagonalCount() : field.getOrder();
3089  }
3090  /*private*/
3091  static writeFieldData(field, buf) {
3092    buf.append(" 'field': { ").append("'name': '").append(field.getName()).append("', ").append("'order': ").append(field.getOrder());
3093    if (field != null && field instanceof PolygonField) {
3094      const pfield = field;
3095      buf.append(", 'parity': '").append(pfield.isOdd() ? "odd" : "even").append("', ").append("'diagonalCount': ").append(pfield.diagonalCount()).append(", ").append("'polygonSides': ").append(pfield.polygonSides());
3096    }
3097    buf.append(" },\n");
3098  }
3099  /*private*/
3100  static writeEmbedding(field, buf) {
3101    const symm = new AntiprismSymmetry(field);
3102    const embeddingRows = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
3103    for (let i = 0; i < 3; i++) {
3104      {
3105        const column = symm.embedInR3(field.basisVector(3, i));
3106        embeddingRows[0 + i] = column.x;
3107        embeddingRows[4 + i] = column.y;
3108        embeddingRows[8 + i] = column.z;
3109      }
3110      ;
3111    }
3112    buf.append(" 'embedding': [ ");
3113    let delim = "";
3114    for (let index = 0; index < embeddingRows.length; index++) {
3115      let f = embeddingRows[index];
3116      {
3117        buf.append(delim).append(f);
3118        delim = ", ";
3119      }
3120    }
3121    buf.append(" ],\n");
3122  }
3123  /*private*/
3124  static writeUnitTermsOrDiagonals(field, buf) {
3125    const limit = _MathTableExporter.getFieldOrderOrDiagonalCount(field);
3126    buf.append(" 'unitTerms': [ ");
3127    let delim = "\n";
3128    for (let i = 0; i < limit; i++) {
3129      {
3130        const number = _MathTableExporter.getUnitTermOrDiagonal(field, i);
3131        const name = i === 0 ? "1" : field["getIrrational$int"](i);
3132        buf.append(delim);
3133        delim = ",\n";
3134        buf.append("  { 'name': '").append(name).append("'");
3135        buf.append(", 'value': ").append(_MathTableExporter.formatAN(number));
3136        buf.append(" }");
3137      }
3138      ;
3139    }
3140    buf.append("\n ],\n");
3141  }
3142  static OPTIONAL_NAMED_VALUES_$LI$() {
3143    if (_MathTableExporter.OPTIONAL_NAMED_VALUES == null) {
3144      _MathTableExporter.OPTIONAL_NAMED_VALUES = ["phi", "rho", "sigma", "alpha", "beta", "gamma", "delta", "epsilon", "theta", "kappa", "lambda", "mu", "\u221A2", "\u221A3", "\u221A5", "\u221A6", "\u221A7", "\u221A8", "\u221A10"];
3145    }
3146    return _MathTableExporter.OPTIONAL_NAMED_VALUES;
3147  }
3148  /*private*/
3149  static writeNamedNumbers(field, buf) {
3150    buf.append(" 'namedNumbers': [");
3151    let delim = "\n";
3152    for (let index = 0; index < _MathTableExporter.OPTIONAL_NAMED_VALUES_$LI$().length; index++) {
3153      let name = _MathTableExporter.OPTIONAL_NAMED_VALUES_$LI$()[index];
3154      {
3155        const number = field.getNumberByName(name);
3156        if (number != null) {
3157          buf.append(delim);
3158          delim = ",\n";
3159          buf.append("  { 'name': '").append(name).append("', ");
3160          buf.append("'value': ").append(_MathTableExporter.formatAN(number)).append(", ");
3161          switch (name) {
3162            case "phi":
3163              _MathTableExporter.writeDiagonalRatio(field, 5, buf);
3164              break;
3165            case "rho":
3166              _MathTableExporter.writeDiagonalRatio(field, 7, buf);
3167              break;
3168            case "sigma":
3169              _MathTableExporter.writeDiagonalRatio(field, 7, buf, 3);
3170              break;
3171            case "\u221A2":
3172              _MathTableExporter.writeDiagonalRatio(field, 4, buf);
3173              break;
3174            case "\u221A3":
3175              _MathTableExporter.writeDiagonalRatio(field, 6, buf);
3176              break;
3177            default:
3178              break;
3179          }
3180          buf.append("'reciprocal': ").append(_MathTableExporter.formatAN(number.reciprocal()));
3181          buf.append(" }");
3182        }
3183      }
3184    }
3185    buf.append("\n ],\n");
3186  }
3187  /*private*/
3188  static writeTrigTable(field, buf) {
3189    const rotationMatrix = new AntiprismSymmetry(field).getRotationMatrix();
3190    const vX = field.basisVector(3, _MathTableExporter.X_$LI$());
3191    const v1 = rotationMatrix.timesColumn(vX);
3192    let bisector = vX.plus(v1).scale(field.getUnitTerm(1).reciprocal());
3193    let v = vX;
3194    const nSides = field.polygonSides();
3195    buf.append(" 'trig': [\n");
3196    for (let i = 0; i < nSides; i++) {
3197      {
3198        _MathTableExporter.writeTrigEntry(i, nSides, v, bisector, buf);
3199        buf.append(i === nSides - 1 ? "\n" : ",\n");
3200        v = rotationMatrix.timesColumn(v);
3201        bisector = rotationMatrix.timesColumn(bisector);
3202      }
3203      ;
3204    }
3205    buf.append(" ],\n");
3206  }
3207  /*private*/
3208  static writeMultiplicationTable(field, buf) {
3209    _MathTableExporter.writeTable(field, buf, "multiplication", (n1, n2) => n1["times$com_vzome_core_algebra_AlgebraicNumber"](n2));
3210  }
3211  /*private*/
3212  static writeDivisionTable(field, buf) {
3213    _MathTableExporter.writeTable(field, buf, "division", (n1, n2) => n1.dividedBy(n2));
3214  }
3215  /*private*/
3216  static writeTable(field, buf, tableName, op) {
3217    const operandFactory = field != null && field instanceof PolygonField ? (n) => {
3218      return field.getUnitDiagonal(n);
3219    } : (n) => {
3220      return field.getUnitTerm(n);
3221    };
3222    const limit = field != null && field instanceof PolygonField ? field.diagonalCount() : field.getOrder();
3223    buf.append(" '").append(tableName).append("': [\n");
3224    let delim1 = "";
3225    for (let i = 0; i < limit; i++) {
3226      {
3227        const n1 = ((target) => typeof target === "function" ? target(i) : target.apply(i))(operandFactory);
3228        buf.append(delim1).append("  [ ");
3229        delim1 = ",\n";
3230        let delim2 = "";
3231        for (let j = 0; j < limit; j++) {
3232          {
3233            const n2 = ((target) => typeof target === "function" ? target(j) : target.apply(j))(operandFactory);
3234            const result = ((target) => typeof target === "function" ? target(n1, n2) : target.apply(n1, n2))(op);
3235            buf.append(delim2);
3236            delim2 = ", ";
3237            buf.append(_MathTableExporter.formatAN(result));
3238          }
3239          ;
3240        }
3241        buf.append(" ]");
3242      }
3243      ;
3244    }
3245    buf.append("\n ],\n");
3246  }
3247  /*private*/
3248  static writeExponentsTable(field, buf) {
3249    const limit = _MathTableExporter.getFieldOrderOrDiagonalCount(field);
3250    const range = 6;
3251    buf.append(" 'exponents': [\n");
3252    let delim1 = "";
3253    for (let i = 1; i < limit; i++) {
3254      {
3255        buf.append(delim1).append("  {");
3256        delim1 = ",\n";
3257        const name = field["getIrrational$int"](i);
3258        buf.append(" 'base': '").append(name).append("'");
3259        {
3260          buf.append(",\n    'positivePowers': [ ");
3261          let delim2 = "";
3262          const base = _MathTableExporter.getUnitTermOrDiagonal(field, i);
3263          let result = base;
3264          for (let power = 1; power <= range; power++) {
3265            {
3266              buf.append(delim2);
3267              delim2 = ", ";
3268              buf.append(_MathTableExporter.formatAN(result));
3269              result = result["times$com_vzome_core_algebra_AlgebraicNumber"](base);
3270            }
3271            ;
3272          }
3273          buf.append(" ]");
3274        }
3275        ;
3276        {
3277          buf.append(",\n    'negativePowers': [ ");
3278          let delim2 = "";
3279          const base = _MathTableExporter.getUnitTermOrDiagonal(field, i).reciprocal();
3280          let result = base;
3281          for (let power = 1; power <= range; power++) {
3282            {
3283              buf.append(delim2);
3284              delim2 = ", ";
3285              buf.append(_MathTableExporter.formatAN(result));
3286              result = result["times$com_vzome_core_algebra_AlgebraicNumber"](base);
3287            }
3288            ;
3289          }
3290          buf.append(" ]");
3291        }
3292        ;
3293        buf.append("\n  }");
3294      }
3295      ;
3296    }
3297    buf.append("\n ],\n");
3298  }
3299  static writeDiagonalRatio(field, divisor, buf, step = 2) {
3300    if (field.polygonSides() % divisor === 0) {
3301      const n = field.polygonSides() / divisor | 0;
3302      const denominator = field.getUnitDiagonal(n - 1);
3303      const numerator = field.getUnitDiagonal(step * n - 1);
3304      buf.append("'numerator': ").append(_MathTableExporter.formatAN(numerator)).append(", ");
3305      buf.append("'denominator': ").append(_MathTableExporter.formatAN(denominator)).append(", ");
3306    } else {
3307      throw new java.lang.IllegalStateException("shouldn't ever get here");
3308    }
3309  }
3310  /*private*/
3311  static writeTrigEntry(i, nSides, vStep, bisector, buf) {
3312    const delim1 = "', ";
3313    const delim2 = ", ";
3314    const infinite = "{ 'alg': '\u221E', 'dec': '\u221E', 'tdf': '\u221E' }";
3315    let v = vStep;
3316    for (let n = 0; n < 2; n++) {
3317      {
3318        const k = i * 2 + n;
3319        const degrees = k * 180 / nSides;
3320        const sin = v.getComponent(_MathTableExporter.Y_$LI$());
3321        const cos = v.getComponent(_MathTableExporter.X_$LI$());
3322        buf.append("  { ");
3323        buf.append("'rot': '").append(k).append("/").append(nSides * 2).append(delim1);
3324        buf.append("'rad': '").append(k).append("\u03C0/").append(nSides).append(delim1);
3325        buf.append("'deg': ").append(degrees).append(delim2);
3326        buf.append("'sin': ").append(_MathTableExporter.formatAN(sin)).append(delim2);
3327        buf.append("'cos': ").append(_MathTableExporter.formatAN(cos)).append(delim2);
3328        buf.append("'tan': ").append(cos.isZero() ? infinite : _MathTableExporter.formatAN(sin.dividedBy(cos))).append(delim2);
3329        buf.append("'csc': ").append(sin.isZero() ? infinite : _MathTableExporter.formatAN(sin.reciprocal())).append(delim2);
3330        buf.append("'sec': ").append(cos.isZero() ? infinite : _MathTableExporter.formatAN(cos.reciprocal())).append(delim2);
3331        buf.append("'cot': ").append(sin.isZero() ? infinite : _MathTableExporter.formatAN(cos.dividedBy(sin)));
3332        buf.append(" }");
3333        if (n === 0) {
3334          buf.append(",\n");
3335        }
3336        v = bisector;
3337      }
3338      ;
3339    }
3340  }
3341  /*private*/
3342  static formatAN(n) {
3343    const buf = new java.lang.StringBuilder();
3344    buf.append("{ 'alg': '").append(n).append("', 'dec': ").append(n.evaluate()).append(", 'tdf': [");
3345    let delim = "";
3346    {
3347      let array = n.toTrailingDivisor();
3348      for (let index = 0; index < array.length; index++) {
3349        let term = array[index];
3350        {
3351          buf.append(delim);
3352          delim = ", ";
3353          buf.append(term);
3354        }
3355      }
3356    }
3357    buf.append("] }");
3358    return buf.toString();
3359  }
3360  /**
3361   * 
3362   * @return {string}
3363   */
3364  getFileExtension() {
3365    return "math.json";
3366  }
3367  /**
3368   * 
3369   * @return {string}
3370   */
3371  getContentType() {
3372    return "application/json";
3373  }
3374};
3375MathTableExporter["__class"] = "com.vzome.core.exporters.MathTableExporter";
3376
3377// src/worker/legacy/exporters.js
3378var exporters2d = {
3379  "pdf": PDFExporter,
3380  "ps": PostScriptExporter,
3381  "svg": SVGExporter
3382};
3383var exporters3d = {
3384  "stl": StlExporter,
3385  "step": STEPExporter,
3386  "scad": OpenScadMeshExporter,
3387  "build123d": PythonBuild123dExporter,
3388  "dxf": DxfExporter,
3389  "off": OffExporter,
3390  "ply": PlyExporter,
3391  "vrml": VRMLExporter,
3392  "pov": POVRayExporter,
3393  "partgeom": PartGeometryExporter,
3394  "openscad": OpenScadExporter,
3395  "math": MathTableExporter
3396  //
3397  //   TODO: These may not all be ResourceLoader-enabled (using GeometryExporter.getBoilerplate), or otherwise web-ready,
3398  //     but they all successfully transpiled with JSweet
3399  //
3400  // 'FORMAT'  : 'VefVectorExporter',
3401  // 'FORMAT'  : 'PdbExporter',
3402  // 'FORMAT'  : 'VefExporter',
3403  // 'FORMAT'  : 'SegExporter',
3404  // 'FORMAT'  : 'VefModelExporter',
3405};
3406var parseColor = (input) => {
3407  const m = input.match(/^#([0-9a-f]{6})$/i)[1];
3408  if (m) {
3409    return new Color(
3410      parseInt(m.substr(0, 2), 16),
3411      parseInt(m.substr(2, 2), 16),
3412      parseInt(m.substr(4, 2), 16)
3413    );
3414  }
3415  return null;
3416};
3417var createLights = (lighting) => {
3418  const { backgroundColor, ambientColor, directionalLights, useWorldDirection } = lighting;
3419  const lights = new Lights();
3420  lights.setBackgroundColor(parseColor(backgroundColor));
3421  lights.setAmbientColor(parseColor(ambientColor));
3422  for (const light of directionalLights) {
3423    const { worldDirection, direction, color } = light;
3424    const [x, y, z] = useWorldDirection ? worldDirection : direction;
3425    lights.addDirectionLight(parseColor(color), new RealVector(x, y, z));
3426  }
3427  return lights;
3428};
3429var createViewMatrix = (camera) => {
3430  const { lookAt, lookDir, up, distance } = camera;
3431  const lookAtRV = new RealVector(...lookAt);
3432  const lookDirRV = new RealVector(...lookDir);
3433  const upRV = new RealVector(...up);
3434  const position = lookAtRV.minus(lookDirRV.scale(distance));
3435  return RealMatrix4.lookAt(position, lookAtRV, upRV);
3436};
3437var createProjectionMatrix = (camera, aspectRatio) => {
3438  const { near, far, distance, width } = camera;
3439  const fovX = 2 * Math.atan(width / 2 / distance);
3440  return RealMatrix4.perspective(fovX, aspectRatio, near, far);
3441};
3442var createCamera = (camera) => {
3443  const { distance, width, perspective, lookAt, up, lookDir, magnification } = camera;
3444  const halfX = width / 2;
3445  const fov = 2 * Math.atan(halfX / distance);
3446  let [x, y, z] = lookAt;
3447  const lookAtRV = new RealVector(x, y, z);
3448  [x, y, z] = up;
3449  const upRV = new RealVector(x, y, z);
3450  [x, y, z] = lookDir;
3451  const lookDirRV = new RealVector(x, y, z);
3452  return {
3453    isPerspective: () => perspective,
3454    getFieldOfView: () => fov,
3455    getViewDistance: () => distance,
3456    getMagnification: () => magnification,
3457    getLookAtPointRV: () => lookAtRV,
3458    getLookDirectionRV: () => lookDirRV,
3459    getUpDirectionRV: () => upRV,
3460    // POVRayExporter will call this to map light directions to world coordinates, in the Java code,
3461    //   but here in Javascript our light directions are *already* in world coordinates.
3462    mapViewToWorld: (rv) => rv
3463  };
3464};
3465var createDocument = (legacyDesign, camera, lighting) => {
3466  const { renderedModel, editor, toolsModel } = legacyDesign;
3467  const lights = createLights(lighting);
3468  const cameraModel = createCamera(camera);
3469  return {
3470    getCameraModel: () => cameraModel,
3471    getSceneLighting: () => lights,
3472    getRenderedModel: () => renderedModel,
3473    getToolsModel: () => toolsModel,
3474    getEditorModel: () => editor,
3475    getDetailsXml: (dom, deep) => null
3476    // TODO: implement this so more exporters work  
3477  };
3478};
3479var export2d = (scene, configuration) => {
3480  const { format, height, width, useShapes, drawOutlines, monochrome, showBackground, useLighting } = configuration;
3481  const { renderedModel, camera, lighting } = scene;
3482  const viewTransform = createViewMatrix(camera);
3483  const projection = createProjectionMatrix(camera, 1);
3484  const snapshotter = new Java2dExporter();
3485  const lights = createLights(lighting);
3486  const snapshot = snapshotter.render2d(renderedModel, viewTransform, projection, lights, height, width, !useShapes, useLighting);
3487  const exporter = new exporters2d[format]();
3488  const out = new StringWriter();
3489  exporter.export(snapshot, out, drawOutlines, monochrome, showBackground);
3490  return out.toString();
3491};
3492var export3d = (scene, configuration) => {
3493  const { format, height, width } = configuration;
3494  const { renderedModel } = scene;
3495  const exporter = new exporters3d[format]();
3496  const out = new StringWriter();
3497  exporter.exportGeometry(renderedModel, null, out, height, width);
3498  return out.toString();
3499};
3500var export3dDocument = (legacyDesign, camera, lighting, configuration) => {
3501  const { format, height, width } = configuration;
3502  const exporter = new exporters3d[format]();
3503  const out = new StringWriter();
3504  const document = createDocument(legacyDesign, camera, lighting);
3505  exporter.exportDocument(document, null, out, height, width);
3506  return out.toString();
3507};
3508export {
3509  export2d,
3510  export3d,
3511  export3dDocument
3512};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.