Using surfaceFeatures to identify and store feature edges, planning to use nearestSurfEdge to identify where to place feature edge constraining points.

This commit is contained in:
graham
2008-08-27 18:58:33 +01:00
parent 955c6354b5
commit 14a575e8a3
7 changed files with 75 additions and 72 deletions

View File

@ -85,8 +85,8 @@ public:
//- The feature angle used to select corners to be //- The feature angle used to select corners to be
// explicitly represented in the mesh. // explicitly represented in the mesh.
// 0 = all features, 180 = no features // 0 = no features, 180 = all features
scalar featAngle; scalar includedAngle;
//- Maximum quadrant angle allowed at a concave corner before //- Maximum quadrant angle allowed at a concave corner before
// additional "mitering" lines are added // additional "mitering" lines are added

View File

@ -61,12 +61,42 @@ int main(int argc, char *argv[])
// Read the surface to conform to // Read the surface to conform to
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
querySurface surf(args.args()[1]); querySurface surf
(
args.args()[1],
readScalar(controlDict.lookup("includedAngle"))
);
Info<< nl Info<< nl
<< "Read surface with " << surf.size() << " triangles from file " << "Read surface with " << surf.size() << " triangles from file "
<< args.args()[1] << nl << endl; << args.args()[1] << nl << endl;
surf.features().writeObj("features");
pointField samples(3);
samples[0] = point(0.9, 0.9, 0.9);
samples[1] = point(0.85, 0.2, 0.2);
samples[2] = point(-0.1, -0.1, 0.25);
labelList edgeLabel;
labelList edgeEndPoint;
pointField edgePoint;
surf.features().nearestSurfEdge
(
surf.features().featureEdges(),
samples,
vector(0.25, 0.25, 0.25),
edgeLabel,
edgeEndPoint,
edgePoint
);
Info<< edgeLabel
<< nl << edgeEndPoint
<< nl << edgePoint << endl;
// Read and triangulation // Read and triangulation
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~

View File

@ -32,7 +32,7 @@ Foam::CV3D::controls::controls(const dictionary& controlDict)
: :
minCellSize(readScalar(controlDict.lookup("minCellSize"))), minCellSize(readScalar(controlDict.lookup("minCellSize"))),
minCellSize2(Foam::sqr(minCellSize)), minCellSize2(Foam::sqr(minCellSize)),
featAngle(readScalar(controlDict.lookup("featureAngle"))), includedAngle(readScalar(controlDict.lookup("includedAngle"))),
maxQuadAngle(readScalar(controlDict.lookup("maxQuadAngle"))), maxQuadAngle(readScalar(controlDict.lookup("maxQuadAngle"))),
insertSurfaceNearestPointPairs insertSurfaceNearestPointPairs
( (

View File

@ -38,17 +38,10 @@ void Foam::CV3D::insertFeaturePoints()
const edgeList& edges = qSurf_.edges(); const edgeList& edges = qSurf_.edges();
const pointField& localPts = qSurf_.localPoints(); const pointField& localPts = qSurf_.localPoints();
labelList featPoints(0); const labelList& featPoints = qSurf_.features().featurePoints();
labelListList featPointFeatEdges(0); labelListList featPointFeatEdges = qSurf_.featurePointFeatureEdges();
qSurf_.extractFeatures scalar planeErrorAngle = 0.1*(180.0 - controls_.includedAngle);
(
controls_.featAngle,
featPoints,
featPointFeatEdges
);
scalar planeErrorAngle = 0.1*controls_.featAngle;
scalar planeErrorAngleCos = cos(mathematicalConstant::pi*planeErrorAngle/180.0); scalar planeErrorAngleCos = cos(mathematicalConstant::pi*planeErrorAngle/180.0);
@ -57,7 +50,7 @@ void Foam::CV3D::insertFeaturePoints()
label ptI = featPoints[i]; label ptI = featPoints[i];
const point& featPt = localPts[ptI]; const point& featPt = localPts[ptI];
Info<< nl <<"Feature at " << featPt << endl;; Info<< nl <<"Feature at " << featPt << endl;
const labelList& featEdges = featPointFeatEdges[i]; const labelList& featEdges = featPointFeatEdges[i];

View File

@ -207,7 +207,7 @@ void Foam::CV3D::insertSurfaceNearestPointPairs()
} }
} }
if (!internalFeatureEdge && dualCellSurfaceIntersection(vit)) if (!internalFeatureEdge && dualCellSurfaceIntersection(vit))
{ {
nearSurfacePoints.append(vert); nearSurfacePoints.append(vert);
surfacePoints.append(pHit.hitPoint()); surfacePoints.append(pHit.hitPoint());

View File

@ -29,7 +29,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::querySurface::querySurface(const fileName& surfaceFileName) Foam::querySurface::querySurface
(
const fileName& surfaceFileName,
const scalar& includedAngle
)
: :
triSurface(surfaceFileName), triSurface(surfaceFileName),
rndGen_(12345), rndGen_(12345),
@ -41,7 +45,8 @@ Foam::querySurface::querySurface(const fileName& surfaceFileName)
8, // maxLevel 8, // maxLevel
4, //10, // leafsize 4, //10, // leafsize
10.0 //3.0 // duplicity 10.0 //3.0 // duplicity
) ),
sFeat_(*this, includedAngle)
{} {}
@ -53,71 +58,41 @@ Foam::querySurface::~querySurface()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::querySurface::extractFeatures Foam::labelListList Foam::querySurface::featurePointFeatureEdges() const
(
const scalar featAngle,
labelList& featPoints,
labelListList& featPointFeatEdges
) const
{ {
scalar featCos = cos(mathematicalConstant::pi*featAngle/180.0); const labelList& featPoints = features().featurePoints();
const labelListList& edgeFaces = this->edgeFaces(); const labelList& featEdges = features().featureEdges();
const labelListList& pointEdges = this->pointEdges();
const pointField& localPoints = this->localPoints();
// const edgeList& edges = this->edges();
const vectorField& faceNormals = this->faceNormals();
DynamicList<label> tempFeatPoints(localPoints.size()); const edgeList& edges = this->edges();
DynamicList<DynamicList<label> > tempFeatPointFeatEdges(localPoints.size()); List<DynamicList<label> > tempFeatPointFeatEdges(featPoints.size());
forAll(pointEdges, ptI) forAll(featPoints, pI)
{ {
// const point& p = localPoints[ptI]; label fP = featPoints[pI];
// const vector& pNormal = pointNormals[ptI]; forAll(featEdges, eI)
const labelList& pEdges = pointEdges[ptI];
DynamicList<label> tempFeatEdges(0);
forAll(pEdges, pE)
{ {
label edgeI = pEdges[pE]; label fE = featEdges[eI];
const labelList& eFaces = edgeFaces[edgeI]; const edge& e(edges[fE]);
if if (e.start() == fP || e.end() == fP)
(
eFaces.size() == 2
&& (faceNormals[eFaces[0]] & faceNormals[eFaces[1]]) < featCos
)
{ {
tempFeatEdges.append(edgeI); tempFeatPointFeatEdges[pI].append(fE);
} }
} }
tempFeatEdges.shrink();
if(tempFeatEdges.size() > 2)
{
tempFeatPoints.append(ptI);
tempFeatPointFeatEdges.append(tempFeatEdges);
}
} }
featPoints.transfer(tempFeatPoints.shrink()); labelListList featPointFeatEdges(tempFeatPointFeatEdges.size());
tempFeatPointFeatEdges.shrink();
featPointFeatEdges.setSize(tempFeatPointFeatEdges.size());
forAll(featPointFeatEdges, fPFE) forAll(featPointFeatEdges, fPFE)
{ {
featPointFeatEdges[fPFE].transfer(tempFeatPointFeatEdges[fPFE].shrink()); featPointFeatEdges[fPFE].transfer(tempFeatPointFeatEdges[fPFE].shrink());
} }
return featPointFeatEdges;
} }
Foam::indexedOctree<Foam::treeDataTriSurface>::volumeType Foam::indexedOctree<Foam::treeDataTriSurface>::volumeType

View File

@ -39,6 +39,7 @@ SourceFiles
#include "triSurface.H" #include "triSurface.H"
#include "treeDataTriSurface.H" #include "treeDataTriSurface.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "surfaceFeatures.H"
#include "Random.H" #include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -64,6 +65,8 @@ class querySurface
// Search engine on surface // Search engine on surface
indexedOctree<treeDataTriSurface> tree_; indexedOctree<treeDataTriSurface> tree_;
surfaceFeatures sFeat_;
// Private Member Functions // Private Member Functions
@ -79,7 +82,11 @@ public:
// Constructors // Constructors
//- Construct given file name of the surface //- Construct given file name of the surface
querySurface(const fileName& surfaceFileName); querySurface
(
const fileName& surfaceFileName,
const scalar& includedAngle
);
// Destructor // Destructor
@ -101,17 +108,15 @@ public:
return tree_; return tree_;
} }
const surfaceFeatures& features() const
{
return sFeat_;
}
// Query // Query
//- Extract feature edges/points labelListList featurePointFeatureEdges() const;
// using the given feature angle in deg
void extractFeatures
(
const scalar featAngle,
labelList& featPoints,
labelListList& featPointFeatEdges
) const;
//- Returns inside, outside or mixed (= close to surface) //- Returns inside, outside or mixed (= close to surface)
indexedOctree<Foam::treeDataTriSurface>::volumeType insideOutside indexedOctree<Foam::treeDataTriSurface>::volumeType insideOutside