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 Info<<
"Scaling points by (" 155 << scaling[2] <<
')' <<
nl;
166 int main(
int argc,
char *argv[])
170 "Transform (translate / rotate / scale) surface points.\n" 171 "Like transformPoints but for surfaces.\n" 172 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z" 180 "Recentre the bounding box before other operations" 186 "Translate by specified <vector> before rotations" 191 "Use bounding box centre as centre for rotations" 197 "Use specified <point> as centre for rotations" 206 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'" 212 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" 217 "Rotate (degrees) about x-axis" 222 "Rotate (degrees) about y-axis" 227 "Rotate (degrees) about z-axis" 233 "Rotate by '(roll pitch yaw)' degrees" 239 "Rotate by '(yaw pitch roll)' degrees" 245 "Uniform or non-uniform input scaling" 251 "Uniform or non-uniform output scaling" 257 "Input format (default: use file extension)" 263 "Output format (default: use file extension)" 291 <<
"No operation supplied, " 292 <<
"use at least one of the following:" <<
nl 295 for (
const auto& opName : operationNames)
309 const word readFileType
314 const word writeFileType
321 if (!hasReadWriteTypes(readFileType, writeFileType))
324 <<
"Unsupported file format(s)" <<
nl 329 Info<<
"Reading surf from " << importName <<
" ..." <<
nl 330 <<
"Writing surf to " << exportName <<
" ..." <<
endl;
341 applyScaling(
points, getScalingOpt(
"read-scale",
args));
347 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
353 Info<<
"Translating points by " << v <<
endl;
359 if (
args.
found(
"auto-centre") && !useRotationCentre)
361 useRotationCentre =
true;
365 if (useRotationCentre)
367 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
375 bool useRotation(
false);
396 const vector& axis = rotAxisAngle.first();
397 const scalar angle = rotAxisAngle.second();
399 Info<<
"Rotating points " <<
nl 400 <<
" about " << axis <<
nl 401 <<
" angle " << angle <<
nl;
408 const scalar angle =
args.
get<scalar>(
"rotate-x");
410 Info<<
"Rotating points about x-axis: " << angle <<
nl;
417 const scalar angle =
args.
get<scalar>(
"rotate-y");
419 Info<<
"Rotating points about y-axis: " << angle <<
nl;
426 const scalar angle =
args.
get<scalar>(
"rotate-z");
428 Info<<
"Rotating points about z-axis: " << angle <<
nl;
435 Info<<
"Rotating points by" <<
nl 436 <<
" roll " << v.x() <<
nl 437 <<
" pitch " << v.y() <<
nl 438 <<
" yaw " << v.z() <<
nl;
445 Info<<
"Rotating points by" <<
nl 446 <<
" yaw " << v.x() <<
nl 447 <<
" pitch " << v.y() <<
nl 448 <<
" roll " << v.z() <<
nl;
456 Info<<
"Rotating points by " << rot <<
endl;
460 if (useRotationCentre)
462 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
467 applyScaling(
points, getScalingOpt(
"write-scale",
args));
470 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...
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if the UList 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.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
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 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.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
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.
bool equal(const T &s1, const T &s2)
Compare two values for equality.
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)