Reverse face orientation

For a give object, how do I reverse the orientation of some faces belong to the object? Using ShapeBuild_ReShape?

Thanks,

Li

Dirk B's picture

It should work like this:

TopoDS_Shape QtOCCViewerContext::ReverseFaceOrientation( const TopoDS_Shape& shape, const TopoDS_Face& face)
{
Handle(BRepTools_ReShape) rebuild = new BRepTools_ReShape;
TopoDS_Shape newface = face.Complemented();
rebuild->Replace(face, newface, Standard_True );
TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_FACE );
return newshape;
}

This works as long as face.Orientation() is TopAbs_FORWARD.
If face.Orientation() is TopAbs_REVERSED, newface.Orientation() correctly returns TopAbs_FORWARD,
but if you Diplay newshape and check the orientation of the replaced face, it still is TopAbs_REVERSED.
Does anyone know why this is so? How can this be fixed?

Dirk

P Dolbey's picture

I wonder what the rest of your QtOCCViewerContext looks like!

Pete

Dirk B's picture

Oops, I didn't mean to leave the class name in the code. The rest of the code does this:
A shape and a face that belongs to the shape are passed to ReverseFaceOrientation. Then the representation of the old shape is deleted and a representation of the new shape
returned by ReverseFaceOrientation is displayed.
I think there is no problem with this.
Here is the solution to my problem. I just overlooked that the function
BRepTools_ReShape::ModeConsiderOrientation()
can also be used to SET the private myConsiderOrientation.
Here is the working code:

TopoDS_Shape ReverseFaceOrientation( const TopoDS_Shape& shape, const TopoDS_Face& face)
{
Handle(BRepTools_ReShape) rebuild = new BRepTools_ReShape();
rebuild->ModeConsiderOrientation() = Standard_True;
TopoDS_Shape newface = face.Complemented();
rebuild->Replace(face, newface, Standard_True );
TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_FACE );
return newshape;
}

P Dolbey's picture

There's no problem with me advertising the class name - it is GPL'd.

Pete