mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Enhance edgeMesh to support more formats.
Read only support:
.bdf, .nas - NASTRAN format. Handles both CBEAM and CROD as lines.
CROD is what Hypermesh happens to output.
Write only support:
.vtk - VTK legacy format in ASCII
Read/write support:
.eMesh - native format, which is simply a list of points, edges
with an additional IOobject header that lets them be moved about
easily to use as a featureEdgeMesh.
.inp - STAR-CD inp/cel/vrt combination
IOobject header)
.obj - Alias waverfront format
Radically simplify surfaceFeatureConvert by using the new edgeMesh
functionality.
This commit is contained in:
@ -26,6 +26,76 @@ License
|
||||
|
||||
#include "edgeMesh.H"
|
||||
#include "mergePoints.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(edgeMesh, 0);
|
||||
defineRunTimeSelectionTable(edgeMesh, fileExtension);
|
||||
defineMemberFunctionSelectionTable(edgeMesh,write,fileExtension);
|
||||
}
|
||||
|
||||
Foam::wordHashSet Foam::edgeMesh::readTypes()
|
||||
{
|
||||
return wordHashSet(*fileExtensionConstructorTablePtr_);
|
||||
}
|
||||
|
||||
Foam::wordHashSet Foam::edgeMesh::writeTypes()
|
||||
{
|
||||
return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::edgeMesh::canReadType
|
||||
(
|
||||
const word& ext,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
return checkSupport
|
||||
(
|
||||
readTypes(),
|
||||
ext,
|
||||
verbose,
|
||||
"reading"
|
||||
);
|
||||
}
|
||||
|
||||
bool Foam::edgeMesh::canWriteType
|
||||
(
|
||||
const word& ext,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
return checkSupport
|
||||
(
|
||||
writeTypes(),
|
||||
ext,
|
||||
verbose,
|
||||
"writing"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::edgeMesh::canRead
|
||||
(
|
||||
const fileName& name,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
word ext = name.ext();
|
||||
if (ext == "gz")
|
||||
{
|
||||
ext = name.lessExt().ext();
|
||||
}
|
||||
return canReadType(ext, verbose);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -63,10 +133,10 @@ void Foam::edgeMesh::calcPointEdges() const
|
||||
forAll(edges_, edgeI)
|
||||
{
|
||||
const edge& e = edges_[edgeI];
|
||||
const label p0 = e[0];
|
||||
const label p1 = e[1];
|
||||
|
||||
label p0 = e[0];
|
||||
pointEdges[p0][nEdgesPerPoint[p0]++] = edgeI;
|
||||
label p1 = e[1];
|
||||
pointEdges[p1][nEdgesPerPoint[p1]++] = edgeI;
|
||||
}
|
||||
}
|
||||
@ -74,32 +144,102 @@ void Foam::edgeMesh::calcPointEdges() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// construct from components
|
||||
Foam::edgeMesh::edgeMesh(const pointField& points, const edgeList& edges)
|
||||
Foam::edgeMesh::edgeMesh()
|
||||
:
|
||||
points_(points),
|
||||
edges_(edges)
|
||||
{}
|
||||
|
||||
|
||||
// construct as copy
|
||||
Foam::edgeMesh::edgeMesh(const edgeMesh& em)
|
||||
:
|
||||
points_(em.points_),
|
||||
edges_(em.edges_),
|
||||
points_(0),
|
||||
edges_(0),
|
||||
pointEdgesPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::edgeMesh::edgeMesh
|
||||
(
|
||||
const pointField& points,
|
||||
const edgeList& edges
|
||||
)
|
||||
:
|
||||
points_(points),
|
||||
edges_(edges),
|
||||
pointEdgesPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::edgeMesh::edgeMesh
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<edgeList>& edgeLst
|
||||
)
|
||||
:
|
||||
points_(0),
|
||||
edges_(0),
|
||||
pointEdgesPtr_(NULL)
|
||||
{
|
||||
points_.transfer(pointLst());
|
||||
edges_.transfer(edgeLst());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::edgeMesh::~edgeMesh()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::edgeMesh::clear()
|
||||
{
|
||||
points_.clear();
|
||||
edges_.clear();
|
||||
pointEdgesPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
void Foam::edgeMesh::reset
|
||||
(
|
||||
const Xfer< pointField >& pointLst,
|
||||
const Xfer< edgeList >& edgeLst
|
||||
)
|
||||
{
|
||||
// Take over new primitive data.
|
||||
// Optimized to avoid overwriting data at all
|
||||
if (&pointLst)
|
||||
{
|
||||
points_.transfer(pointLst());
|
||||
}
|
||||
|
||||
if (&edgeLst)
|
||||
{
|
||||
edges_.transfer(edgeLst());
|
||||
|
||||
// connectivity likely changed
|
||||
pointEdgesPtr_.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::edgeMesh::transfer(edgeMesh& mesh)
|
||||
{
|
||||
points_.transfer(mesh.points_);
|
||||
edges_.transfer(mesh.edges_);
|
||||
pointEdgesPtr_ = mesh.pointEdgesPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::Xfer< Foam::edgeMesh >
|
||||
Foam::edgeMesh::xfer()
|
||||
{
|
||||
return xferMove(*this);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::edgeMesh::regions(labelList& edgeRegion) const
|
||||
{
|
||||
edgeRegion.setSize(edges_.size());
|
||||
edgeRegion = -1;
|
||||
|
||||
label startEdgeI = 0;
|
||||
|
||||
label currentRegion = 0;
|
||||
|
||||
while (true)
|
||||
@ -159,6 +299,16 @@ Foam::label Foam::edgeMesh::regions(labelList& edgeRegion) const
|
||||
}
|
||||
|
||||
|
||||
void Foam::edgeMesh::scalePoints(const scalar scaleFactor)
|
||||
{
|
||||
// avoid bad scaling
|
||||
if (scaleFactor > 0 && scaleFactor != 1.0)
|
||||
{
|
||||
points_ *= scaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::edgeMesh::mergePoints(const scalar mergeDist)
|
||||
{
|
||||
pointField newPoints;
|
||||
@ -180,7 +330,7 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist)
|
||||
|
||||
points_.transfer(newPoints);
|
||||
|
||||
// Renumber and make sure e[0] < e[1] (not really nessecary)
|
||||
// Renumber and make sure e[0] < e[1] (not really necessary)
|
||||
forAll(edges_, edgeI)
|
||||
{
|
||||
edge& e = edges_[edgeI];
|
||||
@ -243,7 +393,7 @@ void Foam::edgeMesh::operator=(const edgeMesh& rhs)
|
||||
{
|
||||
points_ = rhs.points_;
|
||||
edges_ = rhs.edges_;
|
||||
pointEdgesPtr_.reset(NULL);
|
||||
pointEdgesPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user