46inline int countFaces(
const Face&
f)
48 int n = (
f.size() - 2);
49 return n == 2 ? 1 :
n;
58inline void Foam::fileFormats::FLMAsurfaceFormat<Face>::writeShell
64 if (
os.format() == IOstreamOption::BINARY)
66 if (
f.size() == 3 ||
f.size() == 4)
68 putFireLabel(
os,
f.size());
69 for (
const label verti :
f)
71 putFireLabel(
os, verti);
78 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
80 const label fp2 =
f.fcIndex(fp1);
83 putFireLabel(
os,
f[0]);
84 putFireLabel(
os,
f[fp1]);
85 putFireLabel(
os,
f[fp2]);
92 if (
f.size() == 3 ||
f.size() == 4)
94 os <<
' ' <<
f.size();
95 for (
const label verti :
f)
103 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
105 const label fp2 =
f.fcIndex(fp1);
106 os <<
' ' << 3 <<
' '
107 <<
f[0] <<
' ' <<
f[fp1] <<
' ' <<
f[fp2]
116inline void Foam::fileFormats::FLMAsurfaceFormat<Face>::writeType
122 if (
os.format() == IOstreamOption::BINARY)
126 putFireLabel(
os, fireQuad);
130 const label
n = countFaces(
f);
131 for (label i=0; i <
n; ++i)
133 putFireLabel(
os, fireTri);
142 os <<
' ' << fireQuad;
146 const label
n = countFaces(
f);
147 for (label i=0; i <
n; ++i)
149 os <<
' ' << fireTri;
168 <<
"bad output state "
172 const UList<point>& pointLst = surf.
points();
173 const UList<Face>& faceLst = surf.
surfFaces();
174 const UList<label>& faceMap = surf.
faceMap();
177 const surfZoneList zones
180 ? surfaceFormatsCore::oneZone(faceLst, word::null)
184 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
190 labelList zoneCount(zones.size());
196 const surfZone& zone = zones[zonei];
199 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
202 (useFaceMap ? faceMap[faceIndex] : faceIndex);
204 const Face&
f = faceLst[facei];
206 selCount += countFaces(
f);
209 zoneCount[zonei] = selCount;
221 Info<<
nl <<
"points: " << pointLst.size() <<
endl;
222 putFireLabel(
os, pointLst.size());
225 for (
const point& pt : pointLst)
228 putFirePoint(
os, pt);
235 putFireLabel(
os, nFaces);
239 for (
const surfZone& zone : zones)
241 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
244 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
246 const Face&
f = faceLst[facei];
258 putFireLabel(
os, nFaces);
262 for (
const surfZone& zone : zones)
264 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
267 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
269 const Face&
f = faceLst[facei];
280 putFireLabel(
os, zones.size());
286 const surfZone& zone = zones[zonei];
287 const label selCount = zoneCount[zonei];
289 putFireString(
os, zone.name());
290 putFireLabel(
os,
static_cast<int>(FIRECore::cellSelection));
293 putFireLabels(
os, selCount, faceIndex);
294 faceIndex += selCount;
305 IOstreamOption::compressionType comp,
306 const fileName& filename,
307 const MeshedSurfaceProxy<Face>& surf
311 autoPtr<OFstream> osPtr
313 new OFstream(filename, IOstreamOption(IOstreamOption::ASCII, comp))
318 FLMAsurfaceFormat<Face>::write(*osPtr, surf);
320 if (comp == IOstreamOption::COMPRESSED)
327 Foam::mv(filename +
".gz", filename);
333 <<
"Cannot write file " << filename <<
nl
350 FLMAsurfaceFormat<Face>::write
A simple container for options an IOstream can normally have.
@ ASCII
"ascii" (normal default)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED).
@ UNCOMPRESSED
compression = false
@ COMPRESSED
compression = true
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const UList< surfZone > & surfZones() const noexcept
Const access to the surface zones.
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
const pointField & points() const noexcept
Return const access to the points.
bool useFaceMap() const noexcept
Can/should use faceMap?
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Generic output stream using a standard (STL) stream.
label nFaces() const noexcept
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
A surface zone on a MeshedSurface.
static const word null
An empty word.
const word & name() const noexcept
The zone name.
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
List< surfZone > surfZoneList
List of surfZone.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.