1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0024564: Select3D_SensitiveFace gives inaccurate picking depth for AIS_Plane (interior selection)

1) Used more accurate Select3D_SensitiveTriangulation instead of Select3D_SensitiveFace for rectangular sensitives in AIS_Plane::ComputeSelection, AIS_Dimension::ComputeSelection
2) Test case for CR24564
This commit is contained in:
apl 2014-01-24 11:01:42 +04:00 committed by bugmaster
parent be7c077ac5
commit 51f8f60c7a
4 changed files with 107 additions and 43 deletions

View File

@ -54,8 +54,10 @@
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <Select3D_SensitiveTriangle.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Triangulation.hxx>
#include <Standard_CString.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <StdPrs_WFShape.hxx>
@ -1307,13 +1309,21 @@ void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
gp_Trsf aLabelPlane;
aLabelPlane.SetTransformation (aTextAxes, gp::XOY());
TColgp_Array1OfPnt aRectanglePoints (1, 4);
aRectanglePoints.ChangeValue (1) = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue (2) = gp_Pnt (-aDx, aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue (3) = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue (4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane);
TColgp_Array1OfPnt aRectanglePoints(1, 4);
aRectanglePoints.ChangeValue(1) = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue(2) = gp_Pnt (-aDx, aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue(3) = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane);
aRectanglePoints.ChangeValue(4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane);
aTextSensitive = new Select3D_SensitiveFace (aSensitiveOwner, aRectanglePoints);
Poly_Array1OfTriangle aTriangles(1, 2);
aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
aTriangles.ChangeValue(2) = Poly_Triangle(1, 3, 4);
Handle(Poly_Triangulation) aRectanglePoly =
new Poly_Triangulation(aRectanglePoints, aTriangles);
aTextSensitive =
new Select3D_SensitiveTriangulation (aSensitiveOwner, aRectanglePoly, TopLoc_Location(), Standard_True);
}
else
{

View File

@ -221,9 +221,9 @@ is
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard) is redefined virtual;
ComputeSelection (me : mutable;
theSelection : mutable Selection from SelectMgr;
theMode : Integer from Standard) is redefined virtual;
-- Methods from InteractiveObject

View File

@ -49,11 +49,13 @@
#include <DsgPrs_ShadedPlanePresentation.hxx>
#include <UnitsAPI.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <Poly_Triangulation.hxx>
#include <AIS_Drawer.hxx>
#include <TCollection_AsciiString.hxx>
@ -303,47 +305,57 @@ void AIS_Plane::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_G
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
void AIS_Plane::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer /*theMode*/)
{
aSelection->Clear();
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
Handle(Select3D_SensitiveFace) sfac;
theSelection->Clear();
Handle(SelectMgr_EntityOwner) aSensitiveOwner = new SelectMgr_EntityOwner (this, 10);
Handle(Poly_Triangulation) aSensitivePoly;
if (!myIsXYZPlane){
if (!myIsXYZPlane)
{
// plane representing rectangle
Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0;
Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0;
Handle(Geom_Plane) aPlane =
Handle(Geom_Plane)::DownCast (myComponent->Translated (myComponent->Location(), myCenter));
Handle(TColgp_HArray1OfPnt) harr = new TColgp_HArray1OfPnt(1,5);
TColgp_Array1OfPnt& arr = harr->ChangeArray1();
Standard_Real lx = myDrawer->PlaneAspect()->PlaneXLength()/2.;
Standard_Real ly = myDrawer->PlaneAspect()->PlaneYLength()/2.;
const Handle(Geom_Plane)& pl = myComponent;
const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter));
thegoodpl->D0(lx,ly,arr(1));
thegoodpl->D0(lx,-ly,arr(2));
thegoodpl->D0(-lx,-ly,arr(3));
thegoodpl->D0(-lx,ly,arr(4));
arr(5) = arr(1);
sfac = new Select3D_SensitiveFace(eown,harr,myTypeOfSensitivity);
TColgp_Array1OfPnt aRectanglePoints (1, 4);
aPlane->D0 ( aLengthX, aLengthY, aRectanglePoints.ChangeValue (1));
aPlane->D0 ( aLengthX, -aLengthY, aRectanglePoints.ChangeValue (2));
aPlane->D0 (-aLengthX, -aLengthY, aRectanglePoints.ChangeValue (3));
aPlane->D0 (-aLengthX, aLengthY, aRectanglePoints.ChangeValue (4));
Poly_Array1OfTriangle aTriangles (1, 2);
aTriangles.ChangeValue (1) = Poly_Triangle (1, 2, 3);
aTriangles.ChangeValue (2) = Poly_Triangle (1, 3, 4);
aSensitivePoly = new Poly_Triangulation (aRectanglePoints, aTriangles);
}
else {
Handle(TColgp_HArray1OfPnt) harr1 = new TColgp_HArray1OfPnt(1,4);
TColgp_Array1OfPnt& arr1 = harr1->ChangeArray1();
arr1(1) = myCenter;
arr1(2) = myPmin;
arr1(3) = myPmax;
arr1(4) = myCenter;
sfac = new Select3D_SensitiveFace(eown,harr1,myTypeOfSensitivity);
else
{
// plane representing triangle
TColgp_Array1OfPnt aTrianglePoints (1, 3);
aTrianglePoints.ChangeValue (1) = myCenter;
aTrianglePoints.ChangeValue (2) = myPmin;
aTrianglePoints.ChangeValue (3) = myPmax;
Poly_Array1OfTriangle aTriangles (1, 1);
aTriangles.ChangeValue (1) = Poly_Triangle(1, 2, 3);
aSensitivePoly = new Poly_Triangulation (aTrianglePoints, aTriangles);
}
aSelection->Add(sfac);
Standard_Boolean isSensitiveInterior = myTypeOfSensitivity == Select3D_TOS_INTERIOR;
Handle(Select3D_SensitiveTriangulation) aSensitive =
new Select3D_SensitiveTriangulation (aSensitiveOwner,
aSensitivePoly,
TopLoc_Location(),
isSensitiveInterior);
theSelection->Add(aSensitive);
}
//=======================================================================
//function : SetSize
//purpose :

42
tests/bugs/vis/bug24564 Normal file
View File

@ -0,0 +1,42 @@
puts "============"
puts "CR24564"
puts "============"
puts ""
#######################################################################
# Test for sensitivity of box located over AIS_Plane
#######################################################################
set aV "Driver1/Viewer1/View1"
vinit name=$aV l=32 t=32 w=400 h=400
vactivate $aV
vclear
puts "Testing box selection over the plane in orthogonal projection:"
vpoint p1 0 0 0
vpoint p2 1 0 0
vpoint p3 0 1 0
vplane pl1 p1 p2 p3 0
box b 50 50 50
vdisplay b
vfit
vtop
vmoveto 199 200
checkcolor 199 200 0 1 1
if { $stat != 1 } {
puts "Error : The box is not selectable!"
}
puts "Testing box selection over the plane in axonometry projection:"
vaxo
vfit
vmoveto 199 200
checkcolor 199 200 0 1 1
if { $stat != 1 } {
puts "Error : The box is not selectable!"
}