const SelectMgr_IndexedDataMapOfOwnerCriterion& myMapOfCriterion;
};
- //! Compute 3d position for detected entity.
- inline void updatePoint3d (SelectMgr_SortCriterion& theCriterion,
- const gp_GTrsf& theInversedTrsf,
- SelectMgr_SelectingVolumeManager& theMgr)
+ static const Graphic3d_Mat4d SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
+}
+
+//=======================================================================
+// function : updatePoint3d
+// purpose :
+//=======================================================================
+void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriterion,
+ const Handle(SelectBasics_SensitiveEntity)& theEntity,
+ const gp_GTrsf& theInversedTrsf,
+ const SelectMgr_SelectingVolumeManager& theMgr) const
+{
+ if (theMgr.GetActiveSelectionType() != SelectMgr_SelectingVolumeManager::Point)
{
- if (theMgr.GetActiveSelectionType() != SelectMgr_SelectingVolumeManager::Point)
- {
- return;
- }
+ return;
+ }
- theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
- gp_GTrsf anInvTrsf = theInversedTrsf;
- if (theCriterion.Entity->HasInitLocation())
- {
- anInvTrsf = theCriterion.Entity->InvInitLocation() * anInvTrsf;
- }
- if (anInvTrsf.Form() != gp_Identity)
- {
- anInvTrsf.Inverted().Transforms (theCriterion.Point.ChangeCoord());
- }
+ theCriterion.Point = theMgr.DetectedPoint (theCriterion.Depth);
+ gp_GTrsf anInvTrsf = theInversedTrsf;
+ if (theCriterion.Entity->HasInitLocation())
+ {
+ anInvTrsf = theCriterion.Entity->InvInitLocation() * anInvTrsf;
+ }
+ if (anInvTrsf.Form() != gp_Identity)
+ {
+ anInvTrsf.Inverted().Transforms (theCriterion.Point.ChangeCoord());
}
- static const Graphic3d_Mat4d SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
+ if (mySelectingVolumeMgr.Camera().IsNull())
+ {
+ theCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0;
+ }
+ else if (mySelectingVolumeMgr.Camera()->IsOrthographic())
+ {
+ theCriterion.Tolerance = myCameraScale * theEntity->SensitivityFactor();
+ }
+ else
+ {
+ const Standard_Real aDistFromEye = (theCriterion.Point.XYZ() - myCameraEye.XYZ()).Dot (myCameraDir.XYZ());
+ theCriterion.Tolerance = aDistFromEye * myCameraScale * theEntity->SensitivityFactor();
+ }
}
//==================================================
SelectMgr_ViewerSelector::SelectMgr_ViewerSelector():
preferclosest(Standard_True),
myToUpdateTolerance (Standard_True),
+myCameraScale (1.0),
myCurRank (0),
myIsLeftChildQueuedFirst (Standard_False),
myEntityIdx (0)
aCriterion.Priority = anOwner->Priority();
aCriterion.Depth = aPickResult.Depth();
aCriterion.MinDist = aPickResult.DistToGeomCenter();
- aCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0;
aCriterion.ToPreferClosest = preferclosest;
if (SelectMgr_SortCriterion* aPrevCriterion = mystored.ChangeSeek (anOwner))
{
if (aCriterion > *aPrevCriterion)
{
- updatePoint3d (aCriterion, theInversedTrsf, theMgr);
+ updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
*aPrevCriterion = aCriterion;
}
}
else
{
aCriterion.NbOwnerMatches = 1;
- updatePoint3d (aCriterion, theInversedTrsf, theMgr);
+ updatePoint3d (aCriterion, theEntity, theInversedTrsf, theMgr);
mystored.Add (anOwner, aCriterion);
}
}
mySelectingVolumeMgr.WorldViewMatrix(),
mySelectingVolumeMgr.WorldViewProjState(),
aWidth, aHeight);
+ const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
+ if (!aCamera.IsNull())
+ {
+ myCameraEye = aCamera->Eye().XYZ();
+ myCameraDir = aCamera->Direction().XYZ();
+ myCameraScale = aCamera->IsOrthographic()
+ ? aCamera->Scale()
+ : 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0);
+ const double aPixelSize = Max (1.0 / aWidth, 1.0 / aHeight);
+ myCameraScale *= aPixelSize;
+ }
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
{
aMgr = mySelectingVolumeMgr;
}
- const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
const Graphic3d_Mat4d& aProjectionMat = mySelectingVolumeMgr.ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = aBVHSubset != SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent
? mySelectingVolumeMgr.WorldViewMatrix()
--- /dev/null
+puts "# ==================================================================="
+puts "# 0027618: Visualization - selection returns entity overlapped by another entity on border cases"
+puts "# ==================================================================="
+puts ""
+
+pload MODELING VISUALIZATION
+set s 0.001
+box bb 0*$s 0*$s 0*$s 100*$s 100*$s 50*$s
+box bt 50*$s 50*$s 25*$s 20*$s 20*$s 40*$s
+vclear
+vinit View1
+vpoint p0 0*$s 0*$s 0*$s
+vpoint p1 0*$s 100*$s 50*$s
+vdisplay -dispMode 1 -highMode 1 bb bt
+vsetcolor bt RED
+vaxo
+vfit
+
+vpoint pp 245 -190 0
+vdisplay -2d topLeft -topmost pp
+vselmode pp 0 0
+vmoveto 245 190
+
+if { [vreadpixel 235 140 rgb name] == "DARKTURQUOISE" } { puts "Error: top should NOT be highlighted" }
+if { [vreadpixel 235 190 rgb name] != "DARKTURQUOISE" } { puts "Error: bottom should be highlighted" }
+vseldump $imagedir/${casename}_sel_depth.png -type depth
+vseldump $imagedir/${casename}_sel_entity.png -type entity
+
+vcamera -persp
+
+vmoveto 0 0
+vmoveto 245 190
+if { [vreadpixel 235 140 rgb name] == "DARKTURQUOISE" } { puts "Error: top should NOT be highlighted" }
+if { [vreadpixel 235 190 rgb name] != "DARKTURQUOISE" } { puts "Error: bottom should be highlighted" }
+
+vseldump $imagedir/${casename}_perps_sel_depth.png -type depth
+vseldump $imagedir/${casename}_persp_sel_entity.png -type entity