I would like to ask for your advice in a problem, which does not seem difficult, but I just don't get it.
I have a solid, for example a cube. I want to split one face of this cube into two faces.
What I do is:
1. Identify the original face
2. Make the two new "subfaces" and add them to a shell
3. Use ShapeBuild_ReShape(oldFace, newShell) and then Apply this to the cube
Now the problem is after I do that, the solid stops being solid.
I am sure I am doing something wrong ... but I am not sure what this is.
Could someone help?
when you reshape a model you have to make sure all the affected geometries are reshaped. In your example, please note that the face that you want to replace shares edges and vertices with other faces of the cube. So you either have to reshape those too or create (bottom-up) your new faces using the existing geometries (be careful about the the edge/vertices shared by the new faces as this might decide whether you generate a manifold or non-manifold object). Otherwise your solid might "stop being one" or maybe even become invalid.
For the specific case (splitting one face of a cube) you could also proceed a bit differently (depending on what you actually want to achieve): Adding a wire (that looks like an edge splitting the face) to the face you want to split would do the job as well.
Maybe you could also try using BRepFeat_SplitShape (but I don't have experience with that so I'm not sure if it works exactly as you wish).
Thanks a lot for your quick reply.
I was beginning to suspect that that was the case, and what you said now comes at a confirmation. It seems that if all I do is replace the face, that face becomes disconnected because its edges change while the edges of the other faces do not.
I have tried using BRepFeat_SplitShape to add a wire to the face, but in some particular circumstances, like in the case the face that I want to partition is not a simple rectangle but it has a circular hole in the middle, that operation fails. So I was trying to find another way to do the partitioning.
You mentioned adding the wire to the face, which is what I was trying to do with BRepFeat_SplitShape. Do you know any way of doing this other than using BRepFeat_SplitShape? Is there some other function?
I think in order to add a wire to a face you could use BRep_Builder. Although I must admit I have never tried to modify an existing shape with BRep_Builder (always built the model bottom-up). In worst case you would have to rebuild the model with the additional edge...
This series might help you to understand the OCCT topology:
Right, now I think I understand what you meant.
Now that I have a more clear picture of what the problem is, I will do a bit of studying and hopefully come up with a solution, which of course I will post here.
Thanks again for the info and the link,
I once had to do something similar - split an edge that is part of a solid - and found it surprisingly difficult to do.
In the end I used OCCs ShapeUpgrade_EdgeDivide class with ShapeUpgrade_SplitCurve3d and ShapeUpgrade_SplitCurve2d to
correct 2d/3d curves. There are also OCC classes called "ShapeUpgrade_FaceDivide" and "ShapeUpgrade_ShapeDivide" that
might provide the functionality you are looking for.
Alternatively, and this is probably much simpler to do, you might want to try GEOMs Splitter algorithm (GEOMAlgo_Splitter) which you can simply hand over the edge (or a wire) and the solid you want to modify and it does the job for you.
I tried that on a box and it works nicely (see picture attached): The shape is valid afterwards (according to OCC rules) and I can mesh it..
You have to be logged in to download the attached file
Wow, I did not know about this GEOM module. I looked a bit through the class description for GEOMAlgo_Splitter and it really seems to do what I wanted to do. I hope this works well. I will try to compile it this week and see how it goes.
Regarding ShapeUpgrade_* classes, I did know about them, but I was very unsure regarding how to use them. Maybe I could bother you again with some questions on these if the first option fails.