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, sectioning and splitting, and hidden-line drawings, plus bounding boxes, bounding spheres and closest-point queries, which move to analysis.measure in the next major version. Distances are in model units and angles in degrees; every operation returns a new shape. Booleans live in booleans, rounding in fillets and local features such as holes in features.

    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. analysis.measure.extrema gives every closest pair, with the sub-shapes the points lie on.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3[]>

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

      Moves to analysis.measure.closestPointsBetweenTwoShapes in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3[]>

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

      Moves to analysis.measure.closestPointsOnShapeFromPoints in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3[]>

      The closest points, grouped shape by shape

      Moves to analysis.measure.closestPointsOnShapesFromPoints in the next major version; it works here until then.

      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, all in one compound. The shape must contain solids, and a step giving more than 100000 slices is refused.

      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 repeats from the bottom of the shape up to its top. Steps must add up to more than 0 and give at most 100000 slices.

      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] });
      
    • Finds the curves where two shapes meet and joins them end to end into wires, such as the outline a plane cuts from a solid.

      A loop comes back as a closed wire, branches or loose ends as open wires, and shapes that do not meet give an empty list.

      Parameters

      Returns Promise<TopoDSWirePointer[]>

      The wires where the shapes meet

      const box = await bitbybit.occt.shapes.solid.createBox({ width: 10, length: 10, height: 10, center: [0, 5, 0] });
      const plane = await bitbybit.occt.shapes.face.createSquareFace({ size: 20, center: [0, 3, 0], direction: [0, 1, 0] });
      const outline = await bitbybit.occt.operations.sectionWires({ shapeA: box, shapeB: plane, tolerance: 1e-7 });
    • Slices a shape with the plane of each frame, which passes through the frame's origin square to its normal.

      With makeFaces true a slice holds the faces where the plane passes through the solids, holes included; with false, the section wires. A plane that misses the shape gives an empty compound.

      Parameters

      Returns Promise<TopoDSCompoundPointer[]>

      One compound per frame, in the order of the frames

      const slices = await bitbybit.occt.operations.sliceByFrames({
      shape: vase,
      frames: [
      { origin: [0, 2, 0], normal: [0, 1, 0], direction: [1, 0, 0] },
      { origin: [0, 4, 0], normal: [0, 1, 0], direction: [1, 0, 0] },
      ],
      makeFaces: true,
      tolerance: 1e-7,
      });
    • Splits a shape in two with the plane of a frame: what lies on the side the frame's normal points to comes back as front, the rest as back.

      The pieces are solids when the shape has any, else faces, else edges. A shape the plane misses comes back whole on its side.

      Parameters

      Returns Promise<SplitByFrameResult<TopoDSCompoundPointer>>

      The pieces in front of the plane and behind it, each in a compound

      const { front, back } = await bitbybit.occt.operations.splitByFrame({
      shape: box,
      frame: { origin: [2, 0, 0], normal: [1, 0, 0], direction: [0, 1, 0] },
      });
    • Cuts a face into pieces along edges or wires lying on it, like scoring a sheet.

      A cutter cuts only where it lies on the face, and a closed loop inside it cuts out the region it encloses. With no cutters the face comes back whole.

      Parameters

      Returns Promise<TopoDSFacePointer[]>

      The pieces of the face

      const square = await bitbybit.occt.shapes.face.createSquareFace({ size: 10, center: [0, 0, 0], direction: [0, 1, 0] });
      const line = await bitbybit.occt.shapes.edge.line({ start: [0, 0, -6], end: [0, 0, 6] });
      const halves = await bitbybit.occt.operations.splitFaceByWires({ shape: square, wires: [line] });

    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. A solid, or a vector of length 0, is refused.

      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] });
    • Extrudes a shape as extrude does, and reports what each part of the profile became: history.firstFaces and lastFaces are the caps of a face profile (a wire has none), history.facesFromEdges the side swept from each profile edge and history.edgesFromVertices the edge swept from each vertex.

      Parameters

      Returns Promise<ShapeWithHistory<TopoDSShapePointer>>

      The extruded shape and its history

      const { shape, history } = await bitbybit.occt.operations.extrudeWithHistory({ shape: squareFace, direction: [0, 0, 5] });
      const top = history.lastFaces;
    • 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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<number[]>

      One distance per point, in the same order

      Moves to analysis.measure.distancesToShapeFromPoints in the next major version; it works here until then.

      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. analysis.measure.tightBoundingBox follows the exact geometry.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<BoundingBoxPropsDto>

      The box as min, max, center and size

      Moves to analysis.measure.boundingBoxOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3>

      The minimum corner

      Moves to analysis.measure.boundingBoxMinOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3>

      The maximum corner

      Moves to analysis.measure.boundingBoxMaxOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3>

      The center of the box

      Moves to analysis.measure.boundingBoxCenterOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Vector3>

      The width, height and length of the box

      Moves to analysis.measure.boundingBoxSizeOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The box solid

      Moves to analysis.measure.boundingBoxShapeOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<BoundingSpherePropsDto>

      The sphere as center and radius

      Moves to analysis.measure.boundingSphereOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<Point3>

      The center of the sphere

      Moves to analysis.measure.boundingSphereCenterOfShape in the next major version; it works here until then.

      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.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<number>

      The radius

      Moves to analysis.measure.boundingSphereRadiusOfShape in the next major version; it works here until then.

      const radius = await bitbybit.occt.operations.boundingSphereRadiusOfShape({ shape });
      
    • Builds the bounding sphere of a shape as a sphere solid.

      It moves to analysis.measure in the next major version, with the same inputs and result.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The sphere solid

      Moves to analysis.measure.boundingSphereShapeOfShape in the next major version; it works here until then.

      const sphereSolid = await bitbybit.occt.operations.boundingSphereShapeOfShape({ 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 along the surface normal, a negative one against it. Faces are offset one by one, so walls meeting at a sharp edge leave a gap of up to 1.4 times offset, bridged by tolerance.

      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: every point moves by offset at right angles to both the wire and direction, keeping its height along direction.

      Best on smooth wires; round sharp corners first with fillets.fillet3DWire, since at one the offset edges do not meet and come back as a list of edges.

      Parameters

      Returns Promise<TopoDSWirePointer>

      The offset wire, or its edges in order when they do not meet

      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,
      });
    • Sweeps a profile along a flat spine, keeping its place beside it, as a moulding follows a wall.

      Draw the profile about the origin: x along the spine, y to the left of travel, inside a counter-clockwise loop, and z up from the spine's plane. A spine out of plane is refused.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The swept shell or solid

      const spine = await bitbybit.occt.shapes.wire.createSquareWire({ size: 10, center: [0, 0, 0], direction: [0, 1, 0] });
      const profile = await bitbybit.occt.shapes.wire.createPolygonWire({ points: [[0, 0, 0], [0, 1, 0], [0, 1, 3], [0, 0, 3]] });
      const wall = await bitbybit.occt.operations.sweepEvolved({ spine, profile, makeSolid: true });
    • Sweeps a profile along a spine while scaling it, such as a tube that widens toward one end.

      params are places along the spine from 0 to 1, each scaled by the entry of scales at the same position; between them the scale changes smoothly. Place the profile across the start of the spine; makeSolid needs it closed.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The swept solid or shell

      const spine = await bitbybit.occt.shapes.edge.line({ start: [0, 0, 0], end: [0, 10, 0] });
      const profile = await bitbybit.occt.shapes.wire.createCircleWire({ radius: 1, center: [0, 0, 0], direction: [0, 1, 0] });
      const horn = await bitbybit.occt.operations.pipeWithScaling({ spine, profile, params: [0, 1], scales: [1, 2], makeSolid: true });

    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 and may be negative to spin the other way; 360 or more either way makes a full turn, and 0 throws. The profile must not cross the axis along direction.

      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 });
    • Revolves a shape as revolve does, and reports what each part of the profile became: history.firstFaces and lastFaces are the ends of a partial turn, history.facesFromEdges the surface swept from each profile edge, a whole turn included.

      Parameters

      Returns Promise<ShapeWithHistory<TopoDSShapePointer>>

      The revolved shape and its history

      const { shape, history } = await bitbybit.occt.operations.revolveWithHistory({ shape: profile, angle: 90, direction: [0, 0, 1], copy: false });
      

    views

    • Draws a shape seen from a view frame as a technical drawing does, flat on the XZ plane: the edges the eye sees and those that faces hide.

      The eye looks back along the frame's normal. Its origin lands on the world origin, its direction on x and the normal crossed with the direction on z. Both compounds hold edges.

      Parameters

      Returns Promise<HiddenLinesResult<TopoDSCompoundPointer>>

      The visible and the hidden edges, each a compound on the XZ plane

      const { visible, hidden } = await bitbybit.occt.operations.hiddenLines({
      shape: part,
      frame: { origin: [0, 0, 0], normal: [1, 1, 1], direction: [1, 0, -1] },
      exact: true,
      smoothEdges: false,
      hiddenEdges: true,
      focus: 0,
      precision: 0.01,
      });