Skip to content
Snippets Groups Projects
Commit b6a6e40c authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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().
parent bc3bff8e
Branches
Tags
No related merge requests found
...@@ -62,8 +62,8 @@ Usage ...@@ -62,8 +62,8 @@ Usage
-rotate-z angle -rotate-z angle
Rotate (degrees) about z-axis. Rotate (degrees) about z-axis.
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) or -yawPitchRoll : (yaw pitch roll) degrees
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) or -rollPitchYaw : (roll pitch yaw) degrees
-scale scalar|vector -scale scalar|vector
Scale the points by the given scalar or vector on output. Scale the points by the given scalar or vector on output.
...@@ -268,15 +268,18 @@ int main(int argc, char *argv[]) ...@@ -268,15 +268,18 @@ int main(int argc, char *argv[])
); );
argList::addBoolOption argList::addBoolOption
( (
"auto-origin", "auto-centre",
"Use bounding box centre as origin for rotations" "Use bounding box centre as centre for rotations"
); );
argList::addOption argList::addOption
( (
"origin", "centre",
"point", "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 argList::addOption
( (
"rotate", "rotate",
...@@ -437,18 +440,18 @@ int main(int argc, char *argv[]) ...@@ -437,18 +440,18 @@ int main(int argc, char *argv[])
points += v; points += v;
} }
vector origin; vector rotationCentre;
bool useOrigin = args.readIfPresent("origin", origin); bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-origin") && !useOrigin) if (args.found("auto-centre") && !useRotationCentre)
{ {
useOrigin = true; useRotationCentre = true;
origin = boundBox(points).centre(); rotationCentre = boundBox(points).centre();
} }
if (useOrigin) if (useRotationCentre)
{ {
Info<< "Set origin for rotations to " << origin << endl; Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= origin; points -= rotationCentre;
} }
...@@ -545,15 +548,15 @@ int main(int argc, char *argv[]) ...@@ -545,15 +548,15 @@ int main(int argc, char *argv[])
} }
} }
// Output scaling if (useRotationCentre)
applyScaling(points, getScalingOpt("scale", args));
if (useOrigin)
{ {
Info<< "Unset origin for rotations from " << origin << endl; Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += origin; points += rotationCentre;
} }
// Output scaling
applyScaling(points, getScalingOpt("scale", args));
// Set the precision of the points data to 10 // Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
......
...@@ -188,15 +188,18 @@ int main(int argc, char *argv[]) ...@@ -188,15 +188,18 @@ int main(int argc, char *argv[])
); );
argList::addBoolOption argList::addBoolOption
( (
"auto-origin", "auto-centre",
"Use bounding box centre as origin for rotations" "Use bounding box centre as centre for rotations"
); );
argList::addOption argList::addOption
( (
"origin", "centre",
"point", "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 argList::addOption
( (
"rotate", "rotate",
...@@ -352,18 +355,18 @@ int main(int argc, char *argv[]) ...@@ -352,18 +355,18 @@ int main(int argc, char *argv[])
points += v; points += v;
} }
vector origin; vector rotationCentre;
bool useOrigin = args.readIfPresent("origin", origin); bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-origin") && !useOrigin) if (args.found("auto-centre") && !useRotationCentre)
{ {
useOrigin = true; useRotationCentre = true;
origin = boundBox(points).centre(); rotationCentre = boundBox(points).centre();
} }
if (useOrigin) if (useRotationCentre)
{ {
Info<< "Set origin for rotations to " << origin << endl; Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= origin; points -= rotationCentre;
} }
...@@ -455,15 +458,15 @@ int main(int argc, char *argv[]) ...@@ -455,15 +458,15 @@ int main(int argc, char *argv[])
transform(points, rot, points); transform(points, rot, points);
} }
// Output scaling if (useRotationCentre)
applyScaling(points, getScalingOpt("write-scale", args));
if (useOrigin)
{ {
Info<< "Unset origin for rotations from " << origin << endl; Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += origin; points += rotationCentre;
} }
// Output scaling
applyScaling(points, getScalingOpt("write-scale", args));
surf1.movePoints(points); surf1.movePoints(points);
surf1.write(exportName, writeFileType); surf1.write(exportName, writeFileType);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment