Вопросы и ответы

Подписаться на эту рубрику по RSS

Вопросы от читателей, часть 4

When I move the mouse over an entity, it highlights with CYAN color. Is it possible, by code, choose a different color? Is it possible to increase the line width of highlighted shape?

It is possible. Like any other visual attribute of an interactive object, this property is configured via instance of "Drawer" (Prs3d_Drawer). Drawer is a structure storing visual properties. There is a global Drawer per context and a local Drawer per interactive object.

I have 3D scene with a lot of objects (box, sphere, torus...). Is it possible, by code, programmatically, hide some shape?

Easily. Use AIS_InteractiveContext::Erase() method passing there your interactive object.

I draw a box, suppose, with the two bases parallel to XY plane and the height on the Z axis. I need to select the top face and drag it along Z axis direction, at mouse position. I need also catch event when the drag has stopped.

Your question is actually two-fold:

- How to drag a face in a B-Rep model geometrically.

- How to enable user interaction.

You're speaking about some sort of "push/pull" operation which is not readily available in OpenCascade. In Shapr3D (which was based on OpenCascade initially), push/pull was implemented with a Boolean fuse operation. It is the most reliable, but not the most efficient way to achieve the goal of direct editing (what you are actually asking). Ideally, you will need to offset the top face while stitching the neighbor ones. The operation may change or preserve topology of the model. Formally speaking, there are at least three different behaviors of push/pull which you can offer to the user (see the picture below). However, implementation of such operation is quite complicated. It may take several months to get something more or less general.

For user interaction, OpenCascade does not offer any signals or events which you can work with. It is responsibility of an OCCT-based application to handle any user events and update the viewer correspondingly.

I need to add a gizmo to OCC object like in NAROCAD (based on OCCT). Unfortunately, it is C#-based. Any ideas to implement it with C++?

You may want to check AIS_Manipulator class which is designed to handle interactive operations in OpenCascade's viewer. Even if not readily reusable, it still works as a reference to develop your own interactive widget.