#pragma once #ifdef _WIN32 #ifdef WIREROUTINGDLL_EXPORTS // VisualStudio DLL 项目模板会将 _EXPORTS 添加到定义预处理器宏。 #define GEOMETRY_API __declspec(dllexport) // _WIN32 #else #define GEOMETRY_API __declspec(dllimport) #endif #else #define GEOMETRY_API #endif #include #include #include #include using namespace std; template class Vec3 { public: T a, b, c; Vec3(T x = T(), T y = T(), T z = T()) : a(x), b(y), c(z) {} // 修改后代码 T operator[](int i) const { if (i == 0) { return a; } else if (i == 1) { return b; } else if (i == 2) { return c; } return a; } T &operator[](int i) { if (i == 0) { return a; } else if (i == 1) { return b; } else if (i == 2) { return c; } return a; } Vec3 operator+(const Vec3 &other) const { return Vec3(a + other.a, b + other.b, c + other.c); } Vec3 operator/(const float w) const { return Vec3(a / w, b / w, c / w); } Vec3 operator-(const Vec3 &other) const { return Vec3(a - other.a, b - other.b, c - other.c); } Vec3 operator*(const float &w) const { return Vec3(a * w, b * w, c * w); } float length() const { return sqrt(a * a + b * b + c * c); } Vec3 norm() const { return *this / length(); } Vec3 cross(const Vec3 &other) const { return Vec3(b * other.c - c * other.b, c * other.a - a * other.c, a * other.b - b * other.a); } float dot(const Vec3 &other) const { return a * other.a + b * other.b + c * other.c; } }; typedef Vec3 Vec3f; typedef Vec3 Vec3u; class GEOMETRY_API Mesh { public: std::vector vertices; std::vector indices; }; class GEOMETRY_API AABB { public: Vec3f min, max; AABB(); }; class GEOMETRY_API LineSegment { public: Vec3f start; Vec3f end; float length; Vec3f dir; LineSegment(const Vec3f &s, const Vec3f &e); float getLength() const; Vec3f getDir() const; void calculate(); }; struct GEOMETRY_API FaceCenterComparator { const vector &faceCenters; // 替换 YourVectorType 为你的向量类型 int longAxis; FaceCenterComparator(const vector ¢ers, int axis); bool operator()(const size_t &a, const size_t &b) const; };