diff --git a/src/edgeMesh/Make/options b/src/edgeMesh/Make/options index e69de29bb2..280bd02ef2 100644 --- a/src/edgeMesh/Make/options +++ b/src/edgeMesh/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lmeshTools + + diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C index 88d748d439..9045ae5cd9 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C @@ -25,37 +25,39 @@ License \*---------------------------------------------------------------------------*/ #include "featureEdgeMesh.H" +#include "Random.H" +#include "meshTools.H" +#include "linePointRef.H" +#include "OFstream.H" +#include "IFstream.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) : - edgeMesh(io) + edgeMesh(io), + normals_(), + edgeNormals_(edges().size()), + allEdges_(identity(edges().size())) + {} Foam::featureEdgeMesh::featureEdgeMesh ( const IOobject& io, - const pointField& points, - const edgeList& edges + const pointField& pts, + const edgeList& eds, + const vectorField& normals ) : - edgeMesh(io, points, edges) + edgeMesh(io, pts, eds), + normals_(normals), + edgeNormals_(edges().size()), + allEdges_(identity(edges().size())) {} -Foam::featureEdgeMesh::featureEdgeMesh -( - const IOobject& io, - const edgeMesh& em -) -: - edgeMesh(io, em) -{} - - - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::featureEdgeMesh::~featureEdgeMesh() @@ -65,8 +67,83 @@ Foam::featureEdgeMesh::~featureEdgeMesh() // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // +void Foam::featureEdgeMesh::nearestFeatureEdge +( + const pointField& samples, + scalarField searchDistSqr, + labelList& edgeLabel, + pointField& edgePoint, + labelListList& adjacentNormals +) const +{ + edgeLabel.setSize(samples.size()); + edgePoint.setSize(samples.size()); + adjacentNormals.setSize(samples.size()); + + forAll(samples, i) + { + const point& sample = samples[i]; + + pointIndexHit pHit = edgeTree().findNearest + ( + sample, + searchDistSqr[i] + ); + + if (!pHit.hit()) + { + edgeLabel[i] = -1; + } + else + { + edgeLabel[i] = allEdges_[pHit.index()]; + edgePoint[i] = pHit.hitPoint(); + adjacentNormals[i] = edgeNormals_[edgeLabel[i]]; + } + } +} + + +const Foam::indexedOctree& +Foam::featureEdgeMesh::edgeTree() const +{ + if (edgeTree_.empty()) + { + Random rndGen(17301893); + + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox bb + ( + treeBoundBox(points()).extend(rndGen, 1E-4) + ); + + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + + edgeTree_.reset + ( + new indexedOctree + ( + treeDataEdge + ( + false, // cachebb + edges(), // edges + points(), // points + allEdges_ // selected edges + ), + bb, // bb + 8, // maxLevel + 10, // leafsize + 3.0 // duplicity + ) + ); + } + + return edgeTree_(); +} + // ************************************************************************* // diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H index bd96b68cb4..9addecb458 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H @@ -27,6 +27,22 @@ Class Description + 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) + 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 + + SourceFiles featureEdgeMeshI.H featureEdgeMesh.C @@ -37,6 +53,9 @@ SourceFiles #define featureEdgeMesh_H #include "edgeMesh.H" +#include "indexedOctree.H" +#include "treeDataEdge.H" +#include "pointIndexHit.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,8 +70,69 @@ class featureEdgeMesh : public edgeMesh { + +public: + + 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 feature edge (consistency with surfaceFeatures) + }; + +private: + // 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_; + + //- 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_; + + //- Indices of all edges, pre-calculated and stored + labelField allEdges_; + + //- Search tree for edges. + mutable autoPtr > edgeTree_; + + // Private Member Functions //- Disallow default bitwise copy construct @@ -69,16 +149,15 @@ public: //- Construct (read) given an IOobject featureEdgeMesh(const IOobject&); - //- Construct from edgeMesh data + //- Construct from edgeMesh data and featureEdgeMesh ( - const IOobject&, - const pointField&, - const edgeList& + const IOobject& io, + const pointField& pts, + const edgeList& eds, + const vectorField& normals ); - //- Construct as copy - featureEdgeMesh(const IOobject&, const edgeMesh&); //- Destructor ~featureEdgeMesh(); @@ -86,8 +165,27 @@ public: // Member Functions + // Find + + //- Find nearest surface edge for each sample point. + void nearestFeatureEdge + ( + const pointField& samples, + scalarField searchDistSqr, + labelList& edgeLabel, + pointField& edgePoint, + labelListList& adjacentNormals + ) const; + // Access + //- Return the normals of the surfaces adjacent to the feature edges + // and points + inline const vectorField& normals() const; + + //- Demand driven contruction of octree for boundary edges + const indexedOctree& edgeTree() const; + // Check // Edit diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 0e08c13c27..67e4fd7816 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -1097,8 +1097,9 @@ Foam::Map Foam::surfaceFeatures::nearestEdges // Step to next sample point using local distance. // Truncate to max 1/minSampleDist samples per feature edge. -// s += max(minSampleDist*eMag, sampleDist[e.start()]); -s += 0.01*eMag; + + // s += max(minSampleDist*eMag, sampleDist[e.start()]); + s += 0.01*eMag; if (s >= (1-minSampleDist)*eMag) {