How to modify sub-shapes of a given shape without copy

I Tried to invert some normal of faces of a given shape. My normal is modelised by the order in which the vertices of the face are recuperated.

I test a code like that and it works well.

TopoDS_Face aFace;
getVertexInOrder(aFace);
aFace.Reverse();
getVertexInOrder(aFace);

the two results of getVertexInOrder are inversed. Ok that works.

But when I want to modify some faces' normal of a shape, I tried 2 solutions but it doesn't work.

Solution 1°)
using a TopExp::MapShapes(aShape,TopAbs_FACE,faceMap) and get the faces by reference
TopoDS_Face & exploredFace = TopoDS::Face(faceMap(i))
if (hasToBeModified(exploredFace,aListOfFacesToModify ))
exploredFace.Reverse();
...

Problem:
Then when I re-explore the shape, the faces normal have the sames values than before the reverse.

Solution 2)
Same code but the faces are not modified online but added in a sewing algorithm (+ faces that keep the same orientation).Then, the new sewedShape is explored and some orientations of faces are modified in order to have a sort of homogeneityin faces orientation.

If you have ideas, thanks in advance

Christophe

m-aronsson's picture

Hi !

As far as I know, you can't modify a shape, if you want to change it you have to create a new shape and replace the old one with that.

Mikael

Michael Gandyra's picture

Of course you can!

Have a look at these lines of code:
TopoDS_Shape cmpnd; // already exists
TopoDS_Shape theOldFace = aFaceFromTheShape(cmpnd);
TopoDS_Shape theNewFace = theOldFace.Complemented();
Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
// remove it: rebuild->Remove(theOldFace);
// or replace it:
rebuild->Replace(theOldFace, theNewFace, Standard_False);
TopoDS_Shape shcmpnd = rebuild->Apply(cmpnd, TopAbs_SHAPE, 1);

Best regards,
Michael Gandyra

_____________________________________________
Dr.-Ing. Michael Gandyra
Software Development/Digitizing
Steinbichler Optotechnik GmbH
D-83115 Neubeuern

m-aronsson's picture

Hi !

Yes, but are not modifing face, you replace it with another face, which is a modified version of the original face.

Mikael

Michael Gandyra's picture

Yes. Its true, but the (topological) shape itself, where the face lives in, is modified through the replacement of the face. And that is, what was asked for, I think.

Best regards,
Michael Gandyra

_____________________________________________
Dr.-Ing. Michael Gandyra
Software Development/Digitizing
Steinbichler Optotechnik GmbH
D-83115 Neubeuern