Face with internal hole and bounded by a wire, what's wrong?

Hi, I hope someone can help me. I am trying to build a face bounded by a wire, the problem is I am not able to add additional wires as internal holes afterwards. Note that I get the data from another cad system then I have all the trimming curves (i.e. edges) in parameter space (UV). The UV curves I use to build the wires are correct (they form closed loops and are contained in surface parameter domain). This is the code I tried:

Handle (Geom_BSplineSurface) surface;
Handle (Geom2d_BSplineCurve) boundaryCrv1, boundaryCrv2, boundaryCrv3; //these are UV curves
BRepBuilderAPI_MakeWire makeWireBoundary;
TopoDS_Edge boundaryEdge1 = BRepBuilderAPI_MakeEdge(boundaryCrv1, surface);
TopoDS_Edge boundaryEdge2 = BRepBuilderAPI_MakeEdge(boundaryCrv2, surface);
TopoDS_Edge boundaryEdge3 = BRepBuilderAPI_MakeEdge(boundaryCrv3, surface);
makeWireBoundary.Add(boundaryEdge1);
makeWireBoundary.Add(boundaryEdge2);
makeWireBoundary.Add(boundaryEdge3);
//NOTE: following wire is correct, makeWireBoundary.IsDone() returns true on it
TopoDS_Wire wireBoundary = makeWireBoundary; //I tried also = makeWireBoundary.Wire(), nothing changed
BRepBuilderAPI_MakeFace makeFace(surface, wireBoundary);
BRepLib::BuildCurves3d(makeFace); //Is this needed? Anyway nothing changed with or without it
//NOTE: following face is correct (it is bounded by the wire when drawn and BRepAlgo::IsValid(face1) returns true)
TopoDS_Face faceTest = makeFace;

// Now I need to add an internal hole
Handle (Geom2d_BSplineCurve) internalCrv1, internalCrv2; //these are UV curves
BRepBuilderAPI_MakeWire makeWireInternal;
TopoDS_Edge internalEdge1 = BRepBuilderAPI_MakeEdge(internalCrv1, surface);
TopoDS_Edge internalEdge2 = BRepBuilderAPI_MakeEdge(internalCrv2, surface);
makeWireInternal.Add(internalEdge1);
makeWireInternal.Add(internalEdge2);
//NOTE: following wire is also correct, makeWireBoundary.IsDone() returns true on it
TopoDS_Wire wireInternal = makeWireInternal;
makeFace.Add(wireInternal);
TopoDS_Face face = makeFace; //PROBLEM: when this face is drawn the internal hole is missing
Standard_Boolean bIsValid = BRepAlgo::IsValid(face); //PROBLEM: this returns false
BRepBuilderAPI_FaceError error = makeFace.Error(); //This doesn't help because BRepBuilderAPI_FaceDone is returned

I really can't figure out what I'm missing here. Any hint?

Thank you very much!

Gino

Gerhard Hofmann's picture

Hi Gino,
I had the same problem, I think you have to call BRepLib::BuildCurve3d after MakeEdge. You can even ask with ShapeAnalysis_Edge::HasCurve3d whether there is already a 3DCurve. Thsi costed me days!
Let me know whether this works.
Gerhard

p-carret's picture

The shape representing the hole could be the problem...
Make things VERY simple when it fails in OCC. YOu will be able to verufy if your API calls are responsible or if OCC internal algo are failing....
I will not tell you what I guess.

1) Have you try to put a simple hole with a circle edge ?

2) Have you try also with a rectangle (MakePolygon API will help you to build a simple rectangle) ?

3) Have you try to reverse the curve that represent the hole ?

LI's picture

I agree with Gerhard.
And both the bounadary and the internal wire should have orientation. It seems that you haven't considered this problem.