Orientation of faces,wires...

Hi everybody,
I have a question concerning the orientation of faces, wires, edges.
Someone can explain me the relation between the orientation of the wire of a face and the face itself.
Any kind of information would be very helpful for me.

I explain more my problem:
In fact I have to rebuild a face slightly modified (some vertices modified).
I use the tools BRepBuilderAPI_MakeFace,BRepBuilderAPI_MakeWire and BRepBuilderAPI_MakeEdge.

I have problems on the inner holes of some faces which are sometimes filled.
I try then to rebuild the shape with the same orientation (for the faces,wires,edges).

On an concrete example:
My initial shape:
Face :reversed - external wire : forward - inner wire : forward

I want that the rebuilt shape has the same orientation.
When we rebuild a shape, with the BRepBuilderAPI_Make tools, we can't specify directly the orientation.
If I don't modify the orientation, I obtain:
Built shape:
Face : forward - external wire : forward - inner wire : forward

To obtain the good orientation for the face, I reverse its orientation :
Built shape with reverse orientation for the face:
builtFace.Orientation(initialFace.Orientation());
Face : reversed - external wire : reversed - inner wire : reversed

This isn't the solution, because reversing the orienntation of a face has a direct impact on the wires. I then reverse first the orientation of the built wires (external wire : reversed - inner wire : reversed) before reversing the orientation of the face:

wire0.Reverse();
wire1.Reverse();
builtFace.Orientation(initialFace.Orientation());
Face : reversed - external wire : reversed - inner wire : forward

I don't understand why the the external wire is still reversed. I would like to know the relation between the face and the external wire for the orientation.

If you have any idea on the question, please answer.
Thank you.

Elisa

Bearloga's picture

Elisa,
In your particular case you can forget about orientations. Use the class BRepTools_ReShape to change some vertices and obtain the modified copy of the entire shape.

elisa's picture

Thanks Bearloga,

I've tried the BRepTools_ReShape tool. But my first tests weren't convincing.

I have a question concerning the method Apply of this tool.

The document on this method is:
"TopoDS_Shape BRepTools_ReShape::Apply (const TopoDS_Shape&shape,
const TopAbs_ShapeEnum until,
const Standard_Integer buildmode)

Purpose:
Applies the substitution requests to a shape.
gives the level of type until which requests are taken into account.
For subshapes of the type no rebuild and futher exploring are done.
ACTUALLY, NOT IMPLEMENTED BELOW TopAbs_FACE."

What they want to say by "ACTUALLY, NOT IMPLEMENTED BELOW TopAbs_FACE"?

By the way, can you just tell me if I'm using correctly BRepTools_ReShape:

BRepTools_ReShape *change = new BRepTools_ReShape();
// 4 vertices to modify
change->Replace( oldVertex1,newVertex1, false);
change->Replace( oldVertex2,newVertex2, false);
change->Replace( oldVertex3,newVertex3, false);
change->Replace( oldVertex4,newVertex4, false);
TopoDS_Shape result = change->Apply(myFace,TopAbs_Face,0)

Have I to do the replace/apply vertex by vertex?
Thank you very mutch for your help.

I have now resolved my problem for the BRepBuilderAPI_Make...
In fact it was a problem on the constructor of BRepBuilderAPI_MakeFace.
I explain:
If you use the constructor:
BRepBuilderAPI_MakeFace
(const TopoDS_Wire& W,
const Standard_Boolean OnlyPlane = Standard_False);
Then the orientation of your wire will be forward even if you have a reverse wire.

The solution is to use like this:
mybuilder = BRepBuilderAPI_MakeFace();
mybuilder.Init(surface);
mybuilder.Add(externalWire)
mybuilder.Add(internalWire);

Elisa.

Bearloga's picture

Elisa,
BRepTools_ReShape has another method Apply with two arguments, and it does not have the warning:
TopoDS_Shape Apply(const TopoDS_Shape& shape,const TopAbs_ShapeEnum until)
You should call it like this:
TopoDS_Shape result = change->Apply(myFace,TopAbs_VERTEX);
Good luck