!680 面域的导出

pull/680/MERGE
肖诗雅 5 years ago committed by ChenX
parent 37b343af68
commit 660aca1769

@ -6,13 +6,14 @@ import { Entitys2Data } from "./ExportData";
import pako from "pako"; import pako from "pako";
import { HotCMD } from "../Hot/HotCommand"; import { HotCMD } from "../Hot/HotCommand";
import { CURRENT_HOST } from "../Common/HostUrl"; import { CURRENT_HOST } from "../Common/HostUrl";
import { Region } from "../DatabaseServices/Entity/Region";
@HotCMD @HotCMD
export class Command_ExportView implements Command export class Command_ExportView implements Command
{ {
async exec() async exec()
{ {
let ssRes = await app.Editor.GetSelection({ Filter: { filterTypes: [Board] } }); let ssRes = await app.Editor.GetSelection({ Filter: { filterTypes: [Board, Region] } });
if (ssRes.Status !== PromptStatus.OK) return; if (ssRes.Status !== PromptStatus.OK) return;
let ents = ssRes.SelectSet.SelectEntityList; let ents = ssRes.SelectSet.SelectEntityList;

@ -8,8 +8,10 @@ import { Curve } from "../DatabaseServices/Entity/Curve";
import { Entity } from "../DatabaseServices/Entity/Entity"; import { Entity } from "../DatabaseServices/Entity/Entity";
import { ExtrudeSolid } from "../DatabaseServices/Entity/Extrude"; import { ExtrudeSolid } from "../DatabaseServices/Entity/Extrude";
import { Polyline } from "../DatabaseServices/Entity/Polyline"; import { Polyline } from "../DatabaseServices/Entity/Polyline";
import { Region } from "../DatabaseServices/Entity/Region";
import { ObjectId } from "../DatabaseServices/ObjectId"; import { ObjectId } from "../DatabaseServices/ObjectId";
import { PhysicalMaterialRecord } from "../DatabaseServices/PhysicalMaterialRecord"; import { PhysicalMaterialRecord } from "../DatabaseServices/PhysicalMaterialRecord";
import { Shape } from "../DatabaseServices/Shape";
import { TextureTableRecord } from "../DatabaseServices/Texture"; import { TextureTableRecord } from "../DatabaseServices/Texture";
import { Command } from "../Editor/CommandMachine"; import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult"; import { PromptStatus } from "../Editor/PromptResult";
@ -41,6 +43,8 @@ export function Entitys2Data(ents: Entity[])
} }
else if (e instanceof SweepSolid) else if (e instanceof SweepSolid)
d.Entitys.push(ConverSweep2Data(e)); d.Entitys.push(ConverSweep2Data(e));
else if (e instanceof Region)
d.Entitys.push(ConveRegion2Data(e));
} }
if (materials.size > 0) if (materials.size > 0)
{ {
@ -107,6 +111,23 @@ function ConverSweep2Data(e: SweepSolid)
return ed; return ed;
} }
function ConveRegion2Data(e: Region)
{
let reg: any = {};
reg.Type = "Region";
reg.Shapes = e.ShapeManager.ShapeList.map(ConverShape2Data);
reg.OCS = e.OCS.toArray();
return reg;
}
function ConverShape2Data(e: Shape)
{
let d = {} as any;
d.Contour = Curve2Data(e.Outline.Curve);
d.Holes = e.Holes.map(c => Curve2Data(c.Curve));
return d;
}
function ConverMaterial(material: PhysicalMaterialRecord) function ConverMaterial(material: PhysicalMaterialRecord)
{ {
let d: any = {}; let d: any = {};

@ -16,7 +16,7 @@ let cache = new WeakMap();
export class Contour export class Contour
{ {
private m_Curve: Polyline | Circle; private _Curve: Polyline | Circle;
protected SetCurve(cu: Polyline | Circle) protected SetCurve(cu: Polyline | Circle)
{ {
@ -25,7 +25,7 @@ export class Contour
if (cu.Area2 < 0) if (cu.Area2 < 0)
cu.Reverse(); cu.Reverse();
} }
this.m_Curve = cu; this._Curve = cu;
} }
static CreateContour(cus: Curve[] | Polyline | Circle, needLink = true) static CreateContour(cus: Curve[] | Polyline | Circle, needLink = true)
@ -57,15 +57,15 @@ export class Contour
} }
get Curve(): Polyline | Circle get Curve(): Polyline | Circle
{ {
return this.m_Curve; return this._Curve;
} }
get Area() get Area()
{ {
return this.m_Curve.Area; return this._Curve.Area;
} }
get BoundingBox() get BoundingBox()
{ {
return this.m_Curve.BoundingBox; return this._Curve.BoundingBox;
} }
/** /**
* *
@ -75,7 +75,7 @@ export class Contour
*/ */
UnEqualProportionScale(ref: number, dist: number, dir: "x" | "y") UnEqualProportionScale(ref: number, dist: number, dir: "x" | "y")
{ {
let cu = this.m_Curve; let cu = this._Curve;
if (cu instanceof Polyline) if (cu instanceof Polyline)
{ {
let lineData = cu.LineData; let lineData = cu.LineData;
@ -97,7 +97,7 @@ export class Contour
} }
Clone() Clone()
{ {
return Contour.CreateContour([this.m_Curve.Clone()]); return Contour.CreateContour([this._Curve.Clone()]);
} }
//交集:结果数组为空则失败 //交集:结果数组为空则失败
IntersectionBoolOperation(target: Contour): Contour[] IntersectionBoolOperation(target: Contour): Contour[]
@ -190,7 +190,7 @@ export class Contour
let intersectionList: Curve[] = []; let intersectionList: Curve[] = [];
let unionList: Curve[] = []; let unionList: Curve[] = [];
let sourceOutline = this.m_Curve; let sourceOutline = this._Curve;
let targetOutline = target.Curve; let targetOutline = target.Curve;
let interPts = sourceOutline.IntersectWith(targetOutline, IntersectOption.OnBothOperands); let interPts = sourceOutline.IntersectWith(targetOutline, IntersectOption.OnBothOperands);
@ -282,7 +282,7 @@ export class Contour
} }
GetSubtractList(target: Contour) GetSubtractList(target: Contour)
{ {
let sourceOutline = this.m_Curve as Polyline; let sourceOutline = this._Curve as Polyline;
let targetOutline = target.Curve as Polyline; let targetOutline = target.Curve as Polyline;
let interPts = sourceOutline.IntersectWith(targetOutline, IntersectOption.OnBothOperands, 1e-3); let interPts = sourceOutline.IntersectWith(targetOutline, IntersectOption.OnBothOperands, 1e-3);
@ -403,15 +403,15 @@ export class Contour
} }
get Shape(): THREE.Shape get Shape(): THREE.Shape
{ {
return this.m_Curve.Shape; return this._Curve.Shape;
} }
CuInOutline(targetCur: Curve) CuInOutline(targetCur: Curve)
{ {
return isTargetCurInOrOnSourceCur(this.m_Curve, targetCur); return isTargetCurInOrOnSourceCur(this._Curve, targetCur);
} }
Equal(tar: Contour) Equal(tar: Contour)
{ {
return equalCurve(this.m_Curve, tar.m_Curve); return equalCurve(this._Curve, tar._Curve);
} }
} }

@ -9,84 +9,84 @@ import { Polyline } from './Entity/Polyline';
export class Shape export class Shape
{ {
private m_Outline: Contour; private _Outline: Contour;
private m_Holes: Contour[] = []; private _Holes: Contour[] = [];
private m_Shape: TShape = new TShape(); private _Shape: TShape = new TShape();
constructor(out?: Contour, hols?: Contour[]) constructor(out?: Contour, hols?: Contour[])
{ {
this.m_Outline = out || new Contour(); this._Outline = out || new Contour();
hols && this.m_Holes.push(...hols); hols && this._Holes.push(...hols);
} }
get Outline() get Outline()
{ {
return this.m_Outline; return this._Outline;
} }
get Holes() get Holes()
{ {
return this.m_Holes; return this._Holes;
} }
get Area() get Area()
{ {
let outlineArea = this.m_Outline.Area; let outlineArea = this._Outline.Area;
let holeArea = this.m_Holes.map(l => l.Area).reduce((a1, a2) => a1 + a2, 0); let holeArea = this._Holes.map(l => l.Area).reduce((a1, a2) => a1 + a2, 0);
return outlineArea - holeArea; return outlineArea - holeArea;
} }
get BoundingBox() get BoundingBox()
{ {
return this.m_Outline.BoundingBox; return this._Outline.BoundingBox;
} }
set Outline(cus: Contour) set Outline(cus: Contour)
{ {
this.m_Outline = cus; this._Outline = cus;
this.UpdateShape(); this.UpdateShape();
} }
set Holes(cus: Contour[]) set Holes(cus: Contour[])
{ {
this.m_Holes = cus; this._Holes = cus;
this.UpdateShape(); this.UpdateShape();
} }
get Shape() get Shape()
{ {
this.UpdateShape(); this.UpdateShape();
return this.m_Shape; return this._Shape;
} }
get Position() get Position()
{ {
return this.m_Outline.Curve.Position; return this._Outline.Curve.Position;
} }
set Position(p: Vector3) set Position(p: Vector3)
{ {
let vec = p.clone().sub(this.m_Outline.Curve.Position); let vec = p.clone().sub(this._Outline.Curve.Position);
this.m_Outline.Curve.Position = p; this._Outline.Curve.Position = p;
for (let h of this.m_Holes) for (let h of this._Holes)
h.Curve.Position = h.Curve.Position.add(vec); h.Curve.Position = h.Curve.Position.add(vec);
} }
Z0() Z0()
{ {
this.m_Outline.Curve.Z0(); this._Outline.Curve.Z0();
for (let h of this.m_Holes) for (let h of this._Holes)
h.Curve.Z0(); h.Curve.Z0();
} }
MatrixPlanarizere() MatrixPlanarizere()
{ {
this.m_Outline.Curve.MatrixPlanarizere(); this._Outline.Curve.MatrixPlanarizere();
for (let h of this.m_Holes) for (let h of this._Holes)
h.Curve.MatrixPlanarizere(); h.Curve.MatrixPlanarizere();
} }
ApplyMatrix(m: Matrix4) ApplyMatrix(m: Matrix4)
{ {
this.m_Outline.Curve.ApplyMatrix(m); this._Outline.Curve.ApplyMatrix(m);
this.m_Holes.forEach(h => h.Curve.ApplyMatrix(m)); this._Holes.forEach(h => h.Curve.ApplyMatrix(m));
return this; return this;
} }
ApplyScaleMatrix(m: Matrix4): this ApplyScaleMatrix(m: Matrix4): this
{ {
let cu = this.Outline.Curve; let cu = this.Outline.Curve;
let cus = this.m_Holes.map(h => h.Curve); let cus = this._Holes.map(h => h.Curve);
cus.unshift(cu); cus.unshift(cu);
for (let c of cus) for (let c of cus)
{ {
@ -100,7 +100,7 @@ export class Shape
Explode() Explode()
{ {
let cus: Curve[] = []; let cus: Curve[] = [];
let contours: Contour[] = [this.m_Outline, ...this.m_Holes]; let contours: Contour[] = [this._Outline, ...this._Holes];
for (let con of contours) for (let con of contours)
{ {
if (con.Curve instanceof Polyline) if (con.Curve instanceof Polyline)
@ -113,14 +113,14 @@ export class Shape
Clone() Clone()
{ {
let shape = new Shape(); let shape = new Shape();
shape.Outline = this.m_Outline.Clone(); shape.Outline = this._Outline.Clone();
shape.Holes = this.Holes.map(h => h.Clone()); shape.Holes = this.Holes.map(h => h.Clone());
return shape; return shape;
} }
SetColor(color: number) SetColor(color: number)
{ {
this.m_Outline.Curve.ColorIndex = color; this._Outline.Curve.ColorIndex = color;
this.m_Holes.forEach(h => h.Curve.ColorIndex = color); this._Holes.forEach(h => h.Curve.ColorIndex = color);
} }
GetObjectSnapPoints( GetObjectSnapPoints(
snapMode: ObjectSnapMode, snapMode: ObjectSnapMode,
@ -140,8 +140,8 @@ export class Shape
case ObjectSnapMode.Per: case ObjectSnapMode.Per:
case ObjectSnapMode.Tan: case ObjectSnapMode.Tan:
{ {
let cus: Curve[] = [this.m_Outline.Curve]; let cus: Curve[] = [this._Outline.Curve];
for (let h of this.m_Holes) for (let h of this._Holes)
{ {
cus.push(h.Curve); cus.push(h.Curve);
} }
@ -160,7 +160,7 @@ export class Shape
GetGripPoints() GetGripPoints()
{ {
let pts = this.Outline.Curve.GetGripPoints(); let pts = this.Outline.Curve.GetGripPoints();
for (let h of this.m_Holes) for (let h of this._Holes)
{ {
pts.push(...h.Curve.GetGripPoints()); pts.push(...h.Curve.GetGripPoints());
} }
@ -169,13 +169,13 @@ export class Shape
MoveGripPoints(indexList: Array<number>, vec: Vector3) MoveGripPoints(indexList: Array<number>, vec: Vector3)
{ {
let i = indexList[0]; let i = indexList[0];
let outlineIndex = this.m_Outline.Curve.GetGripPoints().length; let outlineIndex = this._Outline.Curve.GetGripPoints().length;
let cu = this.m_Outline.Curve; let cu = this._Outline.Curve;
if (i >= outlineIndex) if (i >= outlineIndex)
{ {
for (let h of this.m_Holes) for (let h of this._Holes)
{ {
let len = h.Curve.GetGripPoints().length; let len = h.Curve.GetGripPoints().length;
if (indexList[0] < outlineIndex + len) if (indexList[0] < outlineIndex + len)
@ -192,7 +192,7 @@ export class Shape
GetStretchPoints() GetStretchPoints()
{ {
let pts = this.Outline.Curve.GetStretchPoints(); let pts = this.Outline.Curve.GetStretchPoints();
for (let h of this.m_Holes) for (let h of this._Holes)
{ {
pts.push(...h.Curve.GetStretchPoints()); pts.push(...h.Curve.GetStretchPoints());
} }
@ -201,7 +201,7 @@ export class Shape
MoveStretchPoints(indexList: Array<number>, vec: Vector3) MoveStretchPoints(indexList: Array<number>, vec: Vector3)
{ {
let outlen = 0; let outlen = 0;
for (let cu of [this.m_Outline.Curve, ...this.m_Holes.map(h => h.Curve)]) for (let cu of [this._Outline.Curve, ...this._Holes.map(h => h.Curve)])
{ {
let count = cu.GetStretchPoints().length; let count = cu.GetStretchPoints().length;
let refIndex = outlen + count; let refIndex = outlen + count;
@ -224,15 +224,15 @@ export class Shape
//交集 如果成功返回一个面域 失败返回0个 //交集 如果成功返回一个面域 失败返回0个
IntersectionBoolOperation(targetShape: Shape): Shape[] IntersectionBoolOperation(targetShape: Shape): Shape[]
{ {
let resOutlines = this.m_Outline.IntersectionBoolOperation(targetShape.m_Outline); let resOutlines = this._Outline.IntersectionBoolOperation(targetShape._Outline);
let cus = this.targetOutlineSubHoleOutline(resOutlines, Shape.mergeContours([...this.m_Holes, ...targetShape.m_Holes])); let cus = this.targetOutlineSubHoleOutline(resOutlines, Shape.mergeContours([...this._Holes, ...targetShape._Holes]));
return Shape.pairHoleAndOutline(cus); return Shape.pairHoleAndOutline(cus);
} }
//并集,如果成功返回1个形状,不成功返回2个形状 //并集,如果成功返回1个形状,不成功返回2个形状
UnionBoolOperation(targetShape: Shape): Shape[] UnionBoolOperation(targetShape: Shape): Shape[]
{ {
let resOutlines = this.m_Outline.UnionBoolOperation(targetShape.m_Outline); let resOutlines = this._Outline.UnionBoolOperation(targetShape._Outline);
let shapes: Shape[] = []; let shapes: Shape[] = [];
//提取出所有的孔洞, 目标线段孔洞和原线段差,如果孔洞和目标相减后有被包围轮廓,应把这个单独提取出来作为形状 //提取出所有的孔洞, 目标线段孔洞和原线段差,如果孔洞和目标相减后有被包围轮廓,应把这个单独提取出来作为形状
@ -256,11 +256,11 @@ export class Shape
}); });
}; };
pickUpHoleOrShape(targetShape.m_Holes, this.m_Holes, this.m_Outline); pickUpHoleOrShape(targetShape._Holes, this._Holes, this._Outline);
pickUpHoleOrShape(this.m_Holes, targetShape.m_Holes, targetShape.m_Outline); pickUpHoleOrShape(this._Holes, targetShape._Holes, targetShape._Outline);
targetShape.m_Holes.forEach(cu => targetShape._Holes.forEach(cu =>
{ {
this.m_Holes.forEach(c => this._Holes.forEach(c =>
{ {
unionHoles.push(...c.IntersectionBoolOperation(cu)); unionHoles.push(...c.IntersectionBoolOperation(cu));
}); });
@ -273,28 +273,28 @@ export class Shape
//如果完全被减掉,就返回0个.其他的返回1个或者n个 //如果完全被减掉,就返回0个.其他的返回1个或者n个
SubstactBoolOperation(targetShape: Shape): Shape[] SubstactBoolOperation(targetShape: Shape): Shape[]
{ {
let resOutlines = this.m_Outline.SubstactBoolOperation(targetShape.m_Outline); let resOutlines = this._Outline.SubstactBoolOperation(targetShape._Outline);
let shapes: Shape[] = []; let shapes: Shape[] = [];
//如果相减,则需要取出被减面域和减数面域的洞的交集,结果还需减去被减面域的全部孔洞 //如果相减,则需要取出被减面域和减数面域的洞的交集,结果还需减去被减面域的全部孔洞
targetShape.m_Holes.forEach(cu => targetShape._Holes.forEach(cu =>
{ {
let tmpInterList = cu.IntersectionBoolOperation(this.m_Outline); let tmpInterList = cu.IntersectionBoolOperation(this._Outline);
shapes.push(...Shape.pairHoleAndOutline(this.targetOutlineSubHoleOutline(tmpInterList, this.m_Holes))); shapes.push(...Shape.pairHoleAndOutline(this.targetOutlineSubHoleOutline(tmpInterList, this._Holes)));
}); });
let fCus = this.targetOutlineSubHoleOutline(resOutlines, Shape.mergeContours([...this.m_Holes, ...targetShape.m_Holes])); let fCus = this.targetOutlineSubHoleOutline(resOutlines, Shape.mergeContours([...this._Holes, ...targetShape._Holes]));
shapes.push(...Shape.pairHoleAndOutline(fCus)); shapes.push(...Shape.pairHoleAndOutline(fCus));
return shapes; return shapes;
} }
Equal(targetShape: Shape) Equal(targetShape: Shape)
{ {
if (this.m_Outline.Equal(targetShape.m_Outline)) if (this._Outline.Equal(targetShape._Outline))
{ {
return this.m_Holes.length === targetShape.m_Holes.length return this._Holes.length === targetShape._Holes.length
&& this.m_Holes.every(h1 => && this._Holes.every(h1 =>
targetShape.m_Holes.some(h2 => h1.Equal(h2)) targetShape._Holes.some(h2 => h1.Equal(h2))
); );
} }
return false; return false;
@ -302,7 +302,7 @@ export class Shape
/** /**
* *
* *
* @private * @private
* @param {Contour[]} tarContours * @param {Contour[]} tarContours
* @param {Contour[]} holes * @param {Contour[]} holes
@ -362,10 +362,10 @@ export class Shape
} }
/** /**
* ,使(),. * ,使(),.
* *
* @private * @private
* @param {Contour[]} holes * @param {Contour[]} holes
* @returns * @returns
* @memberof Shape * @memberof Shape
*/ */
static mergeContours(holes: Contour[]): Contour[] static mergeContours(holes: Contour[]): Contour[]
@ -405,7 +405,7 @@ export class Shape
/** /**
* .(,) * .(,)
* *
* @private * @private
* @param {Contour[]} tmpHoles * @param {Contour[]} tmpHoles
* @returns {Contour[]} . * @returns {Contour[]} .
@ -428,13 +428,13 @@ export class Shape
} }
UpdateShape() UpdateShape()
{ {
this.m_Shape = this.Outline.Shape; this._Shape = this.Outline.Shape;
this.Holes.forEach(h => this.Holes.forEach(h =>
{ {
if (h.Curve instanceof Polyline) if (h.Curve instanceof Polyline)
h.Curve.UpdateMatrixTo(this.Outline.Curve.OCS); h.Curve.UpdateMatrixTo(this.Outline.Curve.OCS);
}); });
this.m_Shape.holes.push(...this.m_Holes.map( this._Shape.holes.push(...this._Holes.map(
h => h =>
{ {
if (h.Curve instanceof Circle) if (h.Curve instanceof Circle)
@ -452,12 +452,12 @@ export class Shape
ReadFile(file: CADFiler) ReadFile(file: CADFiler)
{ {
let ver = file.Read();//1 let ver = file.Read();//1
this.m_Outline = Contour.CreateContour([file.ReadObject() as Curve]); this._Outline = Contour.CreateContour([file.ReadObject() as Curve]);
let count = file.Read(); let count = file.Read();
for (let i = 0; i < count; i++) for (let i = 0; i < count; i++)
{ {
this.m_Holes.push( this._Holes.push(
Contour.CreateContour([file.ReadObject() as Curve]) Contour.CreateContour([file.ReadObject() as Curve])
); );
} }
@ -467,8 +467,8 @@ export class Shape
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
{ {
file.Write(1);//ver file.Write(1);//ver
file.WriteObject(this.m_Outline.Curve); file.WriteObject(this._Outline.Curve);
file.Write(this.m_Holes.length); file.Write(this._Holes.length);
this.m_Holes.forEach(h => file.WriteObject(h.Curve)); this._Holes.forEach(h => file.WriteObject(h.Curve));
} }
} }

@ -6,27 +6,27 @@ import { Matrix4 } from 'three';
export class ShapeManager export class ShapeManager
{ {
private m_ShapeList: Shape[] = []; private _ShapeList: Shape[] = [];
get ShapeList() get ShapeList()
{ {
return this.m_ShapeList.slice(); return this._ShapeList.slice();
} }
get ShapeCount() get ShapeCount()
{ {
return this.m_ShapeList.length; return this._ShapeList.length;
} }
get ShapeArea() get ShapeArea()
{ {
return this.m_ShapeList.map(s => s.Area).reduce((a1, a2) => a1 + a2, 0); return this._ShapeList.map(s => s.Area).reduce((a1, a2) => a1 + a2, 0);
} }
AppendShapeList(shapes: Shape | Shape[]) AppendShapeList(shapes: Shape | Shape[])
{ {
Array.isArray(shapes) ? this.m_ShapeList.push(...shapes) : this.m_ShapeList.push(shapes); Array.isArray(shapes) ? this._ShapeList.push(...shapes) : this._ShapeList.push(shapes);
return this; return this;
} }
Clear() Clear()
{ {
this.m_ShapeList.length = 0; this._ShapeList.length = 0;
} }
BoolOper(otherMg: ShapeManager, booltype: BoolOpeartionType) BoolOper(otherMg: ShapeManager, booltype: BoolOpeartionType)
{ {
@ -44,24 +44,24 @@ export class ShapeManager
IntersectionBoolOperation(target: ShapeManager) IntersectionBoolOperation(target: ShapeManager)
{ {
let shapes: Shape[] = []; let shapes: Shape[] = [];
for (let srcShape of this.m_ShapeList) for (let srcShape of this._ShapeList)
{ {
for (let tarShape of target.m_ShapeList) for (let tarShape of target._ShapeList)
{ {
let tmpShapes = srcShape.IntersectionBoolOperation(tarShape); let tmpShapes = srcShape.IntersectionBoolOperation(tarShape);
shapes.push(...tmpShapes); shapes.push(...tmpShapes);
} }
} }
this.Clear(); this.Clear();
this.m_ShapeList = shapes; this._ShapeList = shapes;
return this.m_ShapeList.length > 0; return this._ShapeList.length > 0;
} }
//并集,如果有一个形状并集成功,就成功 //并集,如果有一个形状并集成功,就成功
UnionBoolOperation(targetMg: ShapeManager) UnionBoolOperation(targetMg: ShapeManager)
{ {
let isSuccess = false; let isSuccess = false;
let srcShapes = this.m_ShapeList; let srcShapes = this._ShapeList;
let tarShapes = targetMg.m_ShapeList; let tarShapes = targetMg._ShapeList;
let alones: Shape[] = [];//孤立的形状 let alones: Shape[] = [];//孤立的形状
for (let src of srcShapes) for (let src of srcShapes)
@ -89,23 +89,23 @@ export class ShapeManager
alones.push(src);//它是孤独的一个形状 alones.push(src);//它是孤独的一个形状
} }
this.m_ShapeList = alones.concat(tarShapes); this._ShapeList = alones.concat(tarShapes);
return isSuccess; return isSuccess;
} }
SubstactBoolOperation(target: ShapeManager) SubstactBoolOperation(target: ShapeManager)
{ {
//减数形状 //减数形状
for (let subtrahendShape of target.m_ShapeList) for (let subtrahendShape of target._ShapeList)
{ {
let tmpShapes: Shape[] = []; let tmpShapes: Shape[] = [];
//被减形状 //被减形状
for (let minuendShape of this.m_ShapeList) for (let minuendShape of this._ShapeList)
{ {
let operatedShapes = minuendShape.SubstactBoolOperation(subtrahendShape); let operatedShapes = minuendShape.SubstactBoolOperation(subtrahendShape);
tmpShapes.push(...operatedShapes); tmpShapes.push(...operatedShapes);
} }
//迭代this形状列表,每次赋予新的结果 //迭代this形状列表,每次赋予新的结果
this.m_ShapeList = tmpShapes; this._ShapeList = tmpShapes;
} }
return true; return true;
} }
@ -120,7 +120,7 @@ export class ShapeManager
*/ */
ApplyMatrix(mat4: Matrix4) ApplyMatrix(mat4: Matrix4)
{ {
for (let s of this.m_ShapeList) for (let s of this._ShapeList)
{ {
s.Outline.Curve.ApplyMatrix(mat4); s.Outline.Curve.ApplyMatrix(mat4);
s.Holes.forEach(o => o.Curve.ApplyMatrix(mat4)); s.Holes.forEach(o => o.Curve.ApplyMatrix(mat4));
@ -135,7 +135,7 @@ export class ShapeManager
{ {
let obj = new Shape(); let obj = new Shape();
obj.ReadFile(file); obj.ReadFile(file);
this.m_ShapeList.push(obj); this._ShapeList.push(obj);
} }
} }
WriteFile(file: CADFiler) WriteFile(file: CADFiler)

Loading…
Cancel
Save