Bitbybit Docs
    Preparing search index...

    Class OCCTOperations

    The modeling operations that turn OpenCascade wires and faces into surfaces and solids and measure shapes: lofting through sections, extruding and revolving, sweeping profiles along paths, offsetting, thickening shells into solids, slicing and splitting, plus bounding boxes, bounding spheres and closest-point queries. Distances are in model units and angles in degrees; every operation returns a new shape. Booleans live in booleans, rounding in fillets.

    Index

    Constructors

    closest pts

    • Finds the pair of points, one on each shape, that are closest to each other.

      The distance between them is the gap between the shapes; it is 0 when they touch or overlap. Throws an error when no pair can be found.

      Parameters

      Returns Promise<Point3[]>

      The point on the first shape and the point on the second

      const [onBox, onSphere] = await bitbybit.occt.operations.closestPointsBetweenTwoShapes({ shape1: box, shape2: sphere });
      
    • Finds, for each point in a list, the closest point on a shape.

      A point already on the shape maps to itself. Useful for snapping points onto a surface.

      Parameters

      Returns Promise<Point3[]>

      One point on the shape per input point, in the same order

      const snapped = await bitbybit.occt.operations.closestPointsOnShapeFromPoints({ shape: sphere, points: [[0, 20, 0], [20, 0, 0]] });
      
    • Finds the closest point on each of several shapes for each point in a list.

      The result is one flat list: all the points for the first shape, in point order, then all the points for the second shape, and so on.

      Parameters

      Returns Promise<Point3[]>

      The closest points, grouped shape by shape

      const snapped = await bitbybit.occt.operations.closestPointsOnShapesFromPoints({ shapes: [box, sphere], points: [[0, 20, 0], [20, 0, 0]] });
      

    divisions

    • Cuts a shape into pieces with other shapes, the way a knife splits a loaf, without removing any material.

      With nonDestructive true, the default, the inputs are left untouched and the result holds the pieces of every shape involved, the cutters included; with false only the pieces of shape come back. localFuzzyTolerance lets geometry that nearly touches count as touching.

      Parameters

      Returns Promise<TopoDSShapePointer[]>

      The pieces

      const pieces = await bitbybit.occt.operations.splitShapeWithShapes({ shape: box, shapes: [cuttingPlane], localFuzzyTolerance: 1e-4, nonDestructive: false });
      
    • Cuts a solid into parallel slices along a direction, like a loaf of bread, every step model units from the bottom of the shape up.

      Each slice is the flat section where a cutting plane meets the solid; they come back together in one compound. The shape must be or contain solids, or an error is thrown.

      Parameters

      Returns Promise<TopoDSCompoundPointer>

      A compound of the section faces

      const layers = await bitbybit.occt.operations.slice({ shape: sphere, step: 0.5, direction: [0, 1, 0] });
      
    • Cuts a solid into parallel slices like slice, but with a repeating pattern of gaps between them, such as 0.1, 0.5, 0.1, 0.5.

      The pattern is applied from the bottom of the shape up and repeats until the top is reached.

      Parameters

      Returns Promise<TopoDSCompoundPointer>

      A compound of the section faces

      const layers = await bitbybit.occt.operations.sliceInStepPattern({ shape: sphere, steps: [0.1, 0.5], direction: [0, 1, 0] });
      

    extrusions

    • Sweeps a shape in a straight line along a vector, whose length is the distance: a face becomes a solid, a wire a shell, an edge a face.

      The shape itself stays at the start of the extrusion; the vector is in model units, so [0, 10, 0] extrudes 10 units up.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The extruded shape

      const disc = await bitbybit.occt.shapes.face.createCircleFace({ radius: 5, center: [0, 0, 0], direction: [0, 1, 0] });
      const cylinder = await bitbybit.occt.operations.extrude({ shape: disc, direction: [0, 10, 0] });
    • Sweeps several shapes along the same vector, as extrude does for one.

      Parameters

      Returns Promise<TopoDSShapePointer[]>

      The extruded shapes, in the same order

      const walls = await bitbybit.occt.operations.extrudeShapes({ shapes: [faceA, faceB], direction: [0, 10, 0] });
      
    • Extrudes a flat shape up along Y by height while twisting it by angle degrees about the Y axis, like a twisted column.

      The shape should lie flat, as the profiles this package creates do. With makeSolid true, the default, a face profile gives a closed solid; a wire gives a twisted shell.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The twisted extrusion

      const square = await bitbybit.occt.shapes.face.createSquareFace({ size: 5, center: [0, 0, 0], direction: [0, 1, 0] });
      const twisted = await bitbybit.occt.operations.rotatedExtrude({ shape: square, height: 20, angle: 90, makeSolid: true });

    lofts

    • Builds a surface through a series of wires, like skin stretched over ribs: each wire is one section and the surface passes through them in list order.

      Edges are accepted as single-edge wires. With makeSolid true and closed sections the result is capped into a solid; otherwise it is a shell. Sections match up best with equal edge counts.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The lofted shell or solid

      const bottom = await bitbybit.occt.shapes.wire.createCircleWire({ radius: 5, center: [0, 0, 0], direction: [0, 1, 0] });
      const upper = await bitbybit.occt.shapes.wire.createSquareWire({ size: 6, center: [0, 10, 0], direction: [0, 1, 0] });
      const vase = await bitbybit.occt.operations.loft({ shapes: [bottom, upper], makeSolid: true });
    • Builds a surface through a series of wires like loft, with control over how the skin is fitted.

      straight makes ruled patches between sections instead of a smooth blend; closed loops the surface from the last section back to the first, and periodic makes that loop smooth by resampling the sections. startVertex and endVertex close the ends to points.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The lofted shell or solid

      const cone = await bitbybit.occt.operations.loftAdvanced({
      shapes: [circleBottom, circleMiddle],
      makeSolid: true,
      closed: false,
      periodic: false,
      straight: false,
      nrPeriodicSections: 10,
      useSmoothing: false,
      maxUDegree: 3,
      tolerance: 1e-7,
      parType: Bit.Inputs.OCCT.approxParametrizationTypeEnum.approxCentripetal,
      endVertex: [0, 20, 0],
      });

    measure

    • Measures how far each point in a list is from a shape, as the straight distance to the closest point on it, in model units.

      The distance is to the shape's surface, so a point inside a solid still reports its distance to the skin.

      Parameters

      Returns Promise<number[]>

      One distance per point, in the same order

      const distances = await bitbybit.occt.operations.distancesToShapeFromPoints({ shape: sphere, points: [[0, 20, 0], [20, 0, 0]] });
      
    • Computes the axis-aligned box that encloses a shape: its minimum and maximum corners, its center and its size along X, Y and Z.

      On curved shapes the box can be a little larger than the shape itself, because the kernel bounds the control geometry rather than the exact surface.

      Parameters

      Returns Promise<BoundingBoxPropsDto>

      The box as min, max, center and size

      const box = await bitbybit.occt.operations.boundingBoxOfShape({ shape });
      console.log(box.size, box.center);
    • Reads the minimum corner of a shape's axis-aligned bounding box, the point with the smallest X, Y and Z.

      Parameters

      Returns Promise<Point3>

      The minimum corner

      const min = await bitbybit.occt.operations.boundingBoxMinOfShape({ shape });
      
    • Reads the maximum corner of a shape's axis-aligned bounding box, the point with the largest X, Y and Z.

      Parameters

      Returns Promise<Point3>

      The maximum corner

      const max = await bitbybit.occt.operations.boundingBoxMaxOfShape({ shape });
      
    • Reads the center of a shape's axis-aligned bounding box, halfway between its two corners.

      This is not the center of mass; shapes.solid.getSolidCenterOfMass and its siblings give that.

      Parameters

      Returns Promise<Point3>

      The center of the box

      const center = await bitbybit.occt.operations.boundingBoxCenterOfShape({ shape });
      
    • Reads the size of a shape's axis-aligned bounding box along X, Y and Z, in model units.

      Parameters

      Returns Promise<Vector3>

      The width, height and length of the box

      const size = await bitbybit.occt.operations.boundingBoxSizeOfShape({ shape });
      
    • Builds the axis-aligned bounding box of a shape as a box solid, handy for drawing it or using it in a boolean.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The box solid

      const boxSolid = await bitbybit.occt.operations.boundingBoxShapeOfShape({ shape });
      
    • Computes a sphere that encloses a shape: it is centered on the bounding box and reaches its corners, so it always contains the shape but is not the smallest possible sphere.

      Parameters

      Returns Promise<BoundingSpherePropsDto>

      The sphere as center and radius

      const sphere = await bitbybit.occt.operations.boundingSphereOfShape({ shape });
      console.log(sphere.radius);
    • Reads the center of a shape's bounding sphere, which is the center of its bounding box.

      Parameters

      Returns Promise<Point3>

      The center of the sphere

      const center = await bitbybit.occt.operations.boundingSphereCenterOfShape({ shape });
      
    • Reads the radius of a shape's bounding sphere, the distance from the bounding box center to its corner, in model units.

      Parameters

      Returns Promise<number>

      The radius

      const radius = await bitbybit.occt.operations.boundingSphereRadiusOfShape({ shape });
      

    offsets

    • Moves the boundary of a shape outward, or inward for a negative distance, by a fixed distance: a wire grows into a parallel outline, a face or solid into a bigger one.

      A wire or edge is offset in its own plane, or on face when given; corners are rounded. A distance of 0 returns the shape as it is.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The offset shape

      const bigger = await bitbybit.occt.operations.offset({ shape: box, distance: 1, tolerance: 0.1 });
      
    • Offsets a shape like offset, with a choice of how corners are joined: arc rounds them, intersection extends the sides to a sharp corner, tangent keeps them tangent.

      removeIntEdges drops the internal edges the offset can leave behind on a solid.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The offset shape

      const sharper = await bitbybit.occt.operations.offsetAdv({
      shape: rectangleWire,
      distance: 1,
      tolerance: 0.1,
      joinType: Bit.Inputs.OCCT.joinTypeEnum.intersection,
      removeIntEdges: false,
      });
    • Gives a face or shell a thickness, turning it into a solid slab or wall of the given offset.

      A positive offset thickens toward the surface normal, a negative one the other way. Use it to turn a lofted or swept skin into something printable.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The thick solid

      const wall = await bitbybit.occt.operations.makeThickSolidSimple({ shape: loftedShell, offset: 0.5 });
      
    • Hollows a solid into a shell of the given wall thickness by removing the listed faces and offsetting the rest.

      Removing the top face of a box, for instance, gives an open cup. offset is the wall thickness, negative to grow inward; joinType says how the offset walls meet at corners, the other flags go to the kernel's thick-solid builder.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The hollowed solid

      const box = await bitbybit.occt.shapes.solid.createBox({ width: 10, length: 10, height: 10, center: [0, 0, 0] });
      const faces = await bitbybit.occt.shapes.face.getFaces({ shape: box });
      const cup = await bitbybit.occt.operations.makeThickSolidByJoin({
      shape: box,
      shapes: [faces[0]],
      offset: -1,
      tolerance: 1e-3,
      intersection: false,
      selfIntersection: false,
      joinType: Bit.Inputs.OCCT.joinTypeEnum.arc,
      removeIntEdges: false,
      });
    • Offsets a wire that does not lie in one plane, by extruding it along direction, thickening the result and reading the offset edge back off it.

      It works best on smooth wires; fillet sharp corners first with fillets.fillet3DWire. When the offset edges cannot be joined into one wire they come back as a list of edges.

      Parameters

      Returns Promise<TopoDSWirePointer>

      The offset wire, or the loose edges when they could not be joined

      const outer = await bitbybit.occt.operations.offset3DWire({ shape: smoothWire, offset: 1, direction: [0, 1, 0] });
      

    pipeing

    • Sweeps a regular polygon along a wire, giving a tube with nrCorners flat sides, for instance a hexagonal bar along a path.

      The polygon of radius is placed at the start of the wire, perpendicular to it. makeSolid gives a solid instead of a shell, trihedronEnum chooses how the profile turns along the path, and forceApproxC1 smooths the result.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The swept solid or shell

      const bar = await bitbybit.occt.operations.pipePolylineWireNGon({
      shape: pathWire,
      radius: 0.5,
      nrCorners: 6,
      makeSolid: true,
      trihedronEnum: Bit.Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal,
      forceApproxC1: false,
      });
    • Sweeps a circle along each of several wires, as pipeWireCylindrical does for one, all with the same radius and options.

      Parameters

      Returns Promise<TopoDSShapePointer[]>

      One tube per wire, in the same order

      const tubes = await bitbybit.occt.operations.pipeWiresCylindrical({
      shapes: [pathA, pathB],
      radius: 0.5,
      makeSolid: true,
      trihedronEnum: Bit.Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal,
      forceApproxC1: false,
      });
    • Sweeps a circle along a wire, giving a round tube of the given radius that follows the path.

      The circle is placed at the start of the wire, perpendicular to it. makeSolid gives a solid instead of a shell, trihedronEnum chooses how the profile turns as it follows the path, and forceApproxC1 smooths the result.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The tube as a solid or shell

      const tube = await bitbybit.occt.operations.pipeWireCylindrical({
      shape: pathWire,
      radius: 0.5,
      makeSolid: true,
      trihedronEnum: Bit.Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal,
      forceApproxC1: false,
      });

    revolutions

    • Spins a shape around an axis through the origin to sweep out a surface or solid: a face gives a solid, a wire a shell.

      angle is in degrees; 360 or more gives a full turn. The axis runs along direction: a profile beside the Y axis revolved about it gives a vase. The profile must not cross it.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The revolved shape

      const profile = await bitbybit.occt.shapes.wire.createPolylineWire({ points: [[2, 0, 0], [4, 0, 0], [3, 10, 0], [2, 12, 0]] });
      const vase = await bitbybit.occt.operations.revolve({ shape: profile, angle: 360, direction: [0, 1, 0], copy: false });