You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.9 KiB

#pragma once
#ifdef _WIN32
#ifdef WIREROUTINGDLL_EXPORTS // VisualStudio DLL 项目模板会将 <PROJECTNAME>_EXPORTS 添加到定义预处理器宏。
#define BRANCH_POINT_API __declspec(dllexport) // _WIN32
#else
#define BRANCH_POINT_API __declspec(dllimport)
#endif
#else
#define BRANCH_POINT_API
#endif
#include "Clip.h"
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cassert>
using namespace std;
// 分支点数据类型
struct BRANCH_POINT_API BranchPoint
{
P coord; // 点坐标
double t; // 分支点相对位置,在0-1之间
double Dis; // 卡箍到卡箍之间的距离
bool fixed; // 位置是否已经固定
Clip *pc1, *pc2; // 存储它相邻的两个卡箍
BranchPoint *pb1, *pb2; // 存储它相邻的两个分支点
double l, r; // 限制t的范围
vector<int> branchPointsInSameSegment; // 同一分段上其他分支点的标号
P ndir; // 所在分支的法线方向
double position; // 距离参考卡箍的距离
double tempt[2]; // 存储分支点在两种情况下的最优位置,0代表异段进同段出
string referClip; // 参考卡箍的名字
int id; // 分支点标号
int mode; // 存储分支点第一次被加入路径属于哪种情况,0代表异段进同段出,1代表同段进异端出
int bundleNodeID; // 分支点属于的bundle段id
bool used; // 分支点是否被使用
void init();
// 初始化
BranchPoint();
// 按两个卡箍初始化
BranchPoint(Clip *c1, Clip *c2);
// 按卡箍和范围初始化
BranchPoint(Clip *c1, Clip *c2, double L, double R);
// 添加左边的分支点
void addL(BranchPoint b);
// 添加右边的分支点
void addR(BranchPoint b);
// 把左边界向右边推d距离
void pushL(double d);
// 把右边界向左边推d距离
void pushR(double d);
// 固定分支点位置
void fix();
// 通道方向反向,分支点也改变其表示形式
void reverse();
// 返回分支点在分支上可以连接到的下一个点
// offSet代表分支点坐标的偏差值
vector<int> getNext(int offSet);
/*计算分支点到卡箍点的权值
reverse=0p
reverse=1p到分支点
*/
double computeWeight(P &p, int inOut, bool reverse);
// 记录分支点最优位置
void recordPos(int mode);
void check(int i);
};
// 维护所有分支点的集合
struct BRANCH_POINT_API BranchPointSet
{
BranchPoint b[MAXPointNum]; // 分支点数组
int branchPointNum; // 分支点总数
BranchPointSet();
// 添加一个分支点,并返回指向它的指针
BranchPoint *addBranchPoint(Clip *pc1, Clip *pc2, int bundleNodeID);
// 获取指向编号为id的分支点的指针
BranchPoint *getBranchPointPointer(int id);
9 months ago
};
extern BRANCH_POINT_API BranchPointSet branchPointSet;