|
@@ -14,7 +14,7 @@ import { Box3D, Sphere3D } from '../geometry';
|
|
|
const boundaryHelperCoarse = new BoundaryHelper('14');
|
|
|
const boundaryHelperFine = new BoundaryHelper('98');
|
|
|
function getBoundaryHelper(count: number) {
|
|
|
- return count > 100_000 ? boundaryHelperCoarse : boundaryHelperFine;
|
|
|
+ return count > 10_000 ? boundaryHelperCoarse : boundaryHelperFine;
|
|
|
}
|
|
|
|
|
|
export type Boundary = { readonly box: Box3D, readonly sphere: Sphere3D }
|
|
@@ -22,16 +22,17 @@ export type Boundary = { readonly box: Box3D, readonly sphere: Sphere3D }
|
|
|
export function getBoundary(data: PositionData): Boundary {
|
|
|
const { x, y, z, radius, indices } = data;
|
|
|
const p = Vec3();
|
|
|
+ const n = OrderedSet.size(indices);
|
|
|
|
|
|
- const boundaryHelper = getBoundaryHelper(OrderedSet.size(indices));
|
|
|
+ const boundaryHelper = getBoundaryHelper(n);
|
|
|
boundaryHelper.reset();
|
|
|
- for (let t = 0, _t = OrderedSet.size(indices); t < _t; t++) {
|
|
|
+ for (let t = 0; t < n; t++) {
|
|
|
const i = OrderedSet.getAt(indices, t);
|
|
|
Vec3.set(p, x[i], y[i], z[i]);
|
|
|
boundaryHelper.includePositionRadius(p, (radius && radius[i]) || 0);
|
|
|
}
|
|
|
boundaryHelper.finishedIncludeStep();
|
|
|
- for (let t = 0, _t = OrderedSet.size(indices); t < _t; t++) {
|
|
|
+ for (let t = 0; t < n; t++) {
|
|
|
const i = OrderedSet.getAt(indices, t);
|
|
|
Vec3.set(p, x[i], y[i], z[i]);
|
|
|
boundaryHelper.radiusPositionRadius(p, (radius && radius[i]) || 0);
|
|
@@ -39,9 +40,9 @@ export function getBoundary(data: PositionData): Boundary {
|
|
|
|
|
|
const sphere = boundaryHelper.getSphere();
|
|
|
|
|
|
- if (!radius && OrderedSet.size(indices) <= 98) {
|
|
|
+ if (!radius && Sphere3D.hasExtrema(sphere) && n <= sphere.extrema.length) {
|
|
|
const extrema: Vec3[] = [];
|
|
|
- for (let t = 0, _t = OrderedSet.size(indices); t < _t; t++) {
|
|
|
+ for (let t = 0; t < n; t++) {
|
|
|
const i = OrderedSet.getAt(indices, t);
|
|
|
extrema.push(Vec3.create(x[i], y[i], z[i]));
|
|
|
}
|