diff --git a/applications/test/surfaceIntersection/Test-surfaceIntersection.C b/applications/test/surfaceIntersection/Test-surfaceIntersection.C index ddf122f60a..b841663790 100644 --- a/applications/test/surfaceIntersection/Test-surfaceIntersection.C +++ b/applications/test/surfaceIntersection/Test-surfaceIntersection.C @@ -41,10 +41,15 @@ using namespace Foam; autoPtr loadSurface ( const Foam::Time& runTime, - const fileName& surfName + const fileName& surfName, + const scalar scaleFactor ) { - Info<< "Reading surface " << surfName << endl; + Info<< "Reading surface " << surfName << nl; + if (scaleFactor > 0) + { + Info<<"Scaling : " << scaleFactor << nl; + } const fileName fallback = runTime.constantPath()/triSurfaceMesh::meshSubDir/surfName; @@ -52,11 +57,11 @@ autoPtr loadSurface autoPtr surfPtr; if (isFile(surfName)) { - surfPtr.set(new triSurface(surfName)); + surfPtr.set(new triSurface(surfName, scaleFactor)); } else if (isFile(fallback)) { - surfPtr.set(new triSurface(fallback)); + surfPtr.set(new triSurface(fallback, scaleFactor)); } else { @@ -102,6 +107,12 @@ int main(int argc, char *argv[]) "mergeTol", "merge points (and edges) using the specified tolerance" ); + argList::addOption + ( + "scale", + "factor", + "geometry scaling factor" + ); #include "addDictOption.H" @@ -117,16 +128,18 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" + const scalar scaleFactor = args.optionLookupOrDefault("scale", -1); + const word outputFile(args.executable() + ".obj"); const fileName surf1Name(args[1]); - triSurface surf1 = loadSurface(runTime, surf1Name)(); + triSurface surf1 = loadSurface(runTime, surf1Name, scaleFactor)(); Info<< surf1Name << " statistics:" << endl; surf1.writeStats(Info); Info<< endl; const fileName surf2Name(args[2]); - triSurface surf2 = loadSurface(runTime, surf2Name)(); + triSurface surf2 = loadSurface(runTime, surf2Name, scaleFactor)(); Info<< surf2Name << " statistics:" << endl; surf2.writeStats(Info); Info<< endl; diff --git a/applications/test/surfaceMeshConvert/Make/files b/applications/test/surfaceMeshConvert/Make/files new file mode 100644 index 0000000000..91a99b3fef --- /dev/null +++ b/applications/test/surfaceMeshConvert/Make/files @@ -0,0 +1,3 @@ +Test-surfaceMeshConvert.C + +EXE = $(FOAM_APPBIN)/Test-surfaceMeshConvert diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/options b/applications/test/surfaceMeshConvert/Make/options similarity index 100% rename from applications/utilities/surface/surfaceMeshConvertTesting/Make/options rename to applications/test/surfaceMeshConvert/Make/options diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C similarity index 98% rename from applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C rename to applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C index 2db1c32b11..39cc729ba3 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C @@ -22,17 +22,16 @@ License along with OpenFOAM. If not, see . Application - surfaceMeshConvertTesting + Test-surfaceMeshConvert Group grpSurfaceUtilities Description - Converts from one surface mesh format to another, but primarily - used for testing functionality. + Test conversions from one surface mesh format to another. Usage - \b surfaceMeshConvertTesting inputFile outputFile [OPTION] + \b Test-surfaceMeshConvert inputFile outputFile [OPTION] Options: - \par -clean diff --git a/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C b/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C index 87ddd4dff9..216f253d5f 100644 --- a/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C +++ b/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) // ~~~~~~~~~~~~~~~~~~~~~ fileFormats::FIREMeshWriter::binary = !args.optionFound("ascii"); - // default: rescale from [m] to [mm] + // Default: no rescaling scalar scaleFactor = 1; if (args.optionReadIfPresent("scale", scaleFactor)) { diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index db2f571043..b082bf39c2 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -43,8 +43,8 @@ Usage or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) - -scale vector - Scales the points by the given vector. + -scale scalar|vector + Scales the points by the given scalar or vector. The any or all of the three options may be specified and are processed in the above order. @@ -182,9 +182,9 @@ int main(int argc, char *argv[]) argList::addOption ( "scale", - "vector", - "scale by the specified amount - eg, '(0.001 0.001 0.001)' for a " - "uniform [mm] to [m] scaling" + "scalar | vector", + "scale by the specified amount - eg, for a uniform [mm] to [m] scaling " + "use either (0.001 0.001 0.001)' or simply '0.001'" ); #include "addRegionOption.H" @@ -262,10 +262,10 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " yaw " << v.z() << nl; - // Convert to radians + // degToRad v *= pi/180.0; - quaternion R(quaternion::rotationSequence::XYZ, v); + const quaternion R(quaternion::rotationSequence::XYZ, v); Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); @@ -282,16 +282,10 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " roll " << v.z() << nl; - // Convert to radians + // degToRad v *= pi/180.0; - scalar yaw = v.x(); - scalar pitch = v.y(); - scalar roll = v.z(); - - quaternion R = quaternion(vector(0, 0, 1), yaw); - R *= quaternion(vector(0, 1, 0), pitch); - R *= quaternion(vector(1, 0, 0), roll); + const quaternion R(quaternion::rotationSequence::ZYX, v); Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); @@ -302,13 +296,34 @@ int main(int argc, char *argv[]) } } - if (args.optionReadIfPresent("scale", v)) + if (args.optionFound("scale")) { - Info<< "Scaling points by " << v << endl; + // Use readList to handle single or multiple values + const List scaling = args.optionReadList("scale"); - points.replace(vector::X, v.x()*points.component(vector::X)); - points.replace(vector::Y, v.y()*points.component(vector::Y)); - points.replace(vector::Z, v.z()*points.component(vector::Z)); + if (scaling.size() == 1) + { + Info<< "Scaling points uniformly by " << scaling[0] << nl; + points *= scaling[0]; + } + else if (scaling.size() == 3) + { + Info<< "Scaling points by (" + << scaling[0] << " " + << scaling[1] << " " + << scaling[2] << ")" << nl; + + points.replace(vector::X, scaling[0]*points.component(vector::X)); + points.replace(vector::Y, scaling[1]*points.component(vector::Y)); + points.replace(vector::Z, scaling[2]*points.component(vector::Z)); + } + else + { + FatalError + << "-scale with 1 or 3 components only" << nl + << "given: " << args["scale"] << endl + << exit(FatalError); + } } // Set the precision of the points data to 10 diff --git a/applications/utilities/surface/surfaceAdd/surfaceAdd.C b/applications/utilities/surface/surfaceAdd/surfaceAdd.C index 5caa3e0703..0be9024ebd 100644 --- a/applications/utilities/surface/surfaceAdd/surfaceAdd.C +++ b/applications/utilities/surface/surfaceAdd/surfaceAdd.C @@ -71,6 +71,12 @@ int main(int argc, char *argv[]) "mergeRegions", "combine regions from both surfaces" ); + argList::addOption + ( + "scale", + "factor", + "geometry scaling factor on input surfaces" + ); argList args(argc, argv); @@ -81,6 +87,8 @@ int main(int argc, char *argv[]) const bool addPoint = args.optionFound("points"); const bool mergeRegions = args.optionFound("mergeRegions"); + const scalar scaleFactor = args.optionLookupOrDefault("scale", -1); + if (addPoint) { Info<< "Reading a surface and adding points from a file" @@ -117,8 +125,12 @@ int main(int argc, char *argv[]) << "Writing : " << outFileName << nl << endl; } - const triSurface surface1(inFileName1); + if (scaleFactor > 0) + { + Info<< "Scaling : " << scaleFactor << nl; + } + const triSurface surface1(inFileName1, scaleFactor); Info<< "Surface1:" << endl; surface1.writeStats(Info); Info<< endl; @@ -131,7 +143,7 @@ int main(int argc, char *argv[]) if (addPoint) { IFstream pointsFile(args["points"]); - pointField extraPoints(pointsFile); + const pointField extraPoints(pointsFile); Info<< "Additional Points:" << extraPoints.size() << endl; @@ -139,17 +151,16 @@ int main(int argc, char *argv[]) label pointi = pointsAll.size(); pointsAll.setSize(pointsAll.size() + extraPoints.size()); - forAll(extraPoints, i) + for (const auto& pt : extraPoints) { - pointsAll[pointi++] = extraPoints[i]; + pointsAll[pointi++] = pt; } combinedSurf = triSurface(surface1, surface1.patches(), pointsAll); } else { - const triSurface surface2(inFileName2); - + const triSurface surface2(inFileName2, scaleFactor); Info<< "Surface2:" << endl; surface2.writeStats(Info); Info<< endl; @@ -165,21 +176,19 @@ int main(int argc, char *argv[]) label pointi = 0; // Copy points1 into pointsAll - forAll(points1, point1i) + for (const auto& pt : points1) { - pointsAll[pointi++] = points1[point1i]; + pointsAll[pointi++] = pt; } // Add surface2 points - forAll(points2, point2i) + for (const auto& pt : points2) { - pointsAll[pointi++] = points2[point2i]; + pointsAll[pointi++] = pt; } label trianglei = 0; - - // Determine map for both regions label nNewPatches = 0; labelList patch1Map(surface1.patches().size()); @@ -192,17 +201,17 @@ int main(int argc, char *argv[]) forAll(surface1.patches(), i) { const word& name = surface1.patches()[i].name(); - HashTable