diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 389024a5179f078a2f128ddbfde01d062f296211..0c5cecc8abd38f2bac6b78bf93cd355868910186 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -169,14 +169,22 @@ int main(int argc, char *argv[]) ( "translate", "vector", - "Translate by specified <vector> - eg, '(1 0 0)' before rotations" + "Translate by specified <vector> before rotations" + ); + argList::addBoolOption + ( + "auto-centre", + "Use bounding box centre as centre for rotations" ); argList::addOption ( - "origin", + "centre", "point", - "Use specified <point> as origin for rotations" + "Use specified <point> as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -290,18 +298,24 @@ int main(int argc, char *argv[]) if (args.readIfPresent("translate", v)) { Info<< "Translating points by " << v << endl; - points += v; } - vector origin; - const bool useOrigin = args.readIfPresent("origin", origin); - if (useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) + { + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); + } + + 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")) { Pair<vector> n1n2 @@ -380,6 +394,13 @@ int main(int argc, char *argv[]) } } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + + List<scalar> scaling; if (args.readListIfPresent("scale", scaling)) { @@ -410,12 +431,6 @@ int main(int argc, char *argv[]) } } - 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 f4d0ccc0d8bb3519cd457536965c61ef9842a6ba..2517b6343da758905083460b5491dd939b5df1f8 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -82,12 +82,20 @@ int main(int argc, char *argv[]) "vector", "Translate by specified <vector> - eg, '(1 0 0)' before rotations" ); + argList::addBoolOption + ( + "auto-centre", + "Use bounding box centre as centre for rotations" + ); argList::addOption ( - "origin", + "centre", "point", - "Use specified <point> as origin for rotations" + "Use specified <point> as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -165,18 +173,24 @@ int main(int argc, char *argv[]) if (args.readIfPresent("translate", v)) { Info<< "Translating points by " << v << endl; - points += v; } - vector origin; - const bool useOrigin = args.readIfPresent("origin", origin); - if (useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) + { + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); + } + + 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")) { Pair<vector> n1n2 @@ -235,6 +249,13 @@ int main(int argc, char *argv[]) points = transform(rot, points); } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + + List<scalar> scaling; if (args.readListIfPresent("scale", scaling)) { @@ -265,11 +286,6 @@ int main(int argc, char *argv[]) } } - if (useOrigin) - { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; - } surf1.movePoints(points); surf1.write(outFileName);