Fri, 06/26/2020 - 13:16
Forums:
Hello,
I'm using OpenCascade within a .Net wrapper and I noticed that AIS_InteractiveContext MoveTo is detecting objects when the point is actually over a part of the object that is clipped by a ClipPlane.
I can handle this locally by checking the world point against the Clip plane's half-space, but I'd like the base behaviour to work.
I looked into SelectMgr_Filter, but as far as I can see, the SelectMgr_EntityOwner passed into IsOk doesn't contain enough information to do these checks.
Is there a proper way to handle this?
Many thanks,
Pete
Sat, 06/27/2020 - 20:25
OCCT 3D Viewer automatically discards picking results for invisible (clipped by planes) parts, so that it does not make sense defining extra selection filters for this task.
Either, you observed some bug, or real usage scenario is more complicated than described.
I would suggest contacting support services if you have received .NET wrapper from Open Cascade.
Mon, 06/29/2020 - 19:25
Hi, Kirill,
I've been looking further into this, so I'll post what I found with a bit more of an explanation. We are using a wrapper, but the calls involved in setting this up are straightforward pass throughs to the C++ side, so I don't think the wrapper is the problem.
I'm trying to create a 'shortening' effect to a long object by having two identical shapes overlap. One is then translated to get rid off the middle. Two clip planes are applied, one to each of the shapes. However, I can create this problem with a simple one-shape version.
Essentially, everything works as expected for the picking until I translate the shape. My translation is being applied through the PrsMgr_PresentableObject::setLocalTransformation() method. The actual object is an AIS_ColouredShape created from a TopoDS_Shape.
I've attached two screenshots. In Clip1, object picking works as expected. However, in Clip2, when I translate the object in the direction of the clip, I'm able to pick-up the object by hovering the invisible section.
The picking is done via the Ais_InteractiveContext.MainSelector().Pick(int, int, view) method
Apologies if this does turn out to be .Net Wrapper related, but thought it worth asking in case anything obvious jumped out.
thanks,
Pete
Mon, 06/29/2020 - 19:31
Are you sure you don't have selection issues on translated object without any clipping planes?
Tue, 06/30/2020 - 11:50
Good idea to check, but it appears I don't have problems when no clipping planes are used.
I've attached another image to show the situation.
A, B, C all work as expected when using MoveTo(int, int, view) followed by MainSelector().NbPicked()
D and E show the problem, where picking appears to find parts that are clipped visually. The whole shape isn't selectable. The size of the erroneous area look suspiciously like the amount of translation that has been applied (zero of the horizontal axis is the left end of A)
The clip plane has been applied to the shapes, not the View.
Thanks for you suggestion, Kirill. I'll think build the C++ version and see if I can recreate there.
Wed, 07/01/2020 - 09:58
Yes, minimal sample reproducing the problem would be better than screenshots.
And I suppose that you are working on OCCT 7.4.0.
Fri, 07/03/2020 - 15:18
Hi, Kirill,
I've reproduced this in the OCC 7.4.0 code samples, so I hope this helps. I'm loading a step file, my test involves inserting a bit of code into the Step loader C++.
If you start with the CSharp samples (I'm launching the IE_WPF_Winforms proj)
1) Add TKG3D.lib to the OCCTProxy's linker input (so we can use Geom_Transform)
2) In ImportStep (OCCTProxy.cpp) replace the body of the forloop that loops over NbShapes with this code, that adds a clip-plane and translates the DisplayShape upwards.
TopoDS_Shape aShape = aReader.Shape( i );
auto displayShape = new AIS_Shape(aShape);
Handle(Graphic3d_ClipPlane) cp = new Graphic3d_ClipPlane(
gp_Pln(
gp_Pnt(0, 0, -10),
gp_Dir(0, 0, -1)));
displayShape->AddClipPlane(cp);
gp_Trsf transform;
transform.SetTranslation(
gp_Vec(0, 0, 20));
displayShape->SetLocalTransformation(transform);
myAISContext()->Display (displayShape, Standard_False);
3) Launch the viewer and import the Screw step model
4) Drag the mouse-cursor over the visually clipped part of the shape. You'll see that it detects some of the object (not all). If you remove the translation, the selection works. (see attached images)
Hope this helps identify whether there is a bug present or not and/or whether I'm using it incorrectly.
thanks,
Pete
Sat, 07/04/2020 - 12:29
Yes, this is a bug. Clipping plane is not ignored by picking, it is applied at wrong location.
Mon, 06/29/2020 - 11:41
Thanks, Kirill. I will investigate further and have a look at the OCCT 3D Viewer.