Shape Healing - how to remove small strip faces


I'm trying to use the Shape Healing package to remove some tiny strip faces. I've included the code that I'm using below. The shape I get back after calling ShapeFix_FixSmallFace::FixStripFace() is NULL so I assumed it was deleted. However the number of faces in my solid doesn't change.

Can anyone see the error or problem with my logic?

Thank you,
Blair Downie

TopoDS_Shape FixSmallStripFaces(TopoDS_Shape theShape)
ShapeAnalysis_CheckSmallFace chkSmallFace;
ShapeFix_FixSmallFace aFixSmallFace;
double thePrec = 1.0e-03;
ShapeAnalysis_ShapeContents shContents;
int after, before = shContents.NbFaces();

TopExp_Explorer fExp;
fExp.Init(theShape, TopAbs_FACE);
for ( ; fExp.More(); fExp.Next() ) {
TopoDS_Face cf = TopoDS::Face(fExp.Current());
TopoDS_Edge E1,E2;
if (chkSmallFace.CheckStripFace (cf,E1,E2,thePrec)) {
TopoDS_Shape aResShape = aFixSmallFace.Shape();
if (aResShape.IsNull()) {
printf("Face was deleted!");
after = shContents.NbFaces();
return theShape;


Lahiru Dilshan's picture

Try to use the following code snippet

TopoDS_Shape resShape = aFixSmallFaec.FixShape();

After removing strip faces from your geometry, the "resShape" will give you the resultant shape. Ensure the tolerance value you give the API is larger enough to identify the defect shapes.

Check this code snippet and let me know the result as well.

Blair Downie's picture

Thanks for the input. It seems that calling Perform() before FixShape() was the key!!

I have a follow up question.

Rather than iterating over all the faces, I called the FixSmallFace operator on just the
input shape.

TopoDS_Shape resShape = aFixSmallFaec.FixShape();

When I checked the number of faces in the new shape 'resShape', it had 6 fewer faces.
I also modified my routine to return the new shape. However when I did the same check in the calling routine.
it had the original number of faces. Is there an additonal call that needs to be made in order to apply the changes and
update the shape before I return from the FixSmallStripFaces function?

Thank you.

Lahiru Dilshan's picture

Try to use a larger tolerance value.

Blair Downie's picture

The issue that I'm having is with the result.

TopoDS_Shape resShape = aFixSmallFace.FixShape();

The small faces do get removed from resShape. I then return the shape to my calling routine. However when I process the shape
in the calling routine the small faces are still there. I don't understand how a larger tolerance would help? Thank you.