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.
102 lines
2.6 KiB
102 lines
2.6 KiB
#pragma once
|
|
|
|
#ifdef _WIN32
|
|
#ifdef WIREROUTINGDLL_EXPORTS // VisualStudio DLL 项目模板会将 <PROJECTNAME>_EXPORTS 添加到定义预处理器宏。
|
|
#define CLIP_API __declspec(dllexport) // _WIN32
|
|
#else
|
|
#define CLIP_API __declspec(dllimport)
|
|
#endif
|
|
#else
|
|
#define CLIP_API
|
|
#endif
|
|
|
|
#include "KDtree.h"
|
|
#include <cmath>
|
|
#include <vector>
|
|
#include <queue>
|
|
#include <map>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
using namespace std;
|
|
|
|
// 卡箍信息
|
|
struct CLIP_API Clip
|
|
{
|
|
string name; // 名字
|
|
P coord, dir; // 坐标和方向,dir的方向视为正面
|
|
int emc; // 卡箍类型,未确定为0
|
|
double dia; // 通过卡箍的线束捆直径
|
|
double maxDia; // 卡箍允许通过的最大线束捆直径
|
|
int id; // 卡箍标号
|
|
int bundleNodeID; // 卡箍暂时属于哪个Bundle
|
|
vector<double> diaset; // 已经通过卡箍的线缆半径集合
|
|
vector<int> channelEdge; // 在近似通道中连接到的卡箍标号
|
|
bool used; // 卡箍是否被使用
|
|
|
|
Clip();
|
|
|
|
// 清除所有通过卡箍的线和通道信息
|
|
void clear();
|
|
|
|
// 在卡箍里加入直径为d的线缆
|
|
void addwire(double d);
|
|
|
|
// 返回通过卡箍的线束捆直径
|
|
double getDia();
|
|
|
|
// 判断直径为d的线缆能否通过
|
|
bool transitable(double d);
|
|
|
|
// 判断从p点到卡箍,应该从哪一面进入,正面为0,反面为1
|
|
int inDir(P p);
|
|
};
|
|
|
|
// 卡箍集,保存所有的卡箍信息
|
|
struct CLIP_API ClipSet
|
|
{
|
|
Clip c[N]; // 卡箍集合,下标从1~clipnum
|
|
int clipnum; // 卡箍总和,卡箍标号范围1`clipnum
|
|
map<P, int> clipid; // 根据点坐标找到卡箍标号
|
|
|
|
ClipSet();
|
|
|
|
// 清除通过卡箍的线缆信息
|
|
void clearWire();
|
|
|
|
// 新加入一个卡箍
|
|
void addclip(P p, P d, string name, int emc);
|
|
|
|
// 添加通过卡箍的导线
|
|
void addwire(int id, double d);
|
|
|
|
void addwire(P &p, double d);
|
|
|
|
// 获取指向编号为id的卡箍的指针
|
|
Clip *getClipPointer(int id, int bundleNodeID);
|
|
|
|
// 判断两个卡箍是否互相为最近(已知i最近的卡箍是j)
|
|
bool bothConnect(int i, int j);
|
|
|
|
// 判断卡箍能否通过
|
|
bool transitable(int id, int emc, double d);
|
|
|
|
// 根据卡箍位置估计飞机的近似中心线
|
|
void computeCenter();
|
|
|
|
// 打印卡箍距离近似中心线的距离
|
|
void printDis();
|
|
|
|
// 根据卡箍位置先创建一个近似的通道,每个卡箍连到距离最近的两个卡箍
|
|
void buildChannel();
|
|
|
|
// 打印所有卡箍信息到clipDir文件,卡箍坐标后面会加上卡箍类型
|
|
/*
|
|
0代表航向卡箍
|
|
1代表垂直向卡箍
|
|
2代表其他方向卡箍
|
|
*/
|
|
void print();
|
|
};
|
|
|
|
extern ClipSet CLIP_API clipSet;
|
|
|