52 const bool mustTriangulate = this->isTri();
59 <<
"Cannot read file " << filename
67 string version =
line.substr(4);
72 <<
"When reading AC3D file " << filename
73 <<
" read header " <<
line <<
" with version "
75 <<
"Only tested reading with version 'b'."
76 <<
" This might give problems" <<
endl;
80 if (!cueTo(is,
"OBJECT",
args) || (
args !=
"world"))
83 <<
"Cannot find \"OBJECT world\" in file " << filename
88 args = cueToOrDie(is,
"kids");
92 label vertexOffset = 0;
99 for (
label zoneI = 0; zoneI < nZones; ++zoneI)
103 args = cueToOrDie(is,
"OBJECT",
"while reading " + names[zoneI]);
106 label nZonePoints = 0;
118 <<
"Did not read up to \"kids 0\" while reading zone "
119 << zoneI <<
" from file " << filename
126 string str = parse<string>(
args);
127 string::stripInvalid<word>(str);
131 else if (cmd ==
"rot")
143 <<
"rot (rotation tensor) command not implemented"
144 <<
"Line:" << cmd <<
' ' <<
args <<
endl
145 <<
"while reading zone " << zoneI <<
endl;
147 else if (cmd ==
"loc")
157 else if (cmd ==
"numvert")
160 nZonePoints = parse<int>(
args);
162 for (
label vertI = 0; vertI < nZonePoints; ++vertI)
169 >> pt.
x() >> pt.
y() >> pt.
z();
172 dynPoints.
append(location + pt);
175 else if (cmd ==
"numsurf")
179 for (
label facei = 0; facei < nFaces; ++facei)
181 static string errorMsg =
182 string(
" while reading face ")
185 +
" from file " + filename;
187 cueToOrDie(is,
"SURF", errorMsg);
188 cueToOrDie(is,
"mat", errorMsg);
189 args = cueToOrDie(is,
"refs", errorMsg);
197 verts[vertI] = parse<int>(
line) + vertexOffset;
202 if (mustTriangulate &&
f.size() > 3)
206 for (
label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
208 label fp2 =
f.fcIndex(fp1);
223 vertexOffset += nZonePoints;
225 else if (cmd ==
"kids")
233 <<
"Can only read objects without kids."
234 <<
" Encountered " << nKids <<
" kids when"
235 <<
" reading zone " << zoneI
246 this->storedPoints().transfer(dynPoints);
247 this->storedFaces().transfer(dynFaces);
250 this->addZones(sizes, names,
true);
251 this->stitchFaces(small);
270 : surfaceFormatsCore::oneZone(faceLst)
278 <<
"output with faceMap is not supported " << filename
287 <<
"Cannot open file for writing " << filename
295 const surfZone& zone = zones[zoneI];
297 os <<
"OBJECT poly" <<
nl
298 <<
"name \"" << zone.
name() <<
"\"\n";
319 os << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
nl;
328 os <<
"SURF 0x20" <<
nl
329 <<
"mat " << zoneI <<
nl
330 <<
"refs " <<
f.size() <<
nl;
334 os <<
f[fp] <<
" 0 0" <<
nl;
338 os <<
"kids 0" <<
endl;
353 if (zoneLst.
size() <= 1)
372 <<
"Cannot open file for writing " << filename
381 const surfZone& zone = zoneLst[zoneI];
383 os <<
"OBJECT poly" <<
nl
384 <<
"name \"" << zone.
name() <<
"\"\n";
404 os << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
413 os <<
"SURF 0x20" <<
nl
414 <<
"mat " << zoneI <<
nl
415 <<
"refs " <<
f.size() <<
nl;
419 os <<
f[fp] <<
" 0 0" <<
nl;
423 os <<
"kids 0" <<
endl;
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool insert(const Key &key)
Insert a new entry.
bool good() const
Return true if next operation might succeed.
ISstream & getLine(string &, const bool continuation=true)
Read line into a string.
Input from memory buffer stream.
void size(const label)
Override size to be inconsistent with allocated storage.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const List< surfZone > & surfZones() const
Const access to the surface zones.
const List< Face > & faces() const
Return const access to the faces.
bool useFaceMap() const
Use faceMap?
const pointField & points() const
Return const access to the points.
const List< Face > & faces() const
Return const access to the faces.
A list of faces which address into the list of points.
label nPoints() const
Return number of points supporting patch faces.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A List obtained as a section of another List.
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.
label size() const
The surface size is the number of faces.
UnsortedMeshedSurface subsetMesh(const labelHashSet &include, labelList &pointMap, labelList &faceMap) const
Return new surface.
A class for handling file names.
A class for handling character strings derived from std::string.
const word & name() const
Return name.
A surface zone on a MeshedSurface.
label start() const
Return start label of this zone in the face list.
label size() const
Return size of this zone in the face list.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
static bool readCmd(IFstream &ACfile, string &cmd, string &args)
Foam::argList args(argc, argv)