mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added triSurface scaling option to surfaceConvert/surfaceMeshConvert
This commit is contained in:
@ -22,9 +22,26 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Application
|
||||||
|
surfaceConvert
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Converts to and from Foam surface format. Optionally orders triangles
|
Converts from one surface mesh format to another
|
||||||
by region.
|
|
||||||
|
Usage
|
||||||
|
- surfaceConvert inputFile outputFile [OPTION]
|
||||||
|
|
||||||
|
@param -clean \n
|
||||||
|
Perform some surface checking/cleanup on the input surface
|
||||||
|
|
||||||
|
@param -scale \<scale\> \n
|
||||||
|
Specify a scaling factor for writing the files
|
||||||
|
|
||||||
|
@param -group \n
|
||||||
|
Orders faces by region
|
||||||
|
|
||||||
|
Note
|
||||||
|
The filename extensions are used to determine the file format type.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -44,34 +61,41 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
argList::validArgs.clear();
|
argList::validArgs.clear();
|
||||||
argList::validOptions.insert("cleanup", "");
|
argList::validArgs.append("inputFile");
|
||||||
|
argList::validArgs.append("outputFile");
|
||||||
|
argList::validOptions.insert("clean", "");
|
||||||
|
argList::validOptions.insert("scale", "scale");
|
||||||
argList::validOptions.insert("group", "");
|
argList::validOptions.insert("group", "");
|
||||||
argList::validArgs.append("input surface file");
|
|
||||||
argList::validArgs.append("output surface file");
|
|
||||||
argList args(argc, argv);
|
argList args(argc, argv);
|
||||||
|
const stringList& params = args.additionalArgs();
|
||||||
|
|
||||||
fileName inFileName(args.additionalArgs()[0]);
|
scalar scaleFactor = 0;
|
||||||
fileName outFileName(args.additionalArgs()[1]);
|
if (args.options().found("scale"))
|
||||||
|
{
|
||||||
|
IStringStream(args.options()["scale"])() >> scaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
if (outFileName == inFileName)
|
fileName importName(params[0]);
|
||||||
|
fileName exportName(params[1]);
|
||||||
|
|
||||||
|
if (importName == exportName)
|
||||||
{
|
{
|
||||||
FatalErrorIn(args.executable())
|
FatalErrorIn(args.executable())
|
||||||
<< "Output file " << outFileName
|
<< "Output file " << exportName << " would overwrite input file."
|
||||||
<< " would overwrite input file."
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info << "Reading : " << inFileName << endl;
|
Info<< "Reading : " << importName << endl;
|
||||||
triSurface surf(inFileName);
|
triSurface surf(importName);
|
||||||
|
|
||||||
Info<< "Read surface:" << endl;
|
Info<< "Read surface:" << endl;
|
||||||
surf.writeStats(Info);
|
surf.writeStats(Info);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
if (args.options().found("clean"))
|
||||||
if (args.options().found("cleanup"))
|
|
||||||
{
|
{
|
||||||
Info << "Cleaning up surface" << endl;
|
Info<< "Cleaning up surface" << endl;
|
||||||
surf.cleanup(true);
|
surf.cleanup(true);
|
||||||
|
|
||||||
Info<< "After cleaning up surface:" << endl;
|
Info<< "After cleaning up surface:" << endl;
|
||||||
@ -83,20 +107,28 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (sortByRegion)
|
if (sortByRegion)
|
||||||
{
|
{
|
||||||
Info << "Reordering faces into groups; one per region." << endl;
|
Info<< "Reordering faces into groups; one per region." << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info << "Maintaining face ordering" << endl;
|
Info<< "Maintaining face ordering" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info << "Writing : " << outFileName << endl;
|
Info<< "writing " << exportName;
|
||||||
surf.write(outFileName, sortByRegion);
|
if (scaleFactor > 0)
|
||||||
|
{
|
||||||
|
Info<< " without scaling" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
|
surf.scalePoints(scaleFactor);
|
||||||
|
}
|
||||||
|
surf.write(exportName, sortByRegion);
|
||||||
|
|
||||||
Info << "End\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -62,8 +62,8 @@ int main(int argc, char *argv[])
|
|||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
argList::validArgs.append("inputFile");
|
argList::validArgs.append("inputFile");
|
||||||
argList::validArgs.append("outputFile");
|
argList::validArgs.append("outputFile");
|
||||||
argList::validOptions.insert("scale", "scale");
|
|
||||||
argList::validOptions.insert("clean", "");
|
argList::validOptions.insert("clean", "");
|
||||||
|
argList::validOptions.insert("scale", "scale");
|
||||||
argList::validOptions.insert("triSurface", "");
|
argList::validOptions.insert("triSurface", "");
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
const stringList& params = args.additionalArgs();
|
const stringList& params = args.additionalArgs();
|
||||||
@ -77,6 +77,13 @@ int main(int argc, char *argv[])
|
|||||||
fileName importName(params[0]);
|
fileName importName(params[0]);
|
||||||
fileName exportName(params[1]);
|
fileName exportName(params[1]);
|
||||||
|
|
||||||
|
if (importName == exportName)
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Output file " << exportName << " would overwrite input file."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!meshedSurface::canRead(importName.ext(), true)
|
!meshedSurface::canRead(importName.ext(), true)
|
||||||
@ -88,10 +95,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (args.options().found("triSurface"))
|
if (args.options().found("triSurface"))
|
||||||
{
|
{
|
||||||
// # include "createTime.H"
|
|
||||||
// instantList timeDirs = timeSelector::select0(runTime, args);
|
|
||||||
// # include "createPolyMesh.H"
|
|
||||||
|
|
||||||
triSurface surf(importName);
|
triSurface surf(importName);
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
@ -107,9 +110,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " triSurface does not yet support scaling "
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
<< scaleFactor << endl;
|
surf.scalePoints(scaleFactor);
|
||||||
// surf.scalePoints(scaleFactor);
|
|
||||||
}
|
}
|
||||||
surf.write(exportName);
|
surf.write(exportName);
|
||||||
}
|
}
|
||||||
@ -123,8 +125,6 @@ int main(int argc, char *argv[])
|
|||||||
surf.checkOrientation(true);
|
surf.checkOrientation(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
surf.scalePoints(scaleFactor);
|
|
||||||
|
|
||||||
Info<< "writing " << exportName;
|
Info<< "writing " << exportName;
|
||||||
if (scaleFactor <= 0)
|
if (scaleFactor <= 0)
|
||||||
{
|
{
|
||||||
@ -133,6 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " with scaling " << scaleFactor << endl;
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
|
surf.scalePoints(scaleFactor);
|
||||||
}
|
}
|
||||||
surf.write(exportName);
|
surf.write(exportName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user