-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli.py
7135 lines (6799 loc) · 315 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Generated by Haxe 4.1.3
# coding: utf-8
import sys
import math as python_lib_Math
import math as Math
import inspect as python_lib_Inspect
import sys as python_lib_Sys
import builtins as python_lib_Builtins
import functools as python_lib_Functools
import random as python_lib_Random
import traceback as python_lib_Traceback
from io import StringIO as python_lib_io_StringIO
class _hx_AnonObject:
_hx_disable_getattr = False
def __init__(self, fields):
self.__dict__ = fields
def __repr__(self):
return repr(self.__dict__)
def __contains__(self, item):
return item in self.__dict__
def __getitem__(self, item):
return self.__dict__[item]
def __getattr__(self, name):
if (self._hx_disable_getattr):
raise AttributeError('field does not exist')
else:
return None
def _hx_hasattr(self,field):
self._hx_disable_getattr = True
try:
getattr(self, field)
self._hx_disable_getattr = False
return True
except AttributeError:
self._hx_disable_getattr = False
return False
class Enum:
_hx_class_name = "Enum"
__slots__ = ("tag", "index", "params")
_hx_fields = ["tag", "index", "params"]
_hx_methods = ["__str__"]
def __init__(self,tag,index,params):
self.tag = tag
self.index = index
self.params = params
def __str__(self):
if (self.params is None):
return self.tag
else:
return self.tag + '(' + (', '.join(str(v) for v in self.params)) + ')'
class Class: pass
class Cli:
_hx_class_name = "Cli"
__slots__ = ()
_hx_statics = ["main"]
@staticmethod
def main():
_g = haxe_ds_StringMap()
_g.h["-o"] = "--output"
_g.h["-w"] = "--width"
_g.h["-h"] = "--height"
abbrev = _g
argv = Sys.args()
_g = haxe_ds_StringMap()
_g.h["--width"] = "800"
_g.h["--height"] = "800"
id = ""
x = (python_lib_Random.random() * 26)
code = None
try:
code = int(x)
except BaseException as _g1:
None
code = None
id = (("null" if id is None else id) + HxOverrides.stringOrNull("".join(map(chr,[(code + 97)]))))
x = (python_lib_Random.random() * 26)
code = None
try:
code = int(x)
except BaseException as _g1:
None
code = None
id = (("null" if id is None else id) + HxOverrides.stringOrNull("".join(map(chr,[(code + 97)]))))
x = (python_lib_Random.random() * 26)
code = None
try:
code = int(x)
except BaseException as _g1:
None
code = None
id = (("null" if id is None else id) + HxOverrides.stringOrNull("".join(map(chr,[(code + 97)]))))
x = (python_lib_Random.random() * 26)
code = None
try:
code = int(x)
except BaseException as _g1:
None
code = None
id = (("null" if id is None else id) + HxOverrides.stringOrNull("".join(map(chr,[(code + 97)]))))
_g.h["--output"] = (("out-" + ("null" if id is None else id)) + ".svg")
_g.h["--transform"] = "auto()"
_g.h["--cull"] = "true"
_g.h["--thresh"] = "0.1"
_g.h["--mode"] = "gradients"
_g.h["--verbose"] = "1"
kwargs = _g
_g = haxe_ds_StringMap()
_g.h["--width"] = "width of output image"
_g.h["--height"] = "height of output image"
_g.h["--output"] = "output filename\n(randomly generated if not specified)"
_g.h["--transform"] = "place the model before rendering\n(multiple commands are left-multiplied in order)\navailable commands:\nfocal(100) translate(1,2,3) scale(4,4,4)\nrotateX(1) rotateY(2) rotateZ(3);\nmatrix(11,12,13,14,21,22,...,43,44)\nrotation angles are in degrees\nuse auto() or auto(zFactor,fFactor) for automatic\nplacement. (cam is fixed at (0,0,0) pointing at +Z,\nfocal() needs to be specified for manual placement)"
_g.h["--cull"] = "don't draw occluded faces\noptions: true/false/custom float value (e.g. 1.5)\nthe float being a multiplier to the 'epsilon',\nallowing ridges just barely occluded to show up"
_g.h["--thresh"] = "apparent ridge threshold\nsmaller => more detailed, larger => cleaner"
_g.h["--mode"] = "visualization technique, options:\nvertices, edges, \nlines (disconnected ridge segments),\npolylines (connected ridges via post-proc),\ngradients (nice render showing ridge strength),\npixels (raster out: depth, norm., curv. maps)"
_g.h["--verbose"] = "verbosity: 0 => errors only, 1 => logs"
desc = _g
if ((len(argv) == 0) or (((argv[0] if 0 < len(argv) else None) == "--help"))):
_hx_str = "\n ___ ___ \n /\\ \\ /\\ \\ \n / \\ \\ / \\ \\ \n / /\\ \\ \\ / /\\ \\ \\ \n / \\~\\ \\ \\ / \\~\\ \\ \\ \n / /\\ \\ \\ \\__\\ / /\\ \\ \\ \\__\\ \n \\/__\\ \\/ / / \\/_| \\/ / / \n \\ / / | | / / \n / / / | |\\/__/ \n / / / | | | \n \\/__/ PPARENT \\|__| IDGES (CLI)\n\nRender line drawings of 3D meshes.\n\nusage: apparentridges [options] [.obj files...]\n\noption default description\n"
python_Lib.printString((("" + ("null" if _hx_str is None else _hx_str)) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
k = kwargs.keys()
while k.hasNext():
k1 = k.next()
defau = kwargs.h.get(k1,None)
ln = k1
a = abbrev.keys()
while a.hasNext():
a1 = a.next()
if (abbrev.h.get(a1,None) == k1):
ln = (("null" if ln is None else ln) + HxOverrides.stringOrNull(((", " + ("null" if a1 is None else a1)))))
ln = StringTools.rpad(ln," ",14)
ln = (("null" if ln is None else ln) + ("null" if defau is None else defau))
ln = StringTools.rpad(ln," ",28)
if (k1 in desc.h):
ln1 = desc.h.get(k1,None)
_g = []
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
_g.append(" ")
ln = (("null" if ln is None else ln) + HxOverrides.stringOrNull(StringTools.replace(ln1,"\n",("\n" + HxOverrides.stringOrNull("".join([python_Boot.toString1(x1,'') for x1 in _g]))))))
ln = (("null" if ln is None else ln) + "\n")
_hx_str = Std.string(ln)
python_Lib.printString((("" + ("null" if _hx_str is None else _hx_str)) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
return 0
args = []
i = 0
while (i < len(argv)):
if (len((argv[i] if i >= 0 and i < len(argv) else None)) == 0):
i = (i + 1)
continue
_this = (argv[i] if i >= 0 and i < len(argv) else None)
if ((("" if ((0 >= len(_this))) else _this[0])) == "-"):
if ((i + 1) >= len(argv)):
print(str(("[error] option without value: " + HxOverrides.stringOrNull((argv[i] if i >= 0 and i < len(argv) else None)))))
return 1
key = (argv[i] if i >= 0 and i < len(argv) else None)
val = python_internal_ArrayImpl._get(argv, (i + 1))
if (key in abbrev.h):
key = abbrev.h.get(key,None)
v = StringTools.replace(val," ","")
kwargs.h[key] = v
i = (i + 2)
continue
args.append((argv[i] if i >= 0 and i < len(argv) else None))
i = (i + 1)
if (len(args) < 1):
print("[warn] no input file.")
return 0
verb = Std.parseInt(kwargs.h.get("--verbose",None))
_g = 0
while (_g < len(args)):
inp = (args[_g] if _g >= 0 and _g < len(args) else None)
_g = (_g + 1)
if (verb > 0):
print(str((("[info] working on " + ("null" if inp is None else inp)) + "...")))
mesh = apparentridges_OBJParser.fromFile(inp)
render = apparentridges_Render(mesh,Std.parseInt(kwargs.h.get("--width",None)),Std.parseInt(kwargs.h.get("--height",None)))
render.setVerbose(verb)
m = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
_g1 = 0
_this = kwargs.h.get("--transform",None)
_g2 = _this.split(")")
while (_g1 < len(_g2)):
t = (_g2[_g1] if _g1 >= 0 and _g1 < len(_g2) else None)
_g1 = (_g1 + 1)
if (len(t) == 0):
continue
_g3 = []
_g4 = 0
_this1 = HxOverrides.arrayGet(t.split("("), 1)
_this2 = python_internal_ArrayImpl._get(_this1.split(")"), 0)
_g5 = _this2.split(",")
while (_g4 < len(_g5)):
x = (_g5[_g4] if _g4 >= 0 and _g4 < len(_g5) else None)
_g4 = (_g4 + 1)
x1 = Std.parseFloat(x)
_g3.append(x1)
def _hx_local_14(x):
return (not python_lib_Math.isnan(x))
nums = list(filter(_hx_local_14,_g3))
if t.startswith("rotateX"):
a = (((nums[0] if 0 < len(nums) else None) * Math.PI) / 180)
A_0 = 1
A_1 = 0
A_2 = 0
A_3 = 0
A_4 = 0
A_5 = (Math.NaN if (((a == Math.POSITIVE_INFINITY) or ((a == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a))
A_6 = -((Math.NaN if (((a == Math.POSITIVE_INFINITY) or ((a == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a)))
A_7 = 0
A_8 = 0
A_9 = (Math.NaN if (((a == Math.POSITIVE_INFINITY) or ((a == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a))
A_10 = (Math.NaN if (((a == Math.POSITIVE_INFINITY) or ((a == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a))
A_11 = 0
A_12 = 0
A_13 = 0
A_14 = 0
A_15 = 1
m = [((((A_0 * (m[0] if 0 < len(m) else None)) + ((A_1 * (m[4] if 4 < len(m) else None)))) + ((A_2 * (m[8] if 8 < len(m) else None)))) + ((A_3 * (m[12] if 12 < len(m) else None)))), ((((A_0 * (m[1] if 1 < len(m) else None)) + ((A_1 * (m[5] if 5 < len(m) else None)))) + ((A_2 * (m[9] if 9 < len(m) else None)))) + ((A_3 * (m[13] if 13 < len(m) else None)))), ((((A_0 * (m[2] if 2 < len(m) else None)) + ((A_1 * (m[6] if 6 < len(m) else None)))) + ((A_2 * (m[10] if 10 < len(m) else None)))) + ((A_3 * (m[14] if 14 < len(m) else None)))), ((((A_0 * (m[3] if 3 < len(m) else None)) + ((A_1 * (m[7] if 7 < len(m) else None)))) + ((A_2 * (m[11] if 11 < len(m) else None)))) + ((A_3 * (m[15] if 15 < len(m) else None)))), ((((A_4 * (m[0] if 0 < len(m) else None)) + ((A_5 * (m[4] if 4 < len(m) else None)))) + ((A_6 * (m[8] if 8 < len(m) else None)))) + ((A_7 * (m[12] if 12 < len(m) else None)))), ((((A_4 * (m[1] if 1 < len(m) else None)) + ((A_5 * (m[5] if 5 < len(m) else None)))) + ((A_6 * (m[9] if 9 < len(m) else None)))) + ((A_7 * (m[13] if 13 < len(m) else None)))), ((((A_4 * (m[2] if 2 < len(m) else None)) + ((A_5 * (m[6] if 6 < len(m) else None)))) + ((A_6 * (m[10] if 10 < len(m) else None)))) + ((A_7 * (m[14] if 14 < len(m) else None)))), ((((A_4 * (m[3] if 3 < len(m) else None)) + ((A_5 * (m[7] if 7 < len(m) else None)))) + ((A_6 * (m[11] if 11 < len(m) else None)))) + ((A_7 * (m[15] if 15 < len(m) else None)))), ((((A_8 * (m[0] if 0 < len(m) else None)) + ((A_9 * (m[4] if 4 < len(m) else None)))) + ((A_10 * (m[8] if 8 < len(m) else None)))) + ((A_11 * (m[12] if 12 < len(m) else None)))), ((((A_8 * (m[1] if 1 < len(m) else None)) + ((A_9 * (m[5] if 5 < len(m) else None)))) + ((A_10 * (m[9] if 9 < len(m) else None)))) + ((A_11 * (m[13] if 13 < len(m) else None)))), ((((A_8 * (m[2] if 2 < len(m) else None)) + ((A_9 * (m[6] if 6 < len(m) else None)))) + ((A_10 * (m[10] if 10 < len(m) else None)))) + ((A_11 * (m[14] if 14 < len(m) else None)))), ((((A_8 * (m[3] if 3 < len(m) else None)) + ((A_9 * (m[7] if 7 < len(m) else None)))) + ((A_10 * (m[11] if 11 < len(m) else None)))) + ((A_11 * (m[15] if 15 < len(m) else None)))), ((((A_12 * (m[0] if 0 < len(m) else None)) + ((A_13 * (m[4] if 4 < len(m) else None)))) + ((A_14 * (m[8] if 8 < len(m) else None)))) + ((A_15 * (m[12] if 12 < len(m) else None)))), ((((A_12 * (m[1] if 1 < len(m) else None)) + ((A_13 * (m[5] if 5 < len(m) else None)))) + ((A_14 * (m[9] if 9 < len(m) else None)))) + ((A_15 * (m[13] if 13 < len(m) else None)))), ((((A_12 * (m[2] if 2 < len(m) else None)) + ((A_13 * (m[6] if 6 < len(m) else None)))) + ((A_14 * (m[10] if 10 < len(m) else None)))) + ((A_15 * (m[14] if 14 < len(m) else None)))), ((((A_12 * (m[3] if 3 < len(m) else None)) + ((A_13 * (m[7] if 7 < len(m) else None)))) + ((A_14 * (m[11] if 11 < len(m) else None)))) + ((A_15 * (m[15] if 15 < len(m) else None))))]
elif t.startswith("rotateY"):
a1 = (((nums[0] if 0 < len(nums) else None) * Math.PI) / 180)
A_01 = (Math.NaN if (((a1 == Math.POSITIVE_INFINITY) or ((a1 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a1))
A_16 = 0
A_21 = (Math.NaN if (((a1 == Math.POSITIVE_INFINITY) or ((a1 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a1))
A_31 = 0
A_41 = 0
A_51 = 1
A_61 = 0
A_71 = 0
A_81 = -((Math.NaN if (((a1 == Math.POSITIVE_INFINITY) or ((a1 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a1)))
A_91 = 0
A_101 = (Math.NaN if (((a1 == Math.POSITIVE_INFINITY) or ((a1 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a1))
A_111 = 0
A_121 = 0
A_131 = 0
A_141 = 0
A_151 = 1
m = [((((A_01 * (m[0] if 0 < len(m) else None)) + ((A_16 * (m[4] if 4 < len(m) else None)))) + ((A_21 * (m[8] if 8 < len(m) else None)))) + ((A_31 * (m[12] if 12 < len(m) else None)))), ((((A_01 * (m[1] if 1 < len(m) else None)) + ((A_16 * (m[5] if 5 < len(m) else None)))) + ((A_21 * (m[9] if 9 < len(m) else None)))) + ((A_31 * (m[13] if 13 < len(m) else None)))), ((((A_01 * (m[2] if 2 < len(m) else None)) + ((A_16 * (m[6] if 6 < len(m) else None)))) + ((A_21 * (m[10] if 10 < len(m) else None)))) + ((A_31 * (m[14] if 14 < len(m) else None)))), ((((A_01 * (m[3] if 3 < len(m) else None)) + ((A_16 * (m[7] if 7 < len(m) else None)))) + ((A_21 * (m[11] if 11 < len(m) else None)))) + ((A_31 * (m[15] if 15 < len(m) else None)))), ((((A_41 * (m[0] if 0 < len(m) else None)) + ((A_51 * (m[4] if 4 < len(m) else None)))) + ((A_61 * (m[8] if 8 < len(m) else None)))) + ((A_71 * (m[12] if 12 < len(m) else None)))), ((((A_41 * (m[1] if 1 < len(m) else None)) + ((A_51 * (m[5] if 5 < len(m) else None)))) + ((A_61 * (m[9] if 9 < len(m) else None)))) + ((A_71 * (m[13] if 13 < len(m) else None)))), ((((A_41 * (m[2] if 2 < len(m) else None)) + ((A_51 * (m[6] if 6 < len(m) else None)))) + ((A_61 * (m[10] if 10 < len(m) else None)))) + ((A_71 * (m[14] if 14 < len(m) else None)))), ((((A_41 * (m[3] if 3 < len(m) else None)) + ((A_51 * (m[7] if 7 < len(m) else None)))) + ((A_61 * (m[11] if 11 < len(m) else None)))) + ((A_71 * (m[15] if 15 < len(m) else None)))), ((((A_81 * (m[0] if 0 < len(m) else None)) + ((A_91 * (m[4] if 4 < len(m) else None)))) + ((A_101 * (m[8] if 8 < len(m) else None)))) + ((A_111 * (m[12] if 12 < len(m) else None)))), ((((A_81 * (m[1] if 1 < len(m) else None)) + ((A_91 * (m[5] if 5 < len(m) else None)))) + ((A_101 * (m[9] if 9 < len(m) else None)))) + ((A_111 * (m[13] if 13 < len(m) else None)))), ((((A_81 * (m[2] if 2 < len(m) else None)) + ((A_91 * (m[6] if 6 < len(m) else None)))) + ((A_101 * (m[10] if 10 < len(m) else None)))) + ((A_111 * (m[14] if 14 < len(m) else None)))), ((((A_81 * (m[3] if 3 < len(m) else None)) + ((A_91 * (m[7] if 7 < len(m) else None)))) + ((A_101 * (m[11] if 11 < len(m) else None)))) + ((A_111 * (m[15] if 15 < len(m) else None)))), ((((A_121 * (m[0] if 0 < len(m) else None)) + ((A_131 * (m[4] if 4 < len(m) else None)))) + ((A_141 * (m[8] if 8 < len(m) else None)))) + ((A_151 * (m[12] if 12 < len(m) else None)))), ((((A_121 * (m[1] if 1 < len(m) else None)) + ((A_131 * (m[5] if 5 < len(m) else None)))) + ((A_141 * (m[9] if 9 < len(m) else None)))) + ((A_151 * (m[13] if 13 < len(m) else None)))), ((((A_121 * (m[2] if 2 < len(m) else None)) + ((A_131 * (m[6] if 6 < len(m) else None)))) + ((A_141 * (m[10] if 10 < len(m) else None)))) + ((A_151 * (m[14] if 14 < len(m) else None)))), ((((A_121 * (m[3] if 3 < len(m) else None)) + ((A_131 * (m[7] if 7 < len(m) else None)))) + ((A_141 * (m[11] if 11 < len(m) else None)))) + ((A_151 * (m[15] if 15 < len(m) else None))))]
elif t.startswith("rotateZ"):
a2 = (((nums[0] if 0 < len(nums) else None) * Math.PI) / 180)
A_02 = (Math.NaN if (((a2 == Math.POSITIVE_INFINITY) or ((a2 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a2))
A_17 = -((Math.NaN if (((a2 == Math.POSITIVE_INFINITY) or ((a2 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a2)))
A_22 = 0
A_32 = 0
A_42 = (Math.NaN if (((a2 == Math.POSITIVE_INFINITY) or ((a2 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.sin(a2))
A_52 = (Math.NaN if (((a2 == Math.POSITIVE_INFINITY) or ((a2 == Math.NEGATIVE_INFINITY)))) else python_lib_Math.cos(a2))
A_62 = 0
A_72 = 0
A_82 = 0
A_92 = 0
A_102 = 1
A_112 = 0
A_122 = 0
A_132 = 0
A_142 = 0
A_152 = 1
m = [((((A_02 * (m[0] if 0 < len(m) else None)) + ((A_17 * (m[4] if 4 < len(m) else None)))) + ((A_22 * (m[8] if 8 < len(m) else None)))) + ((A_32 * (m[12] if 12 < len(m) else None)))), ((((A_02 * (m[1] if 1 < len(m) else None)) + ((A_17 * (m[5] if 5 < len(m) else None)))) + ((A_22 * (m[9] if 9 < len(m) else None)))) + ((A_32 * (m[13] if 13 < len(m) else None)))), ((((A_02 * (m[2] if 2 < len(m) else None)) + ((A_17 * (m[6] if 6 < len(m) else None)))) + ((A_22 * (m[10] if 10 < len(m) else None)))) + ((A_32 * (m[14] if 14 < len(m) else None)))), ((((A_02 * (m[3] if 3 < len(m) else None)) + ((A_17 * (m[7] if 7 < len(m) else None)))) + ((A_22 * (m[11] if 11 < len(m) else None)))) + ((A_32 * (m[15] if 15 < len(m) else None)))), ((((A_42 * (m[0] if 0 < len(m) else None)) + ((A_52 * (m[4] if 4 < len(m) else None)))) + ((A_62 * (m[8] if 8 < len(m) else None)))) + ((A_72 * (m[12] if 12 < len(m) else None)))), ((((A_42 * (m[1] if 1 < len(m) else None)) + ((A_52 * (m[5] if 5 < len(m) else None)))) + ((A_62 * (m[9] if 9 < len(m) else None)))) + ((A_72 * (m[13] if 13 < len(m) else None)))), ((((A_42 * (m[2] if 2 < len(m) else None)) + ((A_52 * (m[6] if 6 < len(m) else None)))) + ((A_62 * (m[10] if 10 < len(m) else None)))) + ((A_72 * (m[14] if 14 < len(m) else None)))), ((((A_42 * (m[3] if 3 < len(m) else None)) + ((A_52 * (m[7] if 7 < len(m) else None)))) + ((A_62 * (m[11] if 11 < len(m) else None)))) + ((A_72 * (m[15] if 15 < len(m) else None)))), ((((A_82 * (m[0] if 0 < len(m) else None)) + ((A_92 * (m[4] if 4 < len(m) else None)))) + ((A_102 * (m[8] if 8 < len(m) else None)))) + ((A_112 * (m[12] if 12 < len(m) else None)))), ((((A_82 * (m[1] if 1 < len(m) else None)) + ((A_92 * (m[5] if 5 < len(m) else None)))) + ((A_102 * (m[9] if 9 < len(m) else None)))) + ((A_112 * (m[13] if 13 < len(m) else None)))), ((((A_82 * (m[2] if 2 < len(m) else None)) + ((A_92 * (m[6] if 6 < len(m) else None)))) + ((A_102 * (m[10] if 10 < len(m) else None)))) + ((A_112 * (m[14] if 14 < len(m) else None)))), ((((A_82 * (m[3] if 3 < len(m) else None)) + ((A_92 * (m[7] if 7 < len(m) else None)))) + ((A_102 * (m[11] if 11 < len(m) else None)))) + ((A_112 * (m[15] if 15 < len(m) else None)))), ((((A_122 * (m[0] if 0 < len(m) else None)) + ((A_132 * (m[4] if 4 < len(m) else None)))) + ((A_142 * (m[8] if 8 < len(m) else None)))) + ((A_152 * (m[12] if 12 < len(m) else None)))), ((((A_122 * (m[1] if 1 < len(m) else None)) + ((A_132 * (m[5] if 5 < len(m) else None)))) + ((A_142 * (m[9] if 9 < len(m) else None)))) + ((A_152 * (m[13] if 13 < len(m) else None)))), ((((A_122 * (m[2] if 2 < len(m) else None)) + ((A_132 * (m[6] if 6 < len(m) else None)))) + ((A_142 * (m[10] if 10 < len(m) else None)))) + ((A_152 * (m[14] if 14 < len(m) else None)))), ((((A_122 * (m[3] if 3 < len(m) else None)) + ((A_132 * (m[7] if 7 < len(m) else None)))) + ((A_142 * (m[11] if 11 < len(m) else None)))) + ((A_152 * (m[15] if 15 < len(m) else None))))]
elif t.startswith("scale"):
A_03 = (nums[0] if 0 < len(nums) else None)
A_18 = 0
A_23 = 0
A_33 = 0
A_43 = 0
A_53 = (nums[1] if 1 < len(nums) else None)
A_63 = 0
A_73 = 0
A_83 = 0
A_93 = 0
A_103 = (nums[2] if 2 < len(nums) else None)
A_113 = 0
A_123 = 0
A_133 = 0
A_143 = 0
A_153 = 1
m = [((((A_03 * (m[0] if 0 < len(m) else None)) + ((A_18 * (m[4] if 4 < len(m) else None)))) + ((A_23 * (m[8] if 8 < len(m) else None)))) + ((A_33 * (m[12] if 12 < len(m) else None)))), ((((A_03 * (m[1] if 1 < len(m) else None)) + ((A_18 * (m[5] if 5 < len(m) else None)))) + ((A_23 * (m[9] if 9 < len(m) else None)))) + ((A_33 * (m[13] if 13 < len(m) else None)))), ((((A_03 * (m[2] if 2 < len(m) else None)) + ((A_18 * (m[6] if 6 < len(m) else None)))) + ((A_23 * (m[10] if 10 < len(m) else None)))) + ((A_33 * (m[14] if 14 < len(m) else None)))), ((((A_03 * (m[3] if 3 < len(m) else None)) + ((A_18 * (m[7] if 7 < len(m) else None)))) + ((A_23 * (m[11] if 11 < len(m) else None)))) + ((A_33 * (m[15] if 15 < len(m) else None)))), ((((A_43 * (m[0] if 0 < len(m) else None)) + ((A_53 * (m[4] if 4 < len(m) else None)))) + ((A_63 * (m[8] if 8 < len(m) else None)))) + ((A_73 * (m[12] if 12 < len(m) else None)))), ((((A_43 * (m[1] if 1 < len(m) else None)) + ((A_53 * (m[5] if 5 < len(m) else None)))) + ((A_63 * (m[9] if 9 < len(m) else None)))) + ((A_73 * (m[13] if 13 < len(m) else None)))), ((((A_43 * (m[2] if 2 < len(m) else None)) + ((A_53 * (m[6] if 6 < len(m) else None)))) + ((A_63 * (m[10] if 10 < len(m) else None)))) + ((A_73 * (m[14] if 14 < len(m) else None)))), ((((A_43 * (m[3] if 3 < len(m) else None)) + ((A_53 * (m[7] if 7 < len(m) else None)))) + ((A_63 * (m[11] if 11 < len(m) else None)))) + ((A_73 * (m[15] if 15 < len(m) else None)))), ((((A_83 * (m[0] if 0 < len(m) else None)) + ((A_93 * (m[4] if 4 < len(m) else None)))) + ((A_103 * (m[8] if 8 < len(m) else None)))) + ((A_113 * (m[12] if 12 < len(m) else None)))), ((((A_83 * (m[1] if 1 < len(m) else None)) + ((A_93 * (m[5] if 5 < len(m) else None)))) + ((A_103 * (m[9] if 9 < len(m) else None)))) + ((A_113 * (m[13] if 13 < len(m) else None)))), ((((A_83 * (m[2] if 2 < len(m) else None)) + ((A_93 * (m[6] if 6 < len(m) else None)))) + ((A_103 * (m[10] if 10 < len(m) else None)))) + ((A_113 * (m[14] if 14 < len(m) else None)))), ((((A_83 * (m[3] if 3 < len(m) else None)) + ((A_93 * (m[7] if 7 < len(m) else None)))) + ((A_103 * (m[11] if 11 < len(m) else None)))) + ((A_113 * (m[15] if 15 < len(m) else None)))), ((((A_123 * (m[0] if 0 < len(m) else None)) + ((A_133 * (m[4] if 4 < len(m) else None)))) + ((A_143 * (m[8] if 8 < len(m) else None)))) + ((A_153 * (m[12] if 12 < len(m) else None)))), ((((A_123 * (m[1] if 1 < len(m) else None)) + ((A_133 * (m[5] if 5 < len(m) else None)))) + ((A_143 * (m[9] if 9 < len(m) else None)))) + ((A_153 * (m[13] if 13 < len(m) else None)))), ((((A_123 * (m[2] if 2 < len(m) else None)) + ((A_133 * (m[6] if 6 < len(m) else None)))) + ((A_143 * (m[10] if 10 < len(m) else None)))) + ((A_153 * (m[14] if 14 < len(m) else None)))), ((((A_123 * (m[3] if 3 < len(m) else None)) + ((A_133 * (m[7] if 7 < len(m) else None)))) + ((A_143 * (m[11] if 11 < len(m) else None)))) + ((A_153 * (m[15] if 15 < len(m) else None))))]
elif t.startswith("translate"):
A_04 = 1
A_19 = 0
A_24 = 0
A_34 = (nums[0] if 0 < len(nums) else None)
A_44 = 0
A_54 = 1
A_64 = 0
A_74 = (nums[1] if 1 < len(nums) else None)
A_84 = 0
A_94 = 0
A_104 = 1
A_114 = (nums[2] if 2 < len(nums) else None)
A_124 = 0
A_134 = 0
A_144 = 0
A_154 = 1
m = [((((A_04 * (m[0] if 0 < len(m) else None)) + ((A_19 * (m[4] if 4 < len(m) else None)))) + ((A_24 * (m[8] if 8 < len(m) else None)))) + ((A_34 * (m[12] if 12 < len(m) else None)))), ((((A_04 * (m[1] if 1 < len(m) else None)) + ((A_19 * (m[5] if 5 < len(m) else None)))) + ((A_24 * (m[9] if 9 < len(m) else None)))) + ((A_34 * (m[13] if 13 < len(m) else None)))), ((((A_04 * (m[2] if 2 < len(m) else None)) + ((A_19 * (m[6] if 6 < len(m) else None)))) + ((A_24 * (m[10] if 10 < len(m) else None)))) + ((A_34 * (m[14] if 14 < len(m) else None)))), ((((A_04 * (m[3] if 3 < len(m) else None)) + ((A_19 * (m[7] if 7 < len(m) else None)))) + ((A_24 * (m[11] if 11 < len(m) else None)))) + ((A_34 * (m[15] if 15 < len(m) else None)))), ((((A_44 * (m[0] if 0 < len(m) else None)) + ((A_54 * (m[4] if 4 < len(m) else None)))) + ((A_64 * (m[8] if 8 < len(m) else None)))) + ((A_74 * (m[12] if 12 < len(m) else None)))), ((((A_44 * (m[1] if 1 < len(m) else None)) + ((A_54 * (m[5] if 5 < len(m) else None)))) + ((A_64 * (m[9] if 9 < len(m) else None)))) + ((A_74 * (m[13] if 13 < len(m) else None)))), ((((A_44 * (m[2] if 2 < len(m) else None)) + ((A_54 * (m[6] if 6 < len(m) else None)))) + ((A_64 * (m[10] if 10 < len(m) else None)))) + ((A_74 * (m[14] if 14 < len(m) else None)))), ((((A_44 * (m[3] if 3 < len(m) else None)) + ((A_54 * (m[7] if 7 < len(m) else None)))) + ((A_64 * (m[11] if 11 < len(m) else None)))) + ((A_74 * (m[15] if 15 < len(m) else None)))), ((((A_84 * (m[0] if 0 < len(m) else None)) + ((A_94 * (m[4] if 4 < len(m) else None)))) + ((A_104 * (m[8] if 8 < len(m) else None)))) + ((A_114 * (m[12] if 12 < len(m) else None)))), ((((A_84 * (m[1] if 1 < len(m) else None)) + ((A_94 * (m[5] if 5 < len(m) else None)))) + ((A_104 * (m[9] if 9 < len(m) else None)))) + ((A_114 * (m[13] if 13 < len(m) else None)))), ((((A_84 * (m[2] if 2 < len(m) else None)) + ((A_94 * (m[6] if 6 < len(m) else None)))) + ((A_104 * (m[10] if 10 < len(m) else None)))) + ((A_114 * (m[14] if 14 < len(m) else None)))), ((((A_84 * (m[3] if 3 < len(m) else None)) + ((A_94 * (m[7] if 7 < len(m) else None)))) + ((A_104 * (m[11] if 11 < len(m) else None)))) + ((A_114 * (m[15] if 15 < len(m) else None)))), ((((A_124 * (m[0] if 0 < len(m) else None)) + ((A_134 * (m[4] if 4 < len(m) else None)))) + ((A_144 * (m[8] if 8 < len(m) else None)))) + ((A_154 * (m[12] if 12 < len(m) else None)))), ((((A_124 * (m[1] if 1 < len(m) else None)) + ((A_134 * (m[5] if 5 < len(m) else None)))) + ((A_144 * (m[9] if 9 < len(m) else None)))) + ((A_154 * (m[13] if 13 < len(m) else None)))), ((((A_124 * (m[2] if 2 < len(m) else None)) + ((A_134 * (m[6] if 6 < len(m) else None)))) + ((A_144 * (m[10] if 10 < len(m) else None)))) + ((A_154 * (m[14] if 14 < len(m) else None)))), ((((A_124 * (m[3] if 3 < len(m) else None)) + ((A_134 * (m[7] if 7 < len(m) else None)))) + ((A_144 * (m[11] if 11 < len(m) else None)))) + ((A_154 * (m[15] if 15 < len(m) else None))))]
elif t.startswith("matrix"):
m = [(((((nums[0] if 0 < len(nums) else None) * (m[0] if 0 < len(m) else None)) + (((nums[1] if 1 < len(nums) else None) * (m[4] if 4 < len(m) else None)))) + (((nums[2] if 2 < len(nums) else None) * (m[8] if 8 < len(m) else None)))) + (((nums[3] if 3 < len(nums) else None) * (m[12] if 12 < len(m) else None)))), (((((nums[0] if 0 < len(nums) else None) * (m[1] if 1 < len(m) else None)) + (((nums[1] if 1 < len(nums) else None) * (m[5] if 5 < len(m) else None)))) + (((nums[2] if 2 < len(nums) else None) * (m[9] if 9 < len(m) else None)))) + (((nums[3] if 3 < len(nums) else None) * (m[13] if 13 < len(m) else None)))), (((((nums[0] if 0 < len(nums) else None) * (m[2] if 2 < len(m) else None)) + (((nums[1] if 1 < len(nums) else None) * (m[6] if 6 < len(m) else None)))) + (((nums[2] if 2 < len(nums) else None) * (m[10] if 10 < len(m) else None)))) + (((nums[3] if 3 < len(nums) else None) * (m[14] if 14 < len(m) else None)))), (((((nums[0] if 0 < len(nums) else None) * (m[3] if 3 < len(m) else None)) + (((nums[1] if 1 < len(nums) else None) * (m[7] if 7 < len(m) else None)))) + (((nums[2] if 2 < len(nums) else None) * (m[11] if 11 < len(m) else None)))) + (((nums[3] if 3 < len(nums) else None) * (m[15] if 15 < len(m) else None)))), (((((nums[4] if 4 < len(nums) else None) * (m[0] if 0 < len(m) else None)) + (((nums[5] if 5 < len(nums) else None) * (m[4] if 4 < len(m) else None)))) + (((nums[6] if 6 < len(nums) else None) * (m[8] if 8 < len(m) else None)))) + (((nums[7] if 7 < len(nums) else None) * (m[12] if 12 < len(m) else None)))), (((((nums[4] if 4 < len(nums) else None) * (m[1] if 1 < len(m) else None)) + (((nums[5] if 5 < len(nums) else None) * (m[5] if 5 < len(m) else None)))) + (((nums[6] if 6 < len(nums) else None) * (m[9] if 9 < len(m) else None)))) + (((nums[7] if 7 < len(nums) else None) * (m[13] if 13 < len(m) else None)))), (((((nums[4] if 4 < len(nums) else None) * (m[2] if 2 < len(m) else None)) + (((nums[5] if 5 < len(nums) else None) * (m[6] if 6 < len(m) else None)))) + (((nums[6] if 6 < len(nums) else None) * (m[10] if 10 < len(m) else None)))) + (((nums[7] if 7 < len(nums) else None) * (m[14] if 14 < len(m) else None)))), (((((nums[4] if 4 < len(nums) else None) * (m[3] if 3 < len(m) else None)) + (((nums[5] if 5 < len(nums) else None) * (m[7] if 7 < len(m) else None)))) + (((nums[6] if 6 < len(nums) else None) * (m[11] if 11 < len(m) else None)))) + (((nums[7] if 7 < len(nums) else None) * (m[15] if 15 < len(m) else None)))), (((((nums[8] if 8 < len(nums) else None) * (m[0] if 0 < len(m) else None)) + (((nums[9] if 9 < len(nums) else None) * (m[4] if 4 < len(m) else None)))) + (((nums[10] if 10 < len(nums) else None) * (m[8] if 8 < len(m) else None)))) + (((nums[11] if 11 < len(nums) else None) * (m[12] if 12 < len(m) else None)))), (((((nums[8] if 8 < len(nums) else None) * (m[1] if 1 < len(m) else None)) + (((nums[9] if 9 < len(nums) else None) * (m[5] if 5 < len(m) else None)))) + (((nums[10] if 10 < len(nums) else None) * (m[9] if 9 < len(m) else None)))) + (((nums[11] if 11 < len(nums) else None) * (m[13] if 13 < len(m) else None)))), (((((nums[8] if 8 < len(nums) else None) * (m[2] if 2 < len(m) else None)) + (((nums[9] if 9 < len(nums) else None) * (m[6] if 6 < len(m) else None)))) + (((nums[10] if 10 < len(nums) else None) * (m[10] if 10 < len(m) else None)))) + (((nums[11] if 11 < len(nums) else None) * (m[14] if 14 < len(m) else None)))), (((((nums[8] if 8 < len(nums) else None) * (m[3] if 3 < len(m) else None)) + (((nums[9] if 9 < len(nums) else None) * (m[7] if 7 < len(m) else None)))) + (((nums[10] if 10 < len(nums) else None) * (m[11] if 11 < len(m) else None)))) + (((nums[11] if 11 < len(nums) else None) * (m[15] if 15 < len(m) else None)))), (((((nums[12] if 12 < len(nums) else None) * (m[0] if 0 < len(m) else None)) + (((nums[13] if 13 < len(nums) else None) * (m[4] if 4 < len(m) else None)))) + (((nums[14] if 14 < len(nums) else None) * (m[8] if 8 < len(m) else None)))) + (((nums[15] if 15 < len(nums) else None) * (m[12] if 12 < len(m) else None)))), (((((nums[12] if 12 < len(nums) else None) * (m[1] if 1 < len(m) else None)) + (((nums[13] if 13 < len(nums) else None) * (m[5] if 5 < len(m) else None)))) + (((nums[14] if 14 < len(nums) else None) * (m[9] if 9 < len(m) else None)))) + (((nums[15] if 15 < len(nums) else None) * (m[13] if 13 < len(m) else None)))), (((((nums[12] if 12 < len(nums) else None) * (m[2] if 2 < len(m) else None)) + (((nums[13] if 13 < len(nums) else None) * (m[6] if 6 < len(m) else None)))) + (((nums[14] if 14 < len(nums) else None) * (m[10] if 10 < len(m) else None)))) + (((nums[15] if 15 < len(nums) else None) * (m[14] if 14 < len(m) else None)))), (((((nums[12] if 12 < len(nums) else None) * (m[3] if 3 < len(m) else None)) + (((nums[13] if 13 < len(nums) else None) * (m[7] if 7 < len(m) else None)))) + (((nums[14] if 14 < len(nums) else None) * (m[11] if 11 < len(m) else None)))) + (((nums[15] if 15 < len(nums) else None) * (m[15] if 15 < len(m) else None))))]
elif t.startswith("focal"):
render.setFocal((nums[0] if 0 < len(nums) else None))
elif t.startswith("auto"):
render.transform(m)
m = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
if (len(nums) == 0):
render.autoPlace()
else:
render.autoPlace((nums[0] if 0 < len(nums) else None),(nums[1] if 1 < len(nums) else None))
else:
print(str(("[warn] invalid transform expression: " + ("null" if t is None else t))))
render.transform(m)
if ((kwargs.h.get("--mode",None) != "edges") and ((kwargs.h.get("--mode",None) != "vertices"))):
if (kwargs.h.get("--cull",None) == "true"):
render.apparentRidges(Std.parseFloat(kwargs.h.get("--thresh",None)))
elif (kwargs.h.get("--cull",None) == "false"):
render.apparentRidges(Std.parseFloat(kwargs.h.get("--thresh",None)),-1)
else:
render.apparentRidges(Std.parseFloat(kwargs.h.get("--thresh",None)),Std.parseFloat(kwargs.h.get("--cull",None)))
if (verb > 0):
print("[info] generating output...")
out = ""
if (kwargs.h.get("--mode",None) == "edges"):
render.edges()
out = apparentridges_SVGWriter.lines(render)
elif (kwargs.h.get("--mode",None) == "vertices"):
render.vertices()
out = apparentridges_SVGWriter.lines(render)
elif (kwargs.h.get("--mode",None) == "lines"):
out = apparentridges_SVGWriter.lines(render)
elif (kwargs.h.get("--mode",None) == "polylines"):
render.buildPolylines()
out = apparentridges_SVGWriter.polylines(render)
elif (kwargs.h.get("--mode",None) == "gradients"):
render.buildPolylines()
out = apparentridges_SVGWriter.gradients(render)
elif (kwargs.h.get("--mode",None) == "pixels"):
if (verb > 0):
print("[info] making depth map...")
d = apparentridges_PixelMap.depth(render,True)
if (verb > 0):
print("[info] making ppm string...")
o = apparentridges_PixelMap.toPPMString(d,render.width,render.height,0,1)
p = (("null" if inp is None else inp) + ".depth.ppm")
sys_io_File.saveContent(p,o)
if (verb > 0):
print(str(("[info] wrote " + ("null" if p is None else p))))
if (verb > 0):
print("[info] making normal map...")
d = apparentridges_PixelMap.normal(render)
o = apparentridges_PixelMap.toPPMString(d,render.width,render.height,-1,1)
p = (("null" if inp is None else inp) + ".normal.ppm")
sys_io_File.saveContent(p,o)
if (verb > 0):
print(str(("[info] wrote " + ("null" if p is None else p))))
if (verb > 0):
print("[info] making curvature map...")
d = apparentridges_PixelMap.curvature(render)
o = apparentridges_PixelMap.toPPMString(d,render.width,render.height,-0.5,0.5)
p = (("null" if inp is None else inp) + ".curv.ppm")
sys_io_File.saveContent(p,o)
if (verb > 0):
print(str(("[info] wrote " + ("null" if p is None else p))))
continue
else:
print("[error] invalid mode")
return 1
if (verb > 0):
print("[info] writing file...")
path = kwargs.h.get("--output",None)
if (path == "stdout"):
_hx_str = Std.string(out)
python_Lib.printString((("" + ("null" if _hx_str is None else _hx_str)) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
else:
if (len(args) > 1):
path = (("null" if inp is None else inp) + ".svg")
sys_io_File.saveContent(path,out)
if (verb > 0):
print(str(("[info] wrote " + ("null" if path is None else path))))
if (verb > 0):
print("[info] all files processed.")
return 0
class Reflect:
_hx_class_name = "Reflect"
__slots__ = ()
_hx_statics = ["field"]
@staticmethod
def field(o,field):
return python_Boot.field(o,field)
class Std:
_hx_class_name = "Std"
__slots__ = ()
_hx_statics = ["isOfType", "string", "parseInt", "shortenPossibleNumber", "parseFloat"]
@staticmethod
def isOfType(v,t):
if ((v is None) and ((t is None))):
return False
if (t is None):
return False
if (t == Dynamic):
return (v is not None)
isBool = isinstance(v,bool)
if ((t == Bool) and isBool):
return True
if ((((not isBool) and (not (t == Bool))) and (t == Int)) and isinstance(v,int)):
return True
vIsFloat = isinstance(v,float)
tmp = None
tmp1 = None
if (((not isBool) and vIsFloat) and (t == Int)):
f = v
tmp1 = (((f != Math.POSITIVE_INFINITY) and ((f != Math.NEGATIVE_INFINITY))) and (not python_lib_Math.isnan(f)))
else:
tmp1 = False
if tmp1:
tmp1 = None
try:
tmp1 = int(v)
except BaseException as _g:
None
tmp1 = None
tmp = (v == tmp1)
else:
tmp = False
if ((tmp and ((v <= 2147483647))) and ((v >= -2147483648))):
return True
if (((not isBool) and (t == Float)) and isinstance(v,(float, int))):
return True
if (t == str):
return isinstance(v,str)
isEnumType = (t == Enum)
if ((isEnumType and python_lib_Inspect.isclass(v)) and hasattr(v,"_hx_constructs")):
return True
if isEnumType:
return False
isClassType = (t == Class)
if ((((isClassType and (not isinstance(v,Enum))) and python_lib_Inspect.isclass(v)) and hasattr(v,"_hx_class_name")) and (not hasattr(v,"_hx_constructs"))):
return True
if isClassType:
return False
tmp = None
try:
tmp = isinstance(v,t)
except BaseException as _g:
None
tmp = False
if tmp:
return True
if python_lib_Inspect.isclass(t):
cls = t
loop = None
def _hx_local_1(intf):
f = (intf._hx_interfaces if (hasattr(intf,"_hx_interfaces")) else [])
if (f is not None):
_g = 0
while (_g < len(f)):
i = (f[_g] if _g >= 0 and _g < len(f) else None)
_g = (_g + 1)
if (i == cls):
return True
else:
l = loop(i)
if l:
return True
return False
else:
return False
loop = _hx_local_1
currentClass = v.__class__
result = False
while (currentClass is not None):
if loop(currentClass):
result = True
break
currentClass = python_Boot.getSuperClass(currentClass)
return result
else:
return False
@staticmethod
def string(s):
return python_Boot.toString1(s,"")
@staticmethod
def parseInt(x):
if (x is None):
return None
try:
return int(x)
except BaseException as _g:
None
base = 10
_hx_len = len(x)
foundCount = 0
sign = 0
firstDigitIndex = 0
lastDigitIndex = -1
previous = 0
_g = 0
_g1 = _hx_len
while (_g < _g1):
i = _g
_g = (_g + 1)
c = (-1 if ((i >= len(x))) else ord(x[i]))
if (((c > 8) and ((c < 14))) or ((c == 32))):
if (foundCount > 0):
return None
continue
else:
c1 = c
if (c1 == 43):
if (foundCount == 0):
sign = 1
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (c1 == 45):
if (foundCount == 0):
sign = -1
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (c1 == 48):
if (not (((foundCount == 0) or (((foundCount == 1) and ((sign != 0))))))):
if (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif ((c1 == 120) or ((c1 == 88))):
if ((previous == 48) and ((((foundCount == 1) and ((sign == 0))) or (((foundCount == 2) and ((sign != 0))))))):
base = 16
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
elif (not (((48 <= c) and ((c <= 57))))):
if (not (((base == 16) and ((((97 <= c) and ((c <= 122))) or (((65 <= c) and ((c <= 90))))))))):
break
if (((foundCount == 0) and ((sign == 0))) or (((foundCount == 1) and ((sign != 0))))):
firstDigitIndex = i
foundCount = (foundCount + 1)
lastDigitIndex = i
previous = c
if (firstDigitIndex <= lastDigitIndex):
digits = HxString.substring(x,firstDigitIndex,(lastDigitIndex + 1))
try:
return (((-1 if ((sign == -1)) else 1)) * int(digits,base))
except BaseException as _g:
return None
return None
@staticmethod
def shortenPossibleNumber(x):
r = ""
_g = 0
_g1 = len(x)
while (_g < _g1):
i = _g
_g = (_g + 1)
c = ("" if (((i < 0) or ((i >= len(x))))) else x[i])
_g2 = HxString.charCodeAt(c,0)
if (_g2 is None):
break
else:
_g3 = _g2
if (((((((((((_g3 == 57) or ((_g3 == 56))) or ((_g3 == 55))) or ((_g3 == 54))) or ((_g3 == 53))) or ((_g3 == 52))) or ((_g3 == 51))) or ((_g3 == 50))) or ((_g3 == 49))) or ((_g3 == 48))) or ((_g3 == 46))):
r = (("null" if r is None else r) + ("null" if c is None else c))
else:
break
return r
@staticmethod
def parseFloat(x):
try:
return float(x)
except BaseException as _g:
None
if (x is not None):
r1 = Std.shortenPossibleNumber(x)
if (r1 != x):
return Std.parseFloat(r1)
return Math.NaN
class Float: pass
class Int: pass
class Bool: pass
class Dynamic: pass
class StringBuf:
_hx_class_name = "StringBuf"
__slots__ = ("b",)
_hx_fields = ["b"]
_hx_methods = ["get_length"]
def __init__(self):
self.b = python_lib_io_StringIO()
def get_length(self):
pos = self.b.tell()
self.b.seek(0,2)
_hx_len = self.b.tell()
self.b.seek(pos,0)
return _hx_len
class StringTools:
_hx_class_name = "StringTools"
__slots__ = ()
_hx_statics = ["isSpace", "ltrim", "rtrim", "trim", "rpad", "replace"]
@staticmethod
def isSpace(s,pos):
if (((len(s) == 0) or ((pos < 0))) or ((pos >= len(s)))):
return False
c = HxString.charCodeAt(s,pos)
if (not (((c > 8) and ((c < 14))))):
return (c == 32)
else:
return True
@staticmethod
def ltrim(s):
l = len(s)
r = 0
while ((r < l) and StringTools.isSpace(s,r)):
r = (r + 1)
if (r > 0):
return HxString.substr(s,r,(l - r))
else:
return s
@staticmethod
def rtrim(s):
l = len(s)
r = 0
while ((r < l) and StringTools.isSpace(s,((l - r) - 1))):
r = (r + 1)
if (r > 0):
return HxString.substr(s,0,(l - r))
else:
return s
@staticmethod
def trim(s):
return StringTools.ltrim(StringTools.rtrim(s))
@staticmethod
def rpad(s,c,l):
if (len(c) <= 0):
return s
buf = StringBuf()
s1 = Std.string(s)
buf.b.write(s1)
while (buf.get_length() < l):
s = Std.string(c)
buf.b.write(s)
return buf.b.getvalue()
@staticmethod
def replace(s,sub,by):
_this = (list(s) if ((sub == "")) else s.split(sub))
return by.join([python_Boot.toString1(x1,'') for x1 in _this])
class haxe_IMap:
_hx_class_name = "haxe.IMap"
__slots__ = ()
class haxe_ds_StringMap:
_hx_class_name = "haxe.ds.StringMap"
__slots__ = ("h",)
_hx_fields = ["h"]
_hx_methods = ["keys"]
_hx_interfaces = [haxe_IMap]
def __init__(self):
self.h = dict()
def keys(self):
return python_HaxeIterator(iter(self.h.keys()))
class python_HaxeIterator:
_hx_class_name = "python.HaxeIterator"
__slots__ = ("it", "x", "has", "checked")
_hx_fields = ["it", "x", "has", "checked"]
_hx_methods = ["next", "hasNext"]
def __init__(self,it):
self.checked = False
self.has = False
self.x = None
self.it = it
def next(self):
if (not self.checked):
self.hasNext()
self.checked = False
return self.x
def hasNext(self):
if (not self.checked):
try:
self.x = self.it.__next__()
self.has = True
except BaseException as _g:
None
if Std.isOfType(haxe_Exception.caught(_g).unwrap(),StopIteration):
self.has = False
self.x = None
else:
raise _g
self.checked = True
return self.has
class Sys:
_hx_class_name = "Sys"
__slots__ = ()
_hx_statics = ["args", "systemName"]
@staticmethod
def args():
argv = python_lib_Sys.argv
return argv[1:None]
@staticmethod
def systemName():
_g = python_lib_Sys.platform
x = _g
if x.startswith("linux"):
return "Linux"
else:
_g1 = _g
_hx_local_0 = len(_g1)
if (_hx_local_0 == 5):
if (_g1 == "win32"):
return "Windows"
else:
raise haxe_Exception.thrown("not supported platform")
elif (_hx_local_0 == 6):
if (_g1 == "cygwin"):
return "Windows"
elif (_g1 == "darwin"):
return "Mac"
else:
raise haxe_Exception.thrown("not supported platform")
else:
raise haxe_Exception.thrown("not supported platform")
class apparentridges_Util:
_hx_class_name = "apparentridges.Util"
__slots__ = ()
_hx_statics = ["rndInt", "min", "sq", "nextMod3", "prevMod3", "trinorm", "ldltdc", "ldltsl", "largestEig2x2", "matIden", "matRotx", "matRoty", "matRotz", "matTrsl", "matScal", "matMult", "matTrfm", "matProj", "uniformHemisphereSampler", "writeFile"]
@staticmethod
def rndInt(x):
x1 = Math.floor((x + 0.5))
try:
return int(x1)
except BaseException as _g:
None
return None
@staticmethod
def min(a,b):
if (a > b):
return b
else:
return a
@staticmethod
def sq(x):
return (x * x)
@staticmethod
def nextMod3(i):
if (i < 2):
return (i + 1)
else:
return (i - 2)
@staticmethod
def prevMod3(i):
if (i > 0):
return (i - 1)
else:
return (i + 2)
@staticmethod
def trinorm(v0,v1,v2):
_x = (v1[0] - v0[0])
_y = (v1[1] - v0[1])
_z = (v1[2] - v0[2])
this1 = [None]*3
this2 = this1
this2[0] = _x
this2[1] = _y
this2[2] = _z
v1 = this2
_x = (v2[0] - v0[0])
_y = (v2[1] - v0[1])
_z = (v2[2] - v0[2])
this1 = [None]*3
this2 = this1
this2[0] = _x
this2[1] = _y
this2[2] = _z
v2 = this2
_x = ((v1[1] * v2[2]) - ((v1[2] * v2[1])))
_y = ((v1[2] * v2[0]) - ((v1[0] * v2[2])))
_z = ((v1[0] * v2[1]) - ((v1[1] * v2[0])))
this1 = [None]*3
this2 = this1
this2[0] = _x
this2[1] = _y
this2[2] = _z
this1 = this2
_x = (this1[0] * 0.5)
_y = (this1[1] * 0.5)
_z = (this1[2] * 0.5)
this1 = [None]*3
this2 = this1
this2[0] = _x
this2[1] = _y
this2[2] = _z
return this2
@staticmethod
def ldltdc(A,rdiag):
N = len(rdiag)
if (N < 1):
return False
elif (N <= 3):
d0 = python_internal_ArrayImpl._get((A[0] if 0 < len(A) else None), 0)
python_internal_ArrayImpl._set(rdiag, 0, (1 / d0))
if (N == 1):
return (d0 != 0)
python_internal_ArrayImpl._set((A[1] if 1 < len(A) else None), 0, python_internal_ArrayImpl._get((A[0] if 0 < len(A) else None), 1))
l10 = ((rdiag[0] if 0 < len(rdiag) else None) * python_internal_ArrayImpl._get((A[1] if 1 < len(A) else None), 0))
d1 = (python_internal_ArrayImpl._get((A[1] if 1 < len(A) else None), 1) - ((l10 * python_internal_ArrayImpl._get((A[1] if 1 < len(A) else None), 0))))
python_internal_ArrayImpl._set(rdiag, 1, (1 / d1))
if (N == 2):
if (d0 != 0):
return (d1 != 0)
else:
return False
x = python_internal_ArrayImpl._get((A[2] if 2 < len(A) else None), 0)
x1 = python_internal_ArrayImpl._get((A[2] if 2 < len(A) else None), 1)
d2 = ((python_internal_ArrayImpl._get((A[2] if 2 < len(A) else None), 2) - (((rdiag[0] if 0 < len(rdiag) else None) * ((x * x))))) - (((rdiag[1] if 1 < len(rdiag) else None) * ((x1 * x1)))))
python_internal_ArrayImpl._set(rdiag, 2, (1 / d2))
python_internal_ArrayImpl._set((A[2] if 2 < len(A) else None), 0, python_internal_ArrayImpl._get((A[0] if 0 < len(A) else None), 2))
python_internal_ArrayImpl._set((A[2] if 2 < len(A) else None), 1, (python_internal_ArrayImpl._get((A[1] if 1 < len(A) else None), 2) - ((l10 * python_internal_ArrayImpl._get((A[2] if 2 < len(A) else None), 0)))))
if ((d0 != 0) and ((d1 != 0))):
return (d2 != 0)
else:
return False
v = []
_g = 0
_g1 = N
while (_g < _g1):
i = _g
_g = (_g + 1)
_g2 = 0
_g3 = i
while (_g2 < _g3):
k = _g2
_g2 = (_g2 + 1)
python_internal_ArrayImpl._set(v, k, (python_internal_ArrayImpl._get((A[i] if i >= 0 and i < len(A) else None), k) * (rdiag[k] if k >= 0 and k < len(rdiag) else None)))
_g4 = i
_g5 = N
while (_g4 < _g5):
j = _g4
_g4 = (_g4 + 1)
sum = python_internal_ArrayImpl._get((A[i] if i >= 0 and i < len(A) else None), j)
_g6 = 0
_g7 = i
while (_g6 < _g7):
k1 = _g6
_g6 = (_g6 + 1)
sum = (sum - (((v[k1] if k1 >= 0 and k1 < len(v) else None) * python_internal_ArrayImpl._get((A[j] if j >= 0 and j < len(A) else None), k1))))
if (i == j):
if (sum == 0):
return False
python_internal_ArrayImpl._set(rdiag, i, (1 / sum))
else:
python_internal_ArrayImpl._set((A[j] if j >= 0 and j < len(A) else None), i, sum)
return True
@staticmethod
def ldltsl(A,rdiag,b,x):
N = len(rdiag)
_g = 0
_g1 = N
while (_g < _g1):
i = _g
_g = (_g + 1)
sum = (b[i] if i >= 0 and i < len(b) else None)
_g2 = 0
_g3 = i
while (_g2 < _g3):
k = _g2
_g2 = (_g2 + 1)
sum = (sum - ((python_internal_ArrayImpl._get((A[i] if i >= 0 and i < len(A) else None), k) * (x[k] if k >= 0 and k < len(x) else None))))
python_internal_ArrayImpl._set(x, i, (sum * (rdiag[i] if i >= 0 and i < len(rdiag) else None)))
_g = 0
_g1 = N
while (_g < _g1):
_i = _g
_g = (_g + 1)
i = ((N - _i) - 1)
sum = 0
_g2 = (i + 1)
_g3 = N
while (_g2 < _g3):
k = _g2
_g2 = (_g2 + 1)
sum = (sum + ((python_internal_ArrayImpl._get((A[k] if k >= 0 and k < len(A) else None), i) * (x[k] if k >= 0 and k < len(x) else None))))
python_internal_ArrayImpl._set(x, i, ((x[i] if i >= 0 and i < len(x) else None) - ((sum * (rdiag[i] if i >= 0 and i < len(rdiag) else None)))))
@staticmethod
def largestEig2x2(m1,m12,m2):
l1 = (0.5 * ((m1 + m2)))
if (l1 > 0.0):
x = (m2 - m1)
v = ((m12 * m12) + ((0.25 * ((x * x)))))
l1 = (l1 + (Math.NaN if ((v < 0)) else python_lib_Math.sqrt(v)))
else:
x = (m2 - m1)
v = ((m12 * m12) + ((0.25 * ((x * x)))))
l1 = (l1 - (Math.NaN if ((v < 0)) else python_lib_Math.sqrt(v)))
_x = (m2 - l1)
_y = -m12
this1 = [None]*3
this2 = this1
this2[0] = _x
this2[1] = _y
this2[2] = 0
e1 = this2
v = (((e1[0] * e1[0]) + ((e1[1] * e1[1]))) + ((e1[2] * e1[2])))
l = (Math.NaN if ((v < 0)) else python_lib_Math.sqrt(v))
if (l > 0):
l = (1 / l)
_g = e1
v = (_g[0] * l)
_g[0] = v
_g = e1
v = (_g[1] * l)
_g[1] = v
_g = e1