flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
78
BACK_BACK/node_modules/d3-octree/src/octree.js
generated
vendored
Executable file
78
BACK_BACK/node_modules/d3-octree/src/octree.js
generated
vendored
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
import tree_add, {addAll as tree_addAll} from "./add.js";
|
||||
import tree_cover from "./cover.js";
|
||||
import tree_data from "./data.js";
|
||||
import tree_extent from "./extent.js";
|
||||
import tree_find from "./find.js";
|
||||
import tree_remove, {removeAll as tree_removeAll} from "./remove.js";
|
||||
import tree_root from "./root.js";
|
||||
import tree_size from "./size.js";
|
||||
import tree_visit from "./visit.js";
|
||||
import tree_visitAfter from "./visitAfter.js";
|
||||
import tree_x, {defaultX} from "./x.js";
|
||||
import tree_y, {defaultY} from "./y.js";
|
||||
import tree_z, {defaultZ} from "./z.js";
|
||||
|
||||
export default function octree(nodes, x, y, z) {
|
||||
var tree = new Octree(x == null ? defaultX : x, y == null ? defaultY : y, z == null ? defaultZ : z, NaN, NaN, NaN, NaN, NaN, NaN);
|
||||
return nodes == null ? tree : tree.addAll(nodes);
|
||||
}
|
||||
|
||||
function Octree(x, y, z, x0, y0, z0, x1, y1, z1) {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._z = z;
|
||||
this._x0 = x0;
|
||||
this._y0 = y0;
|
||||
this._z0 = z0;
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._z1 = z1;
|
||||
this._root = undefined;
|
||||
}
|
||||
|
||||
function leaf_copy(leaf) {
|
||||
var copy = {data: leaf.data}, next = copy;
|
||||
while (leaf = leaf.next) next = next.next = {data: leaf.data};
|
||||
return copy;
|
||||
}
|
||||
|
||||
var treeProto = octree.prototype = Octree.prototype;
|
||||
|
||||
treeProto.copy = function() {
|
||||
var copy = new Octree(this._x, this._y, this._z, this._x0, this._y0, this._z0, this._x1, this._y1, this._z1),
|
||||
node = this._root,
|
||||
nodes,
|
||||
child;
|
||||
|
||||
if (!node) return copy;
|
||||
|
||||
if (!node.length) return copy._root = leaf_copy(node), copy;
|
||||
|
||||
nodes = [{source: node, target: copy._root = new Array(8)}];
|
||||
while (node = nodes.pop()) {
|
||||
for (var i = 0; i < 8; ++i) {
|
||||
if (child = node.source[i]) {
|
||||
if (child.length) nodes.push({source: child, target: node.target[i] = new Array(8)});
|
||||
else node.target[i] = leaf_copy(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
treeProto.add = tree_add;
|
||||
treeProto.addAll = tree_addAll;
|
||||
treeProto.cover = tree_cover;
|
||||
treeProto.data = tree_data;
|
||||
treeProto.extent = tree_extent;
|
||||
treeProto.find = tree_find;
|
||||
treeProto.remove = tree_remove;
|
||||
treeProto.removeAll = tree_removeAll;
|
||||
treeProto.root = tree_root;
|
||||
treeProto.size = tree_size;
|
||||
treeProto.visit = tree_visit;
|
||||
treeProto.visitAfter = tree_visitAfter;
|
||||
treeProto.x = tree_x;
|
||||
treeProto.y = tree_y;
|
||||
treeProto.z = tree_z;
|
||||
Loading…
Add table
Add a link
Reference in a new issue