import oc from "../opencascade/initializer";
import {Face} from "../modeling";
import {Plane} from "../math";
/**
* Creates a polygon based on the specified parameters.
* @memberof primitives-2D
* @alias Polygon
* @param {Object} parameters - The parameters for the polygon.
* @param {Plane} [parameters.plane=Plane.XY] - The plane in which the polygon is constructed.
* @param {Vector[]} parameters.vertices - An array of vertices defining the polygon.
* @returns {Face} A `Face` object representing the constructed polygon.
*/
const Polygon = ({plane = Plane.XY, vertices}) => {
const builder = new oc.BRepBuilderAPI_MakePolygon_1();
vertices.forEach((vertex) => {
const globalPoint = plane.toWorldCoordinates(new oc.gp_Pnt_3(vertex.x, vertex.y, vertex.z));
builder.Add_1(globalPoint);
});
builder.Close();
return new Face(new oc.BRepBuilderAPI_MakeFace_15(builder.Wire(), true).Face());
};
export {Polygon};