mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: pass through format options from sampledSurface to proxy writers
- preliminary work to #1057 - add dictionary selectable format (ascii|binary) to VTKsurfaceFormat, VTPsurfaceFormat
This commit is contained in:
@ -53,7 +53,13 @@ Description
|
||||
|
||||
// Output surface format
|
||||
surfaceFormat vtk;
|
||||
formatOptions { }
|
||||
formatOptions
|
||||
{
|
||||
vtk
|
||||
{
|
||||
precision 10;
|
||||
}
|
||||
}
|
||||
|
||||
surfaces
|
||||
(
|
||||
|
||||
@ -45,6 +45,18 @@ Foam::proxySurfaceWriter::proxySurfaceWriter(const word& fileExt)
|
||||
{}
|
||||
|
||||
|
||||
Foam::proxySurfaceWriter::proxySurfaceWriter
|
||||
(
|
||||
const word& fileExt,
|
||||
const dictionary& options
|
||||
)
|
||||
:
|
||||
surfaceWriter(),
|
||||
fileExtension_(fileExt),
|
||||
options_(options)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::proxySurfaceWriter::write
|
||||
@ -73,8 +85,16 @@ Foam::fileName Foam::proxySurfaceWriter::write
|
||||
Info<< "Writing geometry to " << outputFile << endl;
|
||||
}
|
||||
|
||||
MeshedSurfaceProxy<face>(surf.points(), surf.faces())
|
||||
.write(outputFile, fileExtension_);
|
||||
MeshedSurfaceProxy<face>
|
||||
(
|
||||
surf.points(),
|
||||
surf.faces()
|
||||
).write
|
||||
(
|
||||
outputFile,
|
||||
fileExtension_,
|
||||
options_
|
||||
);
|
||||
|
||||
return outputFile;
|
||||
}
|
||||
|
||||
@ -40,6 +40,9 @@ Description
|
||||
`-- surfaceName.{obj|stl|..}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The formatOptions for proxy are file-type dependent.
|
||||
|
||||
SourceFiles
|
||||
proxySurfaceWriter.C
|
||||
|
||||
@ -63,12 +66,14 @@ class proxySurfaceWriter
|
||||
:
|
||||
public surfaceWriter
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- The file extension associated with the proxy
|
||||
word fileExtension_;
|
||||
|
||||
//- Format options
|
||||
dictionary options_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -79,7 +84,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for a given extension
|
||||
proxySurfaceWriter(const word& fileExt);
|
||||
explicit proxySurfaceWriter(const word& fileExt);
|
||||
|
||||
//- Construct for a given extension, with some output options
|
||||
proxySurfaceWriter(const word& fileExt, const dictionary& options);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
@ -54,46 +54,70 @@ namespace Foam
|
||||
Foam::autoPtr<Foam::surfaceWriter>
|
||||
Foam::surfaceWriter::New(const word& writeType)
|
||||
{
|
||||
auto cstrIter = wordConstructorTablePtr_->cfind(writeType);
|
||||
const auto cstrIter = wordConstructorTablePtr_->cfind(writeType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
if (cstrIter.found())
|
||||
{
|
||||
if (MeshedSurfaceProxy<face>::canWriteType(writeType))
|
||||
{
|
||||
// generally unknown, but can be written via MeshedSurfaceProxy
|
||||
// use 'proxy' handler instead
|
||||
return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
|
||||
}
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown write type \"" << writeType << "\"\n\n"
|
||||
<< "Valid types : "
|
||||
<< wordConstructorTablePtr_->sortedToc() << nl
|
||||
<< "Valid proxy types : "
|
||||
<< MeshedSurfaceProxy<face>::writeTypes() << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
return autoPtr<surfaceWriter>(cstrIter()());
|
||||
}
|
||||
else if (MeshedSurfaceProxy<face>::canWriteType(writeType))
|
||||
{
|
||||
// Unknown, but proxy handler can manage it
|
||||
return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
|
||||
}
|
||||
|
||||
return autoPtr<surfaceWriter>(cstrIter()());
|
||||
FatalErrorInFunction
|
||||
<< "Unknown write type \"" << writeType << "\"\n\n"
|
||||
<< "Valid types : "
|
||||
<< wordConstructorTablePtr_->sortedToc() << nl
|
||||
<< "Valid proxy types : "
|
||||
<< MeshedSurfaceProxy<face>::writeTypes() << endl
|
||||
<< exit(FatalError);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::surfaceWriter>
|
||||
Foam::surfaceWriter::New(const word& writeType, const dictionary& options)
|
||||
{
|
||||
// Constructors with dictionary options
|
||||
auto cstrIter = wordDictConstructorTablePtr_->cfind(writeType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
// Revert to version without options
|
||||
return Foam::surfaceWriter::New(writeType);
|
||||
// Constructor with options (dictionary)
|
||||
const auto cstrIter = wordDictConstructorTablePtr_->cfind(writeType);
|
||||
|
||||
if (cstrIter.found())
|
||||
{
|
||||
return autoPtr<surfaceWriter>(cstrIter()(options));
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<surfaceWriter>(cstrIter()(options));
|
||||
|
||||
// Drop through to version without options
|
||||
|
||||
const auto cstrIter = wordConstructorTablePtr_->cfind(writeType);
|
||||
|
||||
if (cstrIter.found())
|
||||
{
|
||||
return autoPtr<surfaceWriter>(cstrIter()());
|
||||
}
|
||||
else if (MeshedSurfaceProxy<face>::canWriteType(writeType))
|
||||
{
|
||||
// Unknown, but proxy handler can manage it
|
||||
return autoPtr<surfaceWriter>
|
||||
(
|
||||
new proxySurfaceWriter(writeType, options)
|
||||
);
|
||||
}
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Unknown write type \"" << writeType << "\"\n\n"
|
||||
<< "Valid types : "
|
||||
<< wordConstructorTablePtr_->sortedToc() << nl
|
||||
<< "Valid proxy types : "
|
||||
<< MeshedSurfaceProxy<face>::writeTypes() << endl
|
||||
<< exit(FatalError);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ public:
|
||||
vtkSurfaceWriter();
|
||||
|
||||
//- Construct with some output options
|
||||
vtkSurfaceWriter(const dictionary& options);
|
||||
explicit vtkSurfaceWriter(const dictionary& options);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
Reference in New Issue
Block a user