Commit 84fa233c authored by mattijs's avatar mattijs
Browse files

ENH: featureEdgeMesh : merged dev_cvm functionality.

parent 455b8868
EXE_INC = \
-I$(LIB_SRC)/cfdTools/general/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \
-lmeshTools \
-ledgeMesh \
-ltriSurface
......@@ -29,10 +29,13 @@ Description
\*---------------------------------------------------------------------------*/
#include "triangle.H"
#include "triSurface.H"
#include "argList.H"
#include "Time.H"
#include "surfaceFeatures.H"
#include "featureEdgeMesh.H"
#include "treeBoundBox.H"
#include "meshTools.H"
#include "OFstream.H"
......@@ -135,7 +138,8 @@ int main(int argc, char *argv[])
"remove edges within specified bounding box"
);
argList args(argc, argv);
# include "setRootCase.H"
# include "createTime.H"
Info<< "Feature line extraction is only valid on closed manifold surfaces."
<< endl;
......@@ -282,7 +286,6 @@ int main(int argc, char *argv[])
Info<< endl << "Writing edge objs." << endl;
newSet.writeObj("final");
Info<< nl
<< "Final feature set:" << nl
<< " feature points : " << newSet.featurePoints().size() << nl
......@@ -293,6 +296,22 @@ int main(int argc, char *argv[])
<< " internal edges : " << newSet.nInternalEdges() << nl
<< endl;
// Extracting and writing a featureEdgeMesh
Pout<< nl << "Writing featureEdgeMesh to constant/featureEdgeMesh."
<< endl;
featureEdgeMesh feMesh
(
newSet,
runTime,
surfFileName.lessExt().name() + ".featureEdgeMesh"
);
feMesh.writeObj(surfFileName.lessExt().name());
feMesh.write();
Info<< "End\n" << endl;
return 0;
......
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-ltriSurface \
-lmeshTools \
-lfileFormats
......@@ -387,14 +387,4 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist)
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::edgeMesh::operator=(const edgeMesh& rhs)
{
points_ = rhs.points_;
edges_ = rhs.edges_;
pointEdgesPtr_.clear();
}
// ************************************************************************* //
......@@ -69,4 +69,14 @@ inline Foam::edgeList& Foam::edgeMesh::storedEdges()
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::edgeMesh::operator=(const edgeMesh& rhs)
{
points_ = rhs.points_;
edges_ = rhs.edges_;
pointEdgesPtr_.clear();
}
// ************************************************************************* //
......@@ -25,9 +25,27 @@ Class
Foam::featureEdgeMesh
Description
features (lines), readable from file
Feature points are a sorted subset at the start of the overall points list:
0 .. concaveStart_-1 : convex points (w.r.t normals)
concaveStart_-1 .. mixedStart_-1 : concave points
mixedStart_ .. nonFeatureStart_ : mixed internal/external points
nonFeatureStart_ .. size-1 : non-feature points
Feature edges are the edgeList of the edgeMesh and are sorted:
0 .. internalStart_-1 : external edges (convex w.r.t normals)
internalStart_ .. flatStart_-1 : internal edges (concave)
flatStart_ .. openStart_-1 : flat edges (neither concave or convex)
can arise from region interfaces on
flat surfaces
openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces)
multipleStart_ .. size-1 : multiply connected edges
The edge direction and feature edge and feature point adjacent normals
are stored.
SourceFiles
featureEdgeMeshI.H
featureEdgeMesh.C
\*---------------------------------------------------------------------------*/
......@@ -36,7 +54,12 @@ SourceFiles
#define featureEdgeMesh_H
#include "edgeMesh.H"
#include "regIOobject.H"
#include "surfaceFeatures.H"
#include "objectRegistry.H"
#include "IOdictionary.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "pointIndexHit.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -58,11 +81,115 @@ public:
//- Runtime type information
TypeName("featureEdgeMesh");
enum pointStatus
{
CONVEX, // Fully convex point (w.r.t normals)
CONCAVE, // Fully concave point
MIXED, // A point surrounded by both convex and concave edges
NONFEATURE // Not a feature point
};
enum edgeStatus
{
EXTERNAL, // "Convex" edge
INTERNAL, // "Concave" edge
FLAT, // Neither concave or convex, on a flat surface
OPEN, // i.e. only connected to one face
MULTIPLE, // Multiply connected (connected to more than two faces)
NONE // Not a classified feature edge (consistency with
// surfaceFeatures)
};
private:
// Static data
//- Angular closeness tolerance for treating normals as the same
static scalar cosNormalAngleTol_;
//- Index of the start of the convex feature points - static as 0
static label convexStart_;
//- Index of the start of the external feature edges - static as 0
static label externalStart_;
// Private data
//- Index of the start of the concave feature points
label concaveStart_;
//- Index of the start of the mixed type feature points
label mixedStart_;
//- Index of the start of the non-feature points
label nonFeatureStart_;
//- Index of the start of the internal feature edges
label internalStart_;
//- Index of the start of the flat feature edges
label flatStart_;
//- Index of the start of the open feature edges
label openStart_;
//- Index of the start of the multiply-connected feature edges
label multipleStart_;
//- Normals of the features, to be referred to by index by both feature
// points and edges, unsorted
vectorField normals_;
//- Flat and open edges require the direction of the edge
vectorField edgeDirections_;
//- Indices of the normals that are adjacent to the feature edges
labelListList edgeNormals_;
//- Indices of the normals that are adjacent to the feature points
labelListList featurePointNormals_;
//- Feature edges which are on the boundary between regions
labelList regionEdges_;
//- Search tree for all edges
mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
//- Individual search trees for each type of edge
mutable PtrList<indexedOctree<treeDataEdge> > edgeTreesByType_;
// Private Member Functions
//- Classify the type of feature point. Requires valid stored member
// data for edges and normals.
pointStatus classifyFeaturePoint(label ptI) const;
//- Classify the type of feature edge. Requires face centre 0 to face
// centre 1 vector to distinguish internal from external
edgeStatus classifyEdge
(
const List<vector>& norms,
const labelList& edNorms,
const vector& fC0tofC1
) const;
public:
// Static data
//- Number of possible point types (i.e. number of slices)
static label nPointTypes;
//- Number of possible feature edge types (i.e. number of slices)
static label nEdgeTypes;
// Constructors
//- Construct (read) given an IOobject
explicit featureEdgeMesh(const IOobject&);
featureEdgeMesh(const IOobject&);
//- Construct as copy
explicit featureEdgeMesh(const IOobject&, const featureEdgeMesh&);
......@@ -75,14 +202,157 @@ public:
const Xfer<edgeList>&
);
//- Give precedence to the regIOobject write
using regIOobject::write;
//- Construct (read) given surfaceFeatures, an objectRegistry and a
// fileName to write to. Extracts, classifies and reorders the data
// from surfaceFeatures.
featureEdgeMesh
(
const surfaceFeatures& sFeat,
const objectRegistry& obr,
const fileName& sFeatFileName
);
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- Construct from all components
featureEdgeMesh
(
const IOobject& io,
const pointField& pts,
const edgeList& eds,
label concaveStart,
label mixedStart,
label nonFeatureStart,
label internalStart,
label flatStart,
label openStart,
label multipleStart,
const vectorField& normals,
const vectorField& edgeDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelList& regionEdges
);
//- Destructor
~featureEdgeMesh();
// Member Functions
// Find
//- Find nearest surface edge for the sample point.
void nearestFeatureEdge
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for each sample point.
void nearestFeatureEdge
(
const pointField& samples,
const scalarField& searchDistSqr,
List<pointIndexHit>& info
) const;
//- Find the nearest point on each type of feature edge
void nearestFeatureEdgeByType
(
const point& sample,
const scalarField& searchDistSqr,
List<pointIndexHit>& info
) const;
// Access
//- Return the index of the start of the convex feature points
inline label convexStart() const;
//- Return the index of the start of the concave feature points
inline label concaveStart() const;
//- Return the index of the start of the mixed type feature points
inline label mixedStart() const;
//- Return the index of the start of the non-feature points
inline label nonFeatureStart() const;
//- Return the index of the start of the external feature edges
inline label externalStart() const;
//- Return the index of the start of the internal feature edges
inline label internalStart() const;
//- Return the index of the start of the flat feature edges
inline label flatStart() const;
//- Return the index of the start of the open feature edges
inline label openStart() const;
//- Return the index of the start of the multiply-connected feature
// edges
inline label multipleStart() const;
//- Return whether or not the point index is a feature point
inline bool featurePoint(label ptI) const;
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
//- Return the normals of the surfaces adjacent to the feature edges
// and points
inline const vectorField& normals() const;
//- Return the edgeDirection vectors
inline const vectorField& edgeDirections() const;
//- Return the direction of edgeI, pointing away from ptI
inline vector edgeDirection(label edgeI, label ptI) const;
//- Return the indices of the normals that are adjacent to the
// feature edges
inline const labelListList& edgeNormals() const;
//- Return the normal vectors for a given set of normal indices
inline vectorField edgeNormals(const labelList& edgeNormIs) const;
//- Return the normal vectors for a given edge
inline vectorField edgeNormals(label edgeI) const;
//- Return the indices of the normals that are adjacent to the
// feature points
inline const labelListList& featurePointNormals() const;
//- Return the normal vectors for a given feature point
inline vectorField featurePointNormals(label ptI) const;
//- Return the feature edges which are on the boundary between
// regions
inline const labelList& regionEdges() const;
//- Return the pointStatus of a specified point
inline pointStatus getPointStatus(label ptI) const;
//- Return the edgeStatus of a specified edge
inline edgeStatus getEdgeStatus(label edgeI) const;
//- Demand driven construction of octree for boundary edges
const indexedOctree<treeDataEdge>& edgeTree() const;
//- Demand driven construction of octree for boundary edges by type
const PtrList<indexedOctree<treeDataEdge> >&
edgeTreesByType() const;
// Write
//- Write all components of the featureEdgeMesh as obj files
void writeObj(const fileName& prefix) const;
//- Give precedence to the regIOobject write
using regIOobject::write;
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
};
......@@ -92,6 +362,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "featureEdgeMeshI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment