Concept for changing shapes after their creation

I would like to develop a rather simple modeling tool similar to SketchUp but less functionality of course. I've read the tutorials, user guides, code samples and already played around with code but I have the impression that I still don't understand some major concept, that is changing a shape after it has been created. For example you want to move a face in the direction of its normal while connected faces that share the same vertices change accordingly (if possible). All tutorials only show how you can build a shape from scratch assuming you know all parameters of the shape.

I tried to make a simple example by moving one face of a box. So I played around with BRepBuilderAPI_Transform and wanted to move a face or the 4 vertices, but none of the results were satisfying. Either the whole box is moved, or copied and moved, or I only copied and moved the face/vertex.

Another thing that is confusing me is that you always get a copy of TopoDS_Shape after any modeling operation, but I want to change the original shape, since this is the one I have displayed to the user though my AiContext. Maybe that's related to my comprehension problem.

Does OCC actually work like this or do I have to build a shape from scratch anyway when I want to move one face?

 

Sergey Slyadnev's picture

Hello Florian,

What you are describing is a set of direct modeling features (push/pull, face tweaking, etc.) which are not readily available in OpenCascade. Though there are some options you might want to consider:

1) Use Boolean operators together with prismatic features glued locally to the face being pushed/pulled. This solution is not ideal, of course, as it implies global editing of a shape instead of local tweaking. At the same time, this can be a starting point for you to see how things work, check performance, accuracy, robustness, etc.

2) Develop direct modeling operators by yourself. This is not an easy task though, but OpenCascade can generally handle this being the general-purpose B-rep modeler.

You're also right that to modify a topological element, you actually need to construct a new one. But this is more a question to the organization of OpenCascade's topology model. In general, this peculiarity does not restrict you from developing local operators which you described. E.g., to move a face, you will need to construct a new (shifted) one, to rebuild the adjacent faces, but the back face will remain intact.

florian_149749's picture

Wow, thank you for the quick answer, but I'm surprised that such a common thing like push/pull/move of vertices/edges/faces is not yet implemented after so many years of development. Does someone know why this is the case?

I'll have a look at the BRepBuilderAPI and see what's possible on my own ;)