Is there a proper way for OCCT to get the viewable surface of a model at a certain angle?

LJK

Looking around for some CAD
Hi Bros, I'm LJK。
I seem to have a problem now。
I've been using OCCT recently to filter visible faces in a certain direction。
I was going to use the method of intersecting the ray with the plane to get the faces that I can see in the direction I want。
Today,I just found out that there is Face culling function on OpenGL, after I choose any viewing direction, through Face culling, I can get all the faces I see in this direction.

So, I get a question:Is there a similar method in OCCT to get all the visible faces of a model in a certain view?I'm trying to solve this problem, but I don't have any idea at the moment。o_O



The viewing direction is similar to the camera angle of view, and all the faces that can be seen in the camera's angle of view are the faces I need.

1657868879233.png
 

natalia

CAD community veteran
Hi LJK,

There is an idea how to filter visible faces in a certain direction. One is possible ways is doing this from visualization point of view. Sure, there might be others, but may be this one will be appropriate for you.

You may display your model and activate the face selection on it. After, you set needed camera position (viewing direction). Next, you use ‘SelectRectange’ of AIS_InteractiveContext for the whole area of the view (or area that covers whole model). As a result, all visible faces become selected and you can obtain them from the context.

Regarding mentioned face culling possibility of openGl, OCCT uses it. It switches it ON for closed invisible graphical structures to decrease number of redraws. You may have a look at it in OpenGl package. Here, it’s very interesting to know how you connect the faces obtained on openGl level to faces of the model topology. Or, may be, you need not this? It’s difficult to imagine this because these structures are very different and have not explicit connection between if not additionally implemented).

The mentioned by you implementation with the ray and the plane looks appropriate. Here, what about the performance? It should depend on the face complexity, isn’t it? The proposed above way with using ‘SelectRectangle’ is similar to such ray. With difference that this ray intersects not the geometry of the face, but some covering bounding box of the face, that is much time consuming. More to say, not only the box but some BVH tree of such boxes.



By the way, if you’re interesting to have some simple sample how to implement/use ‘SelectRectangle’ functionality, you’re welcome to have a look at ‘extras_viewerNative’ sample in ‘https://gitlab.com/ssv/lessons’ (for sure, in additional to OCCT itself there also exists code of using it). To provide the local selection in proposed sample, just give to the executable as the 1rst argument some BRep file name, and as the second argument, the selection mode ‘4’. To do this multi selection, use left mouse button combination with SHIFT.

Some snapshot of this sample for local selection of edges (selection mode ‘2’):

selectRectangle.png

Regards, Natalia
 

LJK

Looking around for some CAD
Hi LJK,

There is an idea how to filter visible faces in a certain direction. One is possible ways is doing this from visualization point of view. Sure, there might be others, but may be this one will be appropriate for you.

You may display your model and activate the face selection on it. After, you set needed camera position (viewing direction). Next, you use ‘SelectRectange’ of AIS_InteractiveContext for the whole area of the view (or area that covers whole model). As a result, all visible faces become selected and you can obtain them from the context.

Regarding mentioned face culling possibility of openGl, OCCT uses it. It switches it ON for closed invisible graphical structures to decrease number of redraws. You may have a look at it in OpenGl package. Here, it’s very interesting to know how you connect the faces obtained on openGl level to faces of the model topology. Or, may be, you need not this? It’s difficult to imagine this because these structures are very different and have not explicit connection between if not additionally implemented).

The mentioned by you implementation with the ray and the plane looks appropriate. Here, what about the performance? It should depend on the face complexity, isn’t it? The proposed above way with using ‘SelectRectangle’ is similar to such ray. With difference that this ray intersects not the geometry of the face, but some covering bounding box of the face, that is much time consuming. More to say, not only the box but some BVH tree of such boxes.



By the way, if you’re interesting to have some simple sample how to implement/use ‘SelectRectangle’ functionality, you’re welcome to have a look at ‘extras_viewerNative’ sample in ‘https://gitlab.com/ssv/lessons’ (for sure, in additional to OCCT itself there also exists code of using it). To provide the local selection in proposed sample, just give to the executable as the 1rst argument some BRep file name, and as the second argument, the selection mode ‘4’. To do this multi selection, use left mouse button combination with SHIFT.

Some snapshot of this sample for local selection of edges (selection mode ‘2’):

View attachment 376

Regards, Natalia
Hi Natalia, thank you so much for your advice, I'll try it.
 
Top