Bitbybit Docs
    Preparing search index...

    Class OCCTSolid

    Solids in OpenCascade: closed shapes that enclose a volume. Build one from a primitive (createBox, createSphere, createCylinder, createCone, createTorus), from a flat profile extruded front and back (the star, n-gon, heart, beam and other profile solids), or from a closed shell with fromClosedShell; then measure it with the volume, surface area and center of mass getters, and filter points by whether they lie inside it. Vertices, edges, wires, faces, shells and compounds have their own classes beside this one under shapes.

    Index

    Constructors

    beam

    • Creates an I-beam by extruding its flat profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const beam = await bitbybit.occt.shapes.solid.createIBeamProfileSolid({
      width: 10,
      height: 20,
      flangeThickness: 1,
      webThickness: 1,
      alignment: Bit.Inputs.Base.basicAlignmentEnum.midMid,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 0, 1],
      extrusionLengthFront: 100,
      extrusionLengthBack: 0,
      });
    • Creates an H-beam by extruding its flat profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const beam = await bitbybit.occt.shapes.solid.createHBeamProfileSolid({
      width: 20,
      height: 20,
      flangeThickness: 1,
      webThickness: 1,
      alignment: Bit.Inputs.Base.basicAlignmentEnum.midMid,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 0, 1],
      extrusionLengthFront: 100,
      extrusionLengthBack: 0,
      });
    • Creates a T-beam by extruding its flat profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const beam = await bitbybit.occt.shapes.solid.createTBeamProfileSolid({
      width: 10,
      height: 20,
      flangeThickness: 1,
      webThickness: 1,
      alignment: Bit.Inputs.Base.basicAlignmentEnum.midMid,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 0, 1],
      extrusionLengthFront: 100,
      extrusionLengthBack: 0,
      });
    • Creates a U-beam by extruding its flat profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const beam = await bitbybit.occt.shapes.solid.createUBeamProfileSolid({
      width: 10,
      height: 20,
      flangeThickness: 1,
      webThickness: 1,
      flangeWidth: 3,
      alignment: Bit.Inputs.Base.basicAlignmentEnum.midMid,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 0, 1],
      extrusionLengthFront: 100,
      extrusionLengthBack: 0,
      });

    debug

    • Collects diagnostic facts about a solid: whether it is valid, how many faces and edges it has, its surface area and volume, and for every face the surface type, degrees, control point counts, bounds and area.

      An empty or null shape gives a report marked invalid with zero counts.

      Parameters

      Returns Promise<SolidDebugInfo>

      The report with counts, area, volume and one entry per face

      const info = await bitbybit.occt.shapes.solid.debugInfo({ shape: box });
      console.log(info.nbFaces, info.volume);

    filter

    • Keeps the points that lie inside, on the surface of, or outside a solid, as chosen by the keepIn, keepOn and keepOut flags.

      A point counts as on the surface when it is within tolerance of it. Points the kernel cannot classify are kept only with keepUnknown.

      Parameters

      Returns Promise<Point3[]>

      The points that passed the filter, in their original order

      const inside = await bitbybit.occt.shapes.solid.filterSolidPoints({
      shape: box,
      points: [[0, 0, 0], [100, 0, 0]],
      tolerance: 1e-7,
      keepIn: true,
      keepOn: false,
      keepOut: false,
      keepUnknown: false,
      });

    from

    • Turns a closed shell into a solid, so the volume it encloses becomes a body that can be measured, booleaned and meshed.

      The shell must be watertight; a shell with gaps produces a solid the kernel cannot use.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      The solid bounded by the shell

      const solid = await bitbybit.occt.shapes.solid.fromClosedShell({ shape: closedShell });
      

    get

    • Measures the total area of all the faces of a solid.

      Parameters

      Returns Promise<number>

      The surface area in square model units

      const area = await bitbybit.occt.shapes.solid.getSolidSurfaceArea({ shape: box });
      
    • Measures the volume a solid encloses, in cubic model units.

      Parameters

      Returns Promise<number>

      The volume in cubic model units

      const volume = await bitbybit.occt.shapes.solid.getSolidVolume({ shape: box });
      
    • Measures the volume of each solid in a list.

      Parameters

      Returns Promise<number[]>

      One volume per solid, in the same order

      const volumes = await bitbybit.occt.shapes.solid.getSolidsVolumes({ shapes: [box, sphere] });
      
    • Finds the center of mass of a solid, treating it as filled with material of uniform density.

      Parameters

      Returns Promise<Point3>

      The center of mass point

      const center = await bitbybit.occt.shapes.solid.getSolidCenterOfMass({ shape: box });
      
    • Finds the center of mass of each solid in a list, treating each as filled with material of uniform density.

      Parameters

      Returns Promise<Point3[]>

      One point per solid, in the same order

      const centers = await bitbybit.occt.shapes.solid.getSolidsCentersOfMass({ shapes: [box, sphere] });
      
    • Lists the solids inside any shape, such as the bodies of a compound or the result of a boolean.

      A shape that is itself a solid gives a list with that one solid.

      Parameters

      Returns Promise<TopoDSSolidPointer[]>

      The solids found in the shape

      const solids = await bitbybit.occt.shapes.solid.getSolids({ shape: compound });
      

    primitives

    • Creates a box solid with its sides parallel to the axes.

      width runs along X, height along Y (up) and length along Z, all in model units. By default the box is centered on center; with originOnCenter set to false it stands on that point instead, so center becomes the middle of the bottom face.

      Parameters

      • inputs: BoxDto

        Box size, the point it is placed on, and whether it is centered on or stands on it

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const box = await bitbybit.occt.shapes.solid.createBox({ width: 10, length: 20, height: 5, center: [0, 0, 0], originOnCenter: true });
      
    • Creates a cube solid, a box with all three sides the same size, parallel to the axes.

      By default the cube is centered on center; with originOnCenter set to false it stands on that point instead, so center becomes the middle of the bottom face.

      Parameters

      • inputs: Bit.Inputs.OCCT.CubeDto

        Cube size, the point it is placed on, and whether it is centered on or stands on it

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const cube = await bitbybit.occt.shapes.solid.createCube({ size: 10, center: [0, 0, 0], originOnCenter: true });
      
    • Creates a box solid that starts at a corner point and extends along the positive axes.

      The corner with the smallest x, y and z sits at corner; the box reaches width along X, height along Y and length along Z from there, all in model units.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const box = await bitbybit.occt.shapes.solid.createBoxFromCorner({ width: 10, length: 20, height: 5, corner: [0, 0, 0] });
      
    • Creates a cylinder solid with a round base at center, growing height along direction.

      With originOnCenter on, the cylinder is shifted back by half its height so center sits in its middle. angle, in degrees, cuts a wedge out of the full 360 degree round, like a slice of cake.

      Parameters

      • inputs: Bit.Inputs.OCCT.CylinderDto

        Radius, height, base center, direction, an optional partial angle and whether to center on the point

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const cylinder = await bitbybit.occt.shapes.solid.createCylinder({ radius: 5, height: 20, center: [0, 0, 0], direction: [0, 1, 0], angle: 360, originOnCenter: false });
      
    • Creates one cylinder solid along each line, from its start to its end, all with the same radius.

      The height of each cylinder is the length of its line.

      Parameters

      Returns Promise<TopoDSSolidPointer[]>

      One solid per line, in the same order

      const rods = await bitbybit.occt.shapes.solid.createCylindersOnLines({
      lines: [{ start: [0, 0, 0], end: [0, 10, 0] }, { start: [5, 0, 0], end: [5, 10, 0] }],
      radius: 0.5,
      });
    • Creates a cone solid, or a truncated cone when both radii are above 0, standing on a round base at center and growing height along direction.

      radius1 is the base and radius2 the top; a top radius of 0 makes a pointed cone. angle, in degrees, cuts a wedge out of the full 360 degree round.

      Parameters

      • inputs: Bit.Inputs.OCCT.ConeDto

        Base and top radius, height, base center, direction and an optional partial angle

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const cone = await bitbybit.occt.shapes.solid.createCone({ radius1: 5, radius2: 0, height: 10, center: [0, 0, 0], direction: [0, 1, 0], angle: 360 });
      
    • Creates a torus solid, a ring with a round cross-section, centered on center with its axis along direction.

      majorRadius is the distance from the center to the middle of the tube and minorRadius the tube's own radius. angle, in degrees, makes a partial ring instead of the full 360 degrees.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const ring = await bitbybit.occt.shapes.solid.createTorus({ majorRadius: 10, minorRadius: 2, center: [0, 0, 0], direction: [0, 1, 0], angle: 360 });
      
    • Creates a star-shaped solid by extruding a flat star profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown. The star itself is built as shapes.wire.createStarWire builds it.

      Parameters

      • inputs: StarSolidDto

        The star profile and the two extrusion lengths

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const star = await bitbybit.occt.shapes.solid.createStarSolid({
      numRays: 5,
      outerRadius: 10,
      innerRadius: 5,
      half: false,
      center: [0, 0, 0],
      direction: [0, 1, 0],
      extrusionLengthFront: 2,
      extrusionLengthBack: 0,
      });
    • Creates a solid with a regular polygon cross-section by extruding a flat n-gon profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      • inputs: NGonSolidDto

        The polygon profile and the two extrusion lengths

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const hexPrism = await bitbybit.occt.shapes.solid.createNGonSolid({
      nrCorners: 6,
      radius: 5,
      center: [0, 0, 0],
      direction: [0, 1, 0],
      extrusionLengthFront: 10,
      extrusionLengthBack: 0,
      });
    • Creates a solid with a parallelogram cross-section by extruding a flat parallelogram profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const slab = await bitbybit.occt.shapes.solid.createParallelogramSolid({
      width: 10,
      height: 5,
      angle: 15,
      center: [0, 0, 0],
      direction: [0, 1, 0],
      aroundCenter: true,
      extrusionLengthFront: 2,
      extrusionLengthBack: 0,
      });
    • Creates a heart-shaped solid by extruding a flat heart profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      • inputs: HeartSolidDto

        The heart profile and the two extrusion lengths

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const heart = await bitbybit.occt.shapes.solid.createHeartSolid({
      sizeApprox: 10,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 1, 0],
      extrusionLengthFront: 2,
      extrusionLengthBack: 0,
      });
    • Creates a Christmas tree-shaped solid by extruding a flat tree profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const tree = await bitbybit.occt.shapes.solid.createChristmasTreeSolid({
      height: 10,
      innerDist: 1.5,
      outerDist: 3,
      nrSkirts: 5,
      trunkHeight: 1,
      trunkWidth: 1,
      half: false,
      rotation: 0,
      origin: [0, 0, 0],
      direction: [0, 1, 0],
      extrusionLengthFront: 2,
      extrusionLengthBack: 0,
      });
    • Creates an L-shaped solid by extruding a flat L profile forward and backward along its own normal.

      extrusionLengthFront and extrusionLengthBack say how far it grows each way, in model units; at least one must be above 0 or an error is thrown.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      A new solid

      const bracket = await bitbybit.occt.shapes.solid.createLPolygonSolid({
      widthFirst: 10,
      lengthFirst: 20,
      widthSecond: 10,
      lengthSecond: 15,
      align: Bit.Inputs.OCCT.directionEnum.outside,
      rotation: 0,
      center: [0, 0, 0],
      direction: [0, 1, 0],
      extrusionLengthFront: 2,
      extrusionLengthBack: 0,
      });