47 return wordHashSet(*fileExtensionConstructorTablePtr_);
54 return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
65 return fileFormats::surfaceFormatsCore::checkSupport
67 readTypes() | FriendType::readTypes(),
82 return fileFormats::surfaceFormatsCore::checkSupport
84 writeTypes() | ProxyType::writeTypes(),
104 return canReadType(ext, verbose);
125 const word& fileType,
131 if (fileType.empty())
140 <<
"Cannot determine format from filename" <<
nl
145 write(
name, ext, surf, streamOpt, options);
152 auto* mfuncPtr = writefileExtensionMemberFunctionTable(fileType);
157 const wordHashSet delegate(ProxyType::writeTypes());
159 if (!delegate.
found(fileType))
162 <<
"Unknown write format " << fileType <<
nl <<
nl
163 <<
"Valid types:" <<
nl
164 <<
flatOutput((delegate | writeTypes()).sortedToc()) <<
nl
170 name, fileType, streamOpt, options
175 mfuncPtr(
name, surf, streamOpt, options);
198 faceIds_(surf.faceIds_),
223 newFaces[
faceMap[facei]] = origFaces[facei];
232 if (origIds.
size() == origFaces.
size())
238 newFaceIds[
faceMap[facei]] = origIds[facei];
282 this->checkZones(
false);
298 this->checkZones(
false);
315 if (zoneSizes.
size())
317 if (zoneNames.
size())
319 addZones(zoneSizes, zoneNames);
342 if (zoneSizes.
size())
344 if (zoneNames.
size())
377 const bool useGlobalPoints
400 useGlobalPoints ?
mesh.
points() : allBoundary.localPoints()
406 useGlobalPoints ? allBoundary : allBoundary.localFaces()
413 label startFacei = 0;
428 startFacei +=
p.
size();
432 newZones.setSize(nZone);
435 MeshedSurface<face> surf(bPoints, bFaces, newZones);
450 read(
name, fileType);
508 std::move(*(
mesh.releaseGeom()))
553 if (faceMapNewToOld.
empty())
560 if (zones.
size() == 1)
563 zones[0].
size() = faceMapNewToOld.
size();
574 zone.start() = newFacei;
577 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
579 if (faceMapNewToOld[facei] < origEndi)
600 MeshReference::clearOut();
602 storedPoints().clear();
603 storedFaces().clear();
604 storedFaceIds().clear();
605 storedZones().clear();
612 MeshReference::clearGeom();
615 MeshReference::movePoints(newPoints);
618 storedPoints() = newPoints;
626 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
629 this->clearTopology();
634 this->storedPoints() *= scaleFactor;
644 stitchFaces(SMALL, verbose);
662 for (
auto&
f : this->storedFaces())
664 for (label& pointi :
f)
666 label compacti = oldToCompact[pointi];
669 compacti = compactPointMap.size();
670 oldToCompact[pointi] = compacti;
671 compactPointMap.append(pointi);
679 UIndirectList<point>(this->
points(), compactPointMap)
682 this->swapPoints(newPoints);
722 Face&
f = faceLst[facei];
723 for (label& vert :
f)
725 vert = pointMap[vert];
729 if (
f.collapse() >= 3)
731 if (newFacei != facei)
733 faceLst[newFacei] =
f;
740 Pout<<
"MeshedSurface::stitchFaces : "
741 <<
"Removing collapsed face " << facei <<
endl
742 <<
" vertices :" <<
f <<
endl;
747 if (newFacei != faceLst.
size())
751 Pout<<
"MeshedSurface::stitchFaces : "
752 <<
"Removed " << faceLst.
size() - newFacei
763 faceIds_[facei] = faceIds_[
faceMap[facei]];
766 faceIds_.resize(newFacei);
774 MeshReference::clearOut();
787 bool changed =
false;
793 const label maxPointi = this->
points().
size();
798 Face&
f = faceLst[facei];
801 if (
f.collapse() >= 3)
803 for (
const label vert :
f)
805 if (vert < 0 || vert >= maxPointi)
809 <<
" uses point indices outside point range 0.."
827 <<
"face[" << facei <<
"] = " <<
f
828 <<
" does not have three unique vertices" <<
endl;
845 const Face&
f = faceLst[facei];
849 const labelList& neighbours = fFaces[facei];
853 for (
const label neiFacei : neighbours)
855 if (neiFacei <= facei ||
faceMap[neiFacei] < 0)
862 const Face& nei = faceLst[neiFacei];
871 <<
"faces share the same vertices:" <<
nl
872 <<
" face[" << facei <<
"] : " <<
f <<
nl
873 <<
" face[" << neiFacei <<
"] : " << nei <<
endl;
899 if (changed || newFacei < faceLst.
size())
906 <<
"Removed " << faceLst.
size() - newFacei
907 <<
" illegal faces." <<
endl;
916 if (newFacei != facei)
918 faceLst[newFacei] = std::move(faceLst[facei]);
933 faceIds_[facei] = faceIds_[
faceMap[facei]];
936 faceIds_.resize(newFacei);
944 MeshReference::clearOut();
954 return MeshReference::size();
974 for (
const auto&
f : faceLst)
976 nTri +=
f.nTriangles();
980 if (nTri <= faceLst.
size())
995 label
n = faceLst[facei].nTriangles();
1054 for (
const auto&
f : faceLst)
1056 const label
n =
f.nTriangles();
1065 if (nTri <= faceLst.
size())
1071 this->storedFaceIds().clear();
1076 if (this->
points().empty())
1083 const Face&
f = faceLst[facei];
1085 for (label fp = 1; fp <
f.
size() - 1; ++fp)
1089 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1104 const face&
f = faceLst[facei];
1107 f.triangles(this->
points(), nTmp, tmpTri);
1108 for (label triI = 0; triI < nTmp; triI++)
1110 newFaces[nTri] = Face
1121 nTri -= faceLst.
size();
1127 MeshReference::clearOut();
1141 const pointField& locPoints = this->localPoints();
1142 const List<Face>& locFaces = this->localFaces();
1151 oldToNew[pointMap[pointi]] = pointi;
1155 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1158 for (
auto&
f : newFaces)
1160 for (label& vert :
f)
1162 vert = oldToNew[vert];
1174 for (surfZone& zone : newZones)
1177 origEndi += zone.size();
1180 zone.start() = newFacei;
1182 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1184 if (
faceMap[facei] < origEndi)
1195 zone.size() = newFacei - zone.start();
1201 if (faceIds_.size())
1207 MeshedSurface<Face> newSurf;
1208 newSurf.storedFaces().transfer(newFaces);
1209 newSurf.storedPoints().transfer(newPoints);
1210 newSurf.storedZones().transfer(newZones);
1211 newSurf.storedFaceIds().transfer(newFaceIds);
1226 this->subsetMeshMap(include, pointMap,
faceMap);
1227 return this->subsetMeshImpl(pointMap,
faceMap);
1240 this->subsetMeshMap(include, pointMap,
faceMap);
1241 return this->subsetMeshImpl(pointMap,
faceMap);
1253 return this->subsetMesh(include, pointMap,
faceMap);
1265 return this->subsetMesh(include, pointMap,
faceMap);
1276 bitSet include(this->size());
1289 include.
set(zones_[zonei].
range());
1292 return this->subsetMesh(include);
1307 MeshReference::clearOut();
1324 MeshReference::clearOut();
1326 this->storedPoints().transfer(pointLst);
1327 this->storedFaces().transfer(faceLst);
1328 this->storedZones().clear();
1329 this->storedFaceIds().clear();
1344 MeshReference::clearOut();
1369 if (zoneLst.
size() > 1)
1379 faceLst.
swap(sortedFaces);
1391 this->swap(newSurf);
1406 MeshReference::clearOut();
1408 this->storedFaceIds().clear();
1410 this->storedFaces().swap(faces);
1412 this->checkZones(
false);
1420 MeshReference::movePoints(
points);
1422 this->storedPoints().swap(
points);
1439 const word& fileType
1443 transfer(*
New(
name, fileType));
1452 const word& surfName
1472 this->storedPoints() = surf.
points();
1474 this->storedFaceIds() = surf.
faceIds();
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
bool found(const Key &key) const
Return true if hashed entry is found in table.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
The IOstreamOption is a simple container for options an IOstream can normally have.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
static void write(const fileName &name, const MeshedSurfaceProxy &surf, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null)
Write to file, select based on its extension.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
surfZoneList & storedZones()
Non-const access to the zones.
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format? Also checks proxy types.
labelList & storedFaceIds()
Non-const access to face ids.
const surfZoneList & surfZones() const
Const access to the surface zones.
pointField & storedPoints()
Non-const access to global points.
virtual void addZones(const UList< surfZone > &, const bool cullEmpty=false)
Add surface zones.
static wordHashSet writeTypes()
Known writable file-types, without friends or proxies.
virtual void remapFaces(const labelUList &faceMapNewToOld)
Set new zones from faceMap.
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format? Also checks friend types.
virtual void cleanup(const bool verbose)
Remove invalid faces.
virtual ~MeshedSurface()
Destructor.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
void swapPoints(pointField &points)
Swap the stored points.
virtual void compactPoints(labelList &pointMap=const_cast< labelList & >(labelList::null()))
Remove unused points and renumber faces in local visit order.
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
const labelList & faceIds() const
Return const access to faces ids.
const List< Face > & surfFaces() const
Return const access to the faces.
autoPtr< MeshedSurface< Face > > releaseGeom()
Release (clear) geometry and return for reuse.
virtual label nTriangles() const
Count number of triangles.
List< Face > & storedFaces()
Non-const access to the faces.
void transcribe(MeshedSurface< face > &surf)
Transfer points/zones from 'face' to other other shapes.
void swap(MeshedSurface< Face > &surf)
Swap contents.
virtual void clear()
Clear all storage.
virtual bool stitchFaces(const scalar tol=SMALL, const bool verbose=false)
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
friend class MeshedSurface
virtual bool checkFaces(const bool verbose=false)
void operator=(const MeshedSurface< Face > &surf)
Copy assignment.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
const Field< point_type > & points() const noexcept
Return reference to global points.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
virtual bool read()
Re-read model coefficients if they have changed.
A List obtained as a section of another List.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word timeName(const scalar t, const int precision=precision_)
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
label size() const noexcept
The number of elements in the 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.
virtual void clear()
Clear all storage.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
virtual bool write()
Write the output fields.
void movePoints()
Update for new mesh geometry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
label nInternalFaces() const noexcept
Number of internal faces.
transferModelList & transfer()
Transfer.
A surface mesh consisting of general polygon faces that has IO capabilities and a registry for storin...
A surface zone on a MeshedSurface.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
word ext() const
Return file name extension (part after last .)
word lessExt() const
Return word without extension (part before last .)
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Geometric merging of points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
label checkTopology(const polyMesh &mesh, const bool allTopology, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, autoPtr< coordSetWriter > &setWriter)
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool equal(const T &s1, const T &s2)
Compare two values for equality.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
label inplaceMergePoints(PointList &points, const scalar mergeTol, const bool verbose, labelList &pointToUnique)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< surfZone > surfZoneList
errorManipArg< error, int > exit(error &err, const int errNo=1)
UIndirectList< label > labelUIndList
UIndirectList of labels.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.