UNPKG

@bitbybit-dev/base

Version:

Bit By Bit Developers Base CAD Library to Program Geometry

78 lines (77 loc) 3.79 kB
import * as Inputs from "../inputs"; import { Polyline } from "./polyline"; import { Vector } from "./vector"; /** * Contains various mesh helper methods that are not necessarily present in higher level CAD kernels that bitbybit is using. */ export declare class MeshBitByBit { private readonly vector; private readonly polyline; constructor(vector: Vector, polyline: Polyline); /** * Calculates signed distance from a point to a plane (positive=above plane, negative=below). * Example: point=[0,5,0], plane={normal:[0,1,0], d:0} → 5 (point is 5 units above XZ plane) * @param inputs a point and a plane * @returns signed distance * @group base * @shortname signed dist to plane * @drawable false */ signedDistanceToPlane(inputs: Inputs.Mesh.SignedDistanceFromPlaneToPointDto): number; /** * Calculates plane equation from triangle vertices (normal vector and distance from origin). * Returns undefined if triangle is degenerate (zero area, collinear points). * Example: triangle=[[0,0,0], [1,0,0], [0,1,0]] → {normal:[0,0,1], d:0} (XY plane) * @param inputs triangle and tolerance * @returns triangle plane * @group traingle * @shortname triangle plane * @drawable false */ calculateTrianglePlane(inputs: Inputs.Mesh.TriangleToleranceDto): Inputs.Base.TrianglePlane3 | undefined; /** * Calculates intersection segment of two triangles (line segment where they cross). * Returns undefined if triangles don't intersect, are parallel, or are coplanar. * Example: triangle1=[[0,0,0], [2,0,0], [1,2,0]], triangle2=[[1,-1,1], [1,1,1], [1,1,-1]] → [[1,0,0], [1,1,0]] * @param inputs first triangle, second triangle, and tolerance * @returns intersection segment or undefined if no intersection * @group traingle * @shortname triangle-triangle int * @drawable false */ triangleTriangleIntersection(inputs: Inputs.Mesh.TriangleTriangleToleranceDto): Inputs.Base.Segment3 | undefined; /** * Calculates all intersection segments between two triangle meshes (pairwise triangle tests). * Returns array of line segments where mesh surfaces intersect. * Example: cube mesh intersecting with sphere mesh → multiple segments forming intersection curve * @param inputs first mesh, second mesh, and tolerance * @returns array of intersection segments * @group mesh * @shortname mesh-mesh int segments * @drawable false */ meshMeshIntersectionSegments(inputs: Inputs.Mesh.MeshMeshToleranceDto): Inputs.Base.Segment3[]; /** * Calculates intersection polylines between two meshes by sorting segments into connected paths. * Segments are joined end-to-end to form continuous or closed curves. * Example: cube-sphere intersection → closed polyline loops where surfaces meet * @param inputs first mesh, second mesh, and tolerance * @returns array of intersection polylines * @group mesh * @shortname mesh-mesh int polylines * @drawable true */ meshMeshIntersectionPolylines(inputs: Inputs.Mesh.MeshMeshToleranceDto): Inputs.Base.Polyline3[]; /** * Calculates intersection points between two meshes as point arrays (one array per polyline). * Closed polylines have first point duplicated at end. * Example: cube-sphere intersection → arrays of points defining intersection curves * @param inputs first mesh, second mesh, and tolerance * @returns array of intersection points * @group mesh * @shortname mesh-mesh int points * @drawable false */ meshMeshIntersectionPoints(inputs: Inputs.Mesh.MeshMeshToleranceDto): Inputs.Base.Point3[][]; private computeIntersectionPoint; }