Go to the documentation of this file.
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");
97 label vertexOffset = 0;
99 DynamicList<point> dynPoints;
100 DynamicList<Face> dynFaces;
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
290 <<
"refs " <<
f.size() <<
nl;
292 for (
const label verti :
f)
294 os << verti <<
" 0 0" <<
nl;
312 streamOpt.
format(IOstream::ASCII);
321 : surfaceFormatsCore::oneZone(faceLst)
324 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
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(IOstream::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
430 FaceListType(surf.surfFaces(), zoneMap),
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
ISstream & getLine(std::string &str, char delim='\n')
A class for handling file names.
static constexpr const zero Zero
Input from file stream, using an ISstream.
A List obtained as a section of another List.
Base class for mesh zones.
streamFormat format() const noexcept
const pointField & points() const
Input/output from string buffers.
Ostream & endl(Ostream &os)
A class for handling character strings derived from std::string.
static void writeHeader(Ostream &os, const word &fieldName)
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const labelUList & faceMap() const
bool good() const noexcept
static void writeZone(Ostream &os, const Patch &patch, const word &name, const label zoneI)
Generic templated field type.
DynamicList< T, SizeMin > & append(const T &val)
The IOstreamOption is a simple container for options an IOstream can normally have.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Vector< scalar > vector
A scalar version of the templated Vector.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const std::string version
Output to file stream, using an OSstream.
#define FatalErrorInFunction
const word & name() const noexcept
A surface zone on a MeshedSurface.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
List< surfZone > surfZoneList
word name(const expressions::valueTypeCode typeCode)
A List with indirect addressing.
const UList< Face > & surfFaces() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
vector point
Point is a vector.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
UList< label > labelUList
A UList of labels.
Foam::argList args(argc, argv)
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
#define WarningInFunction
surfZoneList sortedZones(labelList &faceMap) const
A list of faces which address into the list of points.
const UList< surfZone > & surfZones() const