Bitbybit Docs
    Preparing search index...

    Class OCCTShapeFix

    Checks and repairs for OpenCascade shapes that came out of a file or an operation with defects: gaps between edges, edges too short to matter, faces turned the wrong way, shells left open, tolerances that drifted. isValid tells whether a shape is well formed, validityReport says what is wrong and where, and freeBoundaries shows the rims of openings; basicShapeRepair is the general fix, the shell, solid and sewing fixes and the wire fixes handle the rest. Every repair returns a new shape.

    Index

    Constructors

    shape

    • Runs the kernel's general repair over a shape: closes small gaps, fixes wire and face defects and brings tolerances into the given range.

      precision is the size of defect to look for, minTolerance and maxTolerance bound the tolerances the repaired shape may carry, all in model units. Try it first on any shape that fails isValid.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The repaired shape

      const fixed = await bitbybit.occt.shapeFix.basicShapeRepair({ shape: imported, precision: 0.001, maxTolerance: 0.01, minTolerance: 0.0001 });
      
    • Tells whether the shape is well formed, which a successful operation does not always guarantee.

      It checks that edges lie on their faces, wires and shells close, and tolerances agree. A fillet too large for its faces fails; a shape passing through itself, such as a pipe wider than its bends, passes. Large parts take a few hundred milliseconds.

      Parameters

      Returns Promise<boolean>

      True when the shape is well formed

      const box = await bitbybit.occt.shapes.solid.createBox({ width: 10, length: 10, height: 10 });
      const rounded = await bitbybit.occt.fillets.filletEdges({ shape: box, radius: 6 });
      const wellFormed = await bitbybit.occt.shapeFix.isValid({ shape: rounded });
    • Checks a shape as isValid does and reports each faulty sub-shape with the checks it fails, and the spread of its tolerances.

      A fault's index is the one the getter of its kind uses: shapes.face.getFace with a face fault's index gives that face. Overlapping faces are not looked for; analysis.clashes.selfIntersections finds those.

      Parameters

      Returns Promise<ValidityReport>

      Whether the shape is valid, its faults and its smallest, largest and average tolerance

      const report = await bitbybit.occt.shapeFix.validityReport({ shape: imported });
      const badFaces = report.faults.filter(fault => fault.type === Bit.Inputs.OCCT.shapeTypeEnum.face).map(fault => fault.index);
    • Finds the edges of a shape that bound only one face, joined into wires: the rims of an open shell's openings, or a lone face's outline and holes.

      Wires that close on themselves come back in closed, the rest in open; a closed solid has none. Edges closer than tolerance, in model units, count as one.

      Parameters

      Returns Promise<FreeBoundaries<TopoDSCompoundPointer>>

      Two compounds of wires, the closed and the open ones

      const rims = await bitbybit.occt.shapeFix.freeBoundaries({ shape: openShell, tolerance: 1e-7 });
      const holes = await bitbybit.occt.shapes.wire.getWires({ shape: rims.closed });
    • Sews the faces of shapes together along edges that lie within tolerance of each other, as shapes.shell.sewFaces does, and reports what it joined and what it left open.

      freeEdges holds the edges left bounding only one face; with nonManifold true an edge may join more than two faces. The shapes given are left as they were.

      Parameters

      Returns Promise<SewReport<TopoDSShapePointer>>

      The sewn shape, the free edges and the counts of free, multiple, sewn and degenerate edges

      const sewn = await bitbybit.occt.shapeFix.sewWithReport({ shapes: faces, tolerance: 1e-4, nonManifold: false });
      const closed = sewn.freeEdgeCount === 0;

    shell

    • Repairs a shell: turns its faces so they all face the same way and fixes its faces and edges.

      When the faces cannot all be turned one way, as on a strip given a half twist, the result is a compound of shells. A shape that is not a shell is refused.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The repaired shell, or a compound of shells

      const shell = await bitbybit.occt.shapes.shell.sewFaces({ shapes: faces, tolerance: 1e-7 });
      const fixed = await bitbybit.occt.shapeFix.fixShell({ shape: shell });

    solid

    • Repairs a solid, or makes one from a closed shell, with its shells fixed and turned so the material is inside.

      A shell that encloses nothing comes back fixed but still a shell, and shells that fix into separate solids come back as a compound of them. Other kinds of shape are refused.

      Parameters

      Returns Promise<TopoDSShapePointer>

      The repaired solid, or a shell or a compound when no single solid can be made

      const shell = await bitbybit.occt.shapes.shell.sewFaces({ shapes: faces, tolerance: 1e-7 });
      const solid = await bitbybit.occt.shapeFix.fixSolid({ shape: shell });
    • Turns a closed solid so its material is inside, which gives an inside-out solid its positive volume back; only the orientation changes.

      A shape that is not a solid, a solid without a shell and a solid whose shell has an opening are refused.

      Parameters

      Returns Promise<TopoDSSolidPointer>

      The solid, oriented with its material inside

      const oriented = await bitbybit.occt.shapeFix.orientClosedSolid({ shape: insideOut });
      const volume = await bitbybit.occt.shapes.solid.getSolidVolume({ shape: oriented });

    wire

    • Removes edges shorter than precsmall from a wire and closes the gaps they leave, so a tiny sliver no longer breaks a fillet or a face.

      With lockvtx true the existing vertices are kept in place; otherwise they may move to close the gap. A precsmall of 0 uses the wire's own tolerance.

      Parameters

      Returns Promise<TopoDSWirePointer>

      The cleaned wire

      const clean = await bitbybit.occt.shapeFix.fixSmallEdgeOnWire({ shape: wire, lockvtx: false, precsmall: 0.001 });
      
    • Rebuilds a wire so its edges run head to tail in one direction along it.

      A wire assembled from loose edges can hold edges pointing against the flow; this walks the wire in order and joins the edges again the right way round, which some operations need.

      Parameters

      Returns Promise<TopoDSWirePointer>

      The wire with consistently oriented edges

      const ordered = await bitbybit.occt.shapeFix.fixEdgeOrientationsAlongWire({ shape: wire });