Go to the documentation of this file.
30 #include "primitivePatch.H"
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
291 writeHeader(os, zones);
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
376 writeHeader(os, zoneLst);
383 os <<
"OBJECT poly" <<
nl
384 <<
"name \"" <<
zone.
name() <<
"\"\n";
398 os <<
"numvert " << subm.nPoints() <<
endl;
400 forAll(subm.localPoints(), ptI)
402 const point& pt = subm.localPoints()[ptI];
404 os << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
407 os <<
"numsurf " << subm.localFaces().
size() <<
endl;
409 forAll(subm.localFaces(), localFaceI)
411 const Face&
f = subm.localFaces()[localFaceI];
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;
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from string.
A class for handling file names.
#define forAll(list, i)
Loop across all elements in list.
bool useFaceMap() const
Use faceMap?
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
bool read(const char *, int32_t &)
A List obtained as a section of another List.
const List< Face > & faces() const
Return const access to the faces.
const pointField & points() const
Return const access to the points.
const List< surfZone > & surfZones() const
Const access to the surface zones.
static bool readCmd(IFstream &ACfile, string &cmd, string &args)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
ISstream & getLine(string &)
Raw, low-level getline into a string function.
label nPoints() const
Return number of points supporting patch faces.
label size() const
The surface size is the number of faces.
Input from memory buffer stream.
const word & name() const
Return name.
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)
UnsortedMeshedSurface subsetMesh(const labelHashSet &include, labelList &pointMap, labelList &faceMap) const
Return new surface.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A surface zone on a MeshedSurface.
Traits class for primitives.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool insert(const Key &key)
Insert a new entry.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
void size(const label)
Override size to be inconsistent with allocated storage.
bool good() const
Return true if next operation might succeed.
Foam::argList args(argc, argv)
#define WarningInFunction
Report a warning using Foam::Warning.
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
word name(const complex &)
Return a string representation of a complex.
A list of faces which address into the list of points.