Go to the documentation of this file.
39 namespace surfaceWriters
98 os << rgb[0] <<
' ' << rgb[1] <<
' ' << rgb[2] <<
',' <<
nl;
111 colourTablePtr_(nullptr)
127 colourTablePtr_(
nullptr)
137 if (!colourTablePtr_)
140 <<
"No colourMap " << tableName <<
" using default" <<
nl;
144 if (!colourTablePtr_)
152 Info<<
"X3D with colourMap '" << tableName <<
"' and range ";
177 open(surf, outputPath, parallel);
192 open(
points, faces, outputPath, parallel);
205 if (useTimeDir() && !
timeName().empty())
208 outputFile = outputPath_.
path() /
timeName() / outputPath_.name();
210 outputFile.
ext(
"x3d");
214 Info<<
"Writing geometry to " << outputFile <<
endl;
244 const word& fieldName,
248 if (!colourTablePtr_)
252 <<
"No output colours set" <<
endl;
254 return this->
write();
262 if (useTimeDir() && !
timeName().empty())
269 outputFile /= fieldName +
'_' + outputPath_.name();
270 outputFile.
ext(
"x3d");
274 Info<<
"Writing field " << fieldName <<
" to " << outputFile <<
endl;
284 const auto&
values = tfield();
299 range.min() -= VSMALL;
300 range.max() += VSMALL;
307 OFstream os(outputFile, streamOpt_);
314 os <<
" <IndexedFaceSet"
315 <<
" colorPerVertex='" <<
Switch(this->isPointData()) <<
"'"
316 <<
" coordIndex='" <<
nl;
318 for (
const auto&
f : surf.
faces())
320 for (
const label vrti :
f)
329 if (!this->isPointData())
331 const label nFaces = surf.
faces().size();
333 os <<
" colorIndex='";
335 for (label i=0; i < nFaces; ++i)
344 writePoints(os, surf.
points());
346 os <<
"<Color color='" <<
nl;
350 for (
const Type& val :
values)
353 vector rgb = colourTablePtr_->value(
x);
360 " </IndexedFaceSet>\n";
static const Enum< predefinedType > predefinedNames
Enumeration names for predefinedType.
A surfaceWriter for X3D files.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
static const colourTable * ptr(const word &tableName)
Look up pointer to colourTable by name, or nullptr on failure.
scalar srange01(const scalarMinMax &range, scalar x)
A (0-1) range for colouring.
A class for handling words, derived from Foam::string.
Base class for surface writers.
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /)
A class for managing temporary objects.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
virtual const faceList & faces() const =0
The faces used for the surface.
Abstract definition of a meshed surface defined by faces and points.
defineTypeName(boundaryDataWriter)
static scalar rangex(const scalarMinMax &range, const Type &val)
A (0-1) range for colouring.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void writeHeader(Ostream &os, const word &fieldName)
Convenience macros for instantiating surfaceWriter methods.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
messageStream Info
Information stream (uses stdout - output is on the master only)
x3dWriter()
Default construct.
static void printColour(Ostream &os, const vector &rgb)
virtual const pointField & points() const =0
The points used for the surface.
static compressionType compressionEnum(const word &compName, const compressionType deflt=compressionType::UNCOMPRESSED)
The compression enum corresponding to the string.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &df)
Macros for easy insertion into run-time selection tables.
word ext() const
Return file name extension (part after last .)
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
addToRunTimeSelectionTable(surfaceWriter, boundaryDataWriter, word)
virtual fileName write()
Write surface geometry to file.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
bool equal(const T &s1, const T &s2)
Compare two values for equality.
#define WarningInFunction
Report a warning using Foam::Warning.
A min/max value pair with additional methods. In addition to conveniently storing values,...
defineSurfaceWriterWriteFields(Foam::surfaceWriters::x3dWriter)
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?