开发:同步偏移算法,Ver:0.0.4
This commit is contained in:
parent
0614d66225
commit
e4827ba295
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
// 将设置放入此文件中以覆盖默认值和用户设置。
|
||||
{
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
//格式化设置
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": false,
|
||||
}
|
179
api.esm.js
179
api.esm.js
@ -1534,7 +1534,8 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
if (!this.IsEmbedEntity)
|
||||
this._drawObject.userData.Entity = this;
|
||||
if (this.IsVisible) {
|
||||
let obj = this.GetDrawObjectFromRenderType((_a = this.__CacheRenderType__) !== null && _a !== void 0 ? _a : userConfig.RenderType);
|
||||
this._CurRenderType = (_a = this.__CacheRenderType__) !== null && _a !== void 0 ? _a : userConfig.RenderType;
|
||||
let obj = this.GetDrawObjectFromRenderType(this._CurRenderType);
|
||||
if (obj)
|
||||
this._drawObject.add(obj);
|
||||
}
|
||||
@ -1561,6 +1562,8 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
}
|
||||
UpdateRenderType(type)
|
||||
{
|
||||
if (this._CurRenderType !== type) {
|
||||
this._CurRenderType = type;
|
||||
if ((this.OnlyRenderType && this.DrawObject.children.length > 0) || !this.Visible)
|
||||
return;
|
||||
Object3DRemoveAll(this.DrawObject);
|
||||
@ -1568,6 +1571,7 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
if (obj)
|
||||
this.DrawObject.add(obj);
|
||||
}
|
||||
}
|
||||
GetDrawObjectFromRenderType(renderType = RenderType.Wireframe)
|
||||
{
|
||||
var _a;
|
||||
@ -1645,6 +1649,7 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
this.UpdateDrawObjectMaterial(type, obj);
|
||||
if (mode & UpdateDraw.Matrix || mode & UpdateDraw.Geometry) {
|
||||
obj.updateMatrixWorld(true);
|
||||
if (this.Id) //如果这个是Jig实体,那么我们更新这个盒子球似乎也没有意义
|
||||
obj.traverse(UpdateBoundingSphere);
|
||||
}
|
||||
}
|
||||
@ -1794,6 +1799,7 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
Clone()
|
||||
{
|
||||
let ent = super.Clone();
|
||||
ent._CurRenderType = this._CurRenderType;
|
||||
ent.Template = undefined;
|
||||
ent.CloneDrawObject(this);
|
||||
return ent;
|
||||
@ -1817,6 +1823,9 @@ let Entity = Entity_1 = class Entity extends CADObject
|
||||
{
|
||||
return this.__ReadFileIng__ || Entity_1.__ReadFileIng__;
|
||||
}
|
||||
/**
|
||||
* 从文件读取,序列化自身,如果需要,重载_ReadFile
|
||||
*/
|
||||
ReadFile(file)
|
||||
{
|
||||
this.__ReadFileIng__ = true;
|
||||
@ -4752,17 +4761,17 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
/**
|
||||
* 曲线为顺时针
|
||||
*/
|
||||
this.m_Clockwise = true;
|
||||
this._Clockwise = true;
|
||||
this._Matrix.setPosition(center);
|
||||
this.m_Radius = radius;
|
||||
this.m_StartAngle = clampRad(startAngle);
|
||||
this.m_EndAngle = clampRad(endAngle);
|
||||
this.m_Clockwise = clockwise;
|
||||
this._Radius = radius;
|
||||
this._StartAngle = clampRad(startAngle);
|
||||
this._EndAngle = clampRad(endAngle);
|
||||
this._Clockwise = clockwise;
|
||||
}
|
||||
get Shape()
|
||||
{
|
||||
let sp = new Shape();
|
||||
sp.absarc(0, 0, this.m_Radius, this.m_StartAngle, this.m_EndAngle, this.m_Clockwise);
|
||||
sp.absarc(0, 0, this._Radius, this._StartAngle, this._EndAngle, this._Clockwise);
|
||||
return sp;
|
||||
}
|
||||
get Center()
|
||||
@ -4790,7 +4799,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
//获得曲线的面积,逆时针为正,顺时针为负.
|
||||
get Area2()
|
||||
{
|
||||
let clockwise = this.m_Clockwise ? -1 : 1;
|
||||
let clockwise = this._Clockwise ? -1 : 1;
|
||||
return 0.5 * this.AllAngle * this.Radius * this.Radius * clockwise;
|
||||
}
|
||||
get IsClose()
|
||||
@ -4802,10 +4811,10 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
let pts = [this.StartPoint, this.EndPoint];
|
||||
//TODO:考虑三维圆弧.
|
||||
let addPts = [
|
||||
this.Center.add(new Vector3(this.m_Radius, 0)),
|
||||
this.Center.add(new Vector3(0, this.m_Radius)),
|
||||
this.Center.add(new Vector3(-this.m_Radius, 0)),
|
||||
this.Center.add(new Vector3(0, -this.m_Radius)),
|
||||
this.Center.add(new Vector3(this._Radius, 0)),
|
||||
this.Center.add(new Vector3(0, this._Radius)),
|
||||
this.Center.add(new Vector3(-this._Radius, 0)),
|
||||
this.Center.add(new Vector3(0, -this._Radius)),
|
||||
];
|
||||
addPts.forEach(p =>
|
||||
{
|
||||
@ -4816,50 +4825,50 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
get Radius()
|
||||
{
|
||||
return this.m_Radius;
|
||||
return this._Radius;
|
||||
}
|
||||
set Radius(v)
|
||||
{
|
||||
this.WriteAllObjectRecord();
|
||||
this.m_Radius = v <= 0 ? 1e-19 : v;
|
||||
this._Radius = v <= 0 ? 1e-19 : v;
|
||||
this.Update();
|
||||
}
|
||||
get IsClockWise()
|
||||
{
|
||||
return this.m_Clockwise;
|
||||
return this._Clockwise;
|
||||
}
|
||||
set IsClockWise(v)
|
||||
{
|
||||
if (v !== this.m_Clockwise) {
|
||||
if (v !== this._Clockwise) {
|
||||
this.WriteAllObjectRecord();
|
||||
this.m_Clockwise = v;
|
||||
this._Clockwise = v;
|
||||
this.Update();
|
||||
}
|
||||
}
|
||||
get StartAngle()
|
||||
{
|
||||
return this.m_StartAngle;
|
||||
return this._StartAngle;
|
||||
}
|
||||
set StartAngle(v)
|
||||
{
|
||||
this.WriteAllObjectRecord();
|
||||
this.m_StartAngle = v;
|
||||
this._StartAngle = v;
|
||||
this.Update();
|
||||
}
|
||||
get EndAngle()
|
||||
{
|
||||
return this.m_EndAngle;
|
||||
return this._EndAngle;
|
||||
}
|
||||
set EndAngle(v)
|
||||
{
|
||||
this.WriteAllObjectRecord();
|
||||
this.m_EndAngle = v;
|
||||
this._EndAngle = v;
|
||||
this.Update();
|
||||
}
|
||||
//******************** Curve function start*****************//
|
||||
get StartPoint()
|
||||
{
|
||||
return polar(new Vector3(), this.m_StartAngle, this.m_Radius).applyMatrix4(this.OCS);
|
||||
return polar(new Vector3(), this._StartAngle, this._Radius).applyMatrix4(this.OCS);
|
||||
}
|
||||
set StartPoint(v)
|
||||
{
|
||||
@ -4868,7 +4877,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
get EndPoint()
|
||||
{
|
||||
return polar(new Vector3(), this.m_EndAngle, this.m_Radius).applyMatrix4(this.OCS);
|
||||
return polar(new Vector3(), this._EndAngle, this._Radius).applyMatrix4(this.OCS);
|
||||
}
|
||||
set EndPoint(v)
|
||||
{
|
||||
@ -4885,7 +4894,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
get Length()
|
||||
{
|
||||
return this.AllAngle * this.m_Radius;
|
||||
return this.AllAngle * this._Radius;
|
||||
}
|
||||
GetParamAtPoint2(pt)
|
||||
{
|
||||
@ -4910,7 +4919,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
let sp = this.StartPoint;
|
||||
let ep = this.EndPoint;
|
||||
reviseMirrorMatrix(this._Matrix);
|
||||
this.m_Clockwise = !this.m_Clockwise;
|
||||
this._Clockwise = !this._Clockwise;
|
||||
this.StartPoint = sp;
|
||||
this.EndPoint = ep;
|
||||
return this;
|
||||
@ -4918,7 +4927,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
GetPointAtParam(param)
|
||||
{
|
||||
let an = this.GetAngleAtParam(param);
|
||||
return polar(new Vector3(), an, this.m_Radius).applyMatrix4(this.OCS);
|
||||
return polar(new Vector3(), an, this._Radius).applyMatrix4(this.OCS);
|
||||
}
|
||||
GetPointAtDistance(distance)
|
||||
{
|
||||
@ -4938,9 +4947,9 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
GetParamAtPoint(pt)
|
||||
{
|
||||
if (this.m_Radius == 0 ||
|
||||
if (this._Radius == 0 ||
|
||||
this.AllAngle == 0 ||
|
||||
!equaln(pt.distanceTo(this.Center), this.m_Radius, 1e-6))
|
||||
!equaln(pt.distanceTo(this.Center), this._Radius, 1e-6))
|
||||
return NaN;
|
||||
return this.GetParamAtAngle(this.GetAngleAtPoint(pt));
|
||||
}
|
||||
@ -4961,14 +4970,12 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
//减去圆弧角度,剩余角度的一半
|
||||
let surplusAngleHalf = Math.PI - allAn / 2;
|
||||
if (ptAllAn > allAn + surplusAngleHalf) //返回负数
|
||||
{
|
||||
return ((ptAllAn - allAn) - (surplusAngleHalf * 2)) / allAn;
|
||||
}
|
||||
else //返回正数
|
||||
return ptAllAn / allAn;
|
||||
}
|
||||
/**
|
||||
* Gets param at angle2
|
||||
* 根据角度获得参数,不过在这里我们可以指定我们是要获取前面的参数还是后面的参数(正负)
|
||||
* @param an
|
||||
* @param [isStart] true:返回负数,false 返回正数
|
||||
* @returns
|
||||
@ -4981,9 +4988,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
//减去圆弧角度,剩余角度的一半
|
||||
let surplusAngleHalf = Math.PI - allAn / 2;
|
||||
if (isStart) //返回负数
|
||||
{
|
||||
return ((ptAllAn - allAn) - (surplusAngleHalf * 2)) / allAn;
|
||||
}
|
||||
else //返回正数
|
||||
return ptAllAn / allAn;
|
||||
}
|
||||
@ -4994,7 +4999,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
GetAngleAtParam(param)
|
||||
{
|
||||
return clampRad(this.m_StartAngle + param * this.AllAngle * (this.m_Clockwise ? -1 : 1));
|
||||
return clampRad(this._StartAngle + param * this.AllAngle * (this._Clockwise ? -1 : 1));
|
||||
}
|
||||
GetSplitCurves(param)
|
||||
{
|
||||
@ -5013,11 +5018,11 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
}
|
||||
GetOffsetCurves(offsetDist)
|
||||
{
|
||||
if (this.m_Clockwise)
|
||||
if (this._Clockwise)
|
||||
offsetDist *= -1;
|
||||
if ((offsetDist + this.m_Radius) > 0) {
|
||||
if ((offsetDist + this._Radius) > 0) {
|
||||
let arc = this.Clone();
|
||||
arc.Radius = offsetDist + this.m_Radius;
|
||||
arc.Radius = offsetDist + this._Radius;
|
||||
return [arc];
|
||||
}
|
||||
return [];
|
||||
@ -5026,33 +5031,33 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
{
|
||||
this.WriteAllObjectRecord();
|
||||
if (newParam < 0) {
|
||||
this.m_StartAngle = this.GetAngleAtParam(newParam);
|
||||
this._StartAngle = this.GetAngleAtParam(newParam);
|
||||
}
|
||||
else if (newParam > 1) {
|
||||
this.m_EndAngle = this.GetAngleAtParam(newParam);
|
||||
this._EndAngle = this.GetAngleAtParam(newParam);
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
Join(cu)
|
||||
{
|
||||
if (cu instanceof Arc_1) {
|
||||
if (equalv3(cu.Center, this.Center) && equaln(cu.m_Radius, this.m_Radius)) {
|
||||
if (equalv3(cu.Center, this.Center) && equaln(cu._Radius, this._Radius)) {
|
||||
this.WriteAllObjectRecord();
|
||||
let [sa, ea] = [cu.StartAngle, cu.EndAngle];
|
||||
if (cu.m_Clockwise != this.m_Clockwise)
|
||||
if (cu._Clockwise != this._Clockwise)
|
||||
[sa, ea] = [ea, sa];
|
||||
let allAn = this.AllAngle;
|
||||
let saAllan = this.ComputeAnlge(sa);
|
||||
let eaAllan = this.ComputeAnlge(ea);
|
||||
if (equaln(sa, this.m_StartAngle)) //this起点对起点
|
||||
if (equaln(sa, this._StartAngle)) //this起点对起点
|
||||
{
|
||||
if (eaAllan > allAn)
|
||||
this.EndAngle = ea;
|
||||
return Status.True;
|
||||
}
|
||||
else if (equaln(sa, this.m_EndAngle)) //this终点对起点
|
||||
else if (equaln(sa, this._EndAngle)) //this终点对起点
|
||||
{
|
||||
if (eaAllan < allAn || equaln(ea, this.m_StartAngle))
|
||||
if (eaAllan < allAn || equaln(ea, this._StartAngle))
|
||||
return Status.ConverToCircle;
|
||||
else
|
||||
this.EndAngle = ea;
|
||||
@ -5066,7 +5071,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
this.StartAngle = sa;
|
||||
return Status.True;
|
||||
}
|
||||
else if (equaln(ea, this.m_EndAngle)) //this终点对终点
|
||||
else if (equaln(ea, this._EndAngle)) //this终点对终点
|
||||
{
|
||||
if (saAllan > allAn)
|
||||
this.StartAngle = sa;
|
||||
@ -5110,8 +5115,8 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
Reverse()
|
||||
{
|
||||
this.WriteAllObjectRecord();
|
||||
this.m_Clockwise = !this.m_Clockwise;
|
||||
[this.m_StartAngle, this.m_EndAngle] = [this.m_EndAngle, this.m_StartAngle];
|
||||
this._Clockwise = !this._Clockwise;
|
||||
[this._StartAngle, this._EndAngle] = [this._EndAngle, this._StartAngle];
|
||||
return this;
|
||||
}
|
||||
IntersectWith2(curve, intType, tolerance = 1e-4)
|
||||
@ -5140,7 +5145,7 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
*/
|
||||
get AllAngle()
|
||||
{
|
||||
return this.ComputeAnlge(this.m_EndAngle);
|
||||
return this.ComputeAnlge(this._EndAngle);
|
||||
}
|
||||
get Bul()
|
||||
{
|
||||
@ -5159,17 +5164,17 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
ComputeAnlge(endAngle)
|
||||
{
|
||||
//顺时针
|
||||
if (this.m_Clockwise) {
|
||||
if (this.m_StartAngle > endAngle)
|
||||
return this.StartAngle - endAngle;
|
||||
if (this._Clockwise) {
|
||||
if (this._StartAngle > endAngle)
|
||||
return this._StartAngle - endAngle;
|
||||
else //越过0点绘制圆弧
|
||||
return (Math.PI * 2) - (endAngle - this.m_StartAngle);
|
||||
return (Math.PI * 2) - (endAngle - this._StartAngle);
|
||||
}
|
||||
else {
|
||||
if (endAngle > this.m_StartAngle)
|
||||
return endAngle - this.m_StartAngle;
|
||||
if (endAngle > this._StartAngle)
|
||||
return endAngle - this._StartAngle;
|
||||
else
|
||||
return (Math.PI * 2) - (this.m_StartAngle - endAngle);
|
||||
return (Math.PI * 2) - (this._StartAngle - endAngle);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -5197,17 +5202,17 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
let allAngle = Math.atan(bul) * 4;
|
||||
let HalfAngle = allAngle * 0.5;
|
||||
//半径
|
||||
this.m_Radius = chordLengthHalf / Math.sin(HalfAngle);
|
||||
this._Radius = chordLengthHalf / Math.sin(HalfAngle);
|
||||
//指向圆心的角度
|
||||
let toCenterAn = chordAn + Math.PI * 0.5; //弦角度转90
|
||||
//圆心
|
||||
let center = midPoint(p1, p2);
|
||||
polar(center, toCenterAn, this.m_Radius - (bul * chordLengthHalf));
|
||||
polar(center, toCenterAn, this._Radius - (bul * chordLengthHalf));
|
||||
this.Center = center.clone().applyMatrix4(this.OCS);
|
||||
this.m_Radius = Math.abs(this.m_Radius);
|
||||
this.m_StartAngle = angle(p1.clone().sub(center));
|
||||
this.m_EndAngle = angle(p2.clone().sub(center));
|
||||
this.m_Clockwise = bul < 0;
|
||||
this._Radius = Math.abs(this._Radius);
|
||||
this._StartAngle = angle(p1.clone().sub(center));
|
||||
this._EndAngle = angle(p2.clone().sub(center));
|
||||
this._Clockwise = bul < 0;
|
||||
return this;
|
||||
}
|
||||
FromThreePoint(pt1, pt2, pt3)
|
||||
@ -5221,14 +5226,14 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
let center = getCircleCenter(pt1, pt2, pt3);
|
||||
this.Center = center.clone().applyMatrix4(this.OCS);
|
||||
//用圆心和其中一个点求距离得到半径:
|
||||
this.m_Radius = center.distanceTo(pt1);
|
||||
this._Radius = center.distanceTo(pt1);
|
||||
//起始角度 端点角度
|
||||
this.m_StartAngle = angle(pt1.clone().sub(center));
|
||||
this.m_EndAngle = angle(pt3.clone().sub(center));
|
||||
this._StartAngle = angle(pt1.clone().sub(center));
|
||||
this._EndAngle = angle(pt3.clone().sub(center));
|
||||
//求出向量p1->p2,p1->p3
|
||||
let p1 = pt2.clone().sub(pt1);
|
||||
let p2 = pt3.clone().sub(pt1);
|
||||
this.m_Clockwise = p1.cross(p2).z < 0;
|
||||
this._Clockwise = p1.cross(p2).z < 0;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@ -5354,9 +5359,9 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
an = this.GetAngleAtParam(pt);
|
||||
else
|
||||
an = angle(pt.clone().applyMatrix4(this.OCSInv));
|
||||
an += Math.PI * 0.5 * (this.m_Clockwise ? -1 : 1);
|
||||
an += Math.PI * 0.5 * (this._Clockwise ? -1 : 1);
|
||||
let ocs = new Matrix4().extractRotation(this.OCS);
|
||||
return polar(new Vector3(), an, this.m_Radius).applyMatrix4(ocs);
|
||||
return polar(new Vector3(), an, this._Radius).applyMatrix4(ocs);
|
||||
}
|
||||
GetClosestPointTo(pt, extend)
|
||||
{
|
||||
@ -5377,20 +5382,20 @@ let Arc = Arc_1 = class Arc extends Curve
|
||||
this.Center = new Vector3().fromArray(file.Read());
|
||||
this.Normal = new Vector3().fromArray(file.Read());
|
||||
}
|
||||
this.m_Radius = file.Read();
|
||||
this.m_StartAngle = file.Read();
|
||||
this.m_EndAngle = file.Read();
|
||||
this.m_Clockwise = file.Read();
|
||||
this._Radius = file.Read();
|
||||
this._StartAngle = file.Read();
|
||||
this._EndAngle = file.Read();
|
||||
this._Clockwise = file.Read();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file)
|
||||
{
|
||||
super.WriteFile(file);
|
||||
file.Write(2);
|
||||
file.Write(this.m_Radius);
|
||||
file.Write(this.m_StartAngle);
|
||||
file.Write(this.m_EndAngle);
|
||||
file.Write(this.m_Clockwise);
|
||||
file.Write(this._Radius);
|
||||
file.Write(this._StartAngle);
|
||||
file.Write(this._EndAngle);
|
||||
file.Write(this._Clockwise);
|
||||
}
|
||||
};
|
||||
Arc = Arc_1 = __decorate([
|
||||
@ -6015,6 +6020,7 @@ function IsPtsAllInOrOnReg(sourceReg, pts)
|
||||
}
|
||||
|
||||
let cache = new WeakMap();
|
||||
const COMBINE_FUZZ = 1e-2;
|
||||
class Contour
|
||||
{
|
||||
SetCurve(cu)
|
||||
@ -6036,7 +6042,7 @@ class Contour
|
||||
}
|
||||
return;
|
||||
}
|
||||
let closeCurve = Contour.Combine(cus, needLink, 1e-2);
|
||||
let closeCurve = Contour.Combine(cus, needLink, COMBINE_FUZZ);
|
||||
if (closeCurve && closeCurve.IsClose) {
|
||||
if (closeCurve instanceof Polyline && closeCurve.CloseMark === false) {
|
||||
closeCurve.CloseMark = true;
|
||||
@ -6187,7 +6193,7 @@ class Contour
|
||||
let sourceOutline = this._Curve;
|
||||
let targetOutline = target.Curve;
|
||||
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
|
||||
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands);
|
||||
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
|
||||
let sourceContainerTarget = this.CuInOutline(targetOutline);
|
||||
let targetContainerSource = target.CuInOutline(sourceOutline);
|
||||
//包含.相交.分离(三种状态)
|
||||
@ -6252,7 +6258,7 @@ class Contour
|
||||
let sourceOutline = this._Curve;
|
||||
let targetOutline = target.Curve;
|
||||
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
|
||||
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, 1e-3);
|
||||
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
|
||||
if (interPts.length <= 1) {
|
||||
//反包含
|
||||
if (fastCurveInCurve2(targetOutline, sourceOutline) || equalCurve(targetOutline, sourceOutline))
|
||||
@ -6335,7 +6341,7 @@ class Contour
|
||||
const targetOutline = con.Curve;
|
||||
if (!IntersectBox2(outBox, targetOutline.BoundingBox))
|
||||
continue;
|
||||
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, 1e-3);
|
||||
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, COMBINE_FUZZ);
|
||||
if (pts.length <= 1) {
|
||||
//反包含
|
||||
if (fastCurveInCurve2(targetOutline, sourceOutline) || equalCurve(targetOutline, sourceOutline))
|
||||
@ -6763,6 +6769,17 @@ class OffsetPolyline
|
||||
cu2.StartPoint = d.sp;
|
||||
if (d.ep)
|
||||
cu2.EndPoint = d.ep;
|
||||
//这是极端情况,圆弧被压缩成0长度圆弧,本质是空圆弧(我们会在下面判断它)(因为精度的问题)
|
||||
//因为精度的问题,这种0圆心角的圆弧会被当成全圆,但是偏移算法中,应该不可能出现全圆弧的圆弧,所以我们压扁它
|
||||
if (cu2 instanceof Arc
|
||||
&& equaln(cu2.StartAngle, cu2.EndAngle, 1e-6)
|
||||
// && !equaln((<Arc>this._SubCurves[d.index]).AllAngle, Math.PI * 2, 1e-3) 应该不会出现
|
||||
) {
|
||||
if (cu2.IsClockWise)
|
||||
cu2.StartAngle = cu2.EndAngle + 1e-6;
|
||||
else
|
||||
cu2.EndAngle = cu2.StartAngle + 1e-6;
|
||||
}
|
||||
}
|
||||
for (let d of this._SubOffsetedCurves) {
|
||||
let cu1 = this._SubCurves[d.index];
|
||||
@ -6817,7 +6834,7 @@ class OffsetPolyline
|
||||
//真理2:隔壁的圆弧不可能破坏当前的圆弧,只能破坏当前的针脚
|
||||
if (l1Intact && d.preArc && d.preArc instanceof Arc) {
|
||||
let a = d.preArc;
|
||||
if (Math.sign(a.Bul) !== this._OffsetDistSign) {
|
||||
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) {
|
||||
let ipts = a.IntersectWith(l1, IntersectOption.OnBothOperands);
|
||||
if (ipts.length === 2) {
|
||||
let sp = SelectNearP(ipts, p1);
|
||||
@ -6829,7 +6846,7 @@ class OffsetPolyline
|
||||
}
|
||||
if (l2Intact && d.nextArc && d.nextArc instanceof Arc) {
|
||||
let a = d.nextArc;
|
||||
if (Math.sign(a.Bul) !== this._OffsetDistSign) {
|
||||
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) {
|
||||
let ipts = a.IntersectWith(l2, IntersectOption.OnBothOperands);
|
||||
if (ipts.length === 2) {
|
||||
let ep = SelectNearP(ipts, p3);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cadapi",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"description": "",
|
||||
"main": "api.esm.js",
|
||||
"module": "api.esm.js",
|
||||
|
Loading…
Reference in New Issue
Block a user