Ruled Surface

Hi

I have a ruled surface which have four edges (three edge have one line each and one edge have an arc). I need to construct a face with this. The face is not a planar face. Can any one help me out this.

Thanks and regards,

Raj Kumar

Guido van Hilst not specified's picture

Hi Raj,

Do you have some example data of the edges?

Here is an example that makes a non-planer face of 4 edges: FaceFromEdges

​Or general face creation: MakeFaces

​Best regards, Guido

Raj Kumar K's picture

Hi Guido,

Below are the sample code i used to make the face. And here while init the GeomFill_BSplineCurves, to use GeomFill_CoonsStyle to make ruled face, to make a ruled face i need NbUPoles and NbVPoles greater than 4 to construct the face, but i get 2 for NbVPoles. I have attached a text file which contains sample data.

TopExp_Explorer anExp(mw.Wire(), TopAbs_EDGE);
            for (; anExp.More(); anExp.Next())
            {
                const TopoDS_Edge& edge = TopoDS::Edge(anExp.Current());
                TopLoc_Location heloc; // this will be output
                Handle(Geom_Curve) c_geom = BRep_Tool::Curve(edge, heloc, u1, u2); //The geometric curve
                Handle(Geom_BSplineCurve) b_geom = Handle(Geom_BSplineCurve)::DownCast(c_geom); //Try to get BSpline curve

                if (!b_geom.IsNull())
                {
                    gp_Trsf transf = heloc.Transformation();
                    b_geom->Transform(transf); // apply original transformation to control points
                    //Store Underlying Geometry
                    crvs.push_back(b_geom);
                }
                else
                {
                    // try to convert it into a b-spline
                    BRepBuilderAPI_NurbsConvert mkNurbs(edge);
                    TopoDS_Edge nurbs = TopoDS::Edge(mkNurbs.Shape());
                    // avoid copying
                    TopLoc_Location heloc2; // this will be output
                    Handle(Geom_Curve) c_geom2 = BRep_Tool::Curve(nurbs, heloc2, u1, u2); //The geometric curve
                    Handle(Geom_BSplineCurve) b_geom2 = Handle(Geom_BSplineCurve)::DownCast(c_geom2); //Try to get BSpline curve

                    if (!b_geom2.IsNull())
                    {
                        gp_Trsf transf = heloc2.Transformation();
                        b_geom2->Transform(transf); // apply original transformation to control points
                        //Store Underlying Geometry
                        crvs.push_back(b_geom2);
                    }
                    else
                    {
                        // BRepBuilderAPI_NurbsConvert failed, try ShapeConstruct_Curve now
                        ShapeConstruct_Curve scc;
                        Handle(Geom_BSplineCurve) spline = scc.ConvertToBSpline(c_geom, u1, u2, Precision::Confusion());
                        if (spline.IsNull())
                            Standard_Failure::Raise("A curve was not a b-spline and could not be converted into one.");
                        gp_Trsf transf = heloc2.Transformation();
                        spline->Transform(transf); // apply original transformation to control points
                        crvs.push_back(spline);
                    }
                }
            }

            GeomFill_FillingStyle fstyle = GeomFill_FillingStyle::GeomFill_CoonsStyle; // getFillingStyle();
            GeomFill_BSplineCurves aSurfBuilder; //Create Surface Builder

            std::size_t edgeCount = crvs.size();
            if (edgeCount == 2)
            {
                aSurfBuilder.Init(crvs[0], crvs[1], fstyle);
            }
            else if (edgeCount == 3)
            {
                aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], fstyle);
            }
            else if (edgeCount == 4)
            {
                aSurfBuilder.Init(crvs[0], crvs[1], crvs[2], crvs[3], fstyle);
            }

            const Handle(Geom_BSplineSurface)& surf = aSurfBuilder.Surface();

            BRepLib_MakeFace mf(surf, mw.Wire());
            auto face = mf.Face();
            BRepAdaptor_Surface surAdapt(face);
            auto edgeType = surAdapt.GetType();

            builder.Add(shell, face);

Thanks and regards

Raj Kumar

Attachments: 
Guido van Hilst not specified's picture

Hi Raj, I have put your data (from Geometry.txt) in BRepFill_Filling and got following result:

See: Make Face From Edges

Is this the shape you wanted?

Raj Kumar K's picture

Hi Guido,

Yes this is the shape i need. Can you please share the code to make the face.

Regards,

Raj Kumar

Guido van Hilst not specified's picture

Hi Raj,

You can see the code in the "Script" tab next to the "View" tab.

See: FaceFromEdges2

​You can also change the code to do experiments, and recompile the script, or open other example scripts.

The scripts are in c#, to use them in c++ you have to modify them a little: remove OC prefix for OCC classes, and remove "new" keyword

See: https://www.youtube.com/watch?v=I23dHBHc1BA

​Best regards, Guido

Raj Kumar K's picture

Hi Guido,

Thank you very much for your replay.

Thanks and regards,

Raj Kumar

Raj Kumar K's picture

Hi,

To create ruled face now I am using BRepFill_Filling method. It is working file, if the number of edges in a edge array is four. If the edge count exceeds then it connot build the ruled face. Is there any method to make it happen.

Thanks and Regards

Raj kumar