Commit 9f61b912 authored by laurence's avatar laurence
Browse files

ENH: Add enum and featurePointEdges.

parent 057eff0e
......@@ -446,6 +446,7 @@ int main(int argc, char *argv[])
edgeDirections,
edgeNormals,
labelListList(0), // featurePointNormals,
labelListList(0), // featurePointEdges,
labelList(0) // regionEdges
);
......
......@@ -39,6 +39,42 @@ License
defineTypeNameAndDebug(Foam::extendedFeatureEdgeMesh, 0);
template<>
const char* Foam::NamedEnum
<
Foam::extendedFeatureEdgeMesh::pointStatus,
4
>::names[] =
{
"convex",
"concave",
"mixed",
"nonFeature"
};
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::pointStatus, 4>
Foam::extendedFeatureEdgeMesh::pointStatusNames_;
template<>
const char* Foam::NamedEnum
<
Foam::extendedFeatureEdgeMesh::edgeStatus,
6
>::names[] =
{
"external",
"internal",
"flat",
"open",
"multiple",
"none"
};
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::edgeStatus, 6>
Foam::extendedFeatureEdgeMesh::edgeStatusNames_;
Foam::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ =
Foam::cos(degToRad(0.1));
......@@ -72,6 +108,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
edgeDirections_(0),
edgeNormals_(0),
featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
......@@ -108,6 +145,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
>> normals_
>> edgeNormals_
>> featurePointNormals_
>> featurePointEdges_
>> regionEdges_;
close();
......@@ -160,6 +198,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(fem.edgeDirections()),
edgeNormals_(fem.edgeNormals()),
featurePointNormals_(fem.featurePointNormals()),
featurePointEdges_(fem.featurePointEdges()),
regionEdges_(fem.regionEdges()),
pointTree_(),
edgeTree_(),
......@@ -187,6 +226,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0),
edgeNormals_(0),
featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
......@@ -225,15 +265,13 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0),
edgeNormals_(0),
featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
edgeTreesByType_()
{
// Extract and reorder the data from surfaceFeatures
const triSurface& surf = sFeat.surface();
const labelList& featureEdges = sFeat.featureEdges();
const labelList& featurePoints = sFeat.featurePoints();
......@@ -273,6 +311,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0),
edgeNormals_(0),
featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0),
pointTree_(),
edgeTree_(),
......@@ -304,6 +343,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
const vectorField& edgeDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
)
:
......@@ -320,6 +360,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(edgeDirections),
edgeNormals_(edgeNormals),
featurePointNormals_(featurePointNormals),
featurePointEdges_(featurePointEdges),
regionEdges_(regionEdges),
pointTree_(),
edgeTree_(),
......@@ -1268,6 +1309,8 @@ bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
<< edgeNormals_ << nl
<< "// featurePointNormals" << nl
<< featurePointNormals_ << nl
<< "// featurePointEdges" << nl
<< featurePointEdges_ << nl
<< "// regionEdges" << nl
<< regionEdges_
<< endl;
......
......@@ -93,6 +93,8 @@ public:
NONFEATURE // Not a feature point
};
static const Foam::NamedEnum<pointStatus, 4> pointStatusNames_;
enum edgeStatus
{
EXTERNAL, // "Convex" edge
......@@ -104,6 +106,9 @@ public:
// surfaceFeatures)
};
static const Foam::NamedEnum<edgeStatus, 6> edgeStatusNames_;
private:
// Static data
......@@ -155,6 +160,10 @@ private:
// (only valid for 0..nonFeatureStart_-1)
labelListList featurePointNormals_;
//- Indices of feature edges attached to feature points. The edges are
// ordered so that they can be circulated.
labelListList featurePointEdges_;
//- Feature edges which are on the boundary between regions
labelList regionEdges_;
......@@ -202,6 +211,7 @@ public:
//- Number of possible feature edge types (i.e. number of slices)
static label nEdgeTypes;
// Constructors
//- Construct (read) given an IOobject
......@@ -260,6 +270,7 @@ public:
const vectorField& edgeDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
);
......@@ -381,6 +392,11 @@ public:
//- Return the normal vectors for a given feature point
inline vectorField featurePointNormals(label ptI) const;
//- Return the edge labels for a given feature point. Edges are
// ordered by the faces that they share. The edge labels
// correspond to the entry in edges().
inline const labelListList& featurePointEdges() const;
//- Return the feature edges which are on the boundary between
// regions
inline const labelList& regionEdges() const;
......
......@@ -115,7 +115,7 @@ inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection
}
else
{
FatalErrorIn("Foam::extendedFeatureEdgeMesh::edgedirection")
FatalErrorIn("Foam::extendedFeatureEdgeMesh::edgeDirection")
<< "Requested ptI " << ptI << " is not a point on the requested "
<< "edgeI " << edgeI << ". edgeI start and end: "
<< e.start() << " " << e.end()
......@@ -191,6 +191,13 @@ inline Foam::vectorField Foam::extendedFeatureEdgeMesh::featurePointNormals
}
inline const Foam::labelListList&
Foam::extendedFeatureEdgeMesh::featurePointEdges() const
{
return featurePointEdges_;
}
inline const Foam::labelList& Foam::extendedFeatureEdgeMesh::regionEdges() const
{
return regionEdges_;
......
......@@ -43,6 +43,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
const edgeList& sFeatEds(surf.edges());
const labelListList& edgeFaces = surf.edgeFaces();
const vectorField& faceNormals = surf.faceNormals();
const labelListList& pointEdges = surf.pointEdges();
// Extract and reorder the data from surfaceFeatures
......@@ -51,6 +52,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// Filling the extendedFeatureEdgeMesh with the raw geometrical data.
label nFeatEds = featureEdges.size();
label nFeatPts = featurePoints.size();
DynamicList<point> tmpPts;
edgeList eds(nFeatEds);
......@@ -59,6 +61,14 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
labelListList edgeNormals(nFeatEds);
DynamicList<label> regionEdges;
// Keep track of the ordered feature point feature edges
labelListList featurePointFeatureEdges(nFeatPts);
forAll(featurePointFeatureEdges, pI)
{
featurePointFeatureEdges[pI] =
labelList(pointEdges[featurePoints[pI]].size(), -1);
}
// Mapping between old and new indices, there is entry in the map for each
// of surf.localPoints, -1 means that this point hasn't been used (yet),
// >= 0 corresponds to the index
......@@ -82,7 +92,6 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// All feature points have been added
nonFeatureStart_ = tmpPts.size();
PackedBoolList isRegionFeatureEdge(regionFeatureEdges);
forAll(featureEdges, i)
......@@ -147,8 +156,43 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
{
regionEdges.append(i);
}
forAll(featurePointFeatureEdges, pI)
{
const labelList& fpfEdges = pointEdges[featurePoints[pI]];
labelList& fpfe = featurePointFeatureEdges[pI];
forAll(fpfEdges, eI)
{
if (sFEI == fpfEdges[eI])
{
fpfe[eI] = i;
}
}
}
}
forAll(featurePointFeatureEdges, pI)
{
const labelList& fpfe = featurePointFeatureEdges[pI];
DynamicList<label> newFeatureEdges(fpfe.size());
forAll(fpfe, eI)
{
const label edgeIndex = fpfe[eI];
if (edgeIndex != -1)
{
newFeatureEdges.append(edgeIndex);
}
}
featurePointFeatureEdges[pI] = newFeatureEdges;
}
// Reorder the edges by classification
List<DynamicList<label> > allEds(nEdgeTypes);
......@@ -222,6 +266,11 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
inplaceReorder(edMap, edgeNormals);
inplaceRenumber(edMap, regionEdges);
forAll(featurePointFeatureEdges, pI)
{
inplaceRenumber(edMap, featurePointFeatureEdges[pI]);
}
pointField pts(tmpPts);
// Initialise the edgeMesh
......@@ -301,6 +350,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
}
inplaceReorder(ptMap, pts);
inplaceReorder(ptMap, featurePointFeatureEdges);
forAll(eds, i)
{
......@@ -311,6 +361,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// renumbered edges
reset(xferMove(pts), xferMove(eds));
// Generate the featurePointNormals
labelListList featurePointNormals(nonFeatureStart_);
......@@ -319,7 +370,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
{
DynamicList<label> tmpFtPtNorms;
const labelList& ptEds = pointEdges()[i];
const labelList& ptEds = edgeMesh::pointEdges()[i];
forAll(ptEds, j)
{
......@@ -359,6 +410,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
}
featurePointNormals_ = featurePointNormals;
featurePointEdges_ = featurePointFeatureEdges;
}
......
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