-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuglymol.js
8686 lines (7290 loc) · 257 KB
/
uglymol.js
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
/*!
* UglyMol v0.7.0. Macromolecular Viewer for Crystallographers.
* Copyright 2014 Nat Echols
* Copyright 2016 Diamond Light Source Ltd
* Copyright 2016 Marcin Wojdyr
* Released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UM = {}));
})(this, (function (exports) { 'use strict';
var VERSION = exports.VERSION = '0.7.0';
// @flow
var UnitCell = function UnitCell(a /*:number*/, b /*:number*/, c /*:number*/,
alpha /*:number*/, beta /*:number*/, gamma /*:number*/) {
if (a <= 0 || b <= 0 || c <= 0 || alpha <= 0 || beta <= 0 || gamma <= 0) {
throw Error('Zero or negative unit cell parameter(s).');
}
this.parameters = [a, b, c, alpha, beta, gamma];
var deg2rad = Math.PI / 180.0;
var cos_alpha = Math.cos(deg2rad * alpha);
var cos_beta = Math.cos(deg2rad * beta);
var cos_gamma = Math.cos(deg2rad * gamma);
var sin_alpha = Math.sin(deg2rad * alpha);
var sin_beta = Math.sin(deg2rad * beta);
var sin_gamma = Math.sin(deg2rad * gamma);
if (sin_alpha === 0 || sin_beta === 0 || sin_gamma === 0) {
throw Error('Impossible angle - N*180deg.');
}
var cos_alpha_star_sin_beta = (cos_beta * cos_gamma - cos_alpha) /
sin_gamma;
var cos_alpha_star = cos_alpha_star_sin_beta / sin_beta;
var s1rca2 = Math.sqrt(1.0 - cos_alpha_star * cos_alpha_star);
// The orthogonalization matrix we use is described in ITfC B p.262:
// "An alternative mode of orthogonalization, used by the Protein
// Data Bank and most programs, is to align the a1 axis of the unit
// cell with the Cartesian X_1 axis, and to align the a*_3 axis with the
// Cartesian X_3 axis."
//
// Zeros in the matrices below are kept to make matrix multiplication
// faster: they make extract_block() 2x (!) faster on V8 4.5.103,
// no difference on FF 50.
/* eslint-disable no-multi-spaces, comma-spacing */
this.orth = [a, b * cos_gamma,c * cos_beta,
0.0, b * sin_gamma, -c * cos_alpha_star_sin_beta,
0.0, 0.0 ,c * sin_beta * s1rca2];
// based on xtal.js which is based on cctbx.uctbx
this.frac = [
1.0 / a,
-cos_gamma / (sin_gamma * a),
-(cos_gamma * cos_alpha_star_sin_beta + cos_beta * sin_gamma) /
(sin_beta * s1rca2 * sin_gamma * a),
0.0,
1.0 / (sin_gamma * b),
cos_alpha_star / (s1rca2 * sin_gamma * b),
0.0,
0.0,
1.0 / (sin_beta * s1rca2 * c) ];
};
UnitCell.prototype.fractionalize = function fractionalize (xyz /*:[number,number,number]*/) {
return multiply(xyz, this.frac);
};
UnitCell.prototype.orthogonalize = function orthogonalize (xyz /*:[number,number,number]*/) {
return multiply(xyz, this.orth);
};
// This function is only used with matrices frac and orth, which have 3 zeros.
// We skip these elements, but it doesn't affect performance (on FF50 and V8).
function multiply(xyz, mat) {
/* eslint-disable indent */
return [mat[0] * xyz[0] + mat[1] * xyz[1] + mat[2] * xyz[2],
/*mat[3] * xyz[0]*/+ mat[4] * xyz[1] + mat[5] * xyz[2],
/*mat[6] * xyz[0] + mat[7] * xyz[1]*/+ mat[8] * xyz[2]];
}
// @flow
/*::
type Num3 = [number, number, number];
*/
var AMINO_ACIDS = [
'ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HIS', 'ILE', 'LEU',
'LYS', 'MET', 'MSE', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL', 'UNK' ];
var NUCLEIC_ACIDS = [
'DA', 'DC', 'DG', 'DT', 'A', 'C', 'G', 'U', 'rA', 'rC', 'rG', 'rU',
'Ar', 'Cr', 'Gr', 'Ur' ];
var NOT_LIGANDS = ['HOH'].concat(AMINO_ACIDS, NUCLEIC_ACIDS);
function modelsFromPDB(pdb_string/*:string*/) {
var models = [new Model()];
var pdb_tail = models[0].from_pdb(pdb_string.split('\n'));
while (pdb_tail != null) {
var model = new Model();
pdb_tail = model.from_pdb(pdb_tail);
if (model.atoms.length > 0) { models.push(model); }
}
return models;
}
var Model = function Model() {
this.atoms = [];
this.unit_cell = null;
this.space_group = null;
this.has_hydrogens = false;
this.lower_bound = [0, 0, 0];
this.upper_bound = [0, 0, 0];
this.residue_map = null;
this.cubes = null;
};
Model.prototype.from_pdb = function from_pdb (pdb_lines /*:string[]*/) /*:?string[]*/ {
var chain_index = 0;// will be ++'ed for the first atom
var last_chain = null;
var atom_i_seq = 0;
var continuation = null;
for (var i = 0; i < pdb_lines.length; i++) {
var line = pdb_lines[i];
var rec_type = line.substring(0, 6).toUpperCase();
if (rec_type === 'ATOM ' || rec_type === 'HETATM') {
var new_atom = new Atom();
new_atom.from_pdb_line(line);
new_atom.i_seq = atom_i_seq++;
if (!this.has_hydrogens && new_atom.element === 'H') {
this.has_hydrogens = true;
}
if (new_atom.chain !== last_chain) {
chain_index++;
}
new_atom.chain_index = chain_index;
last_chain = new_atom.chain;
this.atoms.push(new_atom);
} else if (rec_type === 'ANISOU') ; else if (rec_type === 'CRYST1') {
var a = parseFloat(line.substring(6, 15));
var b = parseFloat(line.substring(15, 24));
var c = parseFloat(line.substring(24, 33));
var alpha = parseFloat(line.substring(33, 40));
var beta = parseFloat(line.substring(40, 47));
var gamma = parseFloat(line.substring(47, 54));
//const sg_symbol = line.substring(55, 66);
this.unit_cell = new UnitCell(a, b, c, alpha, beta, gamma);
} else if (rec_type.substring(0, 3) === 'TER') {
last_chain = null;
} else if (rec_type === 'ENDMDL') {
for (; i < pdb_lines.length; i++) {
if (pdb_lines[i].substring(0, 6).toUpperCase() === 'MODEL ') {
continuation = pdb_lines.slice(i);
break;
}
}
break;
}
}
if (this.atoms.length === 0) { throw Error('No atom records found.'); }
this.calculate_bounds();
this.calculate_connectivity();
return continuation;
};
Model.prototype.calculate_bounds = function calculate_bounds () {
var lower = this.lower_bound = [Infinity, Infinity, Infinity];
var upper = this.upper_bound = [-Infinity, -Infinity, -Infinity];
for (var i = 0; i < this.atoms.length; i++) {
var atom = this.atoms[i];
for (var j = 0; j < 3; j++) {
var v = atom.xyz[j];
if (v < lower[j]) { lower[j] = v; }
if (v > upper[j]) { upper[j] = v; }
}
}
// with a margin
for (var k = 0; k < 3; ++k) {
lower[k] -= 0.001;
upper[k] += 0.001;
}
};
Model.prototype.next_residue = function next_residue (atom /*:?Atom*/, backward /*:?boolean*/) {
var len = this.atoms.length;
var start = (atom ? atom.i_seq : 0) + len;// +len to avoid idx<0 below
for (var i = (atom ? 1 : 0); i < len; i++) {
var idx = (start + (backward ? -i : i)) % len;
var a = this.atoms[idx];
if (!a.is_main_conformer()) { continue; }
if ((a.name === 'CA' && a.element === 'C') || a.name === 'P') {
return a;
}
}
};
Model.prototype.extract_trace = function extract_trace () {
var segments = [];
var current_segment = [];
var last_atom = null;
for (var i = 0; i < this.atoms.length; i++) {
var atom = this.atoms[i];
if (atom.altloc !== '' && atom.altloc !== 'A') { continue; }
if ((atom.name === 'CA' && atom.element === 'C') || atom.name === 'P') {
var start_new = true;
if (last_atom !== null && last_atom.chain_index === atom.chain_index) {
var dxyz2 = atom.distance_sq(last_atom);
if ((atom.name === 'CA' && dxyz2 <= 5.5*5.5) ||
(atom.name === 'P' && dxyz2 < 7.5*7.5)) {
current_segment.push(atom);
start_new = false;
}
}
if (start_new) {
if (current_segment.length > 2) {
segments.push(current_segment);
}
current_segment = [atom];
}
last_atom = atom;
}
}
if (current_segment.length > 2) {
segments.push(current_segment);
}
//console.log(segments.length + " segments extracted");
return segments;
};
Model.prototype.get_residues = function get_residues () {
if (this.residue_map != null) { return this.residue_map; }
var residues = {};
for (var i = 0; i < this.atoms.length; i++) {
var atom = this.atoms[i];
var resid = atom.resid();
var reslist = residues[resid];
if (reslist === undefined) {
residues[resid] = [atom];
} else {
reslist.push(atom);
}
}
this.residue_map = residues;
return residues;
};
// tangent vector to the ribbon representation
Model.prototype.calculate_tangent_vector = function calculate_tangent_vector (residue /*:Atom[]*/) {
var a1 = null;
var a2 = null;
// it may be too simplistic
var peptide = (residue[0].resname.length === 3);
var name1 = peptide ? 'C' : 'C2\'';
var name2 = peptide ? 'O' : 'O4\'';
for (var i = 0; i < residue.length; i++) {
var atom = residue[i];
if (!atom.is_main_conformer()) { continue; }
if (atom.name === name1) {
a1 = atom.xyz;
} else if (atom.name === name2) {
a2 = atom.xyz;
}
}
if (a1 === null || a2 === null) { return [0, 0, 1]; } // arbitrary value
var d = [a1[0]-a2[0], a1[1]-a2[1], a1[2]-a2[2]];
var len = Math.sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
return [d[0]/len, d[1]/len, d[2]/len];
};
Model.prototype.get_center = function get_center () {
var xsum = 0, ysum = 0, zsum = 0;// eslint-disable-line
var n_atoms = this.atoms.length;
for (var i = 0; i < n_atoms; i++) {
var xyz = this.atoms[i].xyz;
xsum += xyz[0];
ysum += xyz[1];
zsum += xyz[2];
}
return [xsum / n_atoms, ysum / n_atoms, zsum / n_atoms];
};
Model.prototype.calculate_connectivity = function calculate_connectivity () {
var atoms = this.atoms;
var cubes = new Cubicles(atoms, 3.0, this.lower_bound, this.upper_bound);
//let cnt = 0;
for (var i = 0; i < cubes.boxes.length; i++) {
var box = cubes.boxes[i];
if (box.length === 0) { continue; }
var nearby_atoms = cubes.get_nearby_atoms(i);
for (var a = 0; a < box.length; a++) {
var atom_id = box[a];
for (var k = 0; k < nearby_atoms.length; k++) {
var j = nearby_atoms[k];
if (j > atom_id && atoms[atom_id].is_bonded_to(atoms[j])) {
atoms[atom_id].bonds.push(j);
atoms[j].bonds.push(atom_id);
//cnt++;
}
}
}
}
//console.log(atoms.length + ' atoms, ' + cnt + ' bonds.');
this.cubes = cubes;
};
Model.prototype.get_nearest_atom = function get_nearest_atom (x /*:number*/, y /*:number*/, z /*:number*/,
atom_name /*:?string*/) {
var cubes = this.cubes;
if (cubes == null) { throw Error('Missing Cubicles'); }
var box_id = cubes.find_box_id(x, y, z);
var indices = cubes.get_nearby_atoms(box_id);
var nearest = null;
var min_d2 = Infinity;
for (var i = 0; i < indices.length; i++) {
var atom = this.atoms[indices[i]];
if (atom_name != null && atom_name !== atom.name) { continue; }
var dx = atom.xyz[0] - x;
var dy = atom.xyz[1] - y;
var dz = atom.xyz[2] - z;
var d2 = dx*dx + dy*dy + dz*dz;
if (d2 < min_d2) {
nearest = atom;
min_d2 = d2;
}
}
return nearest;
};
// Single atom and associated labels
var Atom = function Atom() {
this.hetero = false;
this.name = '';
this.altloc = '';
this.resname = '';
this.chain = '';
this.chain_index = -1;
this.resseq = -1;
this.icode = null;
this.xyz = [0, 0, 0];
this.occ = 1.0;
this.b = 0;
this.element = '';
this.i_seq = -1;
this.is_ligand = null;
this.bonds = [];
};
// http://www.wwpdb.org/documentation/format33/sect9.html#ATOM
Atom.prototype.from_pdb_line = function from_pdb_line (pdb_line /*:string*/) {
if (pdb_line.length < 66) {
throw Error('ATOM or HETATM record is too short: ' + pdb_line);
}
var rec_type = pdb_line.substring(0, 6);
if (rec_type === 'HETATM') {
this.hetero = true;
} else if (rec_type !== 'ATOM ') {
throw Error('Wrong record type: ' + rec_type);
}
this.name = pdb_line.substring(12, 16).trim();
this.altloc = pdb_line.substring(16, 17).trim();
this.resname = pdb_line.substring(17, 20).trim();
this.chain = pdb_line.substring(20, 22).trim();
this.resseq = parseInt(pdb_line.substring(22, 26), 10);
this.icode = pdb_line.substring(26, 27).trim();
var x = parseFloat(pdb_line.substring(30, 38));
var y = parseFloat(pdb_line.substring(38, 46));
var z = parseFloat(pdb_line.substring(46, 54));
this.xyz = [x, y, z];
this.occ = parseFloat(pdb_line.substring(54, 60));
this.b = parseFloat(pdb_line.substring(60, 66));
if (pdb_line.length >= 78) {
this.element = pdb_line.substring(76, 78).trim().toUpperCase();
}
//if (pdb_line.length >= 80) {
//this.charge = pdb_line.substring(78, 80).trim();
//}
this.is_ligand = (NOT_LIGANDS.indexOf(this.resname) === -1);
};
Atom.prototype.b_as_u = function b_as_u () {
// B = 8 * pi^2 * u^2
return Math.sqrt(this.b / (8 * 3.14159 * 3.14159));
};
Atom.prototype.distance_sq = function distance_sq (other /*:Atom*/) {
var dx = this.xyz[0] - other.xyz[0];
var dy = this.xyz[1] - other.xyz[1];
var dz = this.xyz[2] - other.xyz[2];
return dx*dx + dy*dy + dz*dz;
};
Atom.prototype.distance = function distance (other /*:Atom*/) {
return Math.sqrt(this.distance_sq(other));
};
Atom.prototype.midpoint = function midpoint (other /*:Atom*/) {
return [(this.xyz[0] + other.xyz[0]) / 2,
(this.xyz[1] + other.xyz[1]) / 2,
(this.xyz[2] + other.xyz[2]) / 2];
};
Atom.prototype.is_hydrogen = function is_hydrogen () {
return this.element === 'H' || this.element === 'D';
};
Atom.prototype.is_ion = function is_ion () {
return this.element === this.resname;
};
Atom.prototype.is_water = function is_water () {
return this.resname === 'HOH';
};
Atom.prototype.is_same_residue = function is_same_residue (other /*:Atom*/, ignore_altloc /*:?boolean*/) {
return other.resseq === this.resseq && other.icode === this.icode &&
other.chain === this.chain && other.resname === this.resname &&
(ignore_altloc || other.altloc === this.altloc);
};
Atom.prototype.is_same_conformer = function is_same_conformer (other /*:Atom*/) {
return this.altloc === '' || other.altloc === '' ||
this.altloc === other.altloc;
};
Atom.prototype.is_main_conformer = function is_main_conformer () {
return this.altloc === '' || this.altloc === 'A';
};
Atom.prototype.bond_radius = function bond_radius () { // rather crude
if (this.element === 'H') { return 1.3; }
if (this.element === 'S' || this.element === 'P') { return 2.43; }
return 1.99;
};
Atom.prototype.is_bonded_to = function is_bonded_to (other /*:Atom*/) {
var MAX_DIST = 2.2 * 2.2;
if (!this.is_same_conformer(other)) { return false; }
var dxyz2 = this.distance_sq(other);
if (dxyz2 > MAX_DIST) { return false; }
if (this.element === 'H' && other.element === 'H') { return false; }
return dxyz2 <= this.bond_radius() * other.bond_radius();
};
Atom.prototype.resid = function resid () {
return this.resseq + '/' + this.chain;
};
Atom.prototype.long_label = function long_label () {
var a = this;
return a.name + ' /' + a.resseq + ' ' + a.resname + '/' + a.chain +
' - occ: ' + a.occ.toFixed(2) + ' bf: ' + a.b.toFixed(2) +
' ele: ' + a.element + ' pos: (' + a.xyz[0].toFixed(2) + ',' +
a.xyz[1].toFixed(2) + ',' + a.xyz[2].toFixed(2) + ')';
};
Atom.prototype.short_label = function short_label () {
var a = this;
return a.name + ' /' + a.resseq + ' ' + a.resname + '/' + a.chain;
};
/*:: export type AtomT = Atom; */
// Partition atoms into boxes for quick neighbor searching.
var Cubicles = function Cubicles(atoms/*:Atom[]*/, box_length/*:number*/,
lower_bound/*:Num3*/, upper_bound/*:Num3*/) {
this.boxes = [];
this.box_length = box_length;
this.lower_bound = lower_bound;
this.upper_bound = upper_bound;
this.xdim = Math.ceil((upper_bound[0] - lower_bound[0]) / box_length);
this.ydim = Math.ceil((upper_bound[1] - lower_bound[1]) / box_length);
this.zdim = Math.ceil((upper_bound[2] - lower_bound[2]) / box_length);
//console.log("Cubicles: " + this.xdim + "x" + this.ydim + "x" + this.zdim);
var nxyz = this.xdim * this.ydim * this.zdim;
for (var j = 0; j < nxyz; j++) {
this.boxes.push([]);
}
for (var i = 0; i < atoms.length; i++) {
var xyz = atoms[i].xyz;
var box_id = this.find_box_id(xyz[0], xyz[1], xyz[2]);
if (box_id === null) {
throw Error('wrong cubicle');
}
this.boxes[box_id].push(i);
}
};
Cubicles.prototype.find_box_id = function find_box_id (x/*:number*/, y/*:number*/, z/*:number*/) {
var xstep = Math.floor((x - this.lower_bound[0]) / this.box_length);
var ystep = Math.floor((y - this.lower_bound[1]) / this.box_length);
var zstep = Math.floor((z - this.lower_bound[2]) / this.box_length);
var box_id = (zstep * this.ydim + ystep) * this.xdim + xstep;
if (box_id < 0 || box_id >= this.boxes.length) { throw Error('Ups!'); }
return box_id;
};
Cubicles.prototype.get_nearby_atoms = function get_nearby_atoms (box_id/*:number*/) {
var indices = [];
var xydim = this.xdim * this.ydim;
var uv = Math.max(box_id % xydim, 0);
var u = Math.max(uv % this.xdim, 0);
var v = Math.floor(uv / this.xdim);
var w = Math.floor(box_id / xydim);
console.assert((w * xydim) + (v * this.xdim) + u === box_id);
for (var iu = u-1; iu <= u+1; iu++) {
if (iu < 0 || iu >= this.xdim) { continue; }
for (var iv = v-1; iv <= v+1; iv++) {
if (iv < 0 || iv >= this.ydim) { continue; }
for (var iw = w-1; iw <= w+1; iw++) {
if (iw < 0 || iw >= this.zdim) { continue; }
var other_box_id = (iw * xydim) + (iv * this.xdim) + iu;
if (other_box_id >= this.boxes.length || other_box_id < 0) {
throw Error('Box out of bounds: ID ' + other_box_id);
}
var box = this.boxes[other_box_id];
for (var i = 0; i < box.length; i++) {
indices.push(box[i]);
}
}
}
}
return indices;
};
// @flow
/*:: type Num3 = [number, number, number] */
var Block = function Block() {
this._points = null;
this._values = null;
this._size = [0, 0, 0];
};
Block.prototype.set = function set (points /*:Num3[]*/, values/*:number[]*/, size/*:Num3*/) {
if (size[0] <= 0 || size[1] <= 0 || size[2] <= 0) {
throw Error('Grid dimensions are zero along at least one edge');
}
var len = size[0] * size[1] * size[2];
if (values.length !== len || points.length !== len) {
throw Error('isosurface: array size mismatch');
}
this._points = points;
this._values = values;
this._size = size;
};
Block.prototype.clear = function clear () {
this._points = null;
this._values = null;
};
Block.prototype.empty = function empty () /*:boolean*/ {
return this._values === null;
};
Block.prototype.isosurface = function isosurface (isolevel /*: number*/, method /*: string*/) {
//if (method === 'marching tetrahedra') {
//return marchingTetrahedra(block, isolevel);
//}
return marchingCubes(this._size, this._values, this._points,
isolevel, method);
};
/* eslint comma-spacing: 0, no-multi-spaces: 0 */
var edgeTable = new Int32Array([
0x0 , 0x0 , 0x202, 0x302, 0x406, 0x406, 0x604, 0x704,
0x804, 0x805, 0xa06, 0xa06, 0xc0a, 0xd03, 0xe08, 0xf00,
0x90 , 0x98 , 0x292, 0x292, 0x496, 0x49e, 0x694, 0x694,
0x894, 0x894, 0xa96, 0xa96, 0xc9a, 0xc92, 0xe91, 0xe90,
0x230, 0x230, 0x33 , 0x13a, 0x636, 0x636, 0x434, 0x43c,
0xa34, 0xa35, 0x837, 0x936, 0xe3a, 0xf32, 0xc31, 0xd30,
0x2a0, 0x2a8, 0xa3 , 0xaa , 0x6a6, 0x6af, 0x5a4, 0x4ac,
0xaa4, 0xaa4, 0x9a6, 0x8a6, 0xfaa, 0xea3, 0xca1, 0xca0,
0x460, 0x460, 0x662, 0x762, 0x66 , 0x66 , 0x265, 0x364,
0xc64, 0xc65, 0xe66, 0xe66, 0x86a, 0x863, 0xa69, 0xa60,
0x4f0, 0x4f8, 0x6f2, 0x6f2, 0xf6 , 0xfe , 0x2f5, 0x2fc,
0xcf4, 0xcf4, 0xef6, 0xef6, 0x8fa, 0x8f3, 0xaf9, 0xaf0,
0x650, 0x650, 0x453, 0x552, 0x256, 0x256, 0x54 , 0x154,
0xe54, 0xf54, 0xc57, 0xd56, 0xa5a, 0xb52, 0x859, 0x950,
0x7c0, 0x6c1, 0x5c2, 0x4c2, 0x3c6, 0x2ce, 0xc5 , 0xc4 ,
0xfc4, 0xec5, 0xdc6, 0xcc6, 0xbca, 0xac2, 0x8c1, 0x8c0,
0x8c0, 0x8c0, 0xac2, 0xbc2, 0xcc6, 0xcc6, 0xec4, 0xfcc,
0xc4 , 0xc5 , 0x2c6, 0x3c6, 0x4c2, 0x5c2, 0x6c1, 0x7c0,
0x950, 0x859, 0xb52, 0xa5a, 0xd56, 0xc57, 0xe54, 0xe5c,
0x154, 0x54 , 0x25e, 0x256, 0x552, 0x453, 0x658, 0x650,
0xaf0, 0xaf0, 0x8f3, 0x8fa, 0xef6, 0xef6, 0xcf4, 0xcfc,
0x2f4, 0x3f5, 0xff , 0x1f6, 0x6f2, 0x6f3, 0x4f9, 0x5f0,
0xa60, 0xa69, 0x863, 0x86a, 0xe66, 0xe67, 0xd65, 0xc6c,
0x364, 0x265, 0x166, 0x66 , 0x76a, 0x663, 0x460, 0x460,
0xca0, 0xca0, 0xea2, 0xfa2, 0x8a6, 0x8a6, 0xaa4, 0xba4,
0x4ac, 0x5a4, 0x6ae, 0x7a6, 0xaa , 0xa3 , 0x2a8, 0x2a0,
0xd30, 0xc31, 0xf32, 0xe3a, 0x936, 0x837, 0xb35, 0xa34,
0x43c, 0x434, 0x73e, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xe90, 0xc92, 0xc9a, 0xa96, 0xa96, 0x894, 0x89c,
0x694, 0x695, 0x49f, 0x496, 0x292, 0x392, 0x98 , 0x90 ,
0xf00, 0xe08, 0xd03, 0xc0a, 0xa06, 0xa0e, 0x805, 0x804,
0x704, 0x604, 0x506, 0x406, 0x302, 0x202, 0x0 , 0x0]);
// generated from classical triTable by tools/isolut.py
var segTable = [
[],
[],
[1, 9],
[1, 8, 1, 9],
[2, 10, 10, 1],
[2, 10, 10, 1],
[9, 2, 2, 10, 10, 9],
[2, 8, 2, 10, 10, 8, 10, 9],
[11, 2],
[0, 11, 11, 2],
[1, 9, 11, 2],
[1, 11, 11, 2, 1, 9, 9, 11],
[3, 10, 10, 1, 11, 10],
[0, 10, 10, 1, 8, 10, 11, 10],
[3, 9, 11, 9, 11, 10, 10, 9],
[8, 10, 10, 9, 11, 10],
[4, 7],
[4, 3, 4, 7],
[1, 9, 4, 7],
[4, 1, 1, 9, 4, 7, 7, 1],
[2, 10, 10, 1, 4, 7],
[3, 4, 4, 7, 2, 10, 10, 1],
[9, 2, 2, 10, 10, 9, 4, 7],
[2, 10, 10, 9, 9, 2, 9, 7, 7, 2, 4, 7],
[4, 7, 11, 2],
[11, 4, 4, 7, 11, 2, 2, 4],
[1, 9, 4, 7, 11, 2],
[4, 7, 11, 4, 11, 9, 11, 2, 2, 9, 1, 9],
[3, 10, 10, 1, 11, 10, 4, 7],
[1, 11, 11, 10, 10, 1, 1, 4, 4, 11, 4, 7],
[4, 7, 0, 11, 11, 9, 11, 10, 10, 9],
[4, 7, 11, 4, 11, 9, 11, 10, 10, 9],
[9, 5, 5, 4],
[9, 5, 5, 4],
[0, 5, 5, 4, 1, 5],
[8, 5, 5, 4, 3, 5, 1, 5],
[2, 10, 10, 1, 9, 5,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 5, 9],
[4, 5, 5, 9],
[4, 11, 7, 4, 9, 11, 9, 10, 10, 11],
[9, 7, 7, 4, 9, 11, 9, 10, 10, 11],
[1, 10, 10, 11, 11, 1, 11, 4, 4, 1, 7, 4],
[1, 4, 4, 3, 1, 10, 10, 4, 7, 4, 4, 11, 10, 11],
[4, 11, 7, 4, 9, 11, 9, 2, 2, 11, 9, 1],
[9, 7, 7, 4, 9, 11, 9, 1, 1, 11, 2, 11],
[7, 4, 4, 11, 4, 2, 2, 11],
[7, 4, 4, 11, 4, 2, 2, 11, 3, 4],
[2, 9, 9, 10, 10, 2, 2, 7, 7, 9, 7, 4],
[9, 10, 10, 7, 7, 9, 7, 4, 10, 2, 2, 7, 7, 0],
[7, 10, 10, 3, 10, 2, 7, 4, 4, 10, 1, 10, 10, 0],
[1, 10, 10, 2, 7, 4],
[9, 1, 1, 4, 1, 7, 7, 4],
[9, 1, 1, 4, 1, 7, 7, 4, 8, 1],
[3, 4, 7, 4],
[7, 4],
[9, 10, 10, 8, 10, 11],
[9, 3, 9, 11, 9, 10, 10, 11],
[1, 10, 10, 0, 10, 8, 10, 11],
[1, 10, 10, 3, 10, 11],
[2, 11, 11, 1, 11, 9, 9, 1],
[9, 3, 9, 11, 2, 9, 9, 1, 2, 11],
[2, 11, 11, 0],
[2, 11],
[8, 2, 8, 10, 10, 2, 9, 10],
[9, 10, 10, 2, 2, 9],
[8, 2, 8, 10, 10, 2, 1, 8, 1, 10],
[1, 10, 10, 2],
[8, 1, 9, 1],
[9, 1],
[],
[]];
var segTable2 = [
[],
[],
[1, 9],
[1, 9],
[2, 10, 10, 1],
[2, 10, 10, 1],
[2, 10, 10, 9],
[2, 10, 10, 9],
[11, 2],
[11, 2],
[1, 9, 11, 2],
[11, 2, 1, 9],
[10, 1, 11, 10],
[10, 1, 11, 10],
[11, 10, 10, 9],
[10, 9, 11, 10],
[4, 7],
[4, 7],
[1, 9, 4, 7],
[1, 9, 4, 7],
[2, 10, 10, 1, 4, 7],
[4, 7, 2, 10, 10, 1],
[2, 10, 10, 9, 4, 7],
[2, 10, 10, 9, 4, 7],
[4, 7, 11, 2],
[4, 7, 11, 2],
[1, 9, 4, 7, 11, 2],
[4, 7, 11, 2, 1, 9],
[10, 1, 11, 10, 4, 7],
[11, 10, 10, 1, 4, 7],
[4, 7, 11, 10, 10, 9],
[4, 7, 11, 10, 10, 9],
[9, 5, 5, 4],
[9, 5, 5, 4],
[5, 4, 1, 5],
[5, 4, 1, 5],
[2, 10, 10, 1, 9, 5, 5, 4],
[2, 10, 10, 1, 9, 5, 5, 4],
[2, 10, 10, 5, 5, 4],
[2, 10, 10, 5, 5, 4],
[9, 5, 5, 4, 11, 2],
[11, 2, 9, 5, 5, 4],
[5, 4, 1, 5, 11, 2],
[1, 5, 11, 2, 5, 4],
[11, 10, 10, 1, 9, 5, 5, 4],
[9, 5, 5, 4, 10, 1, 11, 10],
[5, 4, 11, 10, 10, 5],
[5, 4, 10, 5, 11, 10],
[5, 7, 9, 5],
[9, 5, 5, 7],
[1, 5, 5, 7],
[1, 5, 5, 7],
[9, 5, 5, 7, 10, 1, 2, 10],
[10, 1, 2, 10, 9, 5, 5, 7],
[5, 7, 10, 5, 2, 10],
[2, 10, 10, 5, 5, 7],
[9, 5, 5, 7, 11, 2],
[9, 5, 5, 7, 11, 2],
[11, 2, 1, 5, 5, 7],
[11, 2, 1, 5, 5, 7],
[9, 5, 5, 7, 10, 1, 11, 10],
[5, 7, 9, 5, 10, 1, 11, 10],
[11, 10, 10, 5, 5, 7],
[11, 10, 10, 5, 5, 7],
[10, 6, 6, 5, 5, 10],
[5, 10, 10, 6, 6, 5],
[1, 9, 5, 10, 10, 6, 6, 5],
[1, 9, 5, 10, 10, 6, 6, 5],
[6, 5, 5, 1, 2, 6],
[6, 5, 5, 1, 2, 6],
[6, 5, 5, 9, 2, 6],
[5, 9, 2, 6, 6, 5],
[11, 2, 10, 6, 6, 5, 5, 10],
[11, 2, 10, 6, 6, 5, 5, 10],
[1, 9, 11, 2, 5, 10, 10, 6, 6, 5],
[5, 10, 10, 6, 6, 5, 1, 9, 11, 2],
[11, 6, 6, 5, 5, 1],
[5, 1, 11, 6, 6, 5],
[11, 6, 6, 5, 5, 9],
[6, 5, 5, 9, 11, 6],
[5, 10, 10, 6, 6, 5, 4, 7],
[4, 7, 6, 5, 5, 10, 10, 6],
[1, 9, 5, 10, 10, 6, 6, 5, 4, 7],
[10, 6, 6, 5, 5, 10, 1, 9, 4, 7],
[2, 6, 6, 5, 5, 1, 4, 7],
[5, 1, 2, 6, 6, 5, 4, 7],
[4, 7, 5, 9, 6, 5, 2, 6],
[4, 7, 5, 9, 6, 5, 2, 6],
[11, 2, 4, 7, 10, 6, 6, 5, 5, 10],
[5, 10, 10, 6, 6, 5, 4, 7, 11, 2],
[1, 9, 4, 7, 11, 2, 5, 10, 10, 6, 6, 5],
[1, 9, 11, 2, 4, 7, 5, 10, 10, 6, 6, 5],
[4, 7, 5, 1, 11, 6, 6, 5],
[5, 1, 11, 6, 6, 5, 4, 7],
[5, 9, 6, 5, 11, 6, 4, 7],
[6, 5, 5, 9, 11, 6, 4, 7],
[9, 10, 6, 4, 10, 6],
[10, 6, 6, 4, 9, 10],
[1, 10, 10, 6, 6, 4],
[6, 4, 1, 10, 10, 6],
[9, 1, 2, 6, 6, 4],
[9, 1, 2, 6, 6, 4],
[2, 6, 6, 4],
[2, 6, 6, 4],
[9, 10, 10, 6, 6, 4, 11, 2],
[11, 2, 9, 10, 10, 6, 6, 4],
[11, 2, 6, 4, 1, 10, 10, 6],
[6, 4, 1, 10, 10, 6, 11, 2],
[6, 4, 9, 1, 11, 6],
[11, 6, 9, 1, 6, 4],
[11, 6, 6, 4],
[6, 4, 11, 6],
[10, 6, 6, 7, 9, 10],
[9, 10, 6, 7, 10, 6],
[10, 6, 6, 7, 1, 10],
[10, 6, 6, 7, 1, 10],
[2, 6, 9, 1, 6, 7],
[2, 6, 9, 1, 6, 7],
[6, 7, 2, 6],
[6, 7, 2, 6],
[11, 2, 10, 6, 9, 10, 6, 7],
[11, 2, 6, 7, 10, 6, 9, 10],
[1, 10, 6, 7, 10, 6, 11, 2],
[11, 2, 10, 6, 1, 10, 6, 7],
[6, 7, 9, 1, 11, 6],
[9, 1, 11, 6, 6, 7],
[6, 7, 11, 6],
[11, 6, 6, 7],
[7, 6, 6, 11],
[7, 6, 6, 11],
[1, 9, 7, 6, 6, 11],
[1, 9, 7, 6, 6, 11],
[10, 1, 2, 10, 6, 11, 7, 6],
[2, 10, 10, 1, 6, 11, 7, 6],
[2, 10, 10, 9, 6, 11, 7, 6],
[6, 11, 7, 6, 2, 10, 10, 9],