曲线信息类
主要是缓存一层包围盒
1,存档曲线Curve
2,复合曲线CompositeCurve3d
3,单元曲线Curve3d
验证包围盒在这里:
https://www.cnblogs.com/JJBox/p/18677417
public class CurveInfo : DRect {
public int RegionColor = 0; // 染色:斜区0,横区1,竖区2
public MyGroup Group { get; }
public ConcurrentBag<double> Paramss { get; }
public Curve3d OriginalC3d { get; }
public CurveInfo(Curve3d cc) {
OriginalC3d = cc;
_left = cc.OrthoBoundBlock.GetMinimumPoint().Y;
_right = cc.OrthoBoundBlock.GetMaximumPoint().Y;
_bottom = cc.OrthoBoundBlock.GetMinimumPoint().X;
_top = cc.OrthoBoundBlock.GetMaximumPoint().X;
Group = new(0);
Paramss = new();
}
public CurveInfo(Curve curve) {
var cc = curve.GetGeCurve();
OriginalC3d = cc;
_left = cc.OrthoBoundBlock.GetMinimumPoint().Y;
_right = cc.OrthoBoundBlock.GetMaximumPoint().Y;
_bottom = cc.OrthoBoundBlock.GetMinimumPoint().X;
_top = cc.OrthoBoundBlock.GetMaximumPoint().X;
Group = new(0);
Paramss = new();
}
// 根据曲线参数打断
public IEnumerable<CurveInfo> BreakCurves() {
var array = Paramss.ToArray();
Array.Sort(array);
return GetSplitCurvesToInfo(array);
}
public IEnumerable<CurveInfo> GetSplitCurvesToInfo(double[] paramss) {
Curve3d[] resultArray = null;
GetSplitCurves(paramss, ref resultArray);
return resultArray.Select(curve3d => new CurveInfo(curve3d));
}
// 断分,扫描线碰撞需要
// 从后面往前打断
// 打断之后只有两个成员,头不输出,用来继续打断.
public void GetSplitCurves(double[] paramss, ref Curve3d[] resultArray) {
int size = paramss.Length + 1;
#if NET80
resultArray = stackalloc Curve3d[size];
#else
resultArray = new Curve3d[size];
#endif
Curve3d cur = OriginalC3d;
for (int i = paramss.Length - 1; i >= 0; i--) {
Curve3d[] cs = cur.GetSplitCurves(paramss[i]);
resultArray[i + 1] = cs.Last();
cur = cs.First();
}
resultArray[0] = cur;
}
// TODO 炸开失败要返回本体,这里炸开有这个功能吗?
// 单元曲线:复合曲线炸开而来.
static Interval _interval = new Interval(Tolerance.Global.EqualPoint);
public Curve3d[] Explode() {
return OriginalC3d.Explode(_interval);
}
public IEnumerable<CurveInfo> ExplodeToInfo() {
return Explode().Select(curve3d => new CurveInfo(curve3d));
}
// 隐式转换
public static implicit operator Curve3d(CurveInfo m) {
return m.OriginalC3d;
}
public static implicit operator CompositeCurve3d(CurveInfo m) {
return Curve.CreateFormGeCurve(m.OriginalC3d))
.ToCompositeCurve3d();
}
public static implicit operator Curve(CurveInfo m) {
return Curve.CreateFormGeCurve(m.OriginalC3d));
}
public bool HasPoint(Point3d pt) {
return OriginalC3d.StartPoint.IsEqualTo(pt, Tolerance.Global)
|| OriginalC3d.EndPoint.IsEqualTo(pt, Tolerance.Global);
}
public bool HasTwoPoint(CurveInfo other) {
return (OriginalC3d.StartPoint.IsEqualTo(other.OriginalC3d.StartPoint, Tolerance.Global)
&& OriginalC3d.EndPoint.IsEqualTo(other.OriginalC3d.EndPoint, Tolerance.Global))
|| (OriginalC3d.StartPoint.IsEqualTo(other.OriginalC3d.EndPoint, Tolerance.Global)
&& OriginalC3d.EndPoint.IsEqualTo(other.OriginalC3d.StartPoint, Tolerance.Global));
}
}
标签:OriginalC3d,return,cc,CurveInfo,net,Curve3d,public,cad
From: https://www.cnblogs.com/JJBox/p/18677524