重命名文件名称.

pull/68/head
ChenX 6 years ago
parent 5aa0362c5d
commit bd6c4ecf2c

@ -9,7 +9,7 @@ import { FixIndex } from '../Common/Utils';
import { equal, equaln, updateGeometry } from '../Geometry/GeUtils'; import { equal, equaln, updateGeometry } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/Enum'; import { RenderType } from '../GraphicsSystem/Enum';
import { IntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith'; import { IntersectOption, IntersectPolylineAndCurve } from '../GraphicsSystem/IntersectWith';
import { PolyOffestUtil } from '../GraphicsSystem/OffestPolyline'; import { PolyOffestUtil } from '../GraphicsSystem/OffsetPolyline';
import { Arc } from './Arc'; import { Arc } from './Arc';
import { Factory } from './CADFactory'; import { Factory } from './CADFactory';
import { CADFile } from './CADFile'; import { CADFile } from './CADFile';
@ -411,7 +411,6 @@ export class Polyline extends Curve
return pl; return pl;
} }
GetSplitCurves(param: number[] | number): Array<Polyline> GetSplitCurves(param: number[] | number): Array<Polyline>
{ {
//参数需要转化为参数数组 //参数需要转化为参数数组

@ -1,122 +0,0 @@
import { Polyline } from '../DatabaseServices/Polyline';
import { Curve } from '../DatabaseServices/Curve';
import { Vector3 } from 'three';
import { IntersectOption } from './IntersectWith';
import { Arc } from '../DatabaseServices/Arc';
import { angle } from '../Geometry/GeUtils';
import { Circle } from '../DatabaseServices/Circle';
export function OffsetPolyline(pl: Polyline, dis: number): Curve[]
{
let oldCus = pl.Explode();
let cuMap = new Map<Curve, Curve>();
//第一次偏移
let offCus = oldCus.map(c =>
{
let newc = c.GetOffsetCurves(dis)[0];
if (newc)
cuMap.set(newc, c);
else
{
//加圆 注意重复
}
return newc;
}
).filter(c => c);
let linkCus = linkCurve(offCus, dis, pl.IsClose, cuMap);
//3.斜率相反的去掉.
return linkCus;
}
//将曲线连接起来
function linkCurve(cus: Curve[], dis, isClose: boolean, cuMap: Map<Curve, Curve>)
{
//sp表示该线段和上一个线段的交点,ep表示和下一个线段的交点.
let ep: Vector3;
if (isClose)
cus.push(cus[0]);
let newCus: Curve[] = [];
let cuCount = cus.length;
for (let i = 0; i < cuCount - 1; i++)
{
let c1 = cus[i];
let c2 = cus[i + 1];
let pts = c1.IntersectWith(c2, IntersectOption.ExtendBoth);
newCus.push(c1);
switch (pts.length)
{
case 0://添加圆弧
{
for (let center of [
cuMap.get(c1).EndPoint,
cuMap.get(c2).StartPoint,
])
{
let cir = new Circle(center, dis);
let pts1 = c1.IntersectWith(cir, IntersectOption.ExtendBoth);
let pts2 = c2.IntersectWith(cir, IntersectOption.ExtendBoth);
if (pts1.length > 0 && pts2.length > 0)
{
c1.EndPoint = selectPoint(pts1, cuMap.get(c1).EndPoint);
c2.StartPoint = selectPoint(pts2, cuMap.get(c2).StartPoint);
let sa = angle(c1.EndPoint.sub(center));
let ea = angle(c2.StartPoint.sub(center));
let c1Deriv = c1.GetFistDeriv(1);
let chord = c2.StartPoint.sub(c1.EndPoint);
let dir = c1Deriv.cross(chord);
let arc = new Arc(center, dis, sa, ea);
arc.IsClockWise = dir.z < 0;
newCus.push(arc);
break;
}
}
continue;//
}
case 1:
{
ep = pts[0];
break;
}
case 2:
{
//计算ep
let oldp = cuMap.get(c1).EndPoint;
ep = pts[0].distanceToSquared(oldp) < pts[1].distanceToSquared(oldp) ?
pts[0] : pts[1];
break;
}
default:
break;
}
c1.EndPoint = ep;
c2.StartPoint = ep;
}
return newCus;
}
function selectPoint(pts: Vector3[], oldp: Vector3)
{
if (pts.length === 1) return pts[0];
return pts[0].distanceToSquared(oldp) < pts[1].distanceToSquared(oldp) ?
pts[0] : pts[1];
}
Loading…
Cancel
Save