feat: add whole-shape mirrored feature
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BitByBitOCCT, OccStateEnum } from '@bitbybit-dev/occt-worker'
|
||||
import type { Inputs } from '@bitbybit-dev/occt'
|
||||
import type { ApplyPlacementInput, BooleanCutInput, BooleanIntersectionInput, BooleanUnionInput, ChamferInput, CreateBoxInput, CreateConeInput, CreateCylinderInput, CreateSphereInput, FilletInput, GeometryCapabilities, GeometryDocumentContext, GeometryFileExport, LinearFeatureParameters, MeshAsset, PadInput, PlanarProfile, PocketInput, Point3, RevolutionInput, ShapeHandle, SubshapeRef, SubshapeTopology } from './types'
|
||||
import type { ApplyPlacementInput, BooleanCutInput, BooleanIntersectionInput, BooleanUnionInput, ChamferInput, CreateBoxInput, CreateConeInput, CreateCylinderInput, CreateSphereInput, FilletInput, GeometryCapabilities, GeometryDocumentContext, GeometryFileExport, LinearFeatureParameters, MeshAsset, MirrorInput, PadInput, PlanarProfile, PocketInput, Point3, RevolutionInput, ShapeHandle, SubshapeRef, SubshapeTopology } from './types'
|
||||
import { createEdgeSubshapeRefs, createSubshapeRefs, createVertexSubshapeRefs } from './topologyNaming'
|
||||
|
||||
type KernelShapeReference = Inputs.OCCT.TopoDSShapePointer
|
||||
@@ -82,6 +82,13 @@ export const validatePlacementInput = (input: ApplyPlacementInput) => {
|
||||
validateShapeContext(input, input.shape)
|
||||
}
|
||||
|
||||
export const validateMirrorInput = (input: MirrorInput) => {
|
||||
validateDocumentContext(input)
|
||||
validateShapeContext(input, input.shape)
|
||||
validateVector(input.origin, 'origin')
|
||||
validateVector(input.normal, 'normal', false)
|
||||
}
|
||||
|
||||
const validateShapeContext = (input: GeometryDocumentContext, shape: ShapeHandle) => {
|
||||
if (shape.documentId !== input.documentId) throw new Error(`Shape belongs to another document: ${shape.id}`)
|
||||
if (shape.documentVersion > input.documentVersion) throw new Error(`Shape version is newer than the result context: ${shape.id}`)
|
||||
@@ -339,6 +346,14 @@ export class BitbybitGeometryRuntime {
|
||||
return this.registerShape(kernelShape, input.documentId, input.documentVersion)
|
||||
}
|
||||
|
||||
async mirror(input: MirrorInput): Promise<ShapeHandle> {
|
||||
validateMirrorInput(input)
|
||||
const source = this.resolveShape(input.shape)
|
||||
const client = await this.readyClient()
|
||||
const kernelShape = await client.occt.transforms.mirrorAlongNormal({ shape: source.reference, origin: input.origin, normal: input.normal })
|
||||
return this.registerShape(kernelShape, input.documentId, input.documentVersion)
|
||||
}
|
||||
|
||||
async union(input: BooleanUnionInput): Promise<ShapeHandle> {
|
||||
validateBooleanUnionInput(input)
|
||||
const shapes = input.shapes.map((shape) => this.resolveShape(shape).reference)
|
||||
|
||||
Reference in New Issue
Block a user