From 10f6db0437b37a365cedff2c57f7571b3787d900 Mon Sep 17 00:00:00 2001 From: Dtouch Date: Fri, 8 Mar 2024 17:41:14 +0800 Subject: [PATCH] winding number testing for tangent curves --- include/SingularityJudger.h | 2 +- include/loop_detector.h | 2 +- intersectTest/myCase/surfaces.txt | 3 +++ main.cpp | 2 +- src/SingularityJudger.cpp | 8 +++++--- src/loop_detector.cpp | 6 +++++- 6 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 intersectTest/myCase/surfaces.txt diff --git a/include/SingularityJudger.h b/include/SingularityJudger.h index aaf8606..b0beaea 100644 --- a/include/SingularityJudger.h +++ b/include/SingularityJudger.h @@ -37,7 +37,7 @@ public: void judge2(pair focusRange_u1, pair focusRange_v1, pair focusRange_u2, pair focusRange_v2); - vector> judge(const vector, pair>> &intersectBoxPairs, + map, int> judge(const vector, pair>> &intersectBoxPairs, pair focusRange_u1, pair focusRange_v1, pair focusRange_u2, pair focusRange_v2); diff --git a/include/loop_detector.h b/include/loop_detector.h index bdbfc1a..be396dd 100644 --- a/include/loop_detector.h +++ b/include/loop_detector.h @@ -41,7 +41,7 @@ public: // vector fields, 即有向距离关于u、v的导数 vector> vectorFields; vector> rotationNumbers; - vector> targetCells; + map, int> targetCells; // <{u patch index, v patch index}, rotation number> // int subPatchEdgeSampleCnt; // 在一个sub patch的采样网格中,边上的采样点个数 // void init(tinynurbs::RationalSurface _s, tinynurbs::RationalSurface _f, int _maxSplitLayer); diff --git a/intersectTest/myCase/surfaces.txt b/intersectTest/myCase/surfaces.txt new file mode 100644 index 0000000..71eb322 --- /dev/null +++ b/intersectTest/myCase/surfaces.txt @@ -0,0 +1,3 @@ +W:= Matrix([[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]]); +P1 := Matrix(4, 4, {(1, 1) = [-2.5, -1.5, 0.0], (1, 2) = [-2.5, -0.5, 0.0], (1, 3) = [-2.5, 0.5, 0.0], (1, 4) = [-2.5, 1.5, 0.0],(2, 1) = [-1.5, -1.5, 0.0], (2, 2) = [-1.5, -0.5, 1.0], (2, 3) = [-1.5, 0.5, 1.0], (2, 4) = [-1.5, 1.5, 0.0],(3, 1) = [1.5, -1.5, 0.0], (3, 2) = [1.5, -0.5, 1.0], (3, 3) = [1.5, 0.5, 1.0], (3, 4) = [1.5, 1.5, 0.0], (4, 1) = [2.5, -1.5, 0.0], (4, 2) = [2.5, -0.5, 0.0], (4, 3) = [2.5, 0.5, 0.0], (4, 4) = [2.5, 1.5, 0.0]}); +P2 := Matrix(4, 4, {(1, 1) = [-1.5, -1.5, 0.0], (1, 2) = [-1.5, -0.5, 0.0], (1, 3) = [-1.5, 0.5, 0.0], (1, 4) = [-1.5, 1.5, 0.0],(2, 1) = [-0.5, -1.5, 0.0], (2, 2) = [-0.5, -0.5, 1.0], (2, 3) = [-0.5, 0.5, 1.0], (2, 4) = [-0.5, 1.5, 0.0],(3, 1) = [0.5, -1.5, 0.0], (3, 2) = [0.5, -0.5, 1.0], (3, 3) = [0.5, 0.5, 1.0], (3, 4) = [0.5, 1.5, 0.0], (4, 1) = [1.5, -1.5, 0.0], (4, 2) = [1.5, -0.5, 0.0], (4, 3) = [1.5, 0.5, 0.0], (4, 4) = [1.5, 1.5, 0.0]}); diff --git a/main.cpp b/main.cpp index b97b449..5e11efb 100644 --- a/main.cpp +++ b/main.cpp @@ -192,7 +192,7 @@ int main() { printf("level: %d, sample cnt: %d * %d\n", level, int(pow(2, level - 1)), int(pow(2, level - 1))); ifstream fin; - fin.open(R"(intersectTest\casea1\surfaces.txt)"); + fin.open(R"(intersectTest\myCase\surfaces.txt)"); string str; string tmp; diff --git a/src/SingularityJudger.cpp b/src/SingularityJudger.cpp index 6be6b2f..3ded92f 100644 --- a/src/SingularityJudger.cpp +++ b/src/SingularityJudger.cpp @@ -81,7 +81,7 @@ bool hasPair(const map, set>> &pairs, pair> SingularityJudger:: +map, int> SingularityJudger:: judge(const vector, pair>> &intersectBoxPairs, pair focusRange_u1, pair focusRange_v1, pair focusRange_u2, pair focusRange_v2) { @@ -131,7 +131,9 @@ judge(const vector, pair>> &intersectBoxPairs, vector(loopDetector.s_subPatchEdgeSampleCnt_v - 1, 0)); for (auto targetCell: loopDetector.targetCells) { - printf("{%d, %d}, ", targetCell.first, targetCell.second); +// printf("{%d, %d}, ", targetCell.first, targetCell.second); + auto uvIdx = targetCell.first; + printf("At parameter index {%d, %d}, the Poincare index is %d\n", uvIdx.first, uvIdx.second, targetCell.second); } printf("\ntarget cells cnt: %lld\n", loopDetector.targetCells.size()); @@ -169,7 +171,7 @@ judge(const vector, pair>> &intersectBoxPairs, void SingularityJudger:: dfs(set> &book, vector>> &cellGroups, const LoopDetector &loopDetector, int i, int x, int y) { book.insert({x, y}); - cellGroups[i].emplace_back(pair(x, y)); + cellGroups[i].emplace_back(x, y); for (auto dir: dirs) { auto nx = x + dir[0], ny = y + dir[1]; if (book.find({nx, ny}) != book.end() || loopDetector.rotationNumbers[nx][ny] == 0)continue; diff --git a/src/loop_detector.cpp b/src/loop_detector.cpp index afc2863..29278c1 100644 --- a/src/loop_detector.cpp +++ b/src/loop_detector.cpp @@ -351,6 +351,9 @@ void LoopDetector::getRotationNumber(const map, set, set