Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | 43x 43x 43x 43x 4x 4x 39x 39x 43x 43x 43x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 262x 26x 26x 2x 2x 2x 26x 2x 2x 2x 26x 26x 26x 26x 26x 26x 26x 26x 26x 4x 4x 4x 4x 4x 26x 26x 344x 26x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 2x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 166x 17x 17x 1x 1x 1x 17x 1x 1x 1x 17x 17x 17x 17x 17x 17x 17x 17x 2x 2x 2x 2x 2x 2x 2x 2x 2x 17x 17x 236x 17x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 94x 12x 12x 2x 2x 2x 12x 2x 2x 2x 12x 12x 12x 12x 12x 12x 12x 3x 3x 3x 12x 12x 122x 12x | import {
TopoDS_Compound,
TopoDS_Edge,
TopoDS_Shape,
} from "../../../bitbybit-dev-occt/bitbybit-dev-occt";
import * as Inputs from "../../api/inputs/inputs";
import { TransformsService } from "./transforms.service";
import { ConverterService } from "./converter.service";
import { WiresService } from "./wires.service";
import { BaseBitByBit } from "../../base";
import { EdgesService } from "./edges.service";
import { EntitiesService } from "./entities.service";
export class DimensionsService {
constructor(
private readonly base: BaseBitByBit,
private readonly transformsService: TransformsService,
private readonly converterService: ConverterService,
private readonly entitiesService: EntitiesService,
private readonly edgesService: EdgesService,
private readonly wiresService: WiresService
) { }
/**
* Evaluates a mathematical expression or template string with a given value
* @param expression The expression to evaluate (can contain 'val' placeholder)
* @param value The numeric value to substitute for 'val'
* @param decimalPlaces Number of decimal places to format the result
* @param removeTrailingZeros Whether to remove trailing zeros from the result
* @returns The evaluated expression as a formatted string
*/
private evaluateExpression(expression: string, value: number, decimalPlaces: number, removeTrailingZeros = false): string {
try {
// Replace 'val' with the actual value in the expression
const evaluatedExpression = expression.replace(/val/g, value.toString());
// Simple math expression evaluation (supports +, -, *, /, parentheses)
// Only allow safe mathematical operations
const safeExpression = evaluatedExpression.replace(/[^0-9+\-*/.() ]/g, "");
if (safeExpression !== evaluatedExpression) {
// If expression contains non-math characters, treat it as a template
// For template strings, we still want to format numbers with decimal places
const formattedValue = removeTrailingZeros
? this.base.math.roundAndRemoveTrailingZeros({ number: value, decimalPlaces }).toString()
: value.toFixed(decimalPlaces);
return expression.replace(/val/g, formattedValue);
}
// Evaluate mathematical expression and apply decimal places
const result = Function("\"use strict\"; return (" + safeExpression + ")")();
return removeTrailingZeros
? this.base.math.roundAndRemoveTrailingZeros({ number: result, decimalPlaces }).toString()
: result.toFixed(decimalPlaces);
} catch (error) {
// If evaluation fails, return the original value formatted
return removeTrailingZeros
? this.base.math.roundAndRemoveTrailingZeros({ number: value, decimalPlaces }).toString()
: value.toFixed(decimalPlaces);
}
}
/**
* Formats dimension label text with optional expression evaluation
* @param value The numeric value to display
* @param labelOverwrite Optional expression to evaluate instead of raw value
* @param decimalPlaces Number of decimal places for formatting
* @param labelSuffix Suffix to append to the text
* @param removeTrailingZeros Whether to remove trailing zeros from the result
* @returns Formatted dimension label text
*/
private formatDimensionLabel(
value: number,
labelOverwrite: string | undefined,
decimalPlaces: number,
labelSuffix: string,
removeTrailingZeros = false
): string {
let result: string;
if (labelOverwrite) {
result = this.evaluateExpression(labelOverwrite, value, decimalPlaces, removeTrailingZeros);
} else E{
if (removeTrailingZeros) {
result = this.base.math.roundAndRemoveTrailingZeros({ number: value, decimalPlaces }).toString();
} else {
result = value.toFixed(decimalPlaces);
}
}
return result + " " + labelSuffix;
}
private createArrow(inputs: {
tipPoint: Inputs.Base.Point3,
direction: Inputs.Base.Vector3,
normal: Inputs.Base.Vector3,
size: number,
angle: number,
flipped: boolean
}): TopoDS_Compound {
const shapesToDelete: TopoDS_Shape[] = [];
// Normalize the direction vector (should point away from tip when not flipped)
const dir = this.base.vector.normalized({ vector: inputs.direction });
// Determine arrow direction based on flip
const arrowDir = inputs.flipped
? dir
: this.base.vector.mul({ vector: dir, scalar: -1 }) as Inputs.Base.Vector3;
// Calculate the perpendicular vector in the plane
const perpendicular = this.base.vector.cross({
first: arrowDir as Inputs.Base.Vector3,
second: inputs.normal
}) as Inputs.Base.Vector3;
const perpNorm = this.base.vector.normalized({ vector: perpendicular });
// Calculate half angle in radians
const halfAngleRad = (inputs.angle / 2) * Math.PI / 180;
// Calculate arrow line endpoints
const baseLength = inputs.size * Math.cos(halfAngleRad);
const sideOffset = inputs.size * Math.sin(halfAngleRad);
// Base point for both arrow lines
const baseVec = this.base.vector.mul({ vector: arrowDir, scalar: baseLength }) as Inputs.Base.Vector3;
const basePoint = this.base.point.translatePoints({
points: [inputs.tipPoint],
translation: baseVec
})[0];
// Calculate the two arrow line endpoints
const sideVec1 = this.base.vector.mul({ vector: perpNorm, scalar: sideOffset }) as Inputs.Base.Vector3;
const sideVec2 = this.base.vector.mul({ vector: perpNorm, scalar: -sideOffset }) as Inputs.Base.Vector3;
const endPoint1 = this.base.point.translatePoints({
points: [basePoint],
translation: sideVec1
})[0];
const endPoint2 = this.base.point.translatePoints({
points: [basePoint],
translation: sideVec2
})[0];
// Create the two arrow lines
const line1 = this.wiresService.createLineWireWithExtensions({
start: inputs.tipPoint,
end: endPoint1,
extensionStart: 0,
extensionEnd: 0
});
const line2 = this.wiresService.createLineWireWithExtensions({
start: inputs.tipPoint,
end: endPoint2,
extensionStart: 0,
extensionEnd: 0
});
const result = this.converterService.makeCompound({ shapes: [line1, line2] });
// Cleanup
shapesToDelete.forEach(shape => shape.delete());
return result;
}
simpleLinearLengthDimension(inputs: Inputs.OCCT.SimpleLinearLengthDimensionDto): TopoDS_Compound {
const shapesToDelete: TopoDS_Shape[] = [];
const lineBetweenPoints = this.wiresService.createLineWireWithExtensions({
start: inputs.start,
end: inputs.end,
extensionStart: inputs.crossingSize,
extensionEnd: inputs.crossingSize,
});
shapesToDelete.push(lineBetweenPoints);
const translatedLine = this.transformsService.translate({
shape: lineBetweenPoints,
translation: inputs.direction,
});
const translatedPts = this.base.point.translatePoints({
points: [inputs.start, inputs.end],
translation: inputs.direction,
});
const translatedStartPt = translatedPts[0];
const translatedEndPt = translatedPts[1];
const startLineToTranslatedPoint = this.wiresService.createLineWireWithExtensions({
start: inputs.start,
end: translatedStartPt,
extensionStart: -inputs.offsetFromPoints,
extensionEnd: inputs.crossingSize,
});
const endLineToTranslatedPoint = this.wiresService.createLineWireWithExtensions({
start: inputs.end,
end: translatedEndPt,
extensionStart: -inputs.offsetFromPoints,
extensionEnd: inputs.crossingSize,
});
const midPt = this.wiresService.midPointOnWire({ shape: translatedLine });
const length = this.base.point.distance({
startPoint: inputs.start,
endPoint: inputs.end,
});
const labelText = this.formatDimensionLabel(
length,
inputs.labelOverwrite,
inputs.decimalPlaces,
inputs.labelSuffix,
inputs.removeTrailingZeros
);
const txtOpt = new Inputs.OCCT.TextWiresDto();
txtOpt.text = labelText;
txtOpt.xOffset = 0;
txtOpt.yOffset = 0;
txtOpt.height = inputs.labelSize;
txtOpt.centerOnOrigin = true;
const txt = this.wiresService.textWiresWithData(txtOpt);
// get the up vector for the dimension plane
const normalThreePoints = this.base.point.normalFromThreePoints({
point1: inputs.start,
point2: inputs.end,
point3: midPt,
reverseNormal: true,
});
const dirStartEnd = this.base.vector.sub({
first: inputs.end,
second: inputs.start,
}) as Inputs.Base.Vector3;
let currentShape = this.transformsService.rotate({
shape: txt.compound,
angle: -90 + (inputs.labelRotation || 0),
axis: [0, 1, 0],
});
shapesToDelete.push(...txt.shapes.map((s) => s.shape));
let previousShape = currentShape;
// Apply horizontal flip if requested
if (inputs.labelFlipHorizontal) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [-1, 1, 1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
// Apply vertical flip if requested
if (inputs.labelFlipVertical) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [1, 1, -1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
shape: currentShape,
fromOrigin: [0, 0, 0],
fromNorm: [0, 1, 0],
fromAx: [0, 0, 1],
toOrigin: [0, 0, 0],
toNorm: normalThreePoints,
toAx: dirStartEnd,
});
shapesToDelete.push(previousShape);
const normDir = this.base.vector.normalized({ vector: inputs.direction });
const offsetLabelVec = this.base.vector.mul({ vector: normDir, scalar: inputs.labelOffset });
const addToDir = this.base.vector.add({
first: midPt,
second: offsetLabelVec,
}) as Inputs.Base.Vector3;
const labelTransformed = this.transformsService.translate({
shape: alignedLabelTxtToDir,
translation: addToDir
});
shapesToDelete.push(alignedLabelTxtToDir);
const shapesToInclude: TopoDS_Shape[] = [translatedLine, startLineToTranslatedPoint, endLineToTranslatedPoint, labelTransformed];
// Add arrows if enabled
if (inputs.endType === Inputs.OCCT.dimensionEndTypeEnum.arrow) {
// Arrow at start point - points outward by default
const startArrow = this.createArrow({
tipPoint: translatedStartPt,
direction: dirStartEnd,
normal: normalThreePoints,
size: inputs.arrowSize,
angle: inputs.arrowAngle,
flipped: !inputs.arrowsFlipped
});
shapesToInclude.push(startArrow);
// Arrow at end point (direction is reversed) - points outward by default
const endArrowDir = this.base.vector.mul({ vector: dirStartEnd, scalar: -1 }) as Inputs.Base.Vector3;
const endArrow = this.createArrow({
tipPoint: translatedEndPt,
direction: endArrowDir,
normal: normalThreePoints,
size: inputs.arrowSize,
angle: inputs.arrowAngle,
flipped: !inputs.arrowsFlipped
});
shapesToInclude.push(endArrow);
}
const res = this.converterService.makeCompound({ shapes: shapesToInclude });
// delete shapes
shapesToDelete.forEach((shape) => {
shape.delete();
});
return res;
}
simpleAngularDimension(inputs: Inputs.OCCT.SimpleAngularDimensionDto): TopoDS_Compound {
const shapesToDelete: TopoDS_Shape[] = [];
const normDir1 = this.base.vector.normalized({ vector: inputs.direction1 });
const endVec = this.base.vector.mul({ vector: normDir1, scalar: inputs.radius }) as Inputs.Base.Point3;
const endPt = this.base.point.translatePoints({
points: [endVec],
translation: inputs.center,
})[0];
const line1WithExt = this.wiresService.createLineWireWithExtensions({
start: inputs.center,
end: endPt,
extensionStart: -inputs.offsetFromCenter,
extensionEnd: inputs.extraSize,
});
const normDir2 = this.base.vector.normalized({ vector: inputs.direction2 });
const endVec2 = this.base.vector.mul({ vector: normDir2, scalar: inputs.radius }) as Inputs.Base.Point3;
const endPt2 = this.base.point.translatePoints({
points: [endVec2],
translation: inputs.center,
})[0];
const line2WithExt = this.wiresService.createLineWireWithExtensions({
start: inputs.center,
end: endPt2,
extensionStart: -inputs.offsetFromCenter,
extensionEnd: inputs.extraSize,
});
const normalThreePoints = this.base.point.normalFromThreePoints({
point1: inputs.center,
point2: endPt,
point3: endPt2,
reverseNormal: true,
});
const normalThreePointsRev = this.base.point.normalFromThreePoints({
point1: inputs.center,
point2: endPt,
point3: endPt2,
reverseNormal: false,
});
const circ = this.entitiesService.createCircle(inputs.radius, inputs.center, normalThreePointsRev, Inputs.OCCT.typeSpecificityEnum.edge) as TopoDS_Edge;
shapesToDelete.push(circ);
const arc = this.edgesService.arcFromCircleAndTwoPoints({
circle: circ,
start: endPt,
end: endPt2,
sense: false,
});
shapesToDelete.push(arc);
const wireArc = this.wiresService.createWireFromEdge({ shape: arc });
const midPt = this.wiresService.midPointOnWire({ shape: wireArc });
let angle = this.base.vector.angleBetween({
first: inputs.direction1,
second: inputs.direction2,
}) as number;
if (inputs.radians) {
angle = this.base.math.degToRad({ number: angle });
}
const labelText = this.formatDimensionLabel(
angle,
inputs.labelOverwrite,
inputs.decimalPlaces,
inputs.labelSuffix,
inputs.removeTrailingZeros
);
const txtOpt = new Inputs.OCCT.TextWiresDto();
txtOpt.text = labelText;
txtOpt.xOffset = 0;
txtOpt.yOffset = 0;
txtOpt.height = inputs.labelSize;
txtOpt.centerOnOrigin = true;
const txt = this.wiresService.textWiresWithData(txtOpt);
const vectorToMid = this.base.vector.sub({
first: midPt,
second: inputs.center,
}) as Inputs.Base.Vector3;
const normVecToMid = this.base.vector.normalized({ vector: vectorToMid }) as Inputs.Base.Vector3;
let currentShape = this.transformsService.rotate({
shape: txt.compound,
angle: inputs.labelRotation || 0,
axis: [0, 1, 0],
});
shapesToDelete.push(...txt.shapes.map((s) => s.shape));
let previousShape = currentShape;
// Apply horizontal flip if requested
if (inputs.labelFlipHorizontal) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [-1, 1, 1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
// Apply vertical flip if requested
if (inputs.labelFlipVertical) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [1, 1, -1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
shape: currentShape,
fromOrigin: [0, 0, 0],
fromNorm: [0, 1, 0],
fromAx: [0, 0, 1],
toOrigin: [0, 0, 0],
toNorm: normalThreePoints,
toAx: normVecToMid,
});
shapesToDelete.push(previousShape);
const offsetLabelVec = this.base.vector.mul({ vector: normVecToMid, scalar: inputs.labelOffset });
const addToDir = this.base.vector.add({
first: midPt,
second: offsetLabelVec,
}) as Inputs.Base.Vector3;
const labelTransformed = this.transformsService.translate({
shape: alignedLabelTxtToDir,
translation: addToDir
});
shapesToDelete.push(alignedLabelTxtToDir);
const shapesToInclude: TopoDS_Shape[] = [line1WithExt, line2WithExt, wireArc, labelTransformed];
// Add arrows if enabled
if (inputs.endType === Inputs.OCCT.dimensionEndTypeEnum.arrow) {
// Get points on the arc at the start and end for arrow placement
const arcStartPoint = this.edgesService.pointOnEdgeAtParam({
shape: arc,
param: 0
});
const arcEndPoint = this.edgesService.pointOnEdgeAtParam({
shape: arc,
param: 1
});
// Get tangent directions at arc endpoints for arrow placement
const arcStartTangent = this.edgesService.tangentOnEdgeAtParam({
shape: arc,
param: 0
});
const arcEndTangent = this.edgesService.tangentOnEdgeAtParam({
shape: arc,
param: 1
});
// Arrow at first direction point (start of arc) - points outward by default
const startArrow = this.createArrow({
tipPoint: arcStartPoint,
direction: arcStartTangent,
normal: normalThreePoints,
size: inputs.arrowSize,
angle: inputs.arrowAngle,
flipped: !inputs.arrowsFlipped
});
shapesToInclude.push(startArrow);
// Reverse the end tangent so both arrows point outward along the arc by default
const reversedEndTangent = this.base.vector.mul({
vector: arcEndTangent,
scalar: -1
}) as Inputs.Base.Vector3;
// Arrow at second direction point (end of arc) - points outward by default
const endArrow = this.createArrow({
tipPoint: arcEndPoint,
direction: reversedEndTangent,
normal: normalThreePoints,
size: inputs.arrowSize,
angle: inputs.arrowAngle,
flipped: !inputs.arrowsFlipped
});
shapesToInclude.push(endArrow);
}
const res = this.converterService.makeCompound({ shapes: shapesToInclude });
// delete shapes
shapesToDelete.forEach((shape) => {
shape.delete();
});
return res;
}
pinWithLabel(inputs: Inputs.OCCT.PinWithLabelDto): TopoDS_Compound {
const pinLine = this.wiresService.createLineWireWithExtensions({
start: inputs.startPoint,
end: inputs.endPoint,
extensionStart: -inputs.offsetFromStart,
extensionEnd: 0,
});
const txtOpt = new Inputs.OCCT.TextWiresDto();
txtOpt.text = inputs.label;
txtOpt.xOffset = 0;
txtOpt.yOffset = 0;
txtOpt.height = inputs.labelSize;
txtOpt.centerOnOrigin = true;
const text = this.wiresService.textWiresWithData(txtOpt);
const textWidth = text.data.width;
const dirNorm = this.base.vector.normalized({ vector: inputs.direction });
const offsetLabelVec = this.base.vector.mul({ vector: dirNorm, scalar: textWidth / 2 + inputs.labelOffset });
// const translateTxtVec = this.vector.add({ first: inputs.direction, second: offsetLabelVec }) as Inputs.Base.Vector3;
const endPtLabelLine = this.base.point.translatePoints({
points: [inputs.endPoint],
translation: inputs.direction,
})[0];
const lineBeneathLabel = this.wiresService.createLineWireWithExtensions({
start: inputs.endPoint,
end: endPtLabelLine,
extensionStart: 0,
extensionEnd: 0,
});
const normalThreePoints = this.base.point.normalFromThreePoints({
point1: inputs.startPoint,
point2: inputs.endPoint,
point3: endPtLabelLine,
reverseNormal: false,
});
let currentShape = this.transformsService.rotate({
shape: text.compound,
angle: -90 + (inputs.labelRotation || 0),
axis: [0, 1, 0],
});
const shapesToDelete = text.shapes.map((s) => s.shape);
let previousShape = currentShape;
// Apply horizontal flip if requested
if (inputs.labelFlipHorizontal) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [-1, 1, 1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
// Apply vertical flip if requested
if (inputs.labelFlipVertical) {
currentShape = this.transformsService.scale3d({
shape: currentShape,
scale: [1, 1, -1],
center: [0, 0, 0]
});
shapesToDelete.push(previousShape);
previousShape = currentShape;
}
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
shape: currentShape,
fromOrigin: [0, 0, 0],
fromNorm: [0, 1, 0],
fromAx: [0, 0, 1],
toOrigin: [0, 0, 0],
toNorm: normalThreePoints,
toAx: dirNorm as Inputs.Base.Vector3,
});
shapesToDelete.push(previousShape);
const addToDir = this.base.vector.add({
first: endPtLabelLine,
second: offsetLabelVec,
}) as Inputs.Base.Vector3;
const labelTransformed = this.transformsService.translate({
shape: alignedLabelTxtToDir,
translation: addToDir,
});
shapesToDelete.push(alignedLabelTxtToDir);
const shapesToInclude: TopoDS_Shape[] = [pinLine, labelTransformed, lineBeneathLabel];
// Add arrow if enabled
if (inputs.endType === Inputs.OCCT.dimensionEndTypeEnum.arrow) {
// Calculate the direction from start to end for the pin
const pinDirection = this.base.vector.sub({
first: inputs.endPoint,
second: inputs.startPoint,
}) as Inputs.Base.Vector3;
// Arrow at the start point (default orientation is flipped, then apply user flip)
const arrow = this.createArrow({
tipPoint: inputs.startPoint,
direction: pinDirection,
normal: normalThreePoints,
size: inputs.arrowSize,
angle: inputs.arrowAngle,
flipped: !inputs.arrowsFlipped
});
shapesToInclude.push(arrow);
}
const res = this.converterService.makeCompound({ shapes: shapesToInclude });
// delete shapes
shapesToDelete.forEach((shape) => {
shape.delete();
});
return res;
}
}
|