增加 点to面投影函数 检测最多点共面函数 修改错层函数(现在不判断是否是平面 是否共面 支持多层直接错层 不成功返回 re长度为0)

This commit is contained in:
szdot 2024-01-19 14:38:31 +08:00
parent b53fa88b7d
commit aa30959d71
6 changed files with 160 additions and 140 deletions

View File

@ -558,7 +558,7 @@ namespace FlightRouteV2
Dictionary<int, List<int>> graph = new Dictionary<int, List<int>>();
Dictionary<int, bool> visited = new Dictionary<int, bool>();
List<List<int>> result = new List<List<int>>();
// 构建图
foreach (var edge in arr)
{
@ -648,42 +648,6 @@ namespace FlightRouteV2
return new_bVecs;
}
/// <summary>
/// 从一组向量集合中 不重复的随机选择4个向量为一组 最多100组 组合成二维数组 如:[[1,2,3,4][5,6,7,8]...]
/// </summary>
/// <param name="vecs">坐标集和</param>
/// <returns>re空数组则代表不够4个坐标 </returns>
private static List<Vector3[]> RandomSel4Vec(Vector3[] vecs)
{
List<Vector3[]> result = new List<Vector3[]>();
int len = vecs.Length;
// 如果坐标数组少于4个或者为空则返回空列表
if (len < 4)
{
return result;
}
// 确定最大可选择的组数最多为100组
int numGroups = Math.Min(len / 4, 100);
List<Vector3> flattenedList = vecs.ToList();
Random random = new Random();
// 遍历每一组
for (int i = 0; i < numGroups; i++)
{
List<Vector3> selectedGroup = new List<Vector3>();
// 随机选择4个不重复的坐标
for (int j = 0; j < 4; j++)
{
int index = random.Next(flattenedList.Count);
selectedGroup.Add(flattenedList[index]);
flattenedList.RemoveAt(index);
}
// 将选择的坐标组成的 List 转换为数组,并添加到结果中
result.Add(selectedGroup.ToArray());
}
return result;
}
/// <summary>
/// 设置中间航点
/// </summary>
/// <param name="aVec">起点</param>
@ -725,7 +689,7 @@ namespace FlightRouteV2
return v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z;
}
/// <summary>
/// 叉积
/// 叉积 ps法线向量
/// </summary>
/// <param name="v1">向量1</param>
/// <param name="v2">向量2</param>
@ -743,7 +707,7 @@ namespace FlightRouteV2
/// <param name="v1">第一个向量</param>
/// <param name="v2">第二个向量</param>
/// <returns>角度</returns>
public static double AngleBetween(Vector3 v1, Vector3 v2)
private static double AngleBetween(Vector3 v1, Vector3 v2)
{
// 计算点积
double dotProduct = DotPro(v1, v2);
@ -761,6 +725,77 @@ namespace FlightRouteV2
return thetaDegrees;
}
/// <summary>
/// 计算某个点到平面垂线与平面的交点
/// </summary>
/// <param name="vec1">平面上的点1</param>
/// <param name="vec2">平面上的点2</param>
/// <param name="vec3">平面上的点3</param>
/// <param name="vec4">垂直于平面的点</param>
/// <returns>交点坐标</returns>
private static Vector3 CalculateIntersectionPoint(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4)
{
// 计算平面的法线向量
Vector3 normal = CrossPro(vec2 - vec1, vec3 - vec1);
normal.Normalize();
// 计算第4个点到平面的距离
double distance = DotPro(normal, vec1);
// 计算第4个点到平面的投影点坐标
double projection = DotPro(normal, vec4) - distance;
// 计算交点坐标
Vector3 intersectionPoint = vec4 - normal * projection;
return intersectionPoint;
}
/// <summary>
/// 找到能组成平面的点的最大数量,并返回组成最大平面的点的索引。
/// </summary>
/// <param name="vecs">Vector3 点的列表。</param>
/// <returns>组成最大平面的点的索引。</returns>
public static List<int> FindMaxPlaneIndices(Vector3[] vecs)
{
int maxPointsOnPlane = 0;
List<int> maxPointsIndices = new List<int>(); //记录返回值
int planeCou = vecs.Length; // 飞机总数
for (int i = 0; i < planeCou; i++)
{
for (int j = i + 1; j < planeCou; j++)
{
for (int k = j + 1; k < planeCou; k++)
{
int currentPointsOnPlane = 3; // 当前遍历的三个点肯定在同一平面上
for (int l = k + 1; l < planeCou; l++)
{
if (IsVecsOnPlane(vecs[i], vecs[j], vecs[k], vecs[l]))
{
// 当前的 l 也在同一平面上
currentPointsOnPlane++;
}
}
// 检查当前平面是否比之前找到的平面更大
if (currentPointsOnPlane > maxPointsOnPlane)
{
maxPointsOnPlane = currentPointsOnPlane;
maxPointsIndices.Clear();
maxPointsIndices.Add(i);
maxPointsIndices.Add(j);
maxPointsIndices.Add(k);
// 添加当前平面的 l 索引
for (int l = k + 1; l < planeCou; l++)
{
if (IsVecsOnPlane(vecs[i], vecs[j], vecs[k], vecs[l]))
{
maxPointsIndices.Add(l);
}
}
}
}
}
}
return maxPointsIndices;
}
/// <summary>
/// 检查4个点是否在一个平面上
/// </summary>
/// <param name="vector1">点1</param>
@ -768,14 +803,14 @@ namespace FlightRouteV2
/// <param name="vector3">点3</param>
/// <param name="vector4">点4</param>
/// <returns>true在一个平面 false不在一个平面</returns>
public static bool IsVecsOnPlane(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4)
private static bool IsVecsOnPlane(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4)
{
//计算三个向量
Vector3 v1v2 = vec2 - vec1;
Vector3 v1v3 = vec3 - vec1;
Vector3 v1v4 = vec4 - vec1;
//计算法线向量
Vector3 normal_vector = CrossPro(v1v2,v1v3);
Vector3 normal_vector = CrossPro(v1v2, v1v3);
//计算点到平面的距离
double distance = DotPro(normal_vector, v1v4) / normal_vector.GetMag();
//设置一个阈值,判断是否共面
@ -817,7 +852,7 @@ namespace FlightRouteV2
private static bool IsPointBetweenLines(Vector3 A, Vector3 B, Vector3 C, Vector3 D, Vector3 P)
{
/// Y轴亚平 即顶视图
A = new Vector3(A.X,0,A.Z);
A = new Vector3(A.X, 0, A.Z);
B = new Vector3(B.X, 0, B.Z);
C = new Vector3(C.X, 0, C.Z);
D = new Vector3(D.X, 0, D.Z);
@ -1140,7 +1175,7 @@ namespace FlightRouteV2
/// <param name="aVecs">始点坐标集合</param>
/// <param name="bVecs">终点坐标集合</param>
/// <returns></returns>
private static List<int[]> AirImitation(Vector3[] aVecs , List<Vector3> bVecs)
private static List<int[]> AirImitation(Vector3[] aVecs, List<Vector3> bVecs)
{
List<int[]> planesCollision = new List<int[]>(); //所有碰撞的组
int planeCou = aVecs.Length; //获取飞机总数
@ -1169,7 +1204,7 @@ namespace FlightRouteV2
/// <param name="aVecs">始点坐标集合</param>
/// <param name="bVecs">终点坐标集合</param>
/// <returns></returns>
private static List<int[]> AirImitation( List<Vector3> aVecs, Vector3[] bVecs)
private static List<int[]> AirImitation(List<Vector3> aVecs, Vector3[] bVecs)
{
List<int[]> planesCollision = new List<int[]>(); //所有碰撞的组
int planeCou = aVecs.Count; //获取飞机总数
@ -1436,7 +1471,7 @@ namespace FlightRouteV2
new_bVecs = tempNew_bVecsS[GetRandomMinIndex(tempLen)];
}
}
t = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - t;
StrPrint($"用时:{t}秒");
StrPrint($"-------智能选择路径计算,结束-------");
@ -1447,12 +1482,10 @@ namespace FlightRouteV2
/// </summary>
/// <param name="aVecs">起始坐标集合</param>
/// <param name="bVecs">终点做标集合</param>
/// <param name="aName">起始坐标航点名称</param>
/// <param name="bName">终点坐标航点名称</param>
/// <param name="StrPrint">日志输出 回调函数</param>
/// <param name="layHight">错层层高</param>
/// <returns>返回一个二维向量坐标集合 middle[0]是第一个中间航点 middle[1]是第二个中间航点 返回空数组则代表两个图形不在一个平面上或者不够4个点</returns>
public static List<List<Vector3>> CollisionLayer(Vector3[] aVecs, Vector3[] bVecs,string aName,string bName ,SomeCalculateWay StrPrint, double layHight = 185)
public static List<List<Vector3>> CollisionLayer(Vector3[] aVecs, Vector3[] bVecs,SomeCalculateWay StrPrint, double layHight = 185)
{
long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
StrPrint("-------错层,开始-------");
@ -1467,102 +1500,71 @@ namespace FlightRouteV2
}
//获取飞机总数
int planeCou = aVecs.Length;
if (planeCou < 2)//至少不少于2架飞机 才开始错层
Vector3[] new_aVecs = aVecs.ToArray(); //a图副本
Vector3[] new_bVecs = bVecs.ToArray(); //b图副本
///把所有点压在 最“共面”上
List<int> maxVecsOfCoplane = FindMaxPlaneIndices(aVecs);// 找出A图共面最多点的索引
if (maxVecsOfCoplane.Count < 4) //a图至少要有4个点 共面
{
StrPrint("图案至少要两个点阵!");
StrPrint("a图案至少有4个点以上共面否则不可执行错层处理");
StrPrint($"-------错层结束-------");
return re;
}
//共面上取三个点
Vector3 vec0 = new_aVecs[maxVecsOfCoplane[0]];
Vector3 vec1 = new_aVecs[maxVecsOfCoplane[1]];
Vector3 vec2 = new_aVecs[maxVecsOfCoplane[2]];
for (int i = 0; i < planeCou; i++) //遍历 把a图和b图点压到 “共面”上
{
if (!(maxVecsOfCoplane.Contains(i))) //除去在共面内的面
{
new_aVecs[i] = CalculateIntersectionPoint(vec0, vec1, vec2, new_aVecs[i]); //压平到共面上
}
new_bVecs[i] = CalculateIntersectionPoint(vec0, vec1, vec2, new_bVecs[i]); //压平到共面上
}
///从ab图案中取最外层3个点 确定一个面 ps:方便后续叉积算法线标量
Vector3 vec0 = new Vector3(0, 0, 0); //记录最外圈一个坐标
Vector3 vec1 = new Vector3(0, 0, 0); //记录离最外圈坐标最远的一个点坐标
Vector3 vec2 = new Vector3(0, 0, 0); //最外圈距离 和最远距离 之和最远的一个点
// 求重心
List<Vector3> allVecs = new List<Vector3>();
for (int i = 0; i < planeCou; i++)
{
allVecs.Add(aVecs[i]);
allVecs.Add(bVecs[i]);
}
Vector3 centerVec = GetPosCenter(allVecs);//重心点
// 遍历所有ab点
double tempLong = 0;
double currentLong;
for (int i = 0; i < planeCou * 2; i++) //取最外圈一个坐标
{
currentLong = GageLength(allVecs[i], centerVec);
if (tempLong < currentLong)
{
vec0 = allVecs[i];
tempLong = currentLong;
}
}
tempLong = 0;
for (int i = 0; i < planeCou * 2; i++) //取最外圈点
{
currentLong = GageLength(allVecs[i], vec0);
if (tempLong < currentLong)
{
vec1 = allVecs[i];
tempLong = currentLong;
}
}
tempLong = 0;
for (int i = 0; i < planeCou * 2; i++) //取最外圈点
{
currentLong =(GageLength(allVecs[i], vec0) + GageLength(allVecs[i], vec1));
if (tempLong < currentLong)
{
vec2 = allVecs[i];
tempLong = currentLong;
}
}
///遍历两个图形所有点 是否在一个平面上
string aNoPlaneSN= "";//记录a图案所有不在一个平面上的点
string bNoPlaneSN = "";//记录b图案所有不在一个平面上的点
for (int i = 0; i < planeCou; i++)
{
if (!IsVecsOnPlane(vec0, vec1, vec2, aVecs[i])) aNoPlaneSN += $"{i+1},";
if (!IsVecsOnPlane(vec0, vec1, vec2, bVecs[i])) bNoPlaneSN += $"{i+1},";
}
if (aNoPlaneSN != "" || bNoPlaneSN != "")
{
if (aNoPlaneSN != "") StrPrint($"“{aName}”:{aNoPlaneSN}号飞机 ,不在一个平面,故不能做搓层处理!");
if (bNoPlaneSN != "") StrPrint($"“{bName}”:{bNoPlaneSN}号飞机 ,不在一个平面,故不能做搓层处理!");
StrPrint($"-------错层,结束-------");
return re;//两个图形不在一个平面上 返回 空数组
}
///检查完毕后
//计算法线向量
///计算法线向量
Vector3 side1 = vec1 - vec0;
Vector3 side2 = vec2 - vec0;
Vector3 normal = CrossPro(side1, side2);
Vector3 normalScalar = normal.NormalizEd();//法线标量
//开始错层
///开始错层
for (int i = 0; i < planeCou; i++)
{
int shiftCou = 1; //记录循环次数 即层数
Vector3 aOrigin = aVecs[i]; //原点位置
Vector3 bOrigin = bVecs[i]; //原点位置
while (OnlyImitation(i, aVecs, bVecs))
Vector3 aOrigin = new_aVecs[i]; //原点位置
Vector3 bOrigin = new_bVecs[i]; //原点位置
while (OnlyImitation(i, new_aVecs, new_bVecs))
{
Vector3 shiftVec = normalScalar * ((shiftCou + 1) / 2 * layHight);
if (shiftCou % 2 == 1)
{
aVecs[i] = aOrigin + shiftVec;
bVecs[i] = bOrigin + shiftVec;
new_aVecs[i] = aOrigin + shiftVec;
new_bVecs[i] = bOrigin + shiftVec;
}
else
{
aVecs[i] = aOrigin - shiftVec;
bVecs[i] = bOrigin - shiftVec;
new_aVecs[i] = aOrigin - shiftVec;
new_bVecs[i] = bOrigin - shiftVec;
}
shiftCou += 1;
}
}
re.Add(aVecs.ToList());
re.Add(bVecs.ToList());
StrPrint($"错层成功");
///计算碰撞
planesCollision = AirImitation(aVecs, new_aVecs).Concat(AirImitation(new_aVecs, new_bVecs)).ToList(); //获取碰撞组
planesCollision = planesCollision.Concat(AirImitation(new_bVecs, bVecs)).ToList();
if (planesCollision.Count == 0)
{
re.Add(new_aVecs.ToList());
re.Add(new_bVecs.ToList());
StrPrint($"错层成功");
}
else
{
StrPrint($"检测有碰撞,错层失败");
}
t = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - t;
StrPrint($"用时:{t}秒");
StrPrint($"-------错层结束-------");
@ -1579,7 +1581,7 @@ namespace FlightRouteV2
/// <param name="isPass">out参数 返回true不碰撞程序直接返回 false有碰撞程序向下执行</param>
/// <param name="mappingId">飞机真实序号的映射关系</param>
/// <returns>返回一个二维数组 返回值长度0没有检测到碰撞或绕行失败 长度1为一个中间航点 长度为3为三个中间航点顺序(前中后)</returns>
public static List<List<Vector3>> ABypassB(Vector3[] aVecs, Vector3[] bVecs,SomeCalculateWay StrPrint, Schedule GetVal, CancellationToken cancellationToken, out bool isPass, List<int> mappingId = null)
public static List<List<Vector3>> ABypassB(Vector3[] aVecs, Vector3[] bVecs, SomeCalculateWay StrPrint, Schedule GetVal, CancellationToken cancellationToken, out bool isPass, List<int> mappingId = null)
{
isPass = false;
long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
@ -1626,8 +1628,8 @@ namespace FlightRouteV2
foreach (int i in collisionGroup)//开始绕碰撞组
{
progress++;
GetVal(progress/collisionGroup.Count*100);
List<Vector3> grv = GetRingVec(aVecs[i], bVecs[i], 0.5, 5, 4, 1500,300);//中间可绕行航点列表
GetVal(progress / collisionGroup.Count * 100);
List<Vector3> grv = GetRingVec(aVecs[i], bVecs[i], 0.5, 5, 4, 1500, 300);//中间可绕行航点列表
StrPrint($"进度:{progress}/{collisionGroup.Count},本次绕行{grv.Count}次");
foreach (Vector3 v in grv)
{
@ -1690,9 +1692,9 @@ namespace FlightRouteV2
progress++;
GetVal(progress / collisionGroup.Count * 100);
//StrPrint($"迭代{c}次{i}号绕行");
List<Vector3> sgrv1 = GetRingVec(aVecs[i], bVecs[i], 0, 30, 10,600, 300);//中间可绕行航点列表
List<Vector3> sgrv1 = GetRingVec(aVecs[i], bVecs[i], 0, 30, 10, 600, 300);//中间可绕行航点列表
sgrv1.Insert(0, secondMiddleVecsOne[i]);
List<Vector3> sgrv2 = GetRingVec(aVecs[i], bVecs[i], 1, 30, 10,600, 300);//中间可绕行航点列表
List<Vector3> sgrv2 = GetRingVec(aVecs[i], bVecs[i], 1, 30, 10, 600, 300);//中间可绕行航点列表
sgrv2.Insert(0, secondMiddleVecsTwo[i]);
StrPrint($"进度:{progress}/{collisionGroup.Count},本次绕行{sgrv1.Count * sgrv2.Count}次");
foreach (Vector3 v1 in sgrv1)
@ -1778,7 +1780,7 @@ namespace FlightRouteV2
foreach (Vector3 v2 in sgrv2)
{
secondMiddleVecsTwo[i] = v2;
if (!OnlyImitation(i, aVecs, secondMiddleVecsOne) && !OnlyImitation(i, secondMiddleVecsOne, thirdMiddleVecs ) && !OnlyImitation(i, thirdMiddleVecs, secondMiddleVecsTwo) && !OnlyImitation(i, secondMiddleVecsTwo, bVecs))
if (!OnlyImitation(i, aVecs, secondMiddleVecsOne) && !OnlyImitation(i, secondMiddleVecsOne, thirdMiddleVecs) && !OnlyImitation(i, thirdMiddleVecs, secondMiddleVecsTwo) && !OnlyImitation(i, secondMiddleVecsTwo, bVecs))
{
isPassMark = true;
break;
@ -1869,7 +1871,7 @@ namespace FlightRouteV2
/// <param name="layHight">偏移层高</param>
/// <param name="direction">层排布方向 "retrun"前后堆叠 "forward"向前排列(如:起点向目标点方向) "backward"向后排列</param>
/// <returns>矩阵</returns>
private static Matrix GetBasisMatrix(Vector3 aVec, Vector3 bVec, double middleProportion, int offCount, double layHight,string direction)
private static Matrix GetBasisMatrix(Vector3 aVec, Vector3 bVec, double middleProportion, int offCount, double layHight, string direction)
{
/// 计算前向向量 k帽
Vector3 k_hat = (bVec - aVec).NormalizEd();
@ -1894,7 +1896,7 @@ namespace FlightRouteV2
{
offShift = middleProportion + offCount * layHight / length;
}
else if(direction == "backward")
else if (direction == "backward")
{
offShift = middleProportion - offCount * layHight / length;
}
@ -1931,7 +1933,7 @@ namespace FlightRouteV2
/// <param name="maxPaunchRadius">设定圆盘半径 的最大值 单位是厘米</param>
/// <param name="direction">层排布方向 "retrun"前后堆叠 "forward"向前排列(如:起点向目标点方向) "backward"向后排列</param>
/// <returns>绕行航点列表</returns>
public static List<Vector3> GetRingVec(Vector3 aVec, Vector3 bVec, double middleProportion, double transfer, double paunch,double maxPaunchRadius, double minPaunchRadius,string direction = "retrun")
public static List<Vector3> GetRingVec(Vector3 aVec, Vector3 bVec, double middleProportion, double transfer, double paunch, double maxPaunchRadius, double minPaunchRadius, string direction = "retrun")
{
List<Vector3> ringVec = new List<Vector3>(); //记录所有绕行中间航点坐标
/// 根据a到b的长度 算出中间绕行几圈
@ -1944,7 +1946,7 @@ namespace FlightRouteV2
{
discRadius = minPaunchRadius;//设定圆盘直径下限
}
int ringCou = (int)Math.Ceiling(discRadius / transfer ); //算层数和圈数 ps:层的厚度 和 圈的直径 为 paunch/航线长度
int ringCou = (int)Math.Ceiling(discRadius / transfer); //算层数和圈数 ps:层的厚度 和 圈的直径 为 paunch/航线长度
/// 不是单圈的话 设置层数跟圈数相等
int layCou = ringCou;
if (singleCircle) layCou = 1;
@ -1989,16 +1991,16 @@ namespace FlightRouteV2
{
new_bVecs[i] = new Vector3(new_bVecs[i].X, 0, new_bVecs[i].Z);
}
int row = 1 ;
for (int i = 0; i < planeCou-2; i++)
int row = 1;
for (int i = 0; i < planeCou - 2; i++)
{
if (!(IsVecsOnLine(new_bVecs[i], new_bVecs[i + 1], new_bVecs[i + 2])))
{
row = i+2;//列
row = i + 2;//列
break;
}
}
int ran = (int)Math.Ceiling((double)planeCou/(double)row);//行
int ran = (int)Math.Ceiling((double)planeCou / (double)row);//行
StrPrint($"{ran}行{row}列");
if (ran > 2)
{
@ -2043,7 +2045,7 @@ namespace FlightRouteV2
}
}
///判断a图的中心点 是否在矩阵内部 在矩阵内部 做一个a b两组中心点对其 ps:相当于朝两边拉散
if (IsPointBetweenLines(new_bVecs[(int)Math.Ceiling(((double)row/5))-1], new_bVecs[(int)Math.Ceiling(((double)row / 5)) - 1+row], new_bVecs[row-((int)Math.Ceiling(((double)row / 5)) - 1)], new_bVecs[(row - ((int)Math.Ceiling(((double)row / 5)) - 1))+row], aCenterPos))
if (IsPointBetweenLines(new_bVecs[(int)Math.Ceiling(((double)row / 5)) - 1], new_bVecs[(int)Math.Ceiling(((double)row / 5)) - 1 + row], new_bVecs[row - ((int)Math.Ceiling(((double)row / 5)) - 1)], new_bVecs[(row - ((int)Math.Ceiling(((double)row / 5)) - 1)) + row], aCenterPos))
{
if (GageLength(new_aVecs[0], aVecs[0]) > GageLength(new_aVecs[planeCou - 1], aVecs[planeCou - 1]))//判断最大偏移量 是第一排 还是最后一排
{

View File

@ -43,13 +43,31 @@ namespace FlyCube
List<Vector3[]> abVecs = FileBase.TxtToPos("C:/Users/szdot/Desktop/1.txt", out string[] fightNames);//从txt文件里面读取航点 信息
Vector3[] aVecs = abVecs[0].ToArray();
Vector3[] bVecs = abVecs[1].ToArray();
Vector3[] vecs = FlyVecFun.NormalPull(aVecs, bVecs, StrPrintAsync);
Vector3[] new_bVecs = FlyVecFun.ContactABOut(aVecs, bVecs, StrPrint);
List<List<Vector3>> listVecs = FlyVecFun.CollisionLayer(aVecs, new_bVecs, StrPrintAsync);
string txta = "";
string txtb = "";
string txtd = "";
for (int i = 0; i < vecs.Length; i++)
for (int i = 0; i < bVecs.Length; i++)
{
txtd += i + " 0" + " " + vecs[i].X + " " + vecs[i].Y + " " + vecs[i].Z + "\r\n";
txta += i + " 0" + " " + listVecs[0][i].X + " " + listVecs[0][i].Y + " " + listVecs[0][i].Z + "\r\n";
txtb += i + " 0" + " " + listVecs[1][i].X + " " + listVecs[1][i].Y + " " + listVecs[1][i].Z + "\r\n";
txtd += i + " 0" + " " + new_bVecs[i].X + " " + new_bVecs[i].Y + " " + new_bVecs[i].Z + "\r\n";
}
string patha = "C:/Users/szdot/Desktop/a.txt";
string pathb = "C:/Users/szdot/Desktop/b.txt";
string pathd = "C:/Users/szdot/Desktop/d.txt";
if (File.Exists(patha))
{
File.Delete(patha);
}
SaveFile(patha, txta);
if (File.Exists(pathb))
{
File.Delete(pathb);
}
SaveFile(pathb, txtb);
if (File.Exists(pathd))
{
File.Delete(pathd);