From 08ad255d89181067886f47d0ef59bb18bd7e9e10 Mon Sep 17 00:00:00 2001 From: xiange Date: Sat, 15 Jun 2024 13:13:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20refactor:=20Adjusted=20code=20or?= =?UTF-8?q?ganization=20for=20shape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chili-core/src/shape/curve.ts | 14 +++++++++++- packages/chili-core/src/shape/shape.ts | 29 ------------------------ packages/chili-core/src/shape/surface.ts | 16 +++++++++++++ packages/chili-occ/src/occCurve.ts | 3 +-- packages/chili-occ/src/occHelps.ts | 4 +--- packages/chili-occ/src/occShape.ts | 5 ++-- 6 files changed, 33 insertions(+), 38 deletions(-) diff --git a/packages/chili-core/src/shape/curve.ts b/packages/chili-core/src/shape/curve.ts index c3a9c835..a387e3d6 100644 --- a/packages/chili-core/src/shape/curve.ts +++ b/packages/chili-core/src/shape/curve.ts @@ -1,7 +1,19 @@ // Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license. import { XYZ } from "../math"; -import { CurveType } from "./shape"; + +export enum CurveType { + Line, + Circle, + Ellipse, + Hyperbola, + Parabola, + BezierCurve, + BSplineCurve, + OffsetCurve, + OtherCurve, + TrimmedCurve, +} export enum Continuity { C0, diff --git a/packages/chili-core/src/shape/shape.ts b/packages/chili-core/src/shape/shape.ts index 32e72ef4..516c5029 100644 --- a/packages/chili-core/src/shape/shape.ts +++ b/packages/chili-core/src/shape/shape.ts @@ -7,35 +7,6 @@ import { IShapeMeshData } from "./meshData"; import { ShapeType } from "./shapeType"; import { ISurface } from "./surface"; -export enum CurveType { - Line, - Circle, - Ellipse, - Hyperbola, - Parabola, - BezierCurve, - BSplineCurve, - OffsetCurve, - OtherCurve, - TrimmedCurve, -} - -export enum SurfaceType { - Plate, - Bezier, - BSpline, - RectangularTrimmed, - Conical, - Cylinder, - Plane, - Spherical, - Toroidal, - Revolution, - Extrusion, - Offset, - Composite, -} - export enum Orientation { FORWARD, REVERSED, diff --git a/packages/chili-core/src/shape/surface.ts b/packages/chili-core/src/shape/surface.ts index d49c94b5..8228cbf0 100644 --- a/packages/chili-core/src/shape/surface.ts +++ b/packages/chili-core/src/shape/surface.ts @@ -3,6 +3,22 @@ import { Plane, XYZ } from "../math"; import { Continuity, ICurve } from "./curve"; +export enum SurfaceType { + Plate, + Bezier, + BSpline, + RectangularTrimmed, + Conical, + Cylinder, + Plane, + Spherical, + Toroidal, + Revolution, + Extrusion, + Offset, + Composite, +} + export interface ISurface { continuity(): Continuity; uIso(u: number): ICurve; diff --git a/packages/chili-occ/src/occCurve.ts b/packages/chili-occ/src/occCurve.ts index 2b891613..adda7cce 100644 --- a/packages/chili-occ/src/occCurve.ts +++ b/packages/chili-occ/src/occCurve.ts @@ -25,14 +25,13 @@ import { Geom_Circle, Geom_Conic, Geom_Curve, + Geom_Ellipse, Geom_Hyperbola, Geom_Line, Geom_OffsetCurve, Geom_Parabola, Geom_TrimmedCurve, } from "../occ-wasm/chili_occ"; - -import { Geom_Ellipse } from "opencascade.js/dist/opencascade.full"; import { OccHelps } from "./occHelps"; export class OccCurve implements ICurve, IDisposable { diff --git a/packages/chili-occ/src/occHelps.ts b/packages/chili-occ/src/occHelps.ts index e3dca7c2..c00ae980 100644 --- a/packages/chili-occ/src/occHelps.ts +++ b/packages/chili-occ/src/occHelps.ts @@ -18,7 +18,6 @@ import { import { GeomAbs_JoinType, GeomAbs_Shape, - GeomPlate_Surface, Geom_BSplineCurve, Geom_BezierCurve, Geom_Circle, @@ -29,7 +28,6 @@ import { Geom_OffsetCurve, Geom_Parabola, Geom_Surface, - Geom_SurfaceOfRevolution, Geom_TrimmedCurve, TopAbs_ShapeEnum, TopTools_ListOfShape, @@ -393,7 +391,7 @@ export class OccHelps { static fromArray(shapes: IShape[]): TopTools_ListOfShape { let listOfShape = new occ.TopTools_ListOfShape_1(); shapes.forEach((shape) => { - if (!(shape instanceof OccFace)) { + if (!(shape instanceof OccShape)) { throw new Error("The OCC kernel only supports OCC geometries."); } listOfShape.Append_1(shape.shape); diff --git a/packages/chili-occ/src/occShape.ts b/packages/chili-occ/src/occShape.ts index f07918ec..77ea092c 100644 --- a/packages/chili-occ/src/occShape.ts +++ b/packages/chili-occ/src/occShape.ts @@ -28,7 +28,6 @@ import { } from "chili-core"; import { BOPTools_AlgoTools3D, - BRepTools, BRep_Tool, TopoDS_Edge, TopoDS_Face, @@ -70,11 +69,11 @@ export class OccShape implements IShape { this.shapeType = OccHelps.getShapeType(shape); } isEmpty(): boolean { - return BOPTools_AlgoTools3D.IsEmptyShape(this.shape); + return occ.BOPTools_AlgoTools3D.IsEmptyShape(this.shape); } isClosed(): boolean { - return BRep_Tool.IsClosed_1(this.shape); + return occ.BRep_Tool.IsClosed_1(this.shape); } section(shape: IShape | Plane): IShape {