@bitbybit-dev/manifold-worker
Version:
Bit By Bit Developers Manifold Based CAD Library to Program Geometry Via WebWorker
216 lines (215 loc) • 8.12 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
* Thanks Manifold community for developing this kernel
*/
export class ManifoldEvaluate {
constructor(manifoldWorkerManager) {
this.manifoldWorkerManager = manifoldWorkerManager;
}
/**
* Get surface area of manifold
* @param inputs manifold
* @returns surface area of manifold
* @group basic
* @shortname surface area
* @drawable false
*/
surfaceArea(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.surfaceArea", inputs);
});
}
/**
* Get volume of manifold
* @param inputs manifold
* @returns volume of manifold
* @group basic
* @shortname volume
* @drawable false
*/
volume(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.volume", inputs);
});
}
/**
* Check if manifold contains triangles
* @param inputs manifold
* @returns boolean indicating emptyness
* @group basic
* @shortname is empty
* @drawable false
*/
isEmpty(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.isEmpty", inputs);
});
}
/**
* Get number of vertices in manifold
* @param inputs manifold
* @returns number of vertices of manifold
* @group basic
* @shortname num vert
* @drawable false
*/
numVert(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.numVert", inputs);
});
}
/**
* Get number of triangles in manifold
* @param inputs manifold
* @returns number of triangles of manifold
* @group basic
* @shortname num triangles
* @drawable false
*/
numTri(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.numTri", inputs);
});
}
/**
* Get number of edges in manifold
* @param inputs manifold
* @returns number of edges of manifold
* @group basic
* @shortname num edges
* @drawable false
*/
numEdge(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.numEdge", inputs);
});
}
/**
* Get number of properties in manifold
* @param inputs manifold
* @returns number of properties of manifold
* @group basic
* @shortname num prop
* @drawable false
*/
numProp(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.numProp", inputs);
});
}
/**
* The number of property vertices in the Manifold. This will always be >=
* numVert, as some physical vertices may be duplicated to account for
* different properties on different neighboring triangles.
* @param inputs manifold
* @returns number of properties of manifold
* @group basic
* @shortname num prop vert
* @drawable false
*/
numPropVert(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.numPropVert", inputs);
});
}
/**
* Returns the axis-aligned bounding box of all the Manifold's vertices.
* @param inputs manifold
* @returns bounding box corner vectors of manifold
* @group basic
* @shortname bounding box
* @drawable false
*/
boundingBox(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.boundingBox", inputs);
});
}
/**
* Returns the tolerance of this Manifold's vertices, which tracks the
* approximate rounding error over all the transforms and operations that have
* led to this state. Any triangles that are colinear within this tolerance
* are considered degenerate and removed. This is the value of ε
* defining
* [ε-valid](https://github.com/elalish/manifold/wiki/Manifold-Library#definition-of-%CE%B5-valid).
* @param inputs manifold
* @returns tolerance of manifold
* @group basic
* @shortname tolerance
* @drawable false
*/
tolerance(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.tolerance", inputs);
});
}
/**
* The genus is a topological property of the manifold, representing the
* number of handles. A sphere is 0, torus 1, etc. It is only meaningful for
* a single mesh, so it is best to call Decompose() first.
* @param inputs manifold
* @returns genus of manifold
* @group basic
* @shortname genus
* @drawable false
*/
genus(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.genus", inputs);
});
}
/**
* Returns the minimum gap between two manifolds. Returns a float between
* 0 and searchLength.
* @param inputs two manifolds and search length
* @returns minimum
* @group basic
* @shortname min gap
* @drawable false
*/
minGap(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.minGap", inputs);
});
}
/**
* If this mesh is an original, this returns its ID that can be referenced
* by product manifolds. If this manifold is a product, this
* returns -1.
* @param inputs manifold
* @returns original id of manifold
* @group basic
* @shortname original id
* @drawable false
*/
originalID(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.originalID", inputs);
});
}
/**
* Returns the reason for an input Mesh producing an empty Manifold. This
* Status will carry on through operations like NaN propogation, ensuring an
* errored mesh doesn't get mysteriously lost. Empty meshes may still show
* NoError, for instance the intersection of non-overlapping meshes.
* @param inputs manifold
* @returns error status string (NoError, NotManifold, InvalidConstruction, etc.)
* @group basic
* @shortname status
* @drawable false
*/
status(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("manifold.evaluate.status", inputs);
});
}
}