From a72ae125b9f9edf28629a75775063956e5882e1a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 18 Aug 2022 11:43:18 +0200 Subject: [PATCH] BUG: incorrect order for output scaling (transformPoints, ...) - the output write scaling should be applied *after* undoing the effects of the specified rotation centre. Fixes #2566 ENH: update option names for transformPoints and surfaceTransformPoints - prefer '-auto-centre' and '-centre', but also accept the previous options '-auto-origin' and '-origin' as aliases. Changing to '-centre' avoids possible confusion with coordinate system origin(). --- .../transformPoints/transformPoints.C | 43 ++++++++++--------- .../surfaceTransformPoints.C | 39 +++++++++-------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 2fdcf6edd0..4edabee83e 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -53,8 +53,8 @@ Usage -rotate-angle (vector angle) Rotate angle degrees about vector axis. - or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) - or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) + or -yawPitchRoll : (yaw pitch roll) degrees + or -rollPitchYaw : (roll pitch yaw) degrees -scale scalar|vector Scale the points by the given scalar or vector on output. @@ -259,15 +259,18 @@ int main(int argc, char *argv[]) ); argList::addBoolOption ( - "auto-origin", - "Use bounding box centre as origin for rotations" + "auto-centre", + "Use bounding box centre as centre for rotations" ); argList::addOption ( - "origin", + "centre", "point", - "Use specified as origin for rotations" + "Use specified as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -411,18 +414,18 @@ int main(int argc, char *argv[]) points += v; } - vector origin; - bool useOrigin = args.readIfPresent("origin", origin); - if (args.found("auto-origin") && !useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) { - useOrigin = true; - origin = boundBox(points).centre(); + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); } - if (useOrigin) + if (useRotationCentre) { - Info<< "Set origin for rotations to " << origin << endl; - points -= origin; + Info<< "Set centre of rotation to " << rotationCentre << endl; + points -= rotationCentre; } if (args.found("rotate")) @@ -503,15 +506,15 @@ int main(int argc, char *argv[]) } } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + // Output scaling applyScaling(points, getScalingOpt("scale", args)); - if (useOrigin) - { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; - } - // Set the precision of the points data to 10 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index 4322a0a530..26df0802ec 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -188,15 +188,18 @@ int main(int argc, char *argv[]) ); argList::addBoolOption ( - "auto-origin", - "Use bounding box centre as origin for rotations" + "auto-centre", + "Use bounding box centre as centre for rotations" ); argList::addOption ( - "origin", + "centre", "point", - "Use specified as origin for rotations" + "Use specified as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -334,18 +337,18 @@ int main(int argc, char *argv[]) points += v; } - vector origin; - bool useOrigin = args.readIfPresent("origin", origin); - if (args.found("auto-origin") && !useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) { - useOrigin = true; - origin = boundBox(points).centre(); + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); } - if (useOrigin) + if (useRotationCentre) { - Info<< "Set origin for rotations to " << origin << endl; - points -= origin; + Info<< "Set centre of rotation to " << rotationCentre << endl; + points -= rotationCentre; } if (args.found("rotate")) @@ -406,15 +409,15 @@ int main(int argc, char *argv[]) points = transform(rot, points); } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + // Output scaling applyScaling(points, getScalingOpt("write-scale", args)); - if (useOrigin) - { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; - } - surf1.movePoints(points); surf1.write(exportName, writeFileType);