|
|
|
@ -11,13 +11,11 @@ import { Polyline } from './Entity/Polyline';
|
|
|
|
|
|
|
|
|
|
export class Shape
|
|
|
|
|
{
|
|
|
|
|
private _Outline: Contour;
|
|
|
|
|
private _Holes: Contour[] = [];
|
|
|
|
|
private _Shape: TShape = new TShape();
|
|
|
|
|
constructor(out?: Contour, hols?: Contour[])
|
|
|
|
|
constructor(
|
|
|
|
|
private _Outline: Contour = new Contour,
|
|
|
|
|
private _Holes: Contour[] = []
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
this._Outline = out || new Contour();
|
|
|
|
|
hols && this._Holes.push(...hols);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Outline()
|
|
|
|
@ -38,21 +36,37 @@ export class Shape
|
|
|
|
|
{
|
|
|
|
|
return this._Outline.BoundingBox;
|
|
|
|
|
}
|
|
|
|
|
set Outline(cus: Contour)
|
|
|
|
|
set Outline(con: Contour)
|
|
|
|
|
{
|
|
|
|
|
this._Outline = cus;
|
|
|
|
|
this.UpdateShape();
|
|
|
|
|
this._Outline = con;
|
|
|
|
|
}
|
|
|
|
|
set Holes(cus: Contour[])
|
|
|
|
|
set Holes(holes: Contour[])
|
|
|
|
|
{
|
|
|
|
|
this._Holes = cus;
|
|
|
|
|
this.UpdateShape();
|
|
|
|
|
this._Holes = holes;
|
|
|
|
|
}
|
|
|
|
|
get Shape()
|
|
|
|
|
|
|
|
|
|
get Shape(): TShape
|
|
|
|
|
{
|
|
|
|
|
this.UpdateShape();
|
|
|
|
|
return this._Shape;
|
|
|
|
|
let shape = this.Outline.Shape;
|
|
|
|
|
for (let h of this._Holes)
|
|
|
|
|
{
|
|
|
|
|
if (h.Curve instanceof Polyline)
|
|
|
|
|
h.Curve.UpdateOCSTo(this.Outline.Curve.OCS);
|
|
|
|
|
|
|
|
|
|
if (h.Curve instanceof Circle)
|
|
|
|
|
{
|
|
|
|
|
let sp = new Path();
|
|
|
|
|
let cen = h.Curve.Center.applyMatrix4(this.Outline.Curve.OCSInv);
|
|
|
|
|
sp.ellipse(cen.x, cen.y, h.Curve.Radius, h.Curve.Radius, 0, 2 * Math.PI, false, 0);
|
|
|
|
|
shape.holes.push(sp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
shape.holes.push(h.Shape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return shape;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Position()
|
|
|
|
|
{
|
|
|
|
|
return this._Outline.Curve.Position;
|
|
|
|
@ -523,25 +537,6 @@ export class Shape
|
|
|
|
|
}
|
|
|
|
|
return holes;
|
|
|
|
|
}
|
|
|
|
|
UpdateShape()
|
|
|
|
|
{
|
|
|
|
|
this._Shape = this.Outline.Shape;
|
|
|
|
|
for (let h of this._Holes)
|
|
|
|
|
{
|
|
|
|
|
if (h.Curve instanceof Polyline)
|
|
|
|
|
h.Curve.UpdateOCSTo(this.Outline.Curve.OCS);
|
|
|
|
|
|
|
|
|
|
if (h.Curve instanceof Circle)
|
|
|
|
|
{
|
|
|
|
|
let sp = new Path();
|
|
|
|
|
let cen = h.Curve.Center.applyMatrix4(this.Outline.Curve.OCSInv);
|
|
|
|
|
sp.ellipse(cen.x, cen.y, h.Curve.Radius, h.Curve.Radius, 0, 2 * Math.PI, false, 0);
|
|
|
|
|
this._Shape.holes.push(sp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
this._Shape.holes.push(h.Shape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//读写文件
|
|
|
|
|
ReadFile(file: CADFiler)
|
|
|
|
|
{
|
|
|
|
|