BUG: stitchTriangles : work on triSurface points

This commit is contained in:
mattijs
2011-02-02 12:44:02 +00:00
parent 3e6bfa814f
commit e0ee9bcf84
7 changed files with 30 additions and 26 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -331,7 +331,7 @@ bool triSurface::readAC(const fileName& ACfileName)
*this = triSurface(faces, patches, allPoints, true);
stitchTriangles(allPoints);
stitchTriangles();
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -422,6 +422,7 @@ bool triSurface::readSTLASCII(const fileName& STLfileName)
setSize(lexer.nTriangles());
DynamicList<label>& STLlabels = lexer.STLlabels();
// Assign triangles
label pointi = 0;
forAll(*this, i)
{
@ -433,8 +434,11 @@ bool triSurface::readSTLASCII(const fileName& STLfileName)
STLlabels.clear();
// Assign coordinates
storedPoints().transfer(rawPoints);
// Stitch all points within SMALL meters.
stitchTriangles(rawPoints);
stitchTriangles();
// Convert solidNames into regionNames
patches_.setSize(lexer.STLsolidNames().size());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -123,7 +123,11 @@ bool Foam::triSurface::readSTLBINARY(const fileName& STLfileName)
//STLfile.close();
stitchTriangles(rawPoints);
// Assign coordinates
storedPoints().transfer(rawPoints);
// Stitch all points within SMALL meters.
stitchTriangles();
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -138,6 +138,7 @@ bool Foam::triSurface::readTRI(const fileName& TRIfileName)
setSize(STLlabels.size());
// Assign triangles
pointI = 0;
SLList<label>::const_iterator iter = STLlabels.begin();
forAll(*this, i)
@ -149,7 +150,10 @@ bool Foam::triSurface::readTRI(const fileName& TRIfileName)
++iter;
}
stitchTriangles(rawPoints);
// Assign coordinates
storedPoints().transfer(rawPoints);
// Merge duplicate points
stitchTriangles();
// Convert solidNames into regionNames
stringList names(STLsolidNames.toc());

View File

@ -31,30 +31,28 @@ License
bool Foam::triSurface::stitchTriangles
(
const pointField& rawPoints,
const scalar tol,
bool verbose
)
{
pointField& ps = storedPoints();
// Merge points
labelList pointMap;
pointField newPoints;
bool hasMerged = mergePoints(rawPoints, tol, verbose, pointMap, newPoints);
bool hasMerged = mergePoints(ps, tol, verbose, pointMap, newPoints);
if (hasMerged)
{
pointField& ps = storedPoints();
if (verbose)
{
Pout<< "stitchTriangles : Merged from " << ps.size()
<< " points down to " << newPoints.size() << endl;
}
// Set the coordinates to the merged ones
ps.transfer(newPoints);
if (verbose)
{
Pout<< "stitchTriangles : Merged from " << rawPoints.size()
<< " points down to " << ps.size() << endl;
}
// Reset the triangle point labels to the unique points array
label newTriangleI = 0;
forAll(*this, i)
@ -151,11 +149,6 @@ bool Foam::triSurface::stitchTriangles
}
}
}
else
{
// Can happen for e.g. single triangle or cloud of unconnected triangles
storedPoints() = rawPoints;
}
return hasMerged;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -809,7 +809,7 @@ void Foam::triSurface::scalePoints(const scalar scaleFactor)
void Foam::triSurface::cleanup(const bool verbose)
{
// Merge points (already done for STL, TRI)
stitchTriangles(points(), SMALL, verbose);
stitchTriangles(SMALL, verbose);
// Merging points might have changed geometric factors
clearOut();

View File

@ -112,7 +112,6 @@ class triSurface
// Returns true if any points merged
bool stitchTriangles
(
const pointField& rawPoints,
const scalar tol = SMALL,
const bool verbose = false
);