52 const bool mustTriangulate = this->isTri();
60 "fileFormats::AC3DsurfaceFormat::read(const fileName&)" 62 <<
"Cannot read file " << filename
70 string version = line.substr(4);
76 "fileFormats::AC3DsurfaceFormat::read(const fileName&)" 78 <<
"When reading AC3D file " << filename
79 <<
" read header " << line <<
" with version " 81 <<
"Only tested reading with version 'b'." 82 <<
" This might give problems" <<
endl;
86 if (!cueTo(is,
"OBJECT", args) || (args !=
"world"))
90 "fileFormats::AC3DsurfaceFormat::read(const fileName&)" 92 <<
"Cannot find \"OBJECT world\" in file " << filename
97 args = cueToOrDie(is,
"kids");
101 label vertexOffset = 0;
108 for (
label zoneI = 0; zoneI < nZones; ++zoneI)
112 args = cueToOrDie(is,
"OBJECT",
"while reading " + names[zoneI]);
115 label nZonePoints = 0;
128 "fileFormats::AC3DsurfaceFormat::read(const fileName&)" 130 <<
"Did not read up to \"kids 0\" while reading zone " 131 << zoneI <<
" from file " << filename
138 string str = parse<string>(
args);
139 string::stripInvalid<word>(str);
143 else if (cmd ==
"rot")
156 "fileFormats::AC3DsurfaceFormat::read" 159 <<
"rot (rotation tensor) command not implemented" 160 <<
"Line:" << cmd <<
' ' << args <<
endl 161 <<
"while reading zone " << zoneI <<
endl;
163 else if (cmd ==
"loc")
173 else if (cmd ==
"numvert")
176 nZonePoints = parse<int>(
args);
178 for (
label vertI = 0; vertI < nZonePoints; ++vertI)
185 >> pt.
x() >> pt.
y() >> pt.
z();
188 dynPoints.
append(location + pt);
191 else if (cmd ==
"numsurf")
195 for (
label faceI = 0; faceI < nFaces; ++faceI)
197 static string errorMsg =
198 string(
" while reading face ")
201 +
" from file " + filename;
203 cueToOrDie(is,
"SURF", errorMsg);
204 cueToOrDie(is,
"mat", errorMsg);
205 args = cueToOrDie(is,
"refs", errorMsg);
213 verts[vertI] = parse<int>(line) + vertexOffset;
218 if (mustTriangulate && f.size() > 3)
222 for (
label fp1 = 1; fp1 < f.size() - 1; ++fp1)
239 vertexOffset += nZonePoints;
241 else if (cmd ==
"kids")
250 "fileFormats::AC3DsurfaceFormat::read(const fileName&)" 252 <<
"Can only read objects without kids." 253 <<
" Encountered " << nKids <<
" kids when" 254 <<
" reading zone " << zoneI
265 this->storedPoints().transfer(dynPoints);
266 this->storedFaces().transfer(dynFaces);
269 this->addZones(sizes, names,
true);
270 this->stitchFaces(SMALL);
289 : surfaceFormatsCore::oneZone(faceLst)
298 "fileFormats::AC3DsurfaceFormat::write" 299 "(const fileName&, const MeshedSurfaceProxy<Face>&)" 301 <<
"output with faceMap is not supported " << filename
311 "fileFormats::AC3DsurfaceFormat::write" 312 "(const fileName&, const MeshedSurfaceProxy<Face>&)" 314 <<
"Cannot open file for writing " << filename
318 writeHeader(os, zones);
324 os <<
"OBJECT poly" <<
nl 325 <<
"name \"" << zone.
name() <<
"\"\n";
346 os << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
nl;
355 os <<
"SURF 0x20" <<
nl 356 <<
"mat " << zoneI <<
nl 357 <<
"refs " << f.size() <<
nl;
361 os << f[fp] <<
" 0 0" <<
nl;
365 os <<
"kids 0" <<
endl;
380 if (zoneLst.
size() <= 1)
400 "fileFormats::AC3DsurfaceFormat::write" 401 "(const fileName&, const MeshedSurfaceProxy<Face>&)" 403 <<
"Cannot open file for writing " << filename
407 writeHeader(os, zoneLst);
414 os <<
"OBJECT poly" <<
nl 415 <<
"name \"" << zone.
name() <<
"\"\n";
422 const label faceI = faceMap[faceIndex++];
423 include.insert(faceI);
435 os << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
444 os <<
"SURF 0x20" <<
nl 445 <<
"mat " << zoneI <<
nl 446 <<
"refs " << f.size() <<
nl;
450 os << f[fp] <<
" 0 0" <<
nl;
454 os <<
"kids 0" <<
endl;
Input from memory buffer stream.
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.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
bool useFaceMap() const
Use faceMap?
word name(const complex &)
Return a string representation of a complex.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling character strings derived from std::string.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
static bool readCmd(IFstream &ACfile, string &cmd, string &args)
const pointField & points() const
Return const access to the points.
label nPoints() const
Return number of points supporting patch faces.
const List< Face > & faces() const
Return const access to the faces.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Provide a means of reading/writing AC3D format.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const List< Face > & faces() const
Return const access to the faces.
label size() const
The surface size is the number of faces.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const List< surfZone > & surfZones() const
Const access to the surface zones.
bool good() const
Return true if next operation might succeed.
ISstream & getLine(string &)
Raw, low-level getline into a string function.
A surface zone on a MeshedSurface.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A list of faces which address into the list of points.
const word & name() const
Return name.
Foam::argList args(argc, argv)
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
Traits class for primitives.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
virtual bool read(const fileName &)
Read from file.
UnsortedMeshedSurface subsetMesh(const labelHashSet &include, labelList &pointMap, labelList &faceMap) const
Return new surface.
A class for handling file names.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool read(const char *, int32_t &)
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List obtained as a section of another List.
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy.
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
const Field< point > & points() const
Return reference to global points.