Browse Source

winding number testing for tangent curves

master
Dtouch 1 year ago
parent
commit
10f6db0437
  1. 2
      include/SingularityJudger.h
  2. 2
      include/loop_detector.h
  3. 3
      intersectTest/myCase/surfaces.txt
  4. 2
      main.cpp
  5. 8
      src/SingularityJudger.cpp
  6. 6
      src/loop_detector.cpp

2
include/SingularityJudger.h

@ -37,7 +37,7 @@ public:
void judge2(pair<int, int> focusRange_u1, pair<int, int> focusRange_v1, void judge2(pair<int, int> focusRange_u1, pair<int, int> focusRange_v1,
pair<int, int> focusRange_u2, pair<int, int> focusRange_v2); pair<int, int> focusRange_u2, pair<int, int> focusRange_v2);
vector<pair<int, int>> judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs, map<pair<int, int>, int> judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs,
pair<int, int> focusRange_u1, pair<int, int> focusRange_v1, pair<int, int> focusRange_u1, pair<int, int> focusRange_v1,
pair<int, int> focusRange_u2, pair<int, int> focusRange_v2); pair<int, int> focusRange_u2, pair<int, int> focusRange_v2);

2
include/loop_detector.h

@ -41,7 +41,7 @@ public:
// vector fields, 即有向距离关于u、v的导数 // vector fields, 即有向距离关于u、v的导数
vector<vector<glm::vec2>> vectorFields; vector<vector<glm::vec2>> vectorFields;
vector<vector<int>> rotationNumbers; vector<vector<int>> rotationNumbers;
vector<pair<int, int>> targetCells; map<pair<int, int>, int> targetCells; // <{u patch index, v patch index}, rotation number>
// int subPatchEdgeSampleCnt; // 在一个sub patch的采样网格中,边上的采样点个数 // int subPatchEdgeSampleCnt; // 在一个sub patch的采样网格中,边上的采样点个数
// void init(tinynurbs::RationalSurface<float> _s, tinynurbs::RationalSurface<float> _f, int _maxSplitLayer); // void init(tinynurbs::RationalSurface<float> _s, tinynurbs::RationalSurface<float> _f, int _maxSplitLayer);

3
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]});

2
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))); printf("level: %d, sample cnt: %d * %d\n", level, int(pow(2, level - 1)), int(pow(2, level - 1)));
ifstream fin; ifstream fin;
fin.open(R"(intersectTest\casea1\surfaces.txt)"); fin.open(R"(intersectTest\myCase\surfaces.txt)");
string str; string str;
string tmp; string tmp;

8
src/SingularityJudger.cpp

@ -81,7 +81,7 @@ bool hasPair(const map<pair<int, int>, set<pair<int, int>>> &pairs, pair<int, in
} }
vector<pair<int, int>> SingularityJudger:: map<pair<int, int>, int> SingularityJudger::
judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs, judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs,
pair<int, int> focusRange_u1, pair<int, int> focusRange_v1, pair<int, int> focusRange_u1, pair<int, int> focusRange_v1,
pair<int, int> focusRange_u2, pair<int, int> focusRange_v2) { pair<int, int> focusRange_u2, pair<int, int> focusRange_v2) {
@ -131,7 +131,9 @@ judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs,
vector<char>(loopDetector.s_subPatchEdgeSampleCnt_v - 1, 0)); vector<char>(loopDetector.s_subPatchEdgeSampleCnt_v - 1, 0));
for (auto targetCell: loopDetector.targetCells) { 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()); printf("\ntarget cells cnt: %lld\n", loopDetector.targetCells.size());
@ -169,7 +171,7 @@ judge(const vector<pair<pair<int, int>, pair<int, int>>> &intersectBoxPairs,
void SingularityJudger:: dfs(set<pair<int, int>> &book, vector<vector<pair<int, int>>> &cellGroups, void SingularityJudger:: dfs(set<pair<int, int>> &book, vector<vector<pair<int, int>>> &cellGroups,
const LoopDetector &loopDetector, int i, int x, int y) { const LoopDetector &loopDetector, int i, int x, int y) {
book.insert({x, y}); book.insert({x, y});
cellGroups[i].emplace_back(pair<int, int>(x, y)); cellGroups[i].emplace_back(x, y);
for (auto dir: dirs) { for (auto dir: dirs) {
auto nx = x + dir[0], ny = y + dir[1]; auto nx = x + dir[0], ny = y + dir[1];
if (book.find({nx, ny}) != book.end() || loopDetector.rotationNumbers[nx][ny] == 0)continue; if (book.find({nx, ny}) != book.end() || loopDetector.rotationNumbers[nx][ny] == 0)continue;

6
src/loop_detector.cpp

@ -351,6 +351,9 @@ void LoopDetector::getRotationNumber(const map<pair<int, int>, set<pair<int, int
targetCells = {}; targetCells = {};
// 以小格子为单位遍历 // 以小格子为单位遍历
for (const auto &boxPair: intersectBoxPairs) { for (const auto &boxPair: intersectBoxPairs) {
if (boxPair.first.first == 127 && boxPair.first.second == 0) {
int haha = 1;
}
float F[2][2], G[2][2]; float F[2][2], G[2][2];
for (int biasI = 0; biasI < 2; biasI++) { for (int biasI = 0; biasI < 2; biasI++) {
for (int biasJ = 0; biasJ < 2; biasJ++) { for (int biasJ = 0; biasJ < 2; biasJ++) {
@ -382,12 +385,13 @@ void LoopDetector::getRotationNumber(const map<pair<int, int>, set<pair<int, int
G[biasI][biasJ] = pTheta_pChi * pV_pv.x + pTheta_pPhi * pV_pv.y; G[biasI][biasJ] = pTheta_pChi * pV_pv.x + pTheta_pPhi * pV_pv.y;
} }
} }
int rotationNumber = int(round(((F[0][1] + F[1][1] - F[0][0] - F[1][0]) * uParamCellSize + int rotationNumber = int(round(((F[0][1] + F[1][1] - F[0][0] - F[1][0]) * uParamCellSize +
(G[0][0] + G[0][1] - G[1][0] - G[1][1]) * vParamCellSize)) / 2.); (G[0][0] + G[0][1] - G[1][0] - G[1][1]) * vParamCellSize)) / 2.);
rotationNumbers[boxPair.first.first - s_subPatchIdxRange_u.first][boxPair.first.second - rotationNumbers[boxPair.first.first - s_subPatchIdxRange_u.first][boxPair.first.second -
s_subPatchIdxRange_v.first] = rotationNumber; s_subPatchIdxRange_v.first] = rotationNumber;
if (rotationNumber != 0) { if (rotationNumber != 0) {
targetCells.emplace_back(boxPair.first.first, boxPair.first.second); targetCells.insert({{boxPair.first.first, boxPair.first.second}, rotationNumber});
} }
} }

Loading…
Cancel
Save