77 static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
79 volatile bool good =
true;
107 if (scaling.
size() == 1)
111 else if (scaling.
size() == 3)
116 equal(scaling[0], scaling[1])
117 &&
equal(scaling[0], scaling[2])
123 else if (!scaling.
empty())
126 <<
"Incorrect number of components, must be 1 or 3." <<
nl 127 <<
" -" << optName <<
' ' <<
args[optName].c_str() <<
endl 131 if (scaling.
size() == 1 &&
equal(scaling[0], 1))
145 if (scaling.
size() == 1)
147 Info<<
"Scaling points uniformly by " << scaling[0] <<
nl;
150 else if (scaling.
size() == 3)
152 const vector factor(scaling[0], scaling[1], scaling[2]);
153 Info<<
"Scaling points by " << factor <<
nl;
161 int main(
int argc,
char *argv[])
165 "Transform (translate / rotate / scale) surface points.\n" 166 "Like transformPoints but for surfaces.\n" 167 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z" 175 "Recentre the bounding box before other operations" 181 "Translate by specified <vector> before rotations" 186 "Use bounding box centre as centre for rotations" 192 "Use specified <point> as centre for rotations" 201 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'" 207 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" 212 "Rotate (degrees) about x-axis" 217 "Rotate (degrees) about y-axis" 222 "Rotate (degrees) about z-axis" 228 "Rotate by '(roll pitch yaw)' degrees" 234 "Rotate by '(yaw pitch roll)' degrees" 240 "Uniform or non-uniform input scaling" 246 "Uniform or non-uniform output scaling" 252 "Input format (default: use file extension)" 258 "Output format (default: use file extension)" 286 <<
"No operation supplied, " 287 <<
"use at least one of the following:" <<
nl 290 for (
const auto& opName : operationNames)
304 const word readFileType
309 const word writeFileType
316 if (!hasReadWriteTypes(readFileType, writeFileType))
319 <<
"Unsupported file format(s)" <<
nl 324 Info<<
"Reading surf from " << importName <<
" ..." <<
nl 325 <<
"Writing surf to " << exportName <<
" ..." <<
endl;
336 applyScaling(
points, getScalingOpt(
"read-scale",
args));
342 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
348 Info<<
"Translating points by " << v <<
endl;
354 if (
args.
found(
"auto-centre") && !useRotationCentre)
356 useRotationCentre =
true;
360 if (useRotationCentre)
362 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
370 bool useRotation(
false);
391 const vector& axis = rotAxisAngle.first();
392 const scalar angle = rotAxisAngle.second();
394 Info<<
"Rotating points " <<
nl 395 <<
" about " << axis <<
nl 396 <<
" angle " << angle <<
nl;
403 const scalar angle =
args.
get<scalar>(
"rotate-x");
405 Info<<
"Rotating points about x-axis: " << angle <<
nl;
412 const scalar angle =
args.
get<scalar>(
"rotate-y");
414 Info<<
"Rotating points about y-axis: " << angle <<
nl;
421 const scalar angle =
args.
get<scalar>(
"rotate-z");
423 Info<<
"Rotating points about z-axis: " << angle <<
nl;
430 Info<<
"Rotating points by" <<
nl 431 <<
" roll " << v.x() <<
nl 432 <<
" pitch " << v.y() <<
nl 433 <<
" yaw " << v.z() <<
nl;
440 Info<<
"Rotating points by" <<
nl 441 <<
" yaw " << v.x() <<
nl 442 <<
" pitch " << v.y() <<
nl 443 <<
" roll " << v.z() <<
nl;
451 Info<<
"Rotating points by " << rot <<
endl;
455 if (useRotationCentre)
457 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
462 applyScaling(
points, getScalingOpt(
"write-scale",
args));
465 surf1.write(exportName, writeFileType);
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool equal(const T &a, const T &b)
Compare two values for equality.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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 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.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
word ext() const
Return file name extension (part after last .)
Namespace for coordinate system rotations.
An ordered pair of two objects of type <T> with first() and second() elements.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
bool has_ext() const
Various checks for extensions.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
ITstream lookup(const word &optName) const
Return an input stream from the named option.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format? Also checks proxy types.
T get(const label index) const
Get a value from the argument at index.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format? Also checks friend types.
PtrList< volScalarField > & Y
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
point centre() const
The centre (midpoint) of the bounding box.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Foam::argList args(argc, argv)
Tensor of scalars, i.e. Tensor<scalar>.
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
bool found(const word &optName) const
Return true if the named option is found.
static constexpr const zero Zero
Global zero (0)