Commit 7f32509a authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: additional surface-related typedefs

- face_type, point_type (similar to STL value_type, etc).
  The naming avoids potential confusion with template parameters.

- rename private typedef from ParentType to MeshReference for more
  consistency with polySurface etc.
parent 74bc5f32
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,10 +29,10 @@ Description
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H"
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "primitiveFacePatch.H"
#include "primitivePatch.H"
#include "Fstream.H"
......@@ -39,15 +40,10 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PrimitivePatch<face, List, const pointField&> myPrimitivePatch;
void writeObj(Ostream& os,const pointField& points)
void writeObj(Ostream& os, const pointField& points)
{
forAll(points, pointi)
for (const point& pt : points)
{
const point& pt = points[pointi];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
}
......@@ -227,7 +223,7 @@ int main(int argc, char *argv[])
// Test addressing
{
myPrimitivePatch pp(patch, patch.points());
primitiveFacePatch pp(patch, patch.points());
const pointField& localPoints = pp.localPoints();
const faceList& localFaces = pp.localFaces();
......@@ -250,8 +246,8 @@ int main(int argc, char *argv[])
// Move construct
{
faceList patchFaces = patch;
pointField allPoints = patch.points();
faceList patchFaces(patch);
pointField allPoints(patch.points());
PrimitivePatch<face, List, pointField, point> storedPatch
(
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -96,14 +96,26 @@ class PrimitivePatch
public:
// Public typedefs
// Public Typedefs
typedef Face FaceType;
//- The face type
typedef Face face_type;
//- The point type
typedef PointType point_type;
//- The face list type
typedef FaceList<Face> FaceListType;
//- The point field type
typedef PointField PointFieldType;
//- Deprecated(2020-03) prefer face_type typedef
// \deprecated(2020-03) prefer face_type typedef
typedef Face FaceType;
// Public data types
// Public Data Types
//- Enumeration defining the surface type. Used in check routines.
enum surfaceTopo
......@@ -115,7 +127,7 @@ public:
private:
// Private data
// Private Data
//- Reference to global list of points
PointField points_;
......
......@@ -166,7 +166,7 @@ void Foam::MeshedSurface<Face>::write
template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface()
:
ParentType(List<Face>(), pointField()),
MeshReference(List<Face>(), pointField()),
zones_()
{}
......@@ -177,7 +177,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const MeshedSurface<Face>& surf
)
:
ParentType(surf.surfFaces(), surf.points()),
MeshReference(surf.surfFaces(), surf.points()),
zones_(surf.zones_)
{}
......@@ -188,7 +188,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UnsortedMeshedSurface<Face>& surf
)
:
ParentType(List<Face>(), surf.points()) // Copy points only
MeshReference(List<Face>(), surf.points()) // Copy points only
{
labelList faceMap;
this->storedZones() = surf.sortedZones(faceMap);
......@@ -237,7 +237,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UList<surfZone>& zoneLst
)
:
ParentType(faceLst, pointLst), // Copy construct
MeshReference(faceLst, pointLst), // Copy construct
zones_(zoneLst)
{}
......@@ -250,7 +250,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UList<surfZone>& zoneLst
)
:
ParentType(faceLst, pointLst, true), // Move construct
MeshReference(faceLst, pointLst, true), // Move construct
zones_(zoneLst)
{}
......@@ -264,7 +264,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UList<word>& zoneNames
)
:
ParentType(faceLst, pointLst), // Copy construct
MeshReference(faceLst, pointLst), // Copy construct
zones_()
{
if (zoneSizes.size())
......@@ -290,7 +290,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
const UList<word>& zoneNames
)
:
ParentType(faceLst, pointLst, true), // Move construct
MeshReference(faceLst, pointLst, true), // Move construct
zones_()
{
if (zoneSizes.size())
......@@ -555,7 +555,7 @@ void Foam::MeshedSurface<Face>::remapFaces
template<class Face>
void Foam::MeshedSurface<Face>::clear()
{
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
storedPoints().clear();
storedFaces().clear();
......@@ -566,10 +566,10 @@ void Foam::MeshedSurface<Face>::clear()
template<class Face>
void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
{
ParentType::clearGeom(); // Changes areas, normals etc.
MeshReference::clearGeom(); // Changes areas, normals etc.
// Adapt for new point position
ParentType::movePoints(newPoints);
MeshReference::movePoints(newPoints);
// Copy new points
storedPoints() = newPoints;
......@@ -582,12 +582,12 @@ void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor)
// Avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
ParentType::clearGeom(); // Changes areas, normals etc.
MeshReference::clearGeom(); // Changes areas, normals etc.
pointField newPoints(scaleFactor*this->points());
// Adapt for new point position
ParentType::movePoints(newPoints);
MeshReference::movePoints(newPoints);
storedPoints() = std::move(newPoints);
}
......@@ -683,7 +683,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
faceMap.clear();
// Topology can change when points are merged, etc
ParentType::clearOut();
MeshReference::clearOut();
return true;
}
......@@ -842,7 +842,7 @@ bool Foam::MeshedSurface<Face>::checkFaces
faceMap.clear();
// Topology can change because of renumbering
ParentType::clearOut();
MeshReference::clearOut();
return changed;
}
......@@ -852,7 +852,7 @@ Foam::label Foam::MeshedSurface<Face>::nTriangles() const
{
if (faceTraits<Face>::isTri())
{
return ParentType::size();
return MeshReference::size();
}
return nTriangles
......@@ -1035,7 +1035,7 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
faceMap.clear();
// Topology can change because of renumbering
ParentType::clearOut();
MeshReference::clearOut();
return nTri;
}
......@@ -1206,7 +1206,7 @@ void Foam::MeshedSurface<Face>::swap
return; // Self-swap is a no-op
}
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
surf.clearOut(); // Topology changes
this->storedPoints().swap(surf.storedPoints());
......@@ -1222,7 +1222,7 @@ void Foam::MeshedSurface<Face>::transfer
List<Face>& faceLst
)
{
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
this->storedPoints().transfer(pointLst);
this->storedFaces().transfer(faceLst);
......@@ -1241,7 +1241,7 @@ void Foam::MeshedSurface<Face>::transfer
return; // Self-assigment is a no-op
}
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
this->storedPoints().transfer(surf.storedPoints());
this->storedFaces().transfer(surf.storedFaces());
......@@ -1302,7 +1302,7 @@ Foam::MeshedSurface<Face>::releaseGeom()
template<class Face>
void Foam::MeshedSurface<Face>::swapFaces(List<Face>& faces)
{
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
this->storedFaces().swap(faces);
}
......@@ -1311,7 +1311,7 @@ void Foam::MeshedSurface<Face>::swapFaces(List<Face>& faces)
template<class Face>
void Foam::MeshedSurface<Face>::swapPoints(pointField& points)
{
ParentType::clearOut(); // Topology changes
MeshReference::clearOut(); // Topology changes
this->storedPoints().swap(points);
}
......
......@@ -105,14 +105,9 @@ private:
// Private Typedefs (convenience)
typedef PrimitivePatch
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
//- Internal mesh storage type
typedef PrimitivePatch<Face, ::Foam::List, pointField, point>
MeshReference;
typedef UnsortedMeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType;
......@@ -160,7 +155,7 @@ protected:
//- Non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
return const_cast<pointField&>(MeshReference::points());
}
//- Non-const access to the faces
......@@ -191,8 +186,11 @@ public:
// Public Typedefs
//- Face type used
typedef Face FaceType;
//- The face type (same as the underlying PrimitivePatch)
typedef Face face_type;
//- The point type (same as the underlying PrimitivePatch)
typedef point point_type;
//- Declare type-name (with debug switch)
......@@ -382,7 +380,7 @@ public:
//- The surface size is the number of faces
label size() const
{
return ParentType::size();
return MeshReference::size();
}
//- Return const access to the faces
......@@ -402,19 +400,19 @@ public:
//- Face area vectors (normals)
const vectorField& Sf() const
{
return ParentType::faceAreas();
return MeshReference::faceAreas();
}
//- Face area magnitudes
const scalarField& magSf() const
{
return ParentType::magFaceAreas();
return MeshReference::magFaceAreas();
}
//- Face centres
const vectorField& Cf() const
{
return ParentType::faceCentres();
return MeshReference::faceCentres();
}
......
......@@ -77,8 +77,11 @@ public:
// Public Typedefs
//- Face type used
typedef Face FaceType;
//- The face type
typedef Face face_type;
//- The point type
typedef point point_type;
//- Declare type-name (with debug switch)
......
......@@ -60,7 +60,7 @@ bool Foam::UnsortedMeshedSurface<Face>::canReadType
{
return fileFormats::surfaceFormatsCore::checkSupport
(
readTypes() | ParentType::readTypes(),
readTypes() | MeshReference::readTypes(),
ext,
verbose,
"reading"
......@@ -161,7 +161,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface()
:
ParentType()
MeshReference()
{}
......@@ -171,7 +171,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const UnsortedMeshedSurface<Face>& surf
)
:
ParentType(surf.points(), surf.surfFaces()), // Copy construct (no zones)
MeshReference(surf.points(), surf.surfFaces()), // Copy construct (no zones)
zoneIds_(surf.zoneIds()),
zoneToc_(surf.zoneToc())
{}
......@@ -183,7 +183,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const MeshedSurface<Face>& surf
)
:
ParentType(surf.points(), surf.surfFaces()), // Copy construct (no zones)
MeshReference(surf.points(), surf.surfFaces()), // Copy construct (no zones)
zoneIds_(),
zoneToc_()
{
......@@ -224,7 +224,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
UList<surfZoneIdentifier>& tocInfo
)
:
ParentType(std::move(pointLst), std::move(faceLst)),
MeshReference(std::move(pointLst), std::move(faceLst)),
zoneIds_(std::move(zoneIds)),
zoneToc_(tocInfo)
{}
......@@ -487,7 +487,7 @@ void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::clear()
{
ParentType::clear();
MeshReference::clear();
zoneIds_.clear();
zoneToc_.clear();
}
......@@ -720,7 +720,7 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
)
{
surfZoneList zoneInfo(surf.surfZones());
ParentType::transfer(surf);
MeshReference::transfer(surf);
setZones(zoneInfo);
}
......
......@@ -96,7 +96,7 @@ private:
// Private Typedefs (convenience)
typedef MeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> MeshReference;
typedef MeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType;
......@@ -161,8 +161,11 @@ public:
// Public Typedefs
//- Face type used
typedef Face FaceType;
//- The face type (same as the underlying PrimitivePatch)
typedef Face face_type;
//- The point type (same as the underlying PrimitivePatch)
typedef point point_type;
//- Declare type-name, virtual type (with debug switch)
......@@ -315,7 +318,7 @@ public:
//- The surface size is the number of faces
label size() const
{
return ParentType::size();
return MeshReference::size();
}
//- Reset size of face and zone list
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -49,13 +49,13 @@ Foam::UnsortedMeshedSurface<Face>::New
if (!cstrIter.found())
{
// No direct reader, delegate to parent if possible
const wordHashSet& delegate = ParentType::readTypes();
const wordHashSet& delegate = MeshReference::readTypes();
if (delegate.found(ext))
{
// Create indirectly
auto surf = autoPtr<UnsortedMeshedSurface<Face>>::New();
surf().transfer(*(ParentType::New(name, ext)));
surf().transfer(*(MeshReference::New(name, ext)));
return surf;
}
......
......@@ -52,7 +52,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class dimensionSet;
class surfZone;
class polySurfaceGeoMesh;
......@@ -87,14 +87,9 @@ private:
// Private Typedefs
typedef PrimitivePatch
<
face,
::Foam::List,
pointField,
point
>
MeshReference;
//- Internal mesh storage type
typedef PrimitivePatch<face, ::Foam::List, pointField, point>
MeshReference;
// Private Data
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,7 +66,7 @@ bool Foam::triSurface::readSTL(const fileName& filename, bool forceBinary)
const labelList& zoneIds = reader.zoneIds();
pointField& pointLst = storedPoints();
List<Face>& faceLst = storedFaces();
List<face_type>& faceLst = storedFaces();
// Sizing
pointLst.setSize(nUniquePoints);
......@@ -80,14 +80,14 @@ bool Foam::triSurface::readSTL(const fileName& filename, bool forceBinary)
// Assign triangles
label pointi = 0;
forAll(faceLst, i)
forAll(faceLst, facei)
{
Face& f = faceLst[i];
auto& f = faceLst[facei];
f[0] = pointMap[pointi++];
f[1] = pointMap[pointi++];
f[2] = pointMap[pointi++];
f.region() = zoneIds[i];
f.region() = zoneIds[facei];
}
// Set patch name/index.
......
......@@ -156,7 +156,7 @@ void Foam::triSurface::checkTriangles(const bool verbose)
// Simple check on indices ok.
const label maxPointi = points().size() - 1;
for (const triSurface::FaceType& f : *this)
for (const auto& f : *this)
{
for (const label verti : f)
{
......@@ -403,7 +403,7 @@ void Foam::triSurface::setDefaultPatches()
Foam::triSurface::triSurface()
:
ParentType(List<Face>(), pointField()),
MeshReference(List<labelledTri>(), pointField()),
patches_(),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -412,7 +412,7 @@ Foam::triSurface::triSurface()
Foam::triSurface::triSurface(const triSurface& surf)
:
ParentType(surf, surf.points()),
MeshReference(surf, surf.points()),
patches_(surf.patches()),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -434,7 +434,7 @@ Foam::triSurface::triSurface
const pointField& pts
)
:
ParentType(triangles, pts),
MeshReference(triangles, pts),
patches_(patches),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -449,7 +449,7 @@ Foam::triSurface::triSurface
const bool reuse
)
:
ParentType(triangles, pts, reuse),
MeshReference(triangles, pts, reuse),
patches_(patches),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -462,7 +462,7 @@ Foam::triSurface::triSurface
const pointField& pts
)
:
ParentType(triangles, pts),
MeshReference(triangles, pts),
patches_(),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -477,7 +477,7 @@ Foam::triSurface::triSurface
const pointField& pts
)
:
ParentType(convertToTri(triangles, 0), pts),
MeshReference(convertToTri(triangles, 0), pts),
patches_(),
sortedEdgeFacesPtr_(nullptr),
edgeOwnerPtr_(nullptr)
......@@ -523,7 +523,7 @@ Foam::triSurface::~triSurface()
void Foam::triSurface::clearTopology()
{
ParentType::clearTopology();
MeshReference::clearTopology();
sortedEdgeFacesPtr_.reset(nullptr);
edgeOwnerPtr_.reset(nullptr);
}
......@@ -531,13 +531,13 @@ void Foam::triSurface::clearTopology()
void Foam::triSurface::clearPatchMeshAddr()
{
ParentType::clearPatchMeshAddr();
MeshReference::clearPatchMeshAddr();
}
void Foam::triSurface::clearOut()
<