Skip to content

Commit

Permalink
🦄 refactor: Adjusted code organization for shape
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Jun 15, 2024
1 parent ac01429 commit 08ad255
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 38 deletions.
14 changes: 13 additions & 1 deletion packages/chili-core/src/shape/curve.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
29 changes: 0 additions & 29 deletions packages/chili-core/src/shape/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions packages/chili-core/src/shape/surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions packages/chili-occ/src/occCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions packages/chili-occ/src/occHelps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import {
GeomAbs_JoinType,
GeomAbs_Shape,
GeomPlate_Surface,
Geom_BSplineCurve,
Geom_BezierCurve,
Geom_Circle,
Expand All @@ -29,7 +28,6 @@ import {
Geom_OffsetCurve,
Geom_Parabola,
Geom_Surface,
Geom_SurfaceOfRevolution,
Geom_TrimmedCurve,
TopAbs_ShapeEnum,
TopTools_ListOfShape,
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions packages/chili-occ/src/occShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from "chili-core";
import {
BOPTools_AlgoTools3D,
BRepTools,
BRep_Tool,
TopoDS_Edge,
TopoDS_Face,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 08ad255

Please sign in to comment.