For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Make hemisphere from cicular face.

Madz T's picture

I have a circular face from which I want to add a bottle cap like hemisphere.

I have the radius of the circular face but not its center point. I've used the following code but the hemisphere doesn't completely fit.

    TopoDS_Face circularFace...;  

    double ToolRadius = 10;
    gp_Dir normal(0,1,0);

    GProp_GProps props;
    BRepGProp::LinearProperties(circularFace, props);
    gp_Pnt centerMass = props.CentreOfMass();//get the center of mass
    gp_Ax2 Ax2(centerMass, normal);
    TopoDS_Face S2 = BRepPrimAPI_MakeSphere(Ax2, ToolRadius, PI);

I've attached an image of the shapes. How can I make the bottle cap completely fit?

Thank you.

PG's picture

If you know circularFace is "circular", extract its outer edge which should be of type GeomAbs_Arc. from that u could get its center as well as radius and 

compute the necessary inputs for the MakeShere API.



Madz T's picture

Thanks PG. That solution worked.

Here's the code I used.

    TopoDS_Edge tnpEdge;
    for(TopExp_Explorer explrV(circularFace, TopAbs_EDGE); explrV.More(); explrV.Next()){
        tnpEdge = TopoDS::Edge(explrV.Current());

    Standard_Real first,last;
    gp_Pnt pntFst, pntLst,pntMdl;
    Handle(Geom_Curve) Projected_Curve = BRep_Tool::Curve(tnpEdge,first,last);
    Projected_Curve->D0((first+ (last-first)/4),pntMdl);
    gce_MakeCirc mkCirc(pntFst, pntLst, pntMdl);
    gp_Circ circ = mkCirc.Value();

    double rad = circ.Radius();
    gp_Pnt mid = circ.Location();

    gp_Ax2 Ax(mid, norm);
    TopoDS_Face S2 = BRepPrimAPI_MakeSphere(Ax, rad, PI);