primitives-1d_line.js

import oc from "../opencascade/initializer";
import {Edge} from "../modeling";
import {Plane, Vector} from "../math";

/**
 * Creates a line based on the start and end points.
 * @memberof primitives-1D
 * @alias Line
 * @param {Object} parameters - The parameters for the line.
 * @param {Plane} [parameters.plane=Plane.XY] - The plane in which the line is constructed.
 * @param {Vector} parameters.start - The start point of the line.
 * @param {Vector} parameters.end - The end point of the line.
 * @returns {Edge} An `Edge` object representing the constructed line.
 */
const Line = ({plane = Plane.XY, start, end}) => {
  const globalStart = plane.toWorldCoordinates(new oc.gp_Pnt_3(start.x, start.y, start.z));
  const globalEnd = plane.toWorldCoordinates(new oc.gp_Pnt_3(end.x, end.y, end.z));
  return new Edge(new oc.BRepBuilderAPI_MakeEdge_3(globalStart, globalEnd).Edge());
};

export {Line};