A display error of TopoDS_Face, redundant triangle

Construct a face with a hole, displays a triangle excess.
So, I think it's mesh error, Some people come across this problem?

void pts2Wires(const vector& pts, TopoDS_Wire& wire)
{
BRepBuilderAPI_MakeWire MWire;
for(int j = 0; j {
gp_Pnt p1(pts[j].X(), pts[j].Y(), pts[j].Z());
gp_Pnt p2(pts[j+1].X(), pts[j+1].Y(), pts[j+1].Z());
if(p1.IsEqual(p2, 0.0000000001))
continue;

TopoDS_Edge Edgeline = BRepBuilderAPI_MakeEdge(p1, p2);
MWire.Add(Edgeline);
}

wire = MWire.Wire();
}

void wire2Face(const TopoDS_Wire& wire, TopoDS_Face& face)
{
BRepBuilderAPI_MakeFace mkf(wire);

if(!mkf.IsDone())
return ;

face = mkf.Face();
}

void Surface()
{
AIS_ListOfInteractive aList;
myAISContext->DisplayedObjects(aList);
AIS_ListIteratorOfListOfInteractive aListIterator;
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
myAISContext->Remove(aListIterator.Value());
}

vector ptsOut, ptsHole;
ptsOut.push_back(gp_Pnt(0,5,0));
ptsOut.push_back(gp_Pnt(25,5,0));
ptsOut.push_back(gp_Pnt(25,0,0));
ptsOut.push_back(gp_Pnt(20,0,0));
ptsOut.push_back(gp_Pnt(20,-2,0));
ptsOut.push_back(gp_Pnt(15,-2,0));
ptsOut.push_back(gp_Pnt(15,0,0));
ptsOut.push_back(gp_Pnt(10,0,0));
ptsOut.push_back(gp_Pnt(10,-2,0));
ptsOut.push_back(gp_Pnt(5,-2,0));
ptsOut.push_back(gp_Pnt(5,0,0));
ptsOut.push_back(gp_Pnt(0,0,0));
ptsOut.push_back(gp_Pnt(0,5,0));

ptsHole.push_back(gp_Pnt(1,4,0));
ptsHole.push_back(gp_Pnt(24,4,0));
ptsHole.push_back(gp_Pnt(24,1,0));
ptsHole.push_back(gp_Pnt(19,1,0));
ptsHole.push_back(gp_Pnt(19,-1,0));
ptsHole.push_back(gp_Pnt(16,-1,0));
ptsHole.push_back(gp_Pnt(16,1,0));
ptsHole.push_back(gp_Pnt(9,1,0));
ptsHole.push_back(gp_Pnt(9,-1,0));
ptsHole.push_back(gp_Pnt(6,-1,0));
ptsHole.push_back(gp_Pnt(6,1,0));
ptsHole.push_back(gp_Pnt(1,1,0));
ptsHole.push_back(gp_Pnt(1,4,0));

TopoDS_Wire wOut,wHole;
pts2Wires(ptsOut, wOut);
pts2Wires(ptsHole, wHole);

TopoDS_Face fOut,fHole;
wire2Face(wOut, fOut);
wire2Face(wHole, fHole);

BRepAlgoAPI_Cut cut(fOut, fHole);

TopoDS_Shape S;
if(cut.IsDone())
{
S = cut.Shape();
}

Handle(AIS_Shape) ais1 = new AIS_Shape(S);
myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
myAISContext->Display(ais1,Standard_False);
Fit();
}

QbProg's picture

I had a similar problem, no solution unless you try to change the tessellation tolerance.

hoya5121's picture

i try modify tessellation tolerance, but no right effect

Stephane Routelous's picture

don't use boolean operations for creating a hole
instead :
BRepBuilderAPI_MakeFace mkf(wOut);
mkf.Add(wHole);
TopoDS_Shape S = mkf.Face();

you just have to check the orientation (direction) of the inner wire for the hole is reversed wrt the outer one.

Stephane

hoya5121's picture

i can't use BRepBuilderAPI_MakeFace,because this is a test for funtion of my soft.

hoya5121's picture

help, please