compiler bug

This commit is contained in:
mattijs
2009-03-17 19:58:06 +00:00
parent a760a63411
commit f0bff1d658
2 changed files with 59 additions and 35 deletions

View File

@ -120,6 +120,29 @@ const Foam::fileName& Foam::triSurfaceMesh::checkFile
} }
bool Foam::triSurfaceMesh::addFaceToEdge
(
const edge& e,
EdgeMap<label>& facesPerEdge
)
{
EdgeMap<label>::iterator eFnd = facesPerEdge.find(e);
if (eFnd != facesPerEdge.end())
{
if (eFnd() == 2)
{
return false;
}
eFnd()++;
}
else
{
facesPerEdge.insert(e, 1);
}
return true;
}
bool Foam::triSurfaceMesh::isSurfaceClosed() const bool Foam::triSurfaceMesh::isSurfaceClosed() const
{ {
// Construct pointFaces. Let's hope surface has compact point // Construct pointFaces. Let's hope surface has compact point
@ -142,48 +165,41 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const
const labelledTri& f = triSurface::operator[](pFaces[i]); const labelledTri& f = triSurface::operator[](pFaces[i]);
label fp = findIndex(f, pointI); label fp = findIndex(f, pointI);
// Forward edge // Something weird: if I expand the code of addFaceToEdge in both
{ // below instances it gives a segmentation violation on some
label p1 = f[f.fcIndex(fp)]; // surfaces. Compiler (4.3.2) problem?
if (p1 > pointI)
// Forward edge
label nextPointI = f[f.fcIndex(fp)];
if (nextPointI > pointI)
{
bool okFace = addFaceToEdge
(
edge(pointI, nextPointI),
facesPerEdge
);
if (!okFace)
{ {
const edge e(pointI, p1); return false;
EdgeMap<label>::iterator eFnd = facesPerEdge.find(e);
if (eFnd != facesPerEdge.end())
{
if (eFnd() == 2)
{
return false;
}
eFnd()++;
}
else
{
facesPerEdge.insert(e, 1);
}
} }
} }
// Reverse edge // Reverse edge
{ label prevPointI = f[f.rcIndex(fp)];
label p1 = f[f.rcIndex(fp)];
if (p1 > pointI) if (prevPointI > pointI)
{
bool okFace = addFaceToEdge
(
edge(pointI, prevPointI),
facesPerEdge
);
if (!okFace)
{ {
const edge e(pointI, p1); return false;
EdgeMap<label>::iterator eFnd = facesPerEdge.find(e);
if (eFnd != facesPerEdge.end())
{
if (eFnd() == 2)
{
return false;
}
eFnd()++;
}
else
{
facesPerEdge.insert(e, 1);
}
} }
} }
} }

View File

@ -42,6 +42,7 @@ SourceFiles
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataTriSurface.H" #include "treeDataTriSurface.H"
#include "treeDataEdge.H" #include "treeDataEdge.H"
#include "EdgeMap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -91,6 +92,13 @@ private:
const fileName& objectName const fileName& objectName
); );
//- Helper function for isSurfaceClosed
static bool addFaceToEdge
(
const edge&,
EdgeMap<label>&
);
//- Check whether surface is closed without calculating any permanent //- Check whether surface is closed without calculating any permanent
// addressing. // addressing.
bool isSurfaceClosed() const; bool isSurfaceClosed() const;