@bitbybit-dev/occt
Version:
Bit By Bit Developers CAD algorithms using OpenCascade Technology kernel. Run in Node and in Browser.
207 lines (206 loc) • 8.05 kB
JavaScript
import * as Inputs from "../../api/inputs/inputs";
export class OCCTEdge {
constructor(occ, och) {
this.occ = occ;
this.och = och;
}
fromBaseLine(inputs) {
return this.line(inputs.line);
}
fromBaseLines(inputs) {
return inputs.lines.map(line => this.line(line));
}
fromBaseSegment(inputs) {
return this.line({ start: inputs.segment[0], end: inputs.segment[1] });
}
fromBaseSegments(inputs) {
return inputs.segments.map(segment => this.line({ start: segment[0], end: segment[1] }));
}
fromPoints(inputs) {
const edges = [];
for (let i = 0; i < inputs.points.length - 1; i++) {
const start = inputs.points[i];
const end = inputs.points[i + 1];
edges.push(this.line({ start, end }));
}
return edges;
}
fromBasePolyline(inputs) {
const points = inputs.polyline.points;
if (inputs.polyline.isClosed) {
points.push(points[0]);
}
return this.fromPoints({ points });
}
fromBaseTriangle(inputs) {
const points = inputs.triangle;
return this.fromBasePolyline({ polyline: { points, isClosed: true } });
}
fromBaseMesh(inputs) {
const edges = [];
inputs.mesh.forEach((triangle) => {
try {
edges.push(this.fromBaseTriangle({ triangle }));
}
catch (e) {
console.warn("Failed to make edges for triangle", triangle);
}
});
return edges.flat();
}
makeEdgeFromGeom2dCurveAndSurface(inputs) {
return this.och.edgesService.makeEdgeFromGeom2dCurveAndSurface(inputs);
}
line(inputs) {
return this.och.edgesService.lineEdge(inputs);
}
arcThroughThreePoints(inputs) {
return this.och.edgesService.arcThroughThreePoints(inputs);
}
arcThroughTwoPointsAndTangent(inputs) {
return this.och.edgesService.arcThroughTwoPointsAndTangent(inputs);
}
arcFromCircleAndTwoPoints(inputs) {
return this.och.edgesService.arcFromCircleAndTwoPoints(inputs);
}
arcFromCircleAndTwoAngles(inputs) {
return this.och.edgesService.arcFromCircleAndTwoAngles(inputs);
}
arcFromCirclePointAndAngle(inputs) {
return this.och.edgesService.arcFromCirclePointAndAngle(inputs);
}
createCircleEdge(inputs) {
return this.och.entitiesService.createCircle(inputs.radius, inputs.center, inputs.direction, Inputs.OCCT.typeSpecificityEnum.edge);
}
createEllipseEdge(inputs) {
return this.och.entitiesService.createEllipse(inputs.radiusMinor, inputs.radiusMajor, inputs.center, inputs.direction, Inputs.OCCT.typeSpecificityEnum.edge);
}
removeInternalEdges(inputs) {
const fusor = new this.occ.ShapeUpgrade_UnifySameDomain_2(inputs.shape, true, true, false);
fusor.Build();
const shape = fusor.Shape();
fusor.delete();
return shape;
}
getEdge(inputs) {
return this.och.shapeGettersService.getEdge(inputs);
}
edgesToPoints(inputs) {
return this.och.edgesService.edgesToPoints(inputs);
}
reversedEdge(inputs) {
const edge = inputs.shape;
const reversed = edge.Reversed();
const result = this.och.converterService.getActualTypeOfShape(reversed);
reversed.delete();
return result;
}
pointOnEdgeAtParam(inputs) {
return this.och.edgesService.pointOnEdgeAtParam(inputs);
}
pointsOnEdgesAtParam(inputs) {
return inputs.shapes.map((shape) => this.och.edgesService.pointOnEdgeAtParam({ shape, param: inputs.param }));
}
tangentOnEdgeAtParam(inputs) {
return this.och.edgesService.tangentOnEdgeAtParam(inputs);
}
tangentsOnEdgesAtParam(inputs) {
return inputs.shapes.map((shape) => this.och.edgesService.tangentOnEdgeAtParam({ shape, param: inputs.param }));
}
startPointOnEdge(inputs) {
return this.och.edgesService.startPointOnEdge(inputs);
}
startPointsOnEdges(inputs) {
return inputs.shapes.map(shape => this.och.edgesService.startPointOnEdge({ shape }));
}
endPointOnEdge(inputs) {
return this.och.edgesService.endPointOnEdge(inputs);
}
endPointsOnEdges(inputs) {
return inputs.shapes.map(shape => this.och.edgesService.endPointOnEdge({ shape }));
}
pointOnEdgeAtLength(inputs) {
return this.och.edgesService.pointOnEdgeAtLength(inputs);
}
pointsOnEdgesAtLength(inputs) {
return inputs.shapes.map((shape) => this.och.edgesService.pointOnEdgeAtLength({ shape, length: inputs.length }));
}
tangentOnEdgeAtLength(inputs) {
return this.och.edgesService.tangentOnEdgeAtLength(inputs);
}
tangentsOnEdgesAtLength(inputs) {
return inputs.shapes.map((shape) => this.och.edgesService.tangentOnEdgeAtLength({ shape, length: inputs.length }));
}
divideEdgeByParamsToPoints(inputs) {
return this.och.edgesService.divideEdgeByParamsToPoints(inputs);
}
divideEdgesByParamsToPoints(inputs) {
return inputs.shapes.map(shape => this.divideEdgeByParamsToPoints({ shape, nrOfDivisions: inputs.nrOfDivisions, removeEndPoint: inputs.removeEndPoint, removeStartPoint: inputs.removeStartPoint }));
}
divideEdgeByEqualDistanceToPoints(inputs) {
return this.och.edgesService.divideEdgeByEqualDistanceToPoints(inputs);
}
divideEdgesByEqualDistanceToPoints(inputs) {
return inputs.shapes.map(shape => this.divideEdgeByEqualDistanceToPoints({ shape, nrOfDivisions: inputs.nrOfDivisions, removeEndPoint: inputs.removeEndPoint, removeStartPoint: inputs.removeStartPoint }));
}
isEdgeLinear(inputs) {
return this.och.edgesService.isEdgeLinear(inputs);
}
isEdgeCircular(inputs) {
return this.och.edgesService.isEdgeCircular(inputs);
}
getEdges(inputs) {
return this.och.shapeGettersService.getEdges(inputs);
}
getEdgesAlongWire(inputs) {
return this.och.edgesService.getEdgesAlongWire(inputs);
}
getCircularEdgesAlongWire(inputs) {
return this.och.edgesService.getCircularEdgesAlongWire(inputs);
}
getLinearEdgesAlongWire(inputs) {
return this.och.edgesService.getLinearEdgesAlongWire(inputs);
}
getEdgeLength(inputs) {
return this.och.edgesService.getEdgeLength(inputs);
}
getEdgeLengthsOfShape(inputs) {
return this.och.edgesService.getEdgeLengthsOfShape(inputs);
}
getEdgesLengths(inputs) {
return this.och.edgesService.getEdgesLengths(inputs);
}
getEdgeCenterOfMass(inputs) {
return this.och.geomService.getLinearCenterOfMass(inputs);
}
getEdgesCentersOfMass(inputs) {
return this.och.edgesService.getEdgesCentersOfMass(inputs);
}
getCornerPointsOfEdgesForShape(inputs) {
return this.och.edgesService.getCornerPointsOfEdgesForShape(inputs);
}
getCircularEdgeCenterPoint(inputs) {
return this.och.edgesService.getCircularEdgeCenterPoint(inputs);
}
getCircularEdgeRadius(inputs) {
return this.och.edgesService.getCircularEdgeRadius(inputs);
}
getCircularEdgePlaneDirection(inputs) {
return this.och.edgesService.getCircularEdgePlaneDirection(inputs);
}
constraintTanLinesFromTwoPtsToCircle(inputs) {
return this.och.edgesService.constraintTanLinesFromTwoPtsToCircle(inputs);
}
constraintTanLinesFromPtToCircle(inputs) {
return this.och.edgesService.constraintTanLinesFromPtToCircle(inputs);
}
constraintTanLinesOnTwoCircles(inputs) {
return this.och.edgesService.constraintTanLinesOnTwoCircles(inputs);
}
constraintTanCirclesOnTwoCircles(inputs) {
return this.och.edgesService.constraintTanCirclesOnTwoCircles(inputs);
}
constraintTanCirclesOnCircleAndPnt(inputs) {
return this.och.edgesService.constraintTanCirclesOnCircleAndPnt(inputs);
}
}