For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Remove common edge from wires

Paul Jimenez's picture
Forums: 

I have a shell box that is fused with a face that "splits" the box in two. The fuse-operation therefore divides 4 of the faces in two, increasing the original face count from 6 (for the box) to 11 (the original 6, the new 4 from the division and the new face). Then, I delete the new face, so it becomes a box with 10 faces. The edges from the now deleted face are still there, though. Now I take the common edge from the upper faces, then the two faces that share it. From each face I get their wire. Finally, I delete the edge from both wires.

In theory it looks fine, but the result is that one of the wires gets two edges removed, and the other one still has its 4 edges.

The common edge is being selected with the mouse, and the code finds the two faces without problems. I'm using the Remove command from BRep_Builder.

Any ideas on what's wrong with that approach?

Thanks in advance.

Lodyzhensky's picture

Dear Paul Jimenez.

As far as I understood:
- you have two faces F1, F2 ("upper faces"). These faces have one shared edge Es;
- you remove Es from the wires of F1, F2.

The question is:
What do you want to obtain finally?

Paul Jimenez's picture

Hi,

What I want to obtain at the end is a single closed wire composed of the, now, open wires of faces F1 and F2. Since I'm removing a shared edge, the first and last vertices of those wires should be the same, so it should be possible to join them, creating a closed wire again. From that closed wire I can create a face.

In other words, the algorithm fuses two coplanar faces given the edge they share. What doesn't work so far is removing the shared edge from the wires. From my tests, two edges are removed from one of the faces' wire, and no edges are removed from the other one.

Could it be a bug in BRep_Builder::Remove, or am I missing something?

Thanks in advance.

Paul Jimenez's picture

Hi again,

After some more testing, I found that the edge I wanted to remove was the second one returned by TopExp_Explorer in WF1, and the last one in WF2. However, the orientation of the edge was different in WF2. IsPartner was used here, but IsSame should work too (same location). Then, I Append'd all the edges I was interested in to a TopTools_ListOfShape that I give to BRepBuilderAPI_MakeWire's Add method. Then, I create a face from it and Add it to my shell (after removing the previous faces and shared edge). The face is Added and selectable, but it's invisible from both sides. I even forced all the edges to have the same orientation as the first added edge before calling the Add method of *_MakeWire, but it didn't solve that problem.

Is there something else I forgot to do?

Lodyzhensky's picture

Dear Paul Jimenez.

Almost everything seems to be Ok.

Try to do the following:
1. Create a new wire W (Use BRep_Builder and his ancestors);
2. Add all the edges except Es to W (Use BRep_Builder::Add(...));
3. Create new face F (use surface from any face F1,F2; (Use BRep_Tool::Surface(...), BRep_Builder::MakeFace(...));
4. Add W to the F (Use BRep_Builder::Add(...));
5. Create a new shell Sh (Use BRep_Builder and his ancestors);
6. Add F and all rest faces Fj to the Sh (Use BRep_Builder::Add(...));
7. Make Sh presentable and selectable as you need

Paul Jimenez's picture

Hi,

Your suggested approach didn't work either. I decided to analyze the wire, and it doesn't seem to be right. These are the results of exploring the edges of the wire (the points are obtained using TopExp::FirstVertex and TopExp::LastVertex without taking into account orientation):

EDGE#: ORIENT.: FIRSTVERTEX LASTVERTEX

Edge1: REVERSED: (-80, 70) (40, 70)
Edge2: FORWARD: (-80, -30) (-80, 70)
Edge3: FORWARD: (-80, -30) (40, -30)
Edge4: FORWARD: (40, -30) (120, -30)
Edge5: FORWARD: (120, -30) (120, 70)
Edge6: FORWARD: (40, 70) (120, 70)

I removed Z since it's the same for all of them.

If I follow those edges, Edge2 and Edge6 seem to be wrongly oriented.

May it be a bug in *_MakeWire when created from a list of edges?

What's even more strange is that ShapeFix doesn't find any problems, but the result is the same.

Paul Jimenez's picture

Hi again,

I changed the algorithm so it adds the edges in the right order, and now it works as expected. It seems to be a bug in BRepBuilderAPI_MakeWire::Add(const TopTools_ListOfShape &), despite the fact it says "The edges are not to be consecutive. But they are to be all connected geometrically or topologically." In the process I also found BRepBuilderAPI_MakeWire::Delete() does NOT delete the current wire, so that's not a valid way to make it 'empty' again.

Thanks for your patience and suggestions.

Lodyzhensky's picture

Dear Paul Jimenez.

1. A wire is just set of edges and nothing more. It is not any miracles here.

If your wire W contains the edges (Edge1,2,...6) that are
a) shared through the vertices;
b) forms closed contour (taking into account orientations of the edges);
there will be no problems with using W for building face F as I've proposed.
It is not necessary to use BRepBuilderAPI_MakeWire::Add() here,
because BRepBuilder::Add() is quite enought for the case.

2. As for the edges (Edge1,2,...6). The dump shows that your edges behave any which way and do not form closed contour. Indeed, try to draw them from start point (P0) to end point (P1). Mark P1 by an arrow in case of FORWARD .Mark P0 by an arrow in case of REVERSED. Have a look at the whole picture. In case of closed contour arrows form unique circulation (clockwise or counter-clockwise but unique).

The questions:
How did you obtain these edges?
Are you sure that these edges are shared through the vertices?

Paul Jimenez's picture

Hi,

The previous attempt to build a face from the closed wire created a blind (I guess that's the word to describe it) face. Even though the wire was indeed closed and TopExp_Explorer returned them in sequence, their orientation wasn't quite right. Now that I'm taking care of adding them in the right sequence, the wire is correctly created, with the orientations fixed, and the final face doesn't have any problems.

I drew the edges in a piece of paper from the results I got from the debugger, and the arrows (that I also drew) didn't follow a unique circulation (Edges 2 and 6 were in the wrong 'direction').

What I did:
* I get the wires from the faces using BRepTools::OuterWire.
* I iterate over the edges of each wire using TopExp_Explorer.
* I add all edges, except for the shared one, to a BRepBuilderAPI_MakeWire for each face (actually from the wire I got from each face). I also take care of putting them in sequence by using a temporary BRepBuilderAPI_MakeWire.
* I add one of the wires to the other to form a unique closed wire (I take care of the order in which I call Add).
* I create a face with BRepBuilderAPI_MakeFace using the wire.
* I remove the previous faces and shared edge from the shell using BRep_Builder::Remove.
* I add the new face to the shell using BRep_Builder::Add.

I got the edges for the dump using TopExp_Explorer, and they indeed are shared through the vertices.

The method I just described works lovely, but the code to do it was longer than I expected (almost 130 lines).

Thanks for your interest and help in this topic.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.