ENH: Add enum and featurePointEdges.

This commit is contained in:
laurence
2012-12-11 17:08:27 +00:00
parent 057eff0e59
commit 9f61b9123b
5 changed files with 125 additions and 6 deletions

View File

@ -446,6 +446,7 @@ int main(int argc, char *argv[])
edgeDirections, edgeDirections,
edgeNormals, edgeNormals,
labelListList(0), // featurePointNormals, labelListList(0), // featurePointNormals,
labelListList(0), // featurePointEdges,
labelList(0) // regionEdges labelList(0) // regionEdges
); );

View File

@ -39,6 +39,42 @@ License
defineTypeNameAndDebug(Foam::extendedFeatureEdgeMesh, 0); 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::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ =
Foam::cos(degToRad(0.1)); Foam::cos(degToRad(0.1));
@ -72,6 +108,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
edgeDirections_(0), edgeDirections_(0),
edgeNormals_(0), edgeNormals_(0),
featurePointNormals_(0), featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0), regionEdges_(0),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
@ -108,6 +145,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
>> normals_ >> normals_
>> edgeNormals_ >> edgeNormals_
>> featurePointNormals_ >> featurePointNormals_
>> featurePointEdges_
>> regionEdges_; >> regionEdges_;
close(); close();
@ -160,6 +198,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(fem.edgeDirections()), edgeDirections_(fem.edgeDirections()),
edgeNormals_(fem.edgeNormals()), edgeNormals_(fem.edgeNormals()),
featurePointNormals_(fem.featurePointNormals()), featurePointNormals_(fem.featurePointNormals()),
featurePointEdges_(fem.featurePointEdges()),
regionEdges_(fem.regionEdges()), regionEdges_(fem.regionEdges()),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
@ -187,6 +226,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0), edgeDirections_(0),
edgeNormals_(0), edgeNormals_(0),
featurePointNormals_(0), featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0), regionEdges_(0),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
@ -225,15 +265,13 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0), edgeDirections_(0),
edgeNormals_(0), edgeNormals_(0),
featurePointNormals_(0), featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0), regionEdges_(0),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
edgeTreesByType_() edgeTreesByType_()
{ {
// Extract and reorder the data from surfaceFeatures // Extract and reorder the data from surfaceFeatures
const triSurface& surf = sFeat.surface(); const triSurface& surf = sFeat.surface();
const labelList& featureEdges = sFeat.featureEdges(); const labelList& featureEdges = sFeat.featureEdges();
const labelList& featurePoints = sFeat.featurePoints(); const labelList& featurePoints = sFeat.featurePoints();
@ -273,6 +311,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(0), edgeDirections_(0),
edgeNormals_(0), edgeNormals_(0),
featurePointNormals_(0), featurePointNormals_(0),
featurePointEdges_(0),
regionEdges_(0), regionEdges_(0),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
@ -304,6 +343,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
const vectorField& edgeDirections, const vectorField& edgeDirections,
const labelListList& edgeNormals, const labelListList& edgeNormals,
const labelListList& featurePointNormals, const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges const labelList& regionEdges
) )
: :
@ -320,6 +360,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
edgeDirections_(edgeDirections), edgeDirections_(edgeDirections),
edgeNormals_(edgeNormals), edgeNormals_(edgeNormals),
featurePointNormals_(featurePointNormals), featurePointNormals_(featurePointNormals),
featurePointEdges_(featurePointEdges),
regionEdges_(regionEdges), regionEdges_(regionEdges),
pointTree_(), pointTree_(),
edgeTree_(), edgeTree_(),
@ -1268,6 +1309,8 @@ bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
<< edgeNormals_ << nl << edgeNormals_ << nl
<< "// featurePointNormals" << nl << "// featurePointNormals" << nl
<< featurePointNormals_ << nl << featurePointNormals_ << nl
<< "// featurePointEdges" << nl
<< featurePointEdges_ << nl
<< "// regionEdges" << nl << "// regionEdges" << nl
<< regionEdges_ << regionEdges_
<< endl; << endl;

View File

@ -93,6 +93,8 @@ public:
NONFEATURE // Not a feature point NONFEATURE // Not a feature point
}; };
static const Foam::NamedEnum<pointStatus, 4> pointStatusNames_;
enum edgeStatus enum edgeStatus
{ {
EXTERNAL, // "Convex" edge EXTERNAL, // "Convex" edge
@ -104,6 +106,9 @@ public:
// surfaceFeatures) // surfaceFeatures)
}; };
static const Foam::NamedEnum<edgeStatus, 6> edgeStatusNames_;
private: private:
// Static data // Static data
@ -155,6 +160,10 @@ private:
// (only valid for 0..nonFeatureStart_-1) // (only valid for 0..nonFeatureStart_-1)
labelListList featurePointNormals_; 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 //- Feature edges which are on the boundary between regions
labelList regionEdges_; labelList regionEdges_;
@ -202,6 +211,7 @@ public:
//- Number of possible feature edge types (i.e. number of slices) //- Number of possible feature edge types (i.e. number of slices)
static label nEdgeTypes; static label nEdgeTypes;
// Constructors // Constructors
//- Construct (read) given an IOobject //- Construct (read) given an IOobject
@ -260,6 +270,7 @@ public:
const vectorField& edgeDirections, const vectorField& edgeDirections,
const labelListList& edgeNormals, const labelListList& edgeNormals,
const labelListList& featurePointNormals, const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges const labelList& regionEdges
); );
@ -381,6 +392,11 @@ public:
//- Return the normal vectors for a given feature point //- Return the normal vectors for a given feature point
inline vectorField featurePointNormals(label ptI) const; 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 //- Return the feature edges which are on the boundary between
// regions // regions
inline const labelList& regionEdges() const; inline const labelList& regionEdges() const;

View File

@ -115,7 +115,7 @@ inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection
} }
else else
{ {
FatalErrorIn("Foam::extendedFeatureEdgeMesh::edgedirection") FatalErrorIn("Foam::extendedFeatureEdgeMesh::edgeDirection")
<< "Requested ptI " << ptI << " is not a point on the requested " << "Requested ptI " << ptI << " is not a point on the requested "
<< "edgeI " << edgeI << ". edgeI start and end: " << "edgeI " << edgeI << ". edgeI start and end: "
<< e.start() << " " << e.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 inline const Foam::labelList& Foam::extendedFeatureEdgeMesh::regionEdges() const
{ {
return regionEdges_; return regionEdges_;

View File

@ -43,6 +43,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
const edgeList& sFeatEds(surf.edges()); const edgeList& sFeatEds(surf.edges());
const labelListList& edgeFaces = surf.edgeFaces(); const labelListList& edgeFaces = surf.edgeFaces();
const vectorField& faceNormals = surf.faceNormals(); const vectorField& faceNormals = surf.faceNormals();
const labelListList& pointEdges = surf.pointEdges();
// Extract and reorder the data from surfaceFeatures // Extract and reorder the data from surfaceFeatures
@ -51,6 +52,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// Filling the extendedFeatureEdgeMesh with the raw geometrical data. // Filling the extendedFeatureEdgeMesh with the raw geometrical data.
label nFeatEds = featureEdges.size(); label nFeatEds = featureEdges.size();
label nFeatPts = featurePoints.size();
DynamicList<point> tmpPts; DynamicList<point> tmpPts;
edgeList eds(nFeatEds); edgeList eds(nFeatEds);
@ -59,6 +61,14 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
labelListList edgeNormals(nFeatEds); labelListList edgeNormals(nFeatEds);
DynamicList<label> regionEdges; 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 // 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), // of surf.localPoints, -1 means that this point hasn't been used (yet),
// >= 0 corresponds to the index // >= 0 corresponds to the index
@ -82,7 +92,6 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// All feature points have been added // All feature points have been added
nonFeatureStart_ = tmpPts.size(); nonFeatureStart_ = tmpPts.size();
PackedBoolList isRegionFeatureEdge(regionFeatureEdges); PackedBoolList isRegionFeatureEdge(regionFeatureEdges);
forAll(featureEdges, i) forAll(featureEdges, i)
@ -147,8 +156,43 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
{ {
regionEdges.append(i); 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 // Reorder the edges by classification
List<DynamicList<label> > allEds(nEdgeTypes); List<DynamicList<label> > allEds(nEdgeTypes);
@ -222,6 +266,11 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
inplaceReorder(edMap, edgeNormals); inplaceReorder(edMap, edgeNormals);
inplaceRenumber(edMap, regionEdges); inplaceRenumber(edMap, regionEdges);
forAll(featurePointFeatureEdges, pI)
{
inplaceRenumber(edMap, featurePointFeatureEdges[pI]);
}
pointField pts(tmpPts); pointField pts(tmpPts);
// Initialise the edgeMesh // Initialise the edgeMesh
@ -301,6 +350,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
} }
inplaceReorder(ptMap, pts); inplaceReorder(ptMap, pts);
inplaceReorder(ptMap, featurePointFeatureEdges);
forAll(eds, i) forAll(eds, i)
{ {
@ -311,6 +361,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
// renumbered edges // renumbered edges
reset(xferMove(pts), xferMove(eds)); reset(xferMove(pts), xferMove(eds));
// Generate the featurePointNormals // Generate the featurePointNormals
labelListList featurePointNormals(nonFeatureStart_); labelListList featurePointNormals(nonFeatureStart_);
@ -319,7 +370,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
{ {
DynamicList<label> tmpFtPtNorms; DynamicList<label> tmpFtPtNorms;
const labelList& ptEds = pointEdges()[i]; const labelList& ptEds = edgeMesh::pointEdges()[i];
forAll(ptEds, j) forAll(ptEds, j)
{ {
@ -359,6 +410,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
} }
featurePointNormals_ = featurePointNormals; featurePointNormals_ = featurePointNormals;
featurePointEdges_ = featurePointFeatureEdges;
} }