Unwanted (hidden) shape detection

Hello everyone,

I'm experiencing this issue: I've create two different AIS_Shape (see IssueOnDetection1.png) at different Z coordinate so that the upper shape partially hides the lower one. Now, looking down to these objects from above (see IssueOnDetection.png), when the mouse hovers on the upper shape (on the left of the image), this is detected and highlighted correctly but, when the mouse crosses the prolongation of any vertical face of the lower shape (see the right part of the image), the upper shape is no longer highlighted and the lower one is detected.

How come? Is there a bug in detection mechanism or am I missing something?

I recently made a porting from a previous release (prior to 6.9) to the 7.3, thus having to deal with new selection mechanism. As prior to this porting, everything worked fine, is this issue of mine somehow related to those big changes?

Many thanks in advance

 

Gianluca

Kirill Gavrilov's picture

Could you share also a piece of the model with the problem?

Gianluca Antoniacci's picture

Hello Kirill,

attached you'll find the brep files for the upper shape (support.brep) and the lower one (bar.brep).

Both are a compSolid object and have been stored in their actual position.

Let me know if you need further information.

Many thanks

Gianluca

Attachments: 
Kirill Gavrilov's picture

Could you replicate the issue in CAD Assistant application?
Why do you port to OCCT 7.3.0, when the latest release is OCCT 7.4.0?

Gianluca Antoniacci's picture

Hello Kirill,

I'm using the C# wrapper and I've been given it when release 7.3.0 has been published. Do you mean that it doesn't happen with 7.4.0?

By the way, I just replicated it within the WPF application that ships with C#wrapper solution. I call the following method:

private void Display2Boxes()
        {
            BRepPrimAPI_MakeBox boxMk1 = new BRepPrimAPI_MakeBox(new gp_Pnt(0, 0, 0), new gp_Pnt(200, 100, 50));
            BRepPrimAPI_MakeBox boxMk2 = new BRepPrimAPI_MakeBox(new gp_Pnt(0, 0, 100), new gp_Pnt(400, 200, 150));
            AIS_Shape newShape1 = new AIS_Shape(boxMk1.Shape());
            AIS_Shape newShape2 = new AIS_Shape(boxMk2.Shape());
            Prs3d_Drawer aDrawer = new Prs3d_Drawer();
            aDrawer.SetColor(_color);
            newShape1.SetAttributes(aDrawer);
            newShape1.SetMaterial(new Graphic3d_MaterialAspect(Graphic3d_NameOfMaterial.Graphic3d_NOM_ALUMINIUM));
            myOcctView.Context.Display(newShape1, 0, 0, false);
            newShape2.SetAttributes(aDrawer);
            newShape2.SetMaterial(new Graphic3d_MaterialAspect(Graphic3d_NameOfMaterial.Graphic3d_NOM_GLASS));
            myOcctView.Context.Display(newShape2, 0, 0, false);
            myOcctView.View.SetProj(V3d_TypeOfOrientation.V3d_Zpos);
            myOcctView.fitAll();
            myOcctView.Context.UpdateCurrentViewer();
        }

and what I get is the same as in my application: when the mouse hovers on the boxes, the upper one hides the lower one and is highlighted; but when the mouse passes exactly on the projection of a vertical face of the lower box, it highlights as if vertical plane were infinite (see attached picture).

Many thanks

Attachments: 
Kirill Gavrilov's picture

Do you mean that it doesn't happen with 7.4.0?

Well, I didn't meant that it doesn't happen - just was curious about usage of old version, as there were some similar problems fixed (but seems to be before OCCT 7.3.0).
Checking the problem in CAD Assistant will help you to know if the problem is easily repoducible and if it is fixed or not in the latest version of OCCT.

but when the mouse passes exactly on the projection of a vertical face of the lower box, it highlights as if vertical plane were infinite

OCCT selection has a logic detecting triangle/ray intersection with prolonging triangle borders to allow selection in some corner cases.
It seems that this algorithm misbehaves at axis-aligned view directions, so that result looks wrong - it might be either a bug in algorithm or bad tolerance value in comparison.
As you can see on your screenshot - the issue happens when mouse is over a sharp edge of a shape below.

You may try debugging the logic in OCCT and contribute patches, as well as contacting Open Cascade for assistance / bug fixing.

Gianluca Antoniacci's picture

Good morning Kirill,

as I told you, I managed to reproduce the problem within the WPF sample application. The strange aspect of this issue is that it's very simple to recreate such a situation and that it is a very common scenario when dealing with simple objects with flat horizontal or vertical faces, thus it should have been reported a long time ago...

it might be either a bug in algorithm or bad tolerance value in comparison.

is there maybe something to set in a more appropriate way (tolerance or something) in order to prevent the comparison mechanism from selecting indefinitely prolonged faces? Maybe so many people don't experience such an issue (and maybe I didn't too, with 6.3.0 version) due to some selection "sensitiveness" parameter or something that triggers this misbehaviour.

Many thanks for your help

Gianluca

Gianluca Antoniacci's picture

Good morning Kirill,

did you manage to find out what is wrong with my data? Is there something new in the selection mechanism that causes this strange behaviour?

Many thanks

Gianluca

Gianluca Antoniacci's picture

I guess that there must be a bug (very strange!!!!) or something wrong in my settings or in my graphical options: I get the same behaviour just by drawing 2 boxes, the smaller below the larger, and setting the camera from above: when the mouse hovers above the vertical faces of the lower box, also if upper box is in between, the vertical face is detected and the lower box (although is hidden by the other) is highlighted.

I hope that this can help.

Gianluca