# I Really need some help (Creating a surface).

Hi All,

Please could somebody give me some guidance.

I want to create a surface which is bounded by any number of edges (i.e. closed wire). The wire may contain more than 4 edges so I assume the Filling algorithms are of no use to me. I have tried to use the BuildPlateSurface but the results seem very unpredictable even wrong. This must be a common problem so could somebody point me in the right direction.

Simon Hello, Simon!

The best way is to use topological objects (TopoDS_Face) for these purposes. Because a face represents a surface, bounded by a wire (a set of edges).

If you want to work only with bounded part of surface check all your actions in the parametric space. In fact, when you create a face from a surface and a wire, complementary curves are created. These curves are 2D presentations of each edge in the parametric space of the base surface. They are parametric bounds of given surface. This is, I suppose, what you are looking for.

If you want to work within these bounds, you have to use them instead of native bounds of your surface. For these purposes you could use TopoDS_Face. This object contains all information you need: the surface and the bounds represented by edges which contain 3D curves and parametric curves.

To create a face, you could use BRepBuilderAPI_MakeFace. To obtain a geometry from topological objects, use methods from BRep_Tool class.

Best regards, Sergey. > Hello, Simon!

Hi Sergey, thanks for the responce.

> The best way is to use topological objects
> (TopoDS_Face) for these purposes. Because a
> face represents a surface, bounded by a wire
> (a set of edges).

This is what I guessed, however I am still a little confused !

> If you want to work only with bounded part
> of surface check all your actions in the
> parametric space. In fact, when you create a
> face from a surface and a wire,
> complementary curves are created.

But... If for example the face I want to create is bounded by a wire which contains 10 edges for example I cannot create a surface to bound by the wire....

> These curves are 2D presentations of each edge in
> the parametric space of the base surface.

base surface ? How do I create this ?

> They are parametric bounds of given surface.
> This is, I suppose, what you are looking
> for.

> If you want to work within these bounds, you
> have to use them instead of native bounds of
> your surface. For these purposes you could
> use TopoDS_Face. This object contains all
> information you need: the surface and the
> bounds represented by edges which contain 3D
> curves and parametric curves.

> To create a face, you could use
> BRepBuilderAPI_MakeFace. To obtain a
> geometry from topological objects, use
> methods from BRep_Tool class.

It would be a big help if you could give me a small example. This is how I have approached the problem so far !

1) I have a list of 10 edges which I know form a closed boundary. 2) I create a wire from these (No problem).

3a) Now I need to create a face. If I use the BRepBuilderAPI_MakeFace(surface,wire) I need a base surface ! how do I create this ?

3b) If I create a face assuming the edges are all planar (BRepBuilderAPI_MakeFace(wire,true)). This works but... when I use the BRep_Tool class to examine the surface the parameter bounds seem very strange, i.e umin and vmin = -200e+100, umax, vmax = 200e100 ??

What would your approach to this problem be ?

I apologise for my incompetence with regards to this problem, but it is very important I get a solution to this soon.

> Best regards, Sergey.

Thank you Sergey.

Simon Dear Simon!

Have a look at the following example:

Standard_Real UFirst, ULast, VFirst, VLast;

// to obtain a base surface from a face, you should do this:

Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);

if (!aSurface.IsNull()) {

aSurface->Bounds(UFirst, ULast, VFirst, VLast);

cout << UFirst << " " << ULast << " " << VFirst << " " << VLast << endl;

// The result will be: -2e+100 2e+100 -2e+100 2e+100 for your face. It is correct, because these bounds are the bounds of base (not trimmed) surface. The "real" bounds are represented by parametric curves:

}

Handle(Geom2d_Curve) a2DCurve;

TopExp_Explorer anExp(aFace, TopAbs_EDGE);

for (; anExp.More(); anExp.Next()) { // For each edge:

TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());

Standard_Real First, Last;

a2DCurve = BRep_Tool::CurveOnSurface(anEdge, aFace, First, Last);

// a2DCurve represents a part of "real" bound in the parametric space of the surface.

if (!a2DCurve.IsNull()) {

// Here is possible to work with this part of bound

}

}

// Another example: if you want to know is the 3D point on the surface given by parameters U0 and V0 belongs to your face or not, you should do the following:

TopAbs_State aState;

gp_Pnt2d aParamPnt(U0, V0);