Bitbybit Docs
    Preparing search index...

    Class OCCTOperations

    将 OpenCascade 线框和面变成曲面和实体并测量形状的建模操作:穿过截面放样,拉伸和旋转成形,沿路径扫掠轮廓,偏移,将壳体加厚为实体,切片和分割,以及边界框、边界球和最近点查询。距离以模型单位表示,角度以度为单位;每个操作都返回新形状。布尔运算位于 booleans,倒圆角位于 fillets

    Index

    Constructors

    closest pts

    • 找出彼此最接近的一对点,每个形状上一个。

      两点之间的距离就是形状之间的间隙;当它们接触或重叠时为 0。找不到任何一对时抛出错误。

      Returns Promise<Point3[]>

      第一个形状上的点和第二个形状上的点

      const [onBox, onSphere] = await bitbybit.occt.operations.closestPointsBetweenTwoShapes({ shape1: box, shape2: sphere });
      
    • 为列表中的每个点找出形状上的最近点。

      已经在形状上的点映射到自身。适用于将点吸附到曲面上。

      Returns Promise<Point3[]>

      每个输入点对应形状上的一个点,顺序相同

      const snapped = await bitbybit.occt.operations.closestPointsOnShapeFromPoints({ shape: sphere, points: [[0, 20, 0], [20, 0, 0]] });
      
    • 为列表中的每个点在多个形状的每一个上找出最近点。

      结果是一个平坦列表:先是第一个形状的所有点,按点的顺序,然后是第二个形状的所有点,依此类推。

      Returns Promise<Point3[]>

      最近点,按形状分组

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

    divisions

    • 用其他形状将形状切成几块,就像刀切面包一样,不移除任何材料。

      nonDestructive 为 true(默认)时,输入保持不变,结果包含所有参与形状的碎块,包括切割体;为 false 时只返回 shape 的碎块。localFuzzyTolerance 让几乎接触的几何算作接触。

      Parameters

      Returns Promise<TopoDSShapePointer[]>

      各个部分

      const pieces = await bitbybit.occt.operations.splitShapeWithShapes({ shape: box, shapes: [cuttingPlane], localFuzzyTolerance: 1e-4, nonDestructive: false });
      
    • 沿某方向将实体切成平行的切片,就像一条面包,从形状底部向上每隔 step 个模型单位一片。

      每片是切割平面与实体相交处的平面截面;它们一起以一个复合体返回。形状必须是或包含实体,否则抛出错误。

      Parameters

      Returns Promise<TopoDSCompoundPointer>

      截面的复合体

      const layers = await bitbybit.occt.operations.slice({ shape: sphere, step: 0.5, direction: [0, 1, 0] });
      
    • slice 一样将实体切成平行的切片,但切片之间的间隙按重复的模式变化,例如 0.1, 0.5, 0.1, 0.5。

      模式从形状底部向上应用并重复,直到到达顶部。

      Parameters

      Returns Promise<TopoDSCompoundPointer>

      截面的复合体

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

    extrusions

    • 沿向量以直线扫掠形状,向量的长度即距离:面变成实体,线框变成壳体,边变成面。

      形状本身留在拉伸的起点;向量以模型单位表示,因此 [0, 10, 0] 向上拉伸 10 个单位。

      Parameters

      Returns Promise<TopoDSShapePointer>

      拉伸后的形状

      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] });
    • 将平面形状沿 Y 向上拉伸 height,同时绕 Y 轴扭转 angle 度,就像扭转的柱子。

      形状应平放,就像本包创建的轮廓那样。makeSolid 为 true(默认)时,面轮廓给出闭合实体;线框给出扭转的壳体。

      Parameters

      Returns Promise<TopoDSShapePointer>

      扭转拉伸体

      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

    • 构建穿过一系列线框的曲面,就像蒙在肋骨上的皮肤:每个线框是一个截面,曲面按列表顺序穿过它们。

      边作为单边线框被接受。makeSolid 为 true 且截面闭合时,结果被封口成实体;否则是壳体。边数相等的截面匹配得最好。

      Parameters

      Returns Promise<TopoDSShapePointer>

      放样得到的壳体或实体

      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 });
    • loft 一样构建穿过一系列线框的曲面,并可控制蒙皮的拟合方式。

      straight 在截面之间生成直纹面片而不是光滑过渡;closed 使曲面从最后一个截面绕回到第一个,periodic 通过对截面重新采样使该环光滑。startVertexendVertex 将端部收拢成点。

      Parameters

      Returns Promise<TopoDSShapePointer>

      放样得到的壳体或实体

      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

    • 测量列表中每个点距形状多远,即到其上最近点的直线距离,以模型单位表示。

      距离是到形状表面的,因此实体内部的点仍报告其到外皮的距离。

      Returns Promise<number[]>

      每个点一个距离,顺序相同

      const distances = await bitbybit.occt.operations.distancesToShapeFromPoints({ shape: sphere, points: [[0, 20, 0], [20, 0, 0]] });
      
    • 计算包围形状的轴对齐盒:其最小和最大角点、中心以及沿 X、Y 和 Z 的尺寸。

      在弯曲的形状上,该盒可能比形状本身略大,因为内核包围的是控制几何而不是精确曲面。

      Parameters

      Returns Promise<BoundingBoxPropsDto>

      minmaxcentersize 表示的边界框

      const box = await bitbybit.occt.operations.boundingBoxOfShape({ shape });
      console.log(box.size, box.center);
    • 读取形状轴对齐包围盒的最小角点,即 X、Y 和 Z 最小的点。

      Parameters

      Returns Promise<Point3>

      最小角点

      const min = await bitbybit.occt.operations.boundingBoxMinOfShape({ shape });
      
    • 读取形状轴对齐包围盒的最大角点,即 X、Y 和 Z 最大的点。

      Parameters

      Returns Promise<Point3>

      最大角点

      const max = await bitbybit.occt.operations.boundingBoxMaxOfShape({ shape });
      
    • 读取形状轴对齐包围盒的中心,位于其两个角点的中间。

      这不是质心;shapes.solid.getSolidCenterOfMass 及其同类方法给出质心。

      Parameters

      Returns Promise<Point3>

      边界框的中心

      const center = await bitbybit.occt.operations.boundingBoxCenterOfShape({ shape });
      
    • 读取形状轴对齐包围盒沿 X、Y 和 Z 的尺寸,以模型单位表示。

      Parameters

      Returns Promise<Vector3>

      边界框的宽度、高度和长度

      const size = await bitbybit.occt.operations.boundingBoxSizeOfShape({ shape });
      
    • 将形状的轴对齐包围盒构建为长方体实体,便于绘制它或在布尔运算中使用它。

      Parameters

      Returns Promise<TopoDSShapePointer>

      长方体实体

      const boxSolid = await bitbybit.occt.operations.boundingBoxShapeOfShape({ shape });
      
    • 计算包围形状的球:它以包围盒为中心并到达其角点,因此总是包含形状,但不是可能的最小球。

      Parameters

      Returns Promise<BoundingSpherePropsDto>

      centerradius 表示的球体

      const sphere = await bitbybit.occt.operations.boundingSphereOfShape({ shape });
      console.log(sphere.radius);
    • 读取形状包围球的中心,即其包围盒的中心。

      Parameters

      Returns Promise<Point3>

      球体的中心

      const center = await bitbybit.occt.operations.boundingSphereCenterOfShape({ shape });
      
    • 读取形状包围球的半径,即从包围盒中心到其角点的距离,以模型单位表示。

      Parameters

      Returns Promise<number>

      半径

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

    offsets

    • offset 一样偏移形状,并可选择角的连接方式:arc 将其倒圆,intersection 将各边延伸成尖角,tangent 保持其相切。

      removeIntEdges 丢弃偏移可能在实体上遗留的内部边。

      Parameters

      Returns Promise<TopoDSShapePointer>

      偏移后的形状

      const sharper = await bitbybit.occt.operations.offsetAdv({
      shape: rectangleWire,
      distance: 1,
      tolerance: 0.1,
      joinType: Bit.Inputs.OCCT.joinTypeEnum.intersection,
      removeIntEdges: false,
      });
    • 为面或壳体赋予厚度,将其变成给定 offset 的实体板或墙。

      正偏移朝曲面法线方向加厚,负偏移朝相反方向。用它将放样或扫掠的蒙皮变成可打印的东西。

      Parameters

      Returns Promise<TopoDSShapePointer>

      加厚后的实体

      const wall = await bitbybit.occt.operations.makeThickSolidSimple({ shape: loftedShell, offset: 0.5 });
      
    • 通过移除列出的面并偏移其余的面,将实体掏空为给定壁厚的壳。

      例如,移除长方体的顶面得到一个开口的杯子。offset 是壁厚,负值向内生长;joinType 指定偏移壁在角部如何相接,其他标志传给内核的加厚实体构建器。

      Parameters

      Returns Promise<TopoDSShapePointer>

      抽壳后的实体

      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,
      });
    • 偏移不在同一平面内的线框,方法是沿 direction 拉伸它、加厚结果并从中读回偏移后的边。

      它在光滑线框上效果最好;先用 fillets.fillet3DWire 对尖角进行圆角。当偏移后的边无法连接成一个线框时,它们以边列表返回。

      Parameters

      Returns Promise<TopoDSWirePointer>

      偏移后的线框,或无法连接时的零散边

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

    pipeing

    • 沿线框扫掠正多边形,得到带 nrCorners 个平面侧边的管,例如沿路径的六角棒。

      半径为 radius 的多边形放置在线框起点处,与之垂直。makeSolid 给出实体而不是壳体,trihedronEnum 选择轮廓沿路径如何转动,forceApproxC1 平滑结果。

      Parameters

      Returns Promise<TopoDSShapePointer>

      扫掠得到的实体或壳体

      const bar = await bitbybit.occt.operations.pipePolylineWireNGon({
      shape: pathWire,
      radius: 0.5,
      nrCorners: 6,
      makeSolid: true,
      trihedronEnum: Bit.Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal,
      forceApproxC1: false,
      });
    • 沿多个线框中的每一个扫掠圆,与 pipeWireCylindrical 对一个线框所做的相同,全部使用相同的半径和选项。

      Parameters

      Returns Promise<TopoDSShapePointer[]>

      每个线框一个管,顺序相同

      const tubes = await bitbybit.occt.operations.pipeWiresCylindrical({
      shapes: [pathA, pathB],
      radius: 0.5,
      makeSolid: true,
      trihedronEnum: Bit.Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal,
      forceApproxC1: false,
      });
    • 沿线框扫掠圆,得到沿路径的给定半径的圆管。

      圆放置在线框起点处,与之垂直。makeSolid 给出实体而不是壳体,trihedronEnum 选择轮廓沿路径前进时如何转动,forceApproxC1 平滑结果。

      Parameters

      Returns Promise<TopoDSShapePointer>

      以实体或壳体表示的管

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

    revolutions

    • 使形状绕经过原点的轴旋转以扫出曲面或实体:面给出实体,线框给出壳体。

      angle 以度为单位;360 或更大给出完整一圈。轴沿 direction:Y 轴旁的轮廓绕它旋转得到一个花瓶。轮廓不得与轴相交。

      Parameters

      Returns Promise<TopoDSShapePointer>

      旋转成形后的形状

      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 });