diff --git a/thirdparty/clip2tri/HPKBUILD b/thirdparty/clip2tri/HPKBUILD index d1d1700b96231348b1d9f24144c82dc6ba76bd77..9844204dc8311fdfcba348727f2f4b5027cfc5d1 100755 --- a/thirdparty/clip2tri/HPKBUILD +++ b/thirdparty/clip2tri/HPKBUILD @@ -15,7 +15,7 @@ # Maintainer: zhangxin pkgname=clip2tri -pkgver=f62a734d22733814b8a970ed8a68a4d94c24fa5f +pkgver=master pkgrel=0 pkgdesc="Using clipper and poly2tri together for robust triangulation" url="https://github.com/raptor/clip2tri" @@ -24,7 +24,8 @@ license=("The MIT License") depends=() makedepends=() -source="https://github.com/raptor/clip2tri.git" +source="https://github.com/raptor/$pkgname.git" +commitid=f62a734d22733814b8a970ed8a68a4d94c24fa5f autounpack=false downloadpackage=false @@ -35,20 +36,19 @@ download_and_patch_flag=true prepare() { if [ "$download_and_patch_flag" == true ] then - git clone $source $builddir - ret=$? - if [ $ret -ne 0 ] + git clone -b $pkgver $source $builddir > $publicbuildlog 2>&1 + if [ $? -ne 0 ] then - echo "git clone failed!" >> $buildlog + return -1 fi cd $builddir - git reset --hard $pkgver - ret=$? - if [ $ret -ne 0 ] + git reset --hard $commitid > $publicbuildlog 2>&1 + if [ $? -ne 0 ] then - echo "git reset failed!" >> $buildlog + cd $OLDPWD + return -2 fi - patch -p1 < ../clip2tri.patch + patch -p1 < ../clip2tri_ohos_test.patch #添加测试用例,未对原库做改动 cd $OLDPWD download_and_patch_flag=false fi @@ -58,7 +58,7 @@ prepare() { build() { cd $builddir ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -B$ARCH-build -S./ > $buildlog 2>&1 - $MAKE -C $ARCH-build >> $buildlog 2>&1 + $MAKE VERBOSE=1 -C $ARCH-build >> $buildlog 2>&1 ret=$? cd $OLDPWD return $ret @@ -66,7 +66,10 @@ build() { package() { cd $builddir - $MAKE -C $ARCH-build install >> $buildlog 2>&1 + mkdir -p ${LYCIUM_ROOT}/usr/$pkgname/$ARCH/include + mkdir -p ${LYCIUM_ROOT}/usr/$pkgname/$ARCH/include/clipper + cp clipper/*.hpp ${LYCIUM_ROOT}/usr/$pkgname/$ARCH/include/clipper + $MAKE VERBOSE=1 -C $ARCH-build install >> $buildlog 2>&1 cd $OLDPWD } diff --git a/thirdparty/clip2tri/clip2tri.patch b/thirdparty/clip2tri/clip2tri.patch deleted file mode 100755 index d0e22962e731fbd6d3bd05688aaa5a5f00ef0709..0000000000000000000000000000000000000000 --- a/thirdparty/clip2tri/clip2tri.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff -Nura clip2tri-master/CMakeLists.txt clip2tri-master_patch/CMakeLists.txt ---- clip2tri-master/CMakeLists.txt 2014-10-30 17:11:28.000000000 -0700 -+++ clip2tri-master_patch/CMakeLists.txt 2023-09-26 20:05:46.554289600 -0700 -@@ -26,6 +26,9 @@ - endif(HAVE_M_LIB) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/clip2tri) -+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/clipper) -+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/poly2tri) - - if(NOT DEFINED BIN_DIR) - set(BIN_DIR bin) -@@ -61,9 +64,27 @@ - ARCHIVE DESTINATION ${LIB_DIR}) - endif(BUILD_STATIC_LIBS) - -+add_executable(test test.cpp) -+target_link_libraries(test PRIVATE clip2tri) -+if(OHOS) -+target_compile_options(test PRIVATE -Wno-format-security) -+endif() -+list(APPEND TARGET_INSTALL_ELEMENT test) -+ -+enable_testing() -+add_test(NAME test_clip2tri COMMAND test) - - # Install header files --install(DIRECTORY clip2tri/ -+file(GLOB CLIP2TRI_HEAD clip2tri/clip2tri.h) -+install( -+ FILES ${CLIP2TRI_HEAD} - DESTINATION include/clip2tri -- FILES_MATCHING PATTERN "*.h" - ) -+ -+file(GLOB CLIPPER_HEAD clipper/clipper.hpp) -+install( -+ FILES ${CLIPPER_HEAD} -+ DESTINATION include/clipper -+) -+ -+ -diff -Nura clip2tri-master/test.cpp clip2tri-master_patch/test.cpp ---- clip2tri-master/test.cpp 2014-10-30 17:11:28.000000000 -0700 -+++ clip2tri-master_patch/test.cpp 2023-09-21 02:23:00.598086266 -0700 -@@ -17,6 +17,19 @@ - - vector boundingPolygon; - -+ Point p1 = {10, 60}; -+ Point p2 = {20, 60}; -+ -+ vector newData = {p1,p2}; -+ inputPolygons.push_back(newData); -+ -+ boundingPolygon.push_back({1,2}); -+ boundingPolygon.push_back({3,4}); -+ - clip2tri clip2tri; - clip2tri.triangulate(inputPolygons, outputTriangles, boundingPolygon); -+ -+ for (const auto& point : outputTriangles) { -+ printf("(%2f, %2f)\n", point.x, point.y); -+ } - } diff --git a/thirdparty/clip2tri/clip2tri_ohos_test.patch b/thirdparty/clip2tri/clip2tri_ohos_test.patch new file mode 100755 index 0000000000000000000000000000000000000000..40e5448ff2c3451d7898dc4bb80234979a9e3684 --- /dev/null +++ b/thirdparty/clip2tri/clip2tri_ohos_test.patch @@ -0,0 +1,97 @@ +diff -Nura clip2tri-master/CMakeLists.txt clip2tri-master_patch/CMakeLists.txt +--- clip2tri-master/CMakeLists.txt 2023-09-28 02:11:44.079155011 -0700 ++++ clip2tri-master_patch/CMakeLists.txt 2023-09-28 02:56:07.517253705 -0700 +@@ -61,6 +61,11 @@ + ARCHIVE DESTINATION ${LIB_DIR}) + endif(BUILD_STATIC_LIBS) + ++add_executable(test test.cpp) ++target_link_libraries(test PRIVATE clip2tri) ++ ++enable_testing() ++add_test(NAME test_clip2tri COMMAND test) + + # Install header files + install(DIRECTORY clip2tri/ +diff -Nura clip2tri-master/test.cpp clip2tri-master_patch/test.cpp +--- clip2tri-master/test.cpp 2014-10-30 17:11:28.000000000 -0700 ++++ clip2tri-master_patch/test.cpp 2023-10-07 02:43:05.945262633 -0700 +@@ -14,9 +14,78 @@ + int main() { + vector > inputPolygons; + vector outputTriangles; // Every 3 points is a triangle ++ vector outputTriangles1; + + vector boundingPolygon; ++ vector boundingPolygon1; ++ ++ vector outputTrianglesCompare={ ++ {0.0, 15.0},{5.0, 10.0},{15.0, 15.0}, ++ {0.0, 15.0},{0.0, 0.0},{5.0, 10.0}, ++ {0.0, 0.0},{5.0, 5.0},{5.0, 10.0}, ++ {5.0, 5.0},{0.0, 0.0},{15.0, 0.0}, ++ {10.0, 5.0},{5.0, 5.0},{15.0, 0.0}, ++ {10.0, 5.0},{15.0, 0.0},{20.0, 5.0}, ++ {10.0, 10.0},{10.0, 5.0},{20.0, 5.0}, ++ {15.0, 15.0},{10.0, 10.0},{20.0, 5.0}, ++ {5.0, 10.0},{10.0, 10.0},{15.0, 15.0}, ++ }; ++ vector outputTrianglesCompare1={ ++ {20.0, 20.0},{0.0, 20.0},{10.0, 10.0}, ++ {10.0, 10.0},{20.0, 0.0},{20.0, 20.0}, ++ {10.0, 10.0},{10.0, 5.0},{20.0, 0.0}, ++ {20.0, 0.0},{10.0, 5.0},{0.0, 0.0}, ++ {10.0, 5.0},{5.0, 5.0},{0.0, 0.0}, ++ {0.0, 0.0},{5.0, 5.0},{5.0, 10.0}, ++ {0.0, 20.0},{0.0, 0.0},{5.0, 10.0}, ++ {0.0, 20.0},{5.0, 10.0},{10.0, 10.0}, ++ }; ++ ++ float eps = 1e-2; ++ ++ Point p1 = {5.0, 5.0}; ++ Point p2 = {10.0, 5.0}; ++ Point p3 = {10.0, 10.0}; ++ Point p4 = {5.0, 10.0}; ++ ++ vector newData = {p1,p2,p3,p4}; ++ inputPolygons.push_back(newData); ++ ++ boundingPolygon.push_back({0.0, 0.0}); ++ boundingPolygon.push_back({15.0, 0.0}); ++ boundingPolygon.push_back({20.0, 5.0}); ++ boundingPolygon.push_back({15.0, 15.0}); ++ boundingPolygon.push_back({0.0, 15.0}); ++ ++ boundingPolygon1.push_back({0.0, 0.0}); ++ boundingPolygon1.push_back({20.0, 0.0}); ++ boundingPolygon1.push_back({20.0, 20.0}); ++ boundingPolygon1.push_back({0.0, 20.0}); + + clip2tri clip2tri; + clip2tri.triangulate(inputPolygons, outputTriangles, boundingPolygon); ++ clip2tri.triangulate(inputPolygons, outputTriangles1, boundingPolygon1); ++ ++ for (const auto& point : outputTriangles) { ++ static int i = 0; ++ if(fabs(point.x - outputTrianglesCompare[i].x) < eps && fabs(point.y - outputTrianglesCompare[i].y) < eps){ ++ i++; ++ continue; ++ } ++ else{ ++ return -1; ++ } ++ } ++ for (const auto& point : outputTriangles1) { ++ static int m = 0; ++ if(fabs(point.x - outputTrianglesCompare1[m].x) < eps && fabs(point.y - outputTrianglesCompare1[m].y) < eps){ ++ m++; ++ continue; ++ } ++ else{ ++ return -1; ++ } ++ } ++ printf("test_ok\n"); ++ return 0; + } diff --git a/thirdparty/clip2tri/docs/hap_integrate.md b/thirdparty/clip2tri/docs/hap_integrate.md index b8013ad8698d0a433caaa79b20f805f59bb9471d..ffac40a55cc5583a2715714ba0a6ce8250abc14b 100755 --- a/thirdparty/clip2tri/docs/hap_integrate.md +++ b/thirdparty/clip2tri/docs/hap_integrate.md @@ -24,7 +24,7 @@ ├── SHA512SUM #三方库校验文件 ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 ├── README_zh.md - ├── clip2tri.patch + ├── clip2tri_ohos_test.patch ``` - 在lycium目录下编译三方库