61 <<
"Cannot read file " << filename <<
nl 76 <<
"When reading AC3D file " << filename
77 <<
" read header " <<
line <<
" with version " 79 <<
"Only tested reading with version 'b'." 80 <<
" This might give problems" <<
endl;
85 if (!cueTo(is,
"OBJECT",
args) ||
args !=
"world")
88 <<
"Cannot find 'OBJECT world' in file " << filename <<
nl 93 args = cueToOrDie(is,
"kids");
94 const label nZones = parse<int>(
args);
97 label vertexOffset = 0;
99 DynamicList<point> dynPoints;
100 DynamicList<Face> dynFaces;
101 List<word>
names(nZones);
102 List<label> sizes(nZones,
Zero);
104 for (label zoneI = 0; zoneI < nZones; ++zoneI)
106 names[zoneI] = surfZone::defaultName(zoneI);
108 args = cueToOrDie(is,
"OBJECT",
"while reading " +
names[zoneI]);
111 label nZonePoints = 0;
120 if (!readCmd(is, cmd,
args))
123 <<
"Did not read up to 'kids 0' while reading zone " 124 << zoneI <<
" from file " << filename <<
nl 131 const string str = parse<string>(
args);
134 else if (cmd ==
"rot")
146 <<
"rot (rotation tensor) command not implemented" 147 <<
"Line:" << cmd <<
' ' <<
args <<
endl 148 <<
"while reading zone " << zoneI <<
endl;
150 else if (cmd ==
"loc")
153 IStringStream lineStream(
args);
160 else if (cmd ==
"numvert")
163 nZonePoints = parse<int>(
args);
165 for (label vertI = 0; vertI < nZonePoints; ++vertI)
168 IStringStream lineStream(line);
172 >> pt.x() >> pt.y() >> pt.z();
175 dynPoints.append(location + pt);
178 else if (cmd ==
"numsurf")
180 const label nFaces = parse<int>(
args);
182 for (label facei = 0; facei < nFaces; ++facei)
184 const string errorMsg =
185 string(
" while reading face ")
188 +
" from file " + filename;
190 cueToOrDie(is,
"SURF", errorMsg);
191 cueToOrDie(is,
"mat", errorMsg);
192 args = cueToOrDie(is,
"refs", errorMsg);
194 const label nVert = parse<int>(
args);
196 List<label> verts(nVert);
200 verts[vertI] = vertexOffset + parse<int>(line);
205 if (faceTraits<Face>::isTri() &&
f.size() > 3)
209 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
211 label fp2 =
f.fcIndex(fp1);
213 dynFaces.append(Face{
f[0],
f[fp1],
f[fp2]});
219 dynFaces.append(Face(
f));
226 vertexOffset += nZonePoints;
228 else if (cmd ==
"kids")
231 const label nKids = parse<int>(
args);
236 <<
"Can only read objects without kids." 237 <<
" Encountered " << nKids <<
" kids when" 238 <<
" reading zone " << zoneI
249 this->storedPoints().transfer(dynPoints);
250 this->storedFaces().transfer(dynFaces);
253 this->addZones(sizes,
names);
254 this->addZonesToFaces();
255 this->stitchFaces(SMALL);
264 template<
class Patch>
274 os <<
"OBJECT poly" <<
nl 275 <<
"name \"" <<
name <<
"\"" <<
nl;
277 os <<
"numvert " <<
patch.nPoints() <<
nl;
281 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
nl;
286 for (
const auto&
f :
patch.localFaces())
288 os <<
"SURF 0x20" <<
nl 289 <<
"mat " << zoneI <<
nl 292 for (
const label verti :
f)
294 os << verti <<
" 0 0" <<
nl;
312 streamOpt.
format(IOstreamOption::ASCII);
321 : surfaceFormatsCore::oneZone(faceLst)
330 <<
"Cannot write file " << filename <<
nl 336 if (zones.
size() == 1)
348 for (
const surfZone& zone : zones)
352 typedef UIndirectList<Face> FaceListType;
354 SubList<label> zoneMap(surf.
faceMap(), zone.range());
356 PrimitivePatch<FaceListType, const pointField&>
patch 358 FaceListType(faceLst, zoneMap),
366 typedef SubList<Face> FaceListType;
368 PrimitivePatch<FaceListType, const pointField&>
patch 370 FaceListType(faceLst, zone.range()),
392 streamOpt.
format(IOstreamOption::ASCII);
398 <<
"Cannot write file " << filename <<
nl 405 if (zoneLst.size() <= 1)
411 : surfaceFormatsCore::oneZone(surf.
surfFaces())
422 for (
const surfZone& zone : zoneLst)
424 typedef UIndirectList<Face> FaceListType;
426 SubList<label> zoneMap(
faceMap, zone.range());
428 PrimitivePatch<FaceListType, const pointField&>
patch A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
void size(const label n)
Older name for setAddressableSize.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
static void writeHeader(Ostream &os, const word &fieldName)
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Input/output from string buffers.
Output to file stream, using an OSstream.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple container for options an IOstream can normally have.
const UList< surfZone > & surfZones() const
Const access to the surface zones.
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
#define forAll(list, i)
Loop across all elements in list.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
bool useFaceMap() const
Can/should use faceMap?
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
const Field< point_type > & points() const noexcept
Return reference to global points.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const List< Face > & surfFaces() const
Return const access to the faces.
OBJstream os(runTime.globalPath()/outputName)
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Input from file stream, using an ISstream.
List< surfZone > surfZoneList
static void writeZone(Ostream &os, const Patch &patch, const word &name, const label zoneI)
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
const labelUList & faceMap() const
Const access to the faceMap, zero-sized when unused.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
const pointField & points() const
Return const access to the points.
bool good() const noexcept
True if next operation might succeed.
const std::string patch
OpenFOAM patch number as a std::string.
List< label > labelList
A List of labels.
Foam::argList args(argc, argv)
streamFormat format() const noexcept
Get the current stream format.
const UList< Face > & surfFaces() const
Return const access to the faces.
static constexpr const zero Zero
Global zero (0)