From 37246be39805e1e4824f4432ffd5f3267dffa706 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 10 Jun 2013 10:13:58 +0200 Subject: [PATCH] operator: additional fix to FindPath Signed-off-by: Thorsten Liebig --- FDTD/operator.cpp | 13 +++++++++- FDTD/operator_cylinder.cpp | 52 +++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index 4e21d4f..76fe7f1 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -355,6 +355,14 @@ int Operator::SnapLine2Mesh(const double* start, const double* stop, unsigned in SnapToMesh(start, uiStart, dualMesh, fullMesh, bStartIn); SnapToMesh(stop, uiStop, dualMesh, fullMesh, bStopIn); + for (int n=0;n<3;++n) + { + if ((start[n]GetDiscLine(n,GetNumberOfLines(n,true)-1)) && (stop[n]>GetDiscLine(n,GetNumberOfLines(n,true)-1))) + return -1; //upper bound violation + } + int ret = 0; if (!(bStartIn[0] && bStartIn[1] && bStartIn[2])) ret = ret + 1; @@ -376,7 +384,10 @@ struct Operator::Grid_Path Operator::FindPath(double start[], double stop[]) struct Grid_Path path; unsigned int uiStart[3],uiStop[3],currPos[3]; - SnapLine2Mesh(start, stop, uiStart, uiStop, false, true); + int ret = SnapLine2Mesh(start, stop, uiStart, uiStop, false, true); + if (ret<0) + return path; + currPos[0]=uiStart[0]; currPos[1]=uiStart[1]; currPos[2]=uiStart[2]; diff --git a/FDTD/operator_cylinder.cpp b/FDTD/operator_cylinder.cpp index 0c2bda7..c18297f 100644 --- a/FDTD/operator_cylinder.cpp +++ b/FDTD/operator_cylinder.cpp @@ -278,37 +278,59 @@ struct Operator::Grid_Path Operator_Cylinder::FindPath(double start[], double st { double l_start[3]; double l_stop[3]; - if (stop[1]PI) + { + if (l_stop[1]>l_start[1]) + l_stop[1]-=2*PI; + else + l_stop[1]+=2*PI; + } + + double help=0; + if (l_start[1]>l_stop[1]) { for (int n=0;n<3;++n) { - l_start[n] = stop[n]; - l_stop[n] = start[n]; - } - } - else - { - for (int n=0;n<3;++n) - { - l_start[n] = start[n]; - l_stop[n] = stop[n]; + help = l_start[n]; + l_start[n] = l_stop[n]; + l_stop[n] = help; } } + double a_start = FitToAlphaRange(l_start[1]); double a_stop = FitToAlphaRange(l_stop[1]); if (a_stop >= a_start) - return Operator_Multithread::FindPath(start, stop); + { + l_start[1] = a_start; + l_stop[1] = a_stop; + return Operator_Multithread::FindPath(l_start, l_stop); + } + + // if a-stop fitted to disc range is now smaller than a-start, it must step over the a-bounds... + + struct Grid_Path path; + for (int n=0;n<3;++n) + { + if ((l_start[n]GetDiscLine(n,GetNumberOfLines(n,true)-1)) && (l_stop[n]>GetDiscLine(n,GetNumberOfLines(n,true)-1))) + return path; //upper bound violation + } if (g_settings.GetVerboseLevel()>2) - { cerr << __func__ << ": A path was leaving the alpha-direction mesh..." << endl; - } // this section comes into play, if the line moves over the angulare mesh-end/start // we try to have one part of the path on both "ends" of the mesh and stitch them together - struct Grid_Path path; struct Grid_Path path1; struct Grid_Path path2;