From 96661c0d978076160515fac082c07943e08cbaf3 Mon Sep 17 00:00:00 2001 From: mattisnowman <matthias@rauter.it> Date: Sun, 2 Oct 2022 14:38:21 +0200 Subject: [PATCH] BUG: Fixed a bug in releaseAreaMapping --- .../releaseAreaMapping/releaseAreaMapping.C | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/applications/utilities/releaseAreaMapping/releaseAreaMapping.C b/applications/utilities/releaseAreaMapping/releaseAreaMapping.C index 27609a0..9655a76 100644 --- a/applications/utilities/releaseAreaMapping/releaseAreaMapping.C +++ b/applications/utilities/releaseAreaMapping/releaseAreaMapping.C @@ -104,8 +104,7 @@ int main(int argc, char *argv[]) << " to default value" << nl; f.ref() = fdefault; } - string str = fieldNames[fieldsI]; - str[0] = toupper(str[0]); + string str = "fa_"+fieldNames[fieldsI]; Info<< "Creating field " << str << nl; @@ -361,12 +360,13 @@ int main(int argc, char *argv[]) { for (unsigned int i=0; i<shp.recordcount(); i++) { - Info << "Mapping record " << i << nl; + Info << "Mapping record " << i << "/" << shp.recordcount() << nl; areaScalarField fold = f; Switch leadingFirstRing = false; + for (int j=0; j<shp.partcount(i); j++) { int numpoints = shp.pointcount(i,j); @@ -485,7 +485,7 @@ int main(int argc, char *argv[]) { for (unsigned int i=0; i<shp.recordcount(); i++) { - Info << "Mapping record " << i << nl; + Info << "Mapping record " << i << "/" << shp.recordcount() << nl; areaScalarField fold = f; @@ -508,15 +508,15 @@ int main(int argc, char *argv[]) scalar mag0 = std::hypot(line0.x(), line0.y()); scalar mag1 = std::hypot(line1.x(), line1.y()); scalar crossp = line0.x()*line1.y()-line0.y()*line1.x(); - scalar angle = std::asin(crossp/mag0/mag1); - //Info << line0 << ", " << line1 << ", " << angle*180./3.1415 << endl; - sumofangles += angle; + + scalar sinC = min(max(crossp/mag0/mag1, -1), 1); + sumofangles += std::asin(sinC); } - Switch clockwise =sumofangles > 0; + const bool clockwise = (sumofangles > 0); - //Info << "sum of angles = " << sumofangles << nl; - //Info << "part is clockwise " << clockwise << nl; + //Info<< "sum of angles: " << sumofangles + // << " clockwise:" << clockwise << nl; HormannAgathos polygon(points, 0.001); -- GitLab