#pragma once #if defined(_WIN32) #if defined(MODERNGLUE_EXPORTS) #define GLUE_API __declspec(dllexport) #else #define GLUE_API __declspec(dllimport) #endif #else #define GLUE_API #endif namespace _cgal { struct Pt2d { double x, y; }; struct Pt3d { double x, y, z; }; template struct CgalArray { T *pData; int count; }; typedef CgalArray Pt2dArr; typedef CgalArray Pt3dArr; // 多边形 struct Polygon2d { Pt2dArr vertices; }; struct Polygon3d { Pt3dArr vertices; }; typedef CgalArray Polygon2dList; typedef CgalArray Polygon3dList; // 多边形带泂 polygon with holes struct Pwh2d { Polygon2d outer_boundary; Polygon2dList inner_holes; }; // 带洞多边形数组 typedef CgalArray Pwh2dList; typedef CgalArray IntArray; enum Bounded_side { eOutside = -1, eIsPoint, eOnside, eInside, SIDE_ERROR, }; } #ifdef __cplusplus extern "C" #endif { // 哪个dll申请内存,就在哪个dll内部释放. // 当 这里的函数以参数的e形式传出了 Pt2dArr 等数据块时,需要调用下面的free函数来释放 // 当 向这里的接口传入 Pt2dArr 等数据块时, 千万不要调用下面的free函数来释放. GLUE_API void mg_cgal_free_Pt2dArray(_cgal::Pt2dArr &arr); GLUE_API void mg_cgal_free_Pt3dArray(_cgal::Pt3dArr &arr); GLUE_API void mg_cgal_free_Polygon2d(_cgal::Polygon2d &poly); GLUE_API void mg_cgal_free_Polygon3d(_cgal::Polygon3d &POly); GLUE_API void mg_cgal_free_Polygon2dList(_cgal::Polygon2dList &arr); GLUE_API void mg_cgal_free_Polygon3dList(_cgal::Polygon3dList &arr); GLUE_API void mg_cgal_free_Pwh2d(_cgal::Pwh2d &pwh); GLUE_API void mg_cgal_free_Pwh2dList(_cgal::Pwh2dList &arr); GLUE_API void mg_cgal_free_IntArray(_cgal::IntArray &arr); GLUE_API bool mg_cgal_less_xy(const _cgal::Pt2d &pt1, const _cgal::Pt2d &pt2); GLUE_API bool mg_cgal_less_xyz(const _cgal::Pt3d &pt1, const _cgal::Pt3d &pt2); /////////////////////////////////////////////////////////////////////////// // 对pts做delaunary三角化,并保存成GePolyFaceMesh结构 GLUE_API void mg_cgal_delaunayTriangulationMesh(const _cgal::Pt3dArr &arPts , _cgal::Pt3dArr &vertexArray , _cgal::IntArray &faceArray); GLUE_API void mg_cgal_delaunayTriangulationMeshWithHolds(const _cgal::Pt3dArr &arPts , const _cgal::Polygon3dList &holds , _cgal::Pt3dArr &vertexArray , _cgal::IntArray &faceArray); // 计算一堆点的凸包曲线 // 传出是一个point数组,按顺序组成一条polygon GLUE_API void mg_cgal_calcConvexHull2D_2d_2d(const _cgal::Pt2dArr &arPts, _cgal::Pt2dArr &poly); GLUE_API void mg_cgal_calcConvexHull2D_3d_2d(const _cgal::Pt3dArr &arPts, _cgal::Pt2dArr &poly); GLUE_API void mg_cgal_calcConvexHull2D_3d_3d(const _cgal::Pt3dArr &arPts, _cgal::Pt3dArr &poly); GLUE_API _cgal::Bounded_side mg_cgal_boundary_check(const _cgal::Pt2d &pt, const _cgal::Pwh2d &gepwh); GLUE_API bool mg_cgal_is_vaild_polygon_with_hole(const _cgal::Pwh2d &geP); GLUE_API bool mg_cgal_is_vaild_polygon(const _cgal::Polygon2d &geP); GLUE_API bool mg_cgal_is_counterclockwise_with_hole(const _cgal::Pwh2d &geP); GLUE_API bool mg_cgal_is_counterclockwise(const _cgal::Pt2d &ptS , const _cgal::Pt2d &ptM , const _cgal::Pt2d &ptE ); GLUE_API bool mg_cgal_is_intersect(const _cgal::Pwh2d &geP, const _cgal::Pwh2d &geQ); GLUE_API void mg_cgal_intersect(const _cgal::Pwh2d &geP , const _cgal::Pwh2d &geQ , _cgal::Pwh2dList &gepwhlst); GLUE_API bool mg_cgal_join(const _cgal::Pwh2d &geP , const _cgal::Pwh2d &geQ , _cgal::Pwh2d &gepwh); GLUE_API void mg_cgal_difference( const _cgal::Pwh2d &geP , const _cgal::Pwh2d &geQ , _cgal::Pwh2dList &gepwhlst); GLUE_API void mg_cgal_symmetric_difference( const _cgal::Pwh2d &geP , const _cgal::Pwh2d &geQ , _cgal::Pwh2dList &gepwhlst); GLUE_API void mg_cgal_sort_xy(const _cgal::Polygon2d &ge, _cgal::Polygon2d &out); GLUE_API void mg_cgal_sort_yx(const _cgal::Polygon2d &ge, _cgal::Polygon2d &out); GLUE_API void mg_cgal_convexHull2d(const _cgal::Pt2dArr &input, _cgal::Pt2dArr &output); #ifdef __cplusplus } #endif