86 lines
1.4 KiB

#pragma once
#ifdef _WIN32
#ifdef WIREROUTINGDLL_EXPORTS // VisualStudio DLL 项目模板会将 <PROJECTNAME>_EXPORTS 添加到定义预处理器宏。
#define KD_TREE_API __declspec(dllexport) // _WIN32
#else
#define KD_TREE_API __declspec(dllimport)
#endif
#else
#define KD_TREE_API
#endif
#include "BVH.h"
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
struct KD_TREE_API point
{
double x[3];
int id;
point();
};
extern bool KD_TREE_API cmp0(const point &a, const point &b);
extern bool KD_TREE_API cmp1(const point &a, const point &b);
extern bool KD_TREE_API cmp2(const point &a, const point &b);
struct KD_TREE_API node
{
double dis;
int id;
bool operator<(node b) const;
node();
node(int id1, double dis1);
};
struct KD_TREE_API tree
{
point p;
double mx[3], mn[3];
int ls, rs, id;
tree();
};
struct KD_TREE_API KDtree
{
int n, tot, root;
double X, Y, Z;
priority_queue<node> q;
vector<int> vec;
point p[MAXPointNum];
tree t[MAXPointNum];
KDtree();
double dis(tree &x);
double mndis(tree &x);
void update(int x);
void query(int x);
void queryd(int x, double d);
void add(P &s);
void build(int &x, int l, int r, int k);
void build();
vector<int> search_by_k(P &s, int k);
// 返回距离s点d以内的所有点的编号
vector<int> search_by_dis(P &s, double d);
};
extern KDtree KD_TREE_API kdtree;