Create Simple Cylinder from basic geom_ primitives

I am trying to figure out how to get Open Cascade to return the edge, wire, and/or face representing the portion of an infinite cylinder (Geom_CylindricalSurface) that sits between two infinite planes (Geom_Plane).

I have managed to construct the top and bottom caps of the cylinder as Faces.  The following snippet shows the construction of the bottom cap face of the cylinder.:

GeomAPI_IntSS intersect01(simpCyl,geoPln02,1.0E-7);      
BRepBuilderAPI_MakeEdge cylEdge(intersect01.Line(1));    
BRepBuilderAPI_MakeWire cylWire(cylEdge);                
BRepBuilderAPI_MakeFace cylFace(cylWire);                
Handle(AIS_Shape) cylShape = new AIS_Shape(TopoDS_Face());

I can similarly get the bottom cap constructed.  The trouble I am have is constructing the edge/wire/face of the body of the cylinder which is the portion of the infinite Geom_CylindricalSurface that lies between the two Geom_Planes.  

Does anyone know how to use the various Open Cascade utilities to return the edge, wire, and/or face representing the portion of the infinite cylinder between two planes?  Or alternatively how to construct the cylindrical body from the two edges/wires of the top and bottom faces of the cylinder?

Here are my plane and cylinder definitions:

 * Creates a plane using the form based on the general plane equation: 
 *      Ax+By+Cz+D=0                                                   
Handle(Geom_Plane) geoPln02 = new Geom_Plane(0.0,0.0,1.0,10.0);        
Handle(Geom_Plane) geoPln03 = new Geom_Plane(0.0,0.0,1.0,-10.0);       
Handle(AIS_Shape) plnShape2 = new AIS_Shape(TopoDS_Face());            

Handle(Geom_CylindricalSurface) simpCyl = new Geom_CylindricalSurface(cylAx3, 5.0); //Creates infinite cylindrical surface

Thanks for any help you can provide!

Walter Rhoden's picture


I managed to hit upon a solution but it may not be the most efficient.  Any alternative ideas/approaches?

Using the 'Face' method from BRepFill I managed to create a face representing the cylinder body from the two edges create from the intersection of the two planes and infinite cylinder:

TopoDS_Face cylSide = BRepFill::Face(cylEdge,cylEdge2);

Where cylEdge is the same edge shown in the original post and cylEdge2 is the top edge on the cylinder created from an intersection between geoPln03 and simpCyl.

I was kind of hoping there would be a method from Open Cascade that would do all of this by acting on the three original geom primitives (2 Geo_Planes and one Geom_CylindricalSurface) but at least it isn't too much effort to achieve what I want.  Any additional advice or alternative methods would be appreciated.


Adam Lo's picture


BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace ( const gp_Cylinder &  C,
    const Standard_Real  UMin,
    const Standard_Real  UMax,
    const Standard_Real  VMin,
    const Standard_Real  VMax 

Make a face from a cylinder.

would seem to do what you want?

Walter Rhoden's picture

Thanks Adam!  This is a reasonable alternative to the BRepFill::Face() I suggested in my followup post.  Unclear which one would be more advantageous.  Appreciate the 411 as I may need to use it if the Geom_CylindricalSource/BRepFill::Face() combination doesn't work out.  

Interestingly, I had attempted to create a gp_Cylinder from the Geom_CylindricalSource I had created.  I tried to use the Cylinder() method to get a gp_Cylinder but it gives a 'variable has incomplete type 'gp_Cylinder'' error which I don't fully understand.

In either case thanks again for the info.

Adam Lo's picture

I suspect using BRepBuilderAPI_MakeFace is a more direct way of doing it and therefore more robust and efficient but I haven't read the source code so can't say for sure.