61 <<
"Cannot read file " << filename <<
nl
71 const string version =
line.substr(4);
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");
97 label vertexOffset = 0;
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);
132 names[zoneI] = word::validate(str);
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")
160 else if (cmd ==
"numvert")
163 nZonePoints = parse<int>(
args);
165 for (label vertI = 0; vertI < nZonePoints; ++vertI)
172 >> pt.
x() >> pt.
y() >> pt.
z();
175 dynPoints.
append(location + pt);
178 else if (cmd ==
"numsurf")
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);
200 verts[vertI] = vertexOffset + parse<int>(
line);
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]});
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);
274 os <<
"OBJECT poly" <<
nl
275 <<
"name \"" <<
name <<
"\"" <<
nl;
277 os <<
"numvert " << patch.nPoints() <<
nl;
279 for (
const point& pt : patch.localPoints())
281 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
nl;
284 os <<
"numsurf " << patch.size() <<
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(IOstream::ASCII);
321 : surfaceFormatsCore::oneZone(faceLst)
330 <<
"Cannot write file " << filename <<
nl
334 writeHeader(
os, zones);
336 if (zones.
size() == 1)
392 streamOpt.
format(IOstream::ASCII);
398 <<
"Cannot write file " << filename <<
nl
405 if (zoneLst.
size() <= 1)
411 : surfaceFormatsCore::oneZone(surf.
surfFaces())
414 writeHeader(
os, zones);
419 writeHeader(
os, zoneLst);
Input/output from string buffers.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Input from file stream, using an ISstream.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
bool good() const noexcept
True if next operation might succeed.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const UList< surfZone > & surfZones() const
Const access to the surface zones.
const UList< Face > & surfFaces() const
Return const access to the faces.
bool useFaceMap() const
Can/should use faceMap?
const pointField & points() const
Return const access to the points.
const labelUList & faceMap() const
Const access to the faceMap, zero-sized when unused.
const List< Face > & surfFaces() const
Return const access to the faces.
Output to file stream, using an OSstream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of faces which address into the list of points.
const Field< point_type > & points() const noexcept
Return reference to global points.
virtual bool read()
Re-read model coefficients if they have changed.
A List obtained as a section of another List.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
virtual bool write()
Write the output fields.
A class for handling character strings derived from std::string.
A surface zone on a MeshedSurface.
A class for handling words, derived from Foam::string.
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)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
static void writeZone(Ostream &os, const Patch &patch, const word &name, const label zoneI)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.