Split algorithm can not work correctly

I have one TopoDS_Face——A,as picture 1.
I have several TopoDS_Face——sequence B.
Sequence B can be sewwed into a whole shell,as picture 2.
What they look like when they combined together,as picture 3.
I made B sequence into a TopTools_ListOfShape,and I name it list B.
I split A using list B,expecting A will be splitted into two parts,but it does not.
I tried several APIs corresponding with split , for example BRepAlgoAPI_Splitter,BRepFeat_SplitShape,BOPAlgo_Builder,but it is still wrong.
It is one piece of code below.

TopTools_ListOfShape RemeshVTKCellManager::splittedShapesFromTwoFaces(const TopoDS_Face& inputFace, const TopTools_ListOfShape& inputList)
{
    BRepAlgoAPI_Splitter fuseBuilder;
    fuseBuilder.SetNonDestructive(Standard_True);
    fuseBuilder.SetRunParallel(Standard_True);
    TopTools_ListOfShape inputFaces;
    inputFaces.Append(inputFace);
    fuseBuilder.SetArguments(inputFaces);
    fuseBuilder.SetTools(inputList);
    fuseBuilder.Build();
    if (fuseBuilder.HasErrors() || fuseBuilder.HasWarnings())
    {
        std::stringstream errorStream;
        fuseBuilder.DumpErrors(errorStream);
        SPDLOG_DEBUG("errorStream : {}", errorStream.str());
        std::stringstream warningStream;
        fuseBuilder.DumpWarnings(warningStream);
        SPDLOG_DEBUG("warningStream : {}", warningStream.str());
    }
    const TopoDS_Shape resultShape = fuseBuilder.Shape();
    TopTools_ListOfShape resultList;
    for (TopExp_Explorer ex(resultShape,TopAbs_FACE);ex.More();ex.Next())
    {
        resultList.Append(TopoDS::Face(ex.Current()));
    }
    return resultList;
}

And the result is shown as picture4,just as you look,it is the same as picture1.
It is not the result what I want.
I want to know how to make it work correctly.

Mikhail Sazonov's picture

Hi,

Your shape has too large tolerance that is larger then the width of a piece of face A that must be cut off.

Let's see the section curve. The corner vertex distance from it is 0.0087 (red line on the picture).

But the tolerance of that vertex is 0.011. Moreover, the tolerance of the bottom edge is 0.01. It means it covers the intersection curve completely, therefore the algorithm considers that this edge can be used instead of the section edge. And, consequently, the face is not split.

If we reduce tolerance down to 0.001 then split operation works. See the result:

Jihui Cong's picture

How did you get the tolerance of shapes?
How did you reduce the tolerance?

Jihui Cong's picture

Is this what you have done?

ShapeFix_ShapeTolerance tolerancer;
TopoDS_Face currentFace = TopoDS::Face(copyTool.Shape());
tolerancer.LimitTolerance(currentFace, 0.0001, 0.0001, TopAbs_VERTEX);
tolerancer.LimitTolerance(currentFace, 0.0001, 0.0001, TopAbs_EDGE);
tolerancer.SetTolerance(currentFace, 0.0001, TopAbs_VERTEX);
tolerancer.SetTolerance(currentFace, 0.0001, TopAbs_EDGE);
Mikhail Sazonov's picture

I did not wrote a line of code. I used Draw commands tolerance, settolerance. Programmatically, you can use what you mentioned.

Jihui Cong's picture

Thank you