UnorientableShape and normals after shape replacement...

I gave my replacing algorithm another try, and now I'm using it to move shapes.

The current test is just to move a vertical edge of a box in the XY plane. Moving a vertical edge of such shape in that plane modifies 4 faces, but only changes the normals of 2 faces. I'm using BRepTools::Update at every step that required modification of a shape, but it doesn't seem to be re-calculating the normals correctly. An analysis on the shape just says it's an UnorientableShape.

I would like to avoid re-creating shapes. Is there anything else I should look into?

Thanks in advance.

Paul Jimenez's picture

Nevermind, I'm following OCC's source code to figure out most of it. I've found it's quite a long process (it also requires using many classes) to achieve the final result I want, but, hopefully, I'll get it done.

BRepTools::Update, BRep_Builder::UpdateFace and the source code of BRepLib_MakeFace and BRepLib_MakeEdge seem to give me all the information that I need.

If I have another problem, I'll let you know. If I find a solution, I'll be sure to point to what I used, so it doesn't become another dead end question in these forums.

tmacedo29's picture

Hi Paul,

I don't know if I understood all the problem, but try to use this code
BRepTools_ReShape Changer;
ShapeFix_Face FaceFix;
for (Exp.Init(YourShape, TopAbs_FACE); Exp.More(); Exp.Next())
{
FaceFix.Init(TopoDS::Face(Exp.Current()));
FaceFix.SetPrecision(0.0001);
FaceFix.FixOrientation();
Changer.Replace(Exp.Current(),FaceFix.Face());
}
YourShape = Changer.Apply(YourShape);

I hope help you.
Regards,

Paul Jimenez's picture

Hi Thiago,

I've decided to avoid using *_ReShape because it loves to create new shapes everywhere. I'm trying to keep track of all inner shapes, but *_ReShape's behavior makes this near impossible.

I've successfully re-created all inner surfaces and curves, but now it's becoming tricky to keep the normals pointing to the right direction after making these changes. I could use the displacement direction and previous normal of the face to calculate the resulting normal, but it's a bit hard to achieve when there's so much stuff that needs to be aware of it. Also, the replacement algorithm should know nothing about this displacement, so it'd be really hacky if I send this to the algorithm. Getting orientations right from a Shell, going through its faces, their wires, their edges and vertices is a nightmare, and using OCC's algorithms is not always the answer (once again, because they love to create new shapes all over the place).

I'll see if I can get some information from the shape's old curves to correctly calculate the normal, and then see how can I manipulate things so they make sense.

Thanks for the suggestion, but it's just not the way to go for my specific case.

Paul.