ENH: cvMeshSurfaceSimplify: make robust for open surfaces

This commit is contained in:
mattijs
2012-03-30 09:23:34 +01:00
parent 50bddce02e
commit 928d81c282
3 changed files with 35 additions and 4 deletions

View File

@ -173,6 +173,8 @@ int main(int argc, char *argv[])
surfaces,
points,
scalarField(points.size(), sqr(GREAT)),
searchableSurface::OUTSIDE, // for non-closed surfaces treat as
// outside
nearestSurfaces,
signedDist
);

View File

@ -693,6 +693,7 @@ void Foam::searchableSurfacesQueries::signedDistance
const labelList& surfacesToTest,
const pointField& samples,
const scalarField& nearestDistSqr,
const searchableSurface::volumeType illegalHandling,
labelList& nearestSurfaces,
scalarField& distance
)
@ -753,9 +754,32 @@ void Foam::searchableSurfacesQueries::signedDistance
}
else
{
FatalErrorIn("signedDistance()")
<< "getVolumeType failure, neither INSIDE or OUTSIDE"
<< exit(FatalError);
switch (illegalHandling)
{
case searchableSurface::OUTSIDE:
{
distance[pointI] = dist;
break;
}
case searchableSurface::INSIDE:
{
distance[pointI] = -dist;
break;
}
default:
{
FatalErrorIn("signedDistance()")
<< "getVolumeType failure,"
<< " neither INSIDE or OUTSIDE."
<< " point:" << surfPoints[i]
<< " surface:"
<< allSurfaces[surfacesToTest[testI]].name()
<< " volType:"
<< searchableSurface::volumeTypeNames[vT]
<< exit(FatalError);
break;
}
}
}
}
}

View File

@ -184,13 +184,18 @@ public:
List<pointIndexHit>&
);
//- Find signed distance to nearest surface
//- Find signed distance to nearest surface. Outside is positive.
// illegalHandling: how to handle non-inside or outside
// OUTSIDE : treat as outside
// INSIDE : treat as inside
// UNKNOWN : throw fatal error
static void signedDistance
(
const PtrList<searchableSurface>& allSurfaces,
const labelList& surfacesToTest,
const pointField& samples,
const scalarField& nearestDistSqr,
const searchableSurface::volumeType illegalHandling,
labelList& nearestSurfaces,
scalarField& distance
);