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.
 
 
 

84 lines
1.4 KiB

#pragma once
#ifdef _WIN32
#ifdef WIREROUTINGDLL_EXPORTS // VisualStudio DLL 项目模板会将 <PROJECTNAME>_EXPORTS 添加到定义预处理器宏。
#define BVH_API __declspec(dllexport) // _WIN32
#else
#define BVH_API __declspec(dllimport)
#endif
#else
#define BVH_API
#endif
#include"ReadXML.h"
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<iostream>
#include<fstream>
#include<sstream>
using namespace std;
extern bool BVH_API PointInTri(Point3& P, Point3& P0, Point3& P1, Point3& P2);
struct BVH_API Triangle{
P p[3];
void getbox(P& _min, P& _max);
void print();
};
extern bool BVH_API cmpt0(const Triangle& a, const Triangle& b);
extern bool BVH_API cmpt1(const Triangle& a, const Triangle& b);
extern bool BVH_API cmpt2(const Triangle& a, const Triangle& b);
struct BVH_API O_AABB {
P _min;
P _max;
int l,r;
O_AABB();
O_AABB(const P& min, const P& max);
bool insig(double x, double a, double b);
bool inbox(const P& p);
bool hit(P& p1, P& p2);
};
struct BVH_API BVH{
int trinum,tot,root;
Triangle tri[MaxSTL];
O_AABB ab[400010];
BVH();
void update(int x);
void build(int &x,int l,int r,int k);
bool TriSegIntersection(Point3& P0, Point3& P1, Point3& P2, Point3& A, Point3& B);
bool TriSegIntersection(Triangle& t, Point3& A, Point3& B);
bool query(int x,int l,int r,P &A,P &B);
bool iscollect(P& A, P& B);
void read_stl(string filename);
};