!2350 开发:实体子类实现清除Geometry

pull/2351/head
林三 1 year ago committed by ChenX
parent 22d300387d
commit 05b684c121

@ -189,6 +189,17 @@ export class CylinderHole extends Hole
} }
} }
ClearDraw(): this
{
if (this._EdgeGeometry)
this._EdgeGeometry.dispose();
this._EdgeGeometry = undefined;
if (this._MeshGeometry)
this._MeshGeometry.dispose();
this._MeshGeometry = undefined;
return super.ClearDraw();
}
protected _ReadFile(file: CADFiler) protected _ReadFile(file: CADFiler)
{ {
super._ReadFile(file); super._ReadFile(file);

@ -453,6 +453,18 @@ export class ExtrudeHole extends Hole
mesh.material = ColorMaterial.GetConceptualMaterial(this.ColorIndex); mesh.material = ColorMaterial.GetConceptualMaterial(this.ColorIndex);
} }
} }
ClearDraw(): this
{
if (this._EdgeGeometry)
this._EdgeGeometry.dispose();
this._EdgeGeometry = undefined;
if (this._MeshGeometry)
this._MeshGeometry.dispose();
this._MeshGeometry = undefined;
return super.ClearDraw();
}
get OBB(): OBB get OBB(): OBB
{ {
let size = this.ContourCurve.BoundingBox.getSize(new Vector3).setZ(this.Height); let size = this.ContourCurve.BoundingBox.getSize(new Vector3).setZ(this.Height);

@ -1,9 +1,9 @@
import { Box3, Face3, Geometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, ShapeUtils, Vector2, Vector3 } from "three"; import { Box3, Face3, Geometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, ShapeUtils, Vector2, Vector3 } from "three";
import { ColorMaterial } from "../../Common/ColorPalette"; import { ColorMaterial } from "../../Common/ColorPalette";
import { Object3DRemoveAll } from "../../Common/Dispose"; import { Object3DRemoveAll } from "../../Common/Dispose";
import { clamp, FixIndex } from "../../Common/Utils"; import { FixIndex, clamp } from "../../Common/Utils";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode"; import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
import { angle, AsVector2, equaln, equalv3, isParallelTo, YAxis, ZeroVec } from "../../Geometry/GeUtils"; import { AsVector2, YAxis, ZeroVec, angle, equaln, equalv3, isParallelTo } from "../../Geometry/GeUtils";
import { Matrix2 } from "../../Geometry/Matrix2"; import { Matrix2 } from "../../Geometry/Matrix2";
import { Orbit } from "../../Geometry/Orbit"; import { Orbit } from "../../Geometry/Orbit";
import { RenderType } from "../../GraphicsSystem/RenderType"; import { RenderType } from "../../GraphicsSystem/RenderType";
@ -298,9 +298,17 @@ export class RevolveSolid extends Entity
UpdateDrawGeometry() UpdateDrawGeometry()
{ {
if (this._MeshGeometry)
this._MeshGeometry.dispose();
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
private static MeshNromal = new MeshNormalMaterial({ wireframe: true }); private static MeshNromal = new MeshNormalMaterial({ wireframe: true });
UpdateDrawObject(type: RenderType, obj: Object3D) UpdateDrawObject(type: RenderType, obj: Object3D)

@ -257,10 +257,20 @@ export class SweepSolid extends Entity
UpdateDrawGeometry() UpdateDrawGeometry()
{ {
if (this._EdgeGeometry)
this._EdgeGeometry.dispose();
this._EdgeGeometry = undefined; this._EdgeGeometry = undefined;
if (this._MeshGeometry)
this._MeshGeometry.dispose();
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
UpdateDrawObject(renderType: RenderType, obj: Object3D) UpdateDrawObject(renderType: RenderType, obj: Object3D)
{ {
DisposeThreeObj(obj); DisposeThreeObj(obj);

@ -2073,6 +2073,12 @@ export class ExtrudeSolid extends Entity
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
UpdateDrawObject(renderType: RenderType, obj: Object3D) UpdateDrawObject(renderType: RenderType, obj: Object3D)
{ {
DisposeThreeObj(obj); DisposeThreeObj(obj);

@ -275,10 +275,20 @@ export class Region extends Entity
UpdateDrawGeometry() UpdateDrawGeometry()
{ {
if (this._EdgeGeometry)
this._EdgeGeometry.dispose();
this._EdgeGeometry = undefined; this._EdgeGeometry = undefined;
if (this._MeshGeometry)
this._MeshGeometry.dispose();
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
{ {
if (renderType === RenderType.Wireframe) if (renderType === RenderType.Wireframe)

@ -429,6 +429,12 @@ export class BulkheadCeiling extends Entity
this._FaceGeometry = undefined; this._FaceGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
GetGripPoints(): Array<Vector3> GetGripPoints(): Array<Vector3>
{ {
let pts = []; let pts = [];

@ -1,4 +1,4 @@
import { Box3, BufferGeometry, Geometry, Line as TLine, LineSegments, Mesh, Object3D, ShapeGeometry, Vector2, Vector3 } from "three"; import { Box3, BufferGeometry, Geometry, LineSegments, Mesh, Object3D, ShapeGeometry, Line as TLine, Vector2, Vector3 } from "three";
import { ColorMaterial } from "../../../../Common/ColorPalette"; import { ColorMaterial } from "../../../../Common/ColorPalette";
import { Box3Ext } from "../../../../Geometry/Box"; import { Box3Ext } from "../../../../Geometry/Box";
import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils";
@ -280,6 +280,11 @@ export class RoomFlatBase extends RoomBase
} }
} }
ClearDraw()
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
//#region -----------------------------File----------------------------- //#region -----------------------------File-----------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化 //对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化

@ -9,7 +9,7 @@ import { UpdateDraw } from "../../../../../Common/Status";
import { ObjectSnapMode } from "../../../../../Editor/ObjectSnapMode"; import { ObjectSnapMode } from "../../../../../Editor/ObjectSnapMode";
import { Box3Ext } from "../../../../../Geometry/Box"; import { Box3Ext } from "../../../../../Geometry/Box";
import { CreatePolylinePath } from "../../../../../Geometry/CreatePolylinePath"; import { CreatePolylinePath } from "../../../../../Geometry/CreatePolylinePath";
import { AsVector3, equalv2, ZAxis } from "../../../../../Geometry/GeUtils"; import { AsVector3, ZAxis, equalv2 } from "../../../../../Geometry/GeUtils";
import { IntersectOption } from "../../../../../GraphicsSystem/IntersectWith"; import { IntersectOption } from "../../../../../GraphicsSystem/IntersectWith";
import { RenderType } from "../../../../../GraphicsSystem/RenderType"; import { RenderType } from "../../../../../GraphicsSystem/RenderType";
import { Factory } from "../../../../CADFactory"; import { Factory } from "../../../../CADFactory";
@ -341,6 +341,12 @@ export class RoomHolePolyline extends RoomHoleBase
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
private _EdgeGeometry: Geometry; private _EdgeGeometry: Geometry;
get EdgeGeometry() get EdgeGeometry()
{ {

@ -1,4 +1,4 @@
import { BufferGeometry, Face3, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, LineSegments, MathUtils, Matrix3, Mesh, Object3D, ShapeUtils, Vector2, Vector3 } from "three"; import { BufferGeometry, Face3, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, LineSegments, MathUtils, Matrix3, Mesh, Object3D, ShapeUtils, Line as TLine, Vector2, Vector3 } from "three";
import { Line2 } from "three/examples/jsm/lines/Line2"; import { Line2 } from "three/examples/jsm/lines/Line2";
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices";
@ -8,7 +8,7 @@ import { ObjectSnapMode } from "../../../../Editor/ObjectSnapMode";
import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils";
import { SubtractRange, Tape } from "../../../../Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2"; import { SubtractRange, Tape } from "../../../../Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2";
import { SplitArcParams, SplitCurvePoints } from "../../../../Geometry/ExtrudeMeshGeomBuilder/SplitCurveParams"; import { SplitArcParams, SplitCurvePoints } from "../../../../Geometry/ExtrudeMeshGeomBuilder/SplitCurveParams";
import { AsVector2, AsVector3, clampRad, equaln, updateGeometry, ZeroVec } from "../../../../Geometry/GeUtils"; import { AsVector2, AsVector3, ZeroVec, clampRad, equaln, updateGeometry } from "../../../../Geometry/GeUtils";
import { RenderType } from "../../../../GraphicsSystem/RenderType"; import { RenderType } from "../../../../GraphicsSystem/RenderType";
import { Factory } from "../../../CADFactory"; import { Factory } from "../../../CADFactory";
import { CADFiler } from "../../../CADFiler"; import { CADFiler } from "../../../CADFiler";
@ -17,7 +17,7 @@ import { Curve } from "../../../Entity/Curve";
import { Line } from "../../../Entity/Line"; import { Line } from "../../../Entity/Line";
import { Polyline } from "../../../Entity/Polyline"; import { Polyline } from "../../../Entity/Polyline";
import { GetArcParam, GetLineParam } from "../../ParseService/GetCurveParam"; import { GetArcParam, GetLineParam } from "../../ParseService/GetCurveParam";
import { applyMixins, CURVE_FACE_TYPE_KEY, CURVE_MESH_NAMES, RoomWallBase, WallFaceType } from "./RoomWallBase"; import { CURVE_FACE_TYPE_KEY, CURVE_MESH_NAMES, RoomWallBase, WallFaceType, applyMixins } from "./RoomWallBase";
import { WallSnapMode } from "./WallSnapMode"; import { WallSnapMode } from "./WallSnapMode";
@Factory @Factory
@ -143,6 +143,11 @@ export class RoomWallArc extends RoomWallBase
this._MeshGeometry = undefined; this._MeshGeometry = undefined;
} }
ClearDraw(): this
{
this.UpdateDrawGeometry();
return super.ClearDraw();
}
private _EdgeGeometry: BufferGeometry; private _EdgeGeometry: BufferGeometry;
private _MeshGeometry: Geometry; private _MeshGeometry: Geometry;

@ -755,8 +755,17 @@ export class RoomWallLine extends RoomWallBase
line.geometry = geometry; line.geometry = geometry;
} }
} }
//#endregion
ClearDraw()
{
if (this._MeshGeometry)
this._MeshGeometry = undefined;
if (this._EdgeGeometry)
this._EdgeGeometry = undefined;
return super.ClearDraw();
}
//#endregion
//#region -------------------------File------------------------- //#region -------------------------File-------------------------
//对象从文件中读取数据,初始化自身 //对象从文件中读取数据,初始化自身

Loading…
Cancel
Save