Make Face does not work.

I begin to use opencascade several weeks ago.
I am excited to develop 3d program, I really appreciate OCC company for provided as opensource.

The following is the code, I met the problem. (OCC 6.3.0 VS6 WinXp)
The code is simple to createCircle/makePrism/makeFace.
The makePrism seems to change the state of aCircle, and successive Makeface does not work
( MF.IsDone() say yes, but none is displayed).
If commented the execution of makePrism, then makeface works.

void OnDebug_test1(Handle_AIS_InteractiveContext myAISContext)
// Create Circle on x-y plane
TopoDS_Wire aCircle;
gp_Circ EL ( gp::XOY(), 10.0 );
Handle(Geom_Circle) anCircle = GC_MakeCircle(EL).Value();
TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge( anCircle );
aCircle = BRepBuilderAPI_MakeWire( aEdge );
// Perform makePrism with aCircle
if ( 1 ) {
gp_Vec v( 0, 0, 50.0 );
TopoDS_Shape tShell = BRepPrimAPI_MakePrism( aCircle, v );
Handle(AIS_Shape) aShape = new AIS_Shape(tShell);
// MakeFace
BRepBuilderAPI_MakeFace MF( aCircle );
if ( MF.IsDone() ) {
TopoDS_Face F = MF.Face();
Handle(AIS_Shape) aShape = new AIS_Shape(F);

Using debugger, I dig into the source and compare the behavior.
I found in case of failing makeface, aCircle say IsCurveOnSurface true.
but I could not understand why it fail to create face in detail.

BRep_CurveOnSurface::IsCurveOnSurface() line 46
BRep_Tool::CurveOnSurface(const TopoDS_Edge & {...}, Handle_Geom2d_Curve & {...}, Handle_Geom_Surface & {...}, TopLoc_Location & {...}, double & -9.2559631349317831e+061, double & -9.2559631349317831e+061, const int 1) line 410 + 22 bytes
BRepLib_FindSurface::Init(const TopoDS_Shape & {...}, const double -1.0000000000000000, const unsigned int 0) line 111 + 57 bytes
BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape & {...}, const double -1.0000000000000000, const unsigned int 0) line 74
BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire & {...}, const unsigned int 0) line 239 + 23 bytes
BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(const TopoDS_Wire & {...}, const unsigned int 0) line 247 + 62 bytes
OnDebug_test1(Handle_AIS_InteractiveContext {...}) line 272 + 73 bytes

To make it work, I found the following solutions.
a) Pass to the makePrism a copy of aCircle
BRepPrimAPI_MakePrism( aCircle, v, Standard_True );
a) Say makeface aPlanerOnly
MF( aCircle, Standard_True );

I am glad if this information is helpfull for other people and welcome any comments or suggestions.

Roman Lygin's picture

Welcome to the club ;-) !

The face requires that its edge has pcurves (i.e. 2D curves in a U,V parameter space of its underlying surface) associated with its surface. The only exception is plane where pcurves can be computed on the fly. I explained this in the recent post about edge (

Therefore indeed, when constructing a face from a wire, you either have to use a planar case (in your case PlanarOnly=Standard_True) or ensure that all the wire edges *already* have pcurces on some surface.

Good luck.

--- - blog on Open CASCADE