Tue, 12/14/2010 - 06:51
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
{
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.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();
}
Tue, 12/14/2010 - 14:12
I had a similar problem, no solution unless you try to change the tessellation tolerance.
Wed, 12/15/2010 - 03:48
i try modify tessellation tolerance, but no right effect
Tue, 12/14/2010 - 17:19
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
Wed, 12/15/2010 - 03:50
i can't use BRepBuilderAPI_MakeFace,because this is a test for funtion of my soft.
Sat, 04/16/2011 - 13:40
help, please