78 static bool hasReadWriteTypes(
const word& readType,
const word& writeType)
80 volatile bool good =
true;
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;
162 int 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" 294 <<
"No operation supplied, " 295 <<
"use at least one of the following:" <<
nl 298 for (
const auto& opName : operationNames)
312 const word readFileType
317 const word writeFileType
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));
350 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
356 Info<<
"Translating points by " << v <<
endl;
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);
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;
411 const scalar angle =
args.
get<scalar>(
"rotate-x");
413 Info<<
"Rotating points about x-axis: " << angle <<
nl;
420 const scalar angle =
args.
get<scalar>(
"rotate-y");
422 Info<<
"Rotating points about y-axis: " << angle <<
nl;
429 const scalar angle =
args.
get<scalar>(
"rotate-z");
431 Info<<
"Rotating points about z-axis: " << angle <<
nl;
438 Info<<
"Rotating points by" <<
nl 439 <<
" roll " << v.x() <<
nl 440 <<
" pitch " << v.y() <<
nl 441 <<
" yaw " << v.z() <<
nl;
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));
491 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.
A cylindrical coordinate system (r-theta-z). The coordinate system angle theta is always in radians...
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)