78static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
80 volatile bool good =
true;
105 List<scalar> scaling;
106 args.readListIfPresent(optName, scaling);
108 if (scaling.
size() == 1)
112 else if (scaling.
size() == 3)
117 equal(scaling[0], scaling[1])
118 &&
equal(scaling[0], scaling[2])
124 else if (!scaling.
empty())
127 <<
"Incorrect number of components, must be 1 or 3." <<
nl
128 <<
" -" << optName <<
' ' <<
args[optName].c_str() <<
endl
132 if (scaling.
size() == 1 &&
equal(scaling[0], 1))
146 if (scaling.
size() == 1)
148 Info<<
"Scaling points uniformly by " << scaling[0] <<
nl;
151 else if (scaling.
size() == 3)
153 const vector factor(scaling[0], scaling[1], scaling[2]);
154 Info<<
"Scaling points by " << factor <<
nl;
162int main(
int argc,
char *argv[])
166 "Transform (translate / rotate / scale) surface points.\n"
167 "Like transformPoints but for surfaces.\n"
168 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
176 "Recentre the bounding box before other operations"
182 "Translate by specified <vector> before rotations"
187 "Use bounding box centre as centre for rotations"
193 "Use specified <point> as centre for rotations"
202 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'"
208 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'"
213 "Rotate (degrees) about x-axis"
218 "Rotate (degrees) about y-axis"
223 "Rotate (degrees) about z-axis"
229 "Rotate by '(roll pitch yaw)' degrees"
235 "Rotate by '(yaw pitch roll)' degrees"
241 "Uniform or non-uniform input scaling"
247 "Uniform or non-uniform output scaling"
253 "Input format (default: use file extension)"
259 "Output format (default: use file extension)"
264 "(originVec axisVec directionVec)",
265 "Tranform cylindrical coordinates to cartesian coordinates"
275 const List<word> operationNames
291 if (!
args.count(operationNames))
294 <<
"No operation supplied, "
295 <<
"use at least one of the following:" <<
nl
298 for (
const auto& opName : operationNames)
312 const word readFileType
314 args.getOrDefault<
word>(
"read-format", getExtension(importName))
317 const word writeFileType
319 args.getOrDefault<
word>(
"write-format", getExtension(exportName))
324 if (!hasReadWriteTypes(readFileType, writeFileType))
327 <<
"Unsupported file format(s)" <<
nl
332 Info<<
"Reading surf from " << importName <<
" ..." <<
nl
333 <<
"Writing surf to " << exportName <<
" ..." <<
endl;
344 applyScaling(
points, getScalingOpt(
"read-scale",
args));
347 if (
args.found(
"recentre"))
350 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
354 if (
args.readIfPresent(
"translate", v))
356 Info<<
"Translating points by " << v <<
endl;
361 bool useRotationCentre =
args.readIfPresent(
"centre", rotationCentre);
362 if (
args.found(
"auto-centre") && !useRotationCentre)
364 useRotationCentre =
true;
368 if (useRotationCentre)
370 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
378 bool useRotation(
false);
380 if (
args.found(
"rotate"))
384 args.lookup(
"rotate")()
392 else if (
args.found(
"rotate-angle"))
396 args.lookup(
"rotate-angle")()
399 const vector& axis = rotAxisAngle.first();
400 const scalar angle = rotAxisAngle.second();
402 Info<<
"Rotating points " <<
nl
403 <<
" about " << axis <<
nl
404 <<
" angle " << angle <<
nl;
409 else if (
args.found(
"rotate-x"))
411 const scalar angle =
args.get<scalar>(
"rotate-x");
413 Info<<
"Rotating points about x-axis: " << angle <<
nl;
418 else if (
args.found(
"rotate-y"))
420 const scalar angle =
args.get<scalar>(
"rotate-y");
422 Info<<
"Rotating points about y-axis: " << angle <<
nl;
427 else if (
args.found(
"rotate-z"))
429 const scalar angle =
args.get<scalar>(
"rotate-z");
431 Info<<
"Rotating points about z-axis: " << angle <<
nl;
436 else if (
args.readIfPresent(
"rollPitchYaw", v))
438 Info<<
"Rotating points by" <<
nl
439 <<
" roll " << v.x() <<
nl
440 <<
" pitch " << v.y() <<
nl
441 <<
" yaw " << v.z() <<
nl;
446 else if (
args.readIfPresent(
"yawPitchRoll", v))
448 Info<<
"Rotating points by" <<
nl
449 <<
" yaw " << v.x() <<
nl
450 <<
" pitch " << v.y() <<
nl
451 <<
" roll " << v.z() <<
nl;
459 Info<<
"Rotating points by " << rot <<
endl;
463 if (useRotationCentre)
465 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
470 applyScaling(
points, getScalingOpt(
"write-scale",
args));
473 if (
args.found(
"cylToCart"))
491 surf1.write(exportName, writeFileType);
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
static bool canWriteType(const word &fileType, bool verbose=false)
static bool canReadType(const word &fileType, bool verbose=false)
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
Extract command arguments and options from the supplied argc and argv parameters.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
A bounding box defined in terms of min/max extrema points.
point centre() const
The centre (midpoint) of the bounding box.
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
A class for handling file names.
Tensor of scalars, i.e. Tensor<scalar>.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Namespace for coordinate system rotations.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
bool equal(const T &a, const T &b)
Compare two values for equality.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
coordSystem::cylindrical cylindricalCS
Compatibility typedef 1806.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)