@achirita/blox
Version:
A CAD library for building 3D models in the browser.
216 lines (215 loc) • 8.75 kB
TypeScript
import { Edge, Vertex, Wire, Solid } from './index';
import { Vector } from '../math';
export class Face {
/**
* Creates a `Face` object from a wire.
* The wire must be closed and form a valid boundary for the face.
* @param {Wire} wire - The wire to create the face from.
* @returns {Face} a new `Face` object created from the given wire.
*/
static fromWire(wire: Wire): Face;
static TYPE: Readonly<{
Plane: "Plane";
Cylinder: "Cylinder";
Cone: "Cone";
Sphere: "Sphere";
Torus: "Torus";
BezierSurface: "BezierSurface";
BSplineSurface: "BSplineSurface";
SurfaceOfRevolution: "SurfaceOfRevolution";
SurfaceOfExtrusion: "SurfaceOfExtrusion";
OffsetSurface: "OffsetSurface";
OtherSurface: "OtherSurface";
}>;
static ORIENTATION: Readonly<{
Forward: "Forward";
Reversed: "Reversed";
Internal: "Internal";
External: "External";
}>;
constructor(wrapped: any);
/**
* Returns the wrapped OpenCascade object.
* @private
*/
private get wrapped();
/**
* Retrieves all edges of the face.
* @returns {Edge[]} An array of `Edge` objects representing the edges of the face.
*/
get edges(): Edge[];
/**
* Retrieves all vertices of the face.
* @returns {Vertex[]} An array of `Vertex` objects representing the vertices of the face.
*/
get vertices(): Vertex[];
/**
* Retrieves the outer wire (boundry) of the face.
* @returns {Wire} A `Wire` object representing the outer wire (boundry) of the face.
*/
get outerWire(): Wire;
/**
* Retrieves all inner wires (holes) of the face.
* @returns {Wire[]} An array of `Wire` objects representing the inner wires (holes) of the face.
*/
get innerWires(): Wire[];
/**
* Computes the normal vector of the face.
* @returns {Vector | undefined} The normal vector if the face is a plane, otherwise `undefined`.
*/
get normal(): Vector | undefined;
/**
* Computes the center of mass of the face.
* @returns {Vector} A `Vector` object representing the center of mass of the face.
*/
get centerOfMass(): Vector;
/**
* Computes the surface area of the face.
* @returns {number} The surface area of the face.
*/
get surfaceArea(): number;
/**
* Computes the x-direction vector of the face.
* @returns {Vector | undefined} The x-direction vector if the face is a plane, otherwise `undefined`.
*/
get xDirection(): Vector | undefined;
/**
* Determines the type of the face's surface.
* @returns {string} The type of the face's surface (e.g., "Plane", "Cylinder").
*/
get type(): string;
/**
* Determines the orientation of the face.
* @returns {string} The orientation ("Forward", "Reversed", "Internal", or "External").
*/
get orientation(): string;
/**
* Translates the face by a specified offset.
* @param {Vector} offset - The translation offset.
* @returns {Face} A new `Face` object representing the translated face.
*/
translate(offset: Vector): Face;
/**
* Rotates the face around a specified axis by a given angle.
* @param {Object} parameters - Rotation parameters.
* @param {Axis} parameters.axis - The axis to rotate around.
* @param {number} parameters.angle - The rotation angle in radians.
* @returns {Face} A new `Face` object representing the rotated face.
*/
rotate({ axis, angle }: {
axis: Axis;
angle: number;
}): Face;
/**
* Mirrors the face across a specified plane.
* @param {Plane} plane - The plane to mirror across.
* @returns {Face} A new `Face` object representing the mirrored face.
*/
mirror(plane: Plane): Face;
/**
* Scales the face by a specified factor.
* @param {number} factor - The scaling factor.
* @returns {Face} A new `Face` object representing the scaled face.
*/
scale(factor: number): Face;
/**
* Splits the face into multiple parts using a specified plane.
* @param {Plane} plane - The plane to split the face with.
* @returns {Face[]} An array of `Face` objects representing the split parts.
*/
split(plane: Plane): Face[];
/**
* Cuts the face using one or more tools (other faces).
* @param {...Face} tools - One or more `Face` objects to use as cutting tools.
* @returns {Face[]} An array of `Face` objects representing the result.
*/
cut(...tools: Face[]): Face[];
/**
* Intersects the face with one or more tools (other faces).
* @param {...Face} tools - One or more `Face` objects to intersect with.
* @returns {Face[]} An array of `Face` objects representing the result.
*/
intersect(...tools: Face[]): Face[];
/**
* Joins the face with one or more tools (other faces).
* @param {...Face} tools - One or more `Face` objects to join with.
* @returns {Face[]} An array of `Face` objects representing the result.
*/
join(...tools: Face[]): Face[];
/**
* Applies a fillet (rounded edge) to selected vertices of the face.
* @param {Object} parameters - Fillet parameters.
* @param {function(Vertex): boolean} parameters.selector - A function to select vertices for the fillet.
* @param {number} parameters.radius - The radius of the fillet.
* @returns {Face} A new `Face` object with the fillet applied.
*/
fillet({ selector, radius }: {
selector: (arg0: Vertex) => boolean;
radius: number;
}): Face;
/**
* Applies a chamfer (beveled edge) to selected vertices of the face.
* @param {Object} parameters - Chamfer parameters.
* @param {function(Edge): boolean} parameters.selector - A function to select vertices for the chamfer.
* @param {number} parameters.distance - The distance of the chamfer.
* @returns {Face} A new `Face` object with the chamfer applied.
*/
chamfer({ selector, distance }: {
selector: (arg0: Edge) => boolean;
distance: number;
}): Face;
/**
* Extrudes the face by a specified distance to create a 3D solid.
* @param {number} distance - The extrusion distance.
* @returns {Solid} A new `Solid` object representing the extruded face.
*/
extrude(distance: number): Solid;
/**
* Revolves the face around a specified axis by a given angle to create a 3D solid.
* @param {Object} parameters - Revolution parameters.
* @param {Axis} parameters.axis - The axis to revolve around.
* @param {number} parameters.angle - The revolution angle in radians.
* @returns {Solid} A new `Solid` object representing the revolved face.
*/
revolve({ axis, angle }: {
axis: Axis;
angle: number;
}): Solid;
/**
* Offsets the face's outline by a specified distance. Face holes are also offset by a specified distance.
* @param {Object} parameters - Offset parameters.
* @param {number} parameters.distance - The offset distance for the face outline.
* @param {number} [parameters.holeDistance=0] - The offset distance for the face holes.
* @param {('arc'|'tangent'|'intersection')} [parameters.joinType="tangent"] - The join type for the offset.
* @returns {Face} A new `Face` object representing the offset face.
*/
offset({ distance, holeDistance, joinType }: {
distance: number;
holeDistance?: number;
joinType?: ("arc" | "tangent" | "intersection");
}): Face;
/**
* Reverses the orientation of the face.
* @returns {Face} A new `Face` object with the reversed orientation.
*/
reverse(): Face;
/**
* Checks if the face is parallel to the given direction. Only applicable for planar faces.
* @param {Vector} direction - The direction vector to test.
* @returns {boolean|undefined} `true` if the face is parallel to the direction, `false` otherwise, or `undefined` if not a planar face.
*/
isParallel(direction: Vector): boolean | undefined;
/**
* Checks if the face is perpendicular to the given direction. Only applicable for planar faces.
* @param {Vector} direction - The direction vector to test.
* @returns {boolean|undefined} `true` if the face is perpendicular to the direction, `false` otherwise, or `undefined` if not a planar face.
*/
isPerpendicular(direction: Vector): boolean | undefined;
/**
* Computes the hash code for the face.
* @returns {number} The hash code.
* @private
*/
private hashCode;
#private;
}