Create a cone from simple geom shapes

I am looking for a way to create a solid cone shape based on the vertex point of the cone and an intersecting edge/wire created by the intersection of the cone and a plane.  I have done this for cylinder with two planes (Geom_Plane) and a simple cylinder (Geom_CylindricalSurface).  I then create two edges (BRepBuilderAPI_MakeEdge) based on the intersection between the planes and the cylinder.  Finally I used BRepFill::Face() with the two edges to create the side of the cylinder (whole code is pasted below).

What I am having trouble with is how to take a similar approach for a cone (Geom_ConicalSurface) intersected by a plane (Geom_Plane).  I can successfully create the intersecting edge with ​GeomAPI_IntSS and ​BRepBuilderAPI_MakeEdge.  The problem is that there is no BRepFill::Face() that allows for a point and an edge.

In case you think to ask why I don't use the various primitive methods to make a cone directly like BRepPrimAPI_MakeCone(), it is because of the nature of the project I am working on.  This is a translator from a different 3d geometry system used to simulate physics problems to opencascade.  This other system provides geometry in terms of basic planar objects that can then be combined in arbitrary ways to create closed shapes.  I need to try to follow a similar approach in opencascade, if at all possible.

Thanks in advance for any and all answers. tips, etc.

Here is my basic cylinder code.  Kinda long with lots of comments:

    /*
     * 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);

    // Create a basic cylinder
    gp_Pnt cylPnt(10.0, 10.0, 0.0);
    /*
     * Coordinate system to define the placement of the cylinder and
     * the direction of the axis of the cylinder.
     * Consists of three arguments:
     *  1. A starting point through which the axis of the cylinder passes
     *  2. A vector that defines the direction of the axis from the starting point
     *  3. A vector that defines the x direction which generally just needs to be normal
     *     to the axis vector.
     */
    Standard_Real angle(0.0); // Angle from z axis in X-Z plane
    Standard_Real angRad = angle*M_PI/180.0;
    Standard_Real vAxisX = sin(angRad);
    Standard_Real vAxisY = 0.0;
    Standard_Real vAxisZ = cos(angRad);
    Standard_Real vXdirX = cos(angRad);
    Standard_Real vXdirY = 0.0;
    Standard_Real vXdirZ = sin(angRad);
    gp_Ax3 cylAx3(cylPnt,gp_Dir(vAxisX, vAxisY ,vAxisZ),gp_Dir(vXdirX,vXdirY,vXdirZ));
    Handle(Geom_CylindricalSurface) simpCyl = new Geom_CylindricalSurface(cylAx3, 5.0); //Creates infinite cylindrical surface

    /*
     * Create the bottom face of the cylinder based on the intersection
     * between the bottom infinite plane and the infinite cylinder.
     *
     * In this case there is only a single intersecting line (a circle)
     * and therefore only a single edge added to the wire.
     */
    GeomAPI_IntSS intersect01(simpCyl,geoPln02,1.0E-7);          // Determine the intersecting line​
    BRepBuilderAPI_MakeEdge cylEdge(intersect01.Line(1));        // Create an edge from the line​
    BRepBuilderAPI_MakeWire cylWire(cylEdge);                    // Create a wire from the edge​
    BRepBuilderAPI_MakeFace cylFace(cylWire);                    // Create a face from the wire
    Handle(AIS_Shape) cylShape = new AIS_Shape(cylFace.Face());  // This creates a displayable shape
    // Does the same as above for the bottom face of cylinder​
    GeomAPI_IntSS intersect02(simpCyl,geoPln03,1.0E-7);            // Determine the intersecting line​
    BRepBuilderAPI_MakeEdge cylEdge2(intersect02.Line(1));         // Create an edge from the line​
    BRepBuilderAPI_MakeWire cylWire2(cylEdge2);                    // Create a wire from the edge​
    BRepBuilderAPI_MakeFace cylFace2(cylWire2);                    // Create a face from the wire
    Handle(AIS_Shape) cylShape2 = new AIS_Shape(cylFace2.Face());  // This creates a displayable shape
    // Creates the side of the cylinder from the top and bottom edges​
    TopoDS_Face cylSide = BRepFill::Face(cylEdge,cylEdge2);
    Handle(AIS_Shape) cylSideShp = new AIS_Shape(cylSide);
    /*
     * This creates a shell out of the three faces/shapes that
     * represent the top, bottom, and body of the cylinder.
     * The Perform() method needs to be called after each face/shape
     * is added to the shell.  This is needed to keep the normals of
     * the underlying surfaces of the shell properly aligned.  This
     * becomes important when creating the solid.
     */​
    BRepBuilderAPI_Sewing cylSew;
    cylSew.Add(cylSideShp->Shape());
    cylSew.Perform();
    cylSew.Add(cylShape->Shape());
    cylSew.Perform();
    cylSew.Add(cylShape2->Shape());
    cylSew.Perform();
    TopoDS_Shape cylSewShape = cylSew.SewedShape();

 
Walter Rhoden's picture

So I finally found the answer!  The key to doing this is BRepOffsetAPI_ThruSections (Most misleading function name ever! and frankly MakeFace should have similar functionality).  This is covered briefly in the tutorial and searching on this forum will bring up some further examples and discussions.  So here is a little code snippet to show the basics of this:​

    Handle(Geom_ConicalSurface) coneSurf = new Geom_ConicalSurface(coneAx3,M_PI_4,0.0);
    TopoDS_Vertex coneVert = BRepBuilderAPI_MakeVertex(coneSurf->Apex());​
    BRepOffsetAPI_ThruSections coneTool(Standard_True);
    coneTool.AddVertex(coneVert);
    TopoDS_Face cutPlane = BRepBuilderAPI_MakeFace(geoPln02->Pln());
    GeomAPI_IntSS conInt01(coneSurf, geoPln02,1.0E-7);      // Determine intersecting line
    BRepBuilderAPI_MakeEdge coneEdge(conInt01.Line(1));     // Create an edge from the line
    BRepBuilderAPI_MakeWire coneWire(coneEdge);             // Create a Wire from the edge
    BRepBuilderAPI_MakeFace coneFace(coneWire);             // Create a face from the wire
    Handle(AIS_Shape) coneEndFace = new AIS_Shape(coneFace.Face());
    coneTool.AddWire(coneWire);
    Handle(AIS_Shape) coneBodyShape = new AIS_Shape(coneTool.Shape());