39void Foam::fileFormats::VTKsurfaceFormat<Face>::writePolys
42 const UList<Face>& faces
46 label nConnectivity = 0;
47 for (
const Face&
f : faces)
49 nConnectivity +=
f.size();
52 vtk::legacy::beginPolys
63 for (
const Face&
f : faces)
100 <<
"Cannot read file " << filename <<
nl
115 "vtk::surfaceFormat",
125 const faceList& faces = reader.faces();
130 for (
auto fieldName : {
"region",
"STLSolidLabeling" })
132 const labelIOField* lptr =
133 reader.cellData().findObject<labelIOField>(fieldName);
138 for (
const auto& region : *lptr)
140 zones[i++] = label(region);
151 for (
const auto& region : *sptr)
153 zones[i++] = label(region);
161 const label nZones =
max(zones)+1;
165 zoneNames[i] = surfZone::defaultName(i);
171 if (faceTraits<Face>::isTri())
173 for (
const face&
f : faces)
175 nTri +=
f.nTriangles();
179 DynamicList<label> dynElemId;
181 if (nTri > faces.size())
186 DynamicList<Face> dynFaces(nTri);
187 DynamicList<label> dynZones(nTri);
191 const face&
f = faces[facei];
192 for (label fp1 = 1; fp1 <
f.size() - 1; fp1++)
194 const label fp2 =
f.fcIndex(fp1);
196 dynFaces.append(Face{
f[0],
f[fp1],
f[fp2]});
197 dynZones.append(zones[facei]);
204 for (
const label zonei : dynZones)
209 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
212 this->addZones(zoneSizes, zoneNames);
216 DynamicList<Face> dynFaces(faces.size());
217 DynamicList<label> dynZones(std::move(zones));
219 for (
const face&
f : faces)
221 dynFaces.append(Face(
f));
226 for (
const label zonei : dynZones)
231 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
234 this->addZones(zoneSizes, zoneNames);
236 this->addZonesToFaces();
269 std::ofstream
os(filename, std::ios::binary);
278 label nConnectivity = 0;
279 for (
const Face&
f : faceLst)
281 nConnectivity +=
f.size();
296 const Face&
f = faceLst[
faceMap[faceIndex++]];
308 writePolys(
format(), faceLst);
312 if (zones.
size() > 1)
330 std::ofstream
os(filename, std::ios::binary);
const dictionary formatOptions(propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL))
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 as an ISstream, normally using std::ifstream for the actual input.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A simple container for options an IOstream can normally have.
bool good() const noexcept
True if next operation might succeed.
void clear()
Clear the list, i.e. set size to zero.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const UList< surfZone > & surfZones() const noexcept
Const access to the surface zones.
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
const pointField & points() const noexcept
Return const access to the points.
bool useFaceMap() const noexcept
Can/should use faceMap?
pointField & storedPoints()
Non-const access to global points.
virtual void addZones(const UList< surfZone > &, const bool cullEmpty=false)
Add surface zones.
void sortFacesAndStore(DynamicList< Face > &unsortedFaces, DynamicList< label > &zoneIds, DynamicList< label > &elemIds, bool sorted)
Sort faces by zones and store sorted faces.
const List< Face > & surfFaces() const
Return const access to the faces.
friend class UnsortedMeshedSurface
bool addZonesToFaces()
Propagate zone information on face regions.
const Field< point_type > & points() const noexcept
Return reference to global points.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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...
virtual const labelList & zoneIds() const
Return const access to the zone ids.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static bool isTri()
Face-type only handles triangles. Not true in general.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Registry of regIOobjects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
A surface zone on a MeshedSurface.
Reader for vtk UNSTRUCTURED_GRID legacy files. Supports single CELLS, POINTS etc. entry only.
const faceList & faces() const noexcept
2D cells (=faces)
const objectRegistry & cellData() const noexcept
Cell based fields.
const pointField & points() const noexcept
Points.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
void beginPolys(std::ostream &os, label nPolys, label nConnectivity)
Emit header for POLYGONS (with trailing newline).
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
List< surfZone > surfZoneList
List of surfZone.
static void writeHeader(Ostream &os, const word &fieldName)
List< face > faceList
List of faces.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOField< label > labelIOField
IO for a Field of label.
errorManipArg< error, int > exit(error &err, const int errNo=1)
IOField< scalar > scalarIOField
IO for a Field of scalar.
constexpr char nl
The newline '\n' character (0x0a).
word format(conversionProperties.get< word >("format"))
#define forAll(list, i)
Loop across all elements in list.