1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0031548: Visualization, SelectBasics_PickResult - include surface normal into picking details

SelectMgr_SortCriterion::Normal, SelectBasics_PickResult::SurfaceNormal() - added new property.
SelectMgr_RectangularFrustum::Overlaps() for triangle sets new normal property.
gp_GTrsf::GetMat4() - added conversion into NCollection_Mat4 similar to gp_Trsf::GetMat4().
This commit is contained in:
kgv
2020-05-05 01:23:41 +03:00
committed by bugmaster
parent 23fe70ec52
commit 2615c2d705
6 changed files with 85 additions and 22 deletions

View File

@@ -669,6 +669,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
thePickResult.SetPickedPoint (thePnt1);
thePickResult.SetSurfaceNormal (aTriangleNormal);
return !theClipRange.IsClipped (thePickResult.Depth());
}
@@ -687,6 +688,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
{
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
thePickResult.SetPickedPoint (aPtOnPlane);
thePickResult.SetSurfaceNormal (aTriangleNormal);
return !theClipRange.IsClipped (thePickResult.Depth());
}

View File

@@ -17,6 +17,7 @@
#ifndef _SelectMgr_SortCriterion_HeaderFile
#define _SelectMgr_SortCriterion_HeaderFile
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <Precision.hxx>
#include <Select3D_SensitiveEntity.hxx>
@@ -29,6 +30,7 @@ public:
Handle(Select3D_SensitiveEntity) Entity; //!< detected entity
gp_Pnt Point; //!< 3D point
Graphic3d_Vec3 Normal; //!< surface normal or 0 vector if undefined
Standard_Real Depth; //!< distance from the view plane to the entity
Standard_Real MinDist; //!< distance from the clicked point to the entity on the view plane
Standard_Real Tolerance; //!< tolerance used for selecting candidates

View File

@@ -76,9 +76,17 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
return;
}
bool hasNormal = false;
if (thePickResult.HasPickedPoint())
{
theCriterion.Point = thePickResult.PickedPoint();
theCriterion.Point = thePickResult.PickedPoint();
theCriterion.Normal = thePickResult.SurfaceNormal();
const float aNormLen2 = theCriterion.Normal.SquareModulus();
if (aNormLen2 > ShortRealEpsilon())
{
hasNormal = true;
theCriterion.Normal *= 1.0f / sqrtf (aNormLen2);
}
}
else if (!thePickResult.IsValid())
{
@@ -97,7 +105,15 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
}
if (anInvTrsf.Form() != gp_Identity)
{
anInvTrsf.Inverted().Transforms (theCriterion.Point.ChangeCoord());
const gp_GTrsf anInvInvTrsd = anInvTrsf.Inverted();
anInvInvTrsd.Transforms (theCriterion.Point.ChangeCoord());
if (hasNormal)
{
Graphic3d_Mat4d aMat4;
anInvInvTrsd.GetMat4 (aMat4);
const Graphic3d_Vec4d aNormRes = aMat4 * Graphic3d_Vec4d (Graphic3d_Vec3d (theCriterion.Normal), 0.0);
theCriterion.Normal = Graphic3d_Vec3 (aNormRes.xyz());
}
}
if (mySelectingVolumeMgr.Camera().IsNull())