Fixed regression of SelectMgr_ViewerSelector::SetPixelTolerance(). Removed redundant myToUpdateTolerance flag.
SelectMgr_AxisIntersector::raySegmentDistance() - fixed usage of SquareModulus() instead of Modulus().
SelectMgr_ViewerSelector::TraverseSensitives() now skips both BVHSubset_2dPersistent and BVHSubset_3dPersistent relying on Camera.
AIS_ViewController::handleXRMoveTo() now uses interface for picking by Axis explicitly
instead of emulating axis by point picking.
{
throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
}
+ myMainSel->Pick (theXPix, theYPix, theView);
+ return moveTo (theView, theToRedrawOnUpdate);
+}
+//=======================================================================
+//function : MoveTo
+//purpose :
+//=======================================================================
+AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const gp_Ax1& theAxis,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate)
+{
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
+ }
+ myMainSel->Pick (theAxis, theView);
+ return moveTo (theView, theToRedrawOnUpdate);
+}
+
+//=======================================================================
+//function : moveTo
+//purpose :
+//=======================================================================
+AIS_StatusOfDetection AIS_InteractiveContext::moveTo (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate)
+{
myCurDetected = 0;
myCurHighlighted = 0;
myDetectedSeq.Clear();
Standard_Boolean toUpdateViewer = Standard_False;
myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
- myMainSel->Pick (theXPix, theYPix, theView);
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
// (the objects must be AIS_Shapes)
const Handle(V3d_View)& theView,
const Standard_Boolean theToRedrawOnUpdate);
+ //! Relays axis theAxis to the interactive context selectors.
+ //! This is done by the view theView passing this axis to the main viewer and updating it.
+ //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
+ //! @sa PickingStrategy()
+ Standard_EXPORT AIS_StatusOfDetection MoveTo (const gp_Ax1& theAxis,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate);
+
//! Clears the list of entities detected by MoveTo() and resets dynamic highlighting.
//! @param theToRedrawImmediate if TRUE, the main Viewer will be redrawn on update
//! @return TRUE if viewer needs to be updated (e.g. there were actually dynamically highlighted entities)
Standard_EXPORT void InitAttributes();
+ //! Highlights detected objects.
+ //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to update view.
+ Standard_EXPORT AIS_StatusOfDetection moveTo (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate);
+
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
Standard_EXPORT void unselectOwners (const Handle(AIS_InteractiveObject)& theObject);
{
return;
}
- if (myXRCameraTmp.IsNull())
- {
- myXRCameraTmp = new Graphic3d_Camera();
- }
handleXRTurnPad (theCtx, theView);
handleXRTeleport(theCtx, theView);
handleXRPicking (theCtx, theView);
const Standard_Boolean theToHighlight)
{
//ResetPreviousMoveTo();
+ const gp_Ax1 aViewAxis = theView->View()->ViewAxisInWorld (thePose);
Standard_Integer aPickResult = 0;
-
- Handle(Graphic3d_Camera) aCamBack = theView->Camera();
- myXRCameraTmp->Copy (aCamBack);
- theView->View()->ComputeXRPosedCameraFromBase (*myXRCameraTmp, thePose);
- theView->SetCamera (myXRCameraTmp);
- Graphic3d_Vec2i aPickPixel;
- theView->Window()->Size (aPickPixel.x(), aPickPixel.y());
- aPickPixel /= 2;
- const Standard_Integer aSelTolerBack = theCtx->MainSelector()->CustomPixelTolerance();
- theCtx->MainSelector()->SetPixelTolerance (1);
- theView->AutoZFit();
if (theToHighlight)
{
- theCtx->MoveTo (aPickPixel.x(), aPickPixel.y(), theView, false);
+ theCtx->MoveTo (aViewAxis, theView, false);
if (!theCtx->DetectedOwner().IsNull())
{
- // ignore 2D objects
- for (aPickResult = 1; !theCtx->DetectedOwner()->Selectable()->TransformPersistence().IsNull(); ++aPickResult)
- {
- if (theCtx->HilightNextDetected (theView, false) <= 1)
- {
- theCtx->ClearDetected();
- aPickResult = 0;
- break;
- }
- }
+ aPickResult = 1;
}
}
else
{
- theCtx->MainSelector()->Pick (aPickPixel.x(), aPickPixel.y(), theView);
- for (Standard_Integer aPickIter = 1; aPickIter <= theCtx->MainSelector()->NbPicked(); ++aPickIter)
+ theCtx->MainSelector()->Pick (aViewAxis, theView);
+ if (theCtx->MainSelector()->NbPicked() >= 1)
{
- const SelectMgr_SortCriterion& aPickedData = theCtx->MainSelector()->PickedData (aPickIter);
- if (!aPickedData.Entity->OwnerId()->Selectable()->TransformPersistence().IsNull())
- {
- // skip 2d objects
- continue;
- }
-
- aPickResult = aPickIter;
- break;
+ aPickResult = 1;
}
}
- theCtx->MainSelector()->SetPixelTolerance (aSelTolerBack);
- theView->SetCamera (aCamBack);
+
return aPickResult;
}
protected: //! @name XR input variables
NCollection_Array1<Handle(AIS_XRTrackedDevice)> myXRPrsDevices; //!< array of XR tracked devices presentations
- Handle(Graphic3d_Camera) myXRCameraTmp; //!< temporary camera
Quantity_Color myXRLaserTeleColor; //!< color of teleport laser
Quantity_Color myXRLaserPickColor; //!< color of picking laser
Aspect_XRTrackedDeviceRole myXRLastTeleportHand;//!< active hand for teleport
void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; }
//! Convert XR pose to world space.
- //! @param theTrsfXR [in] transformation defined in VR local coordinate system,
+ //! @param thePoseXR [in] transformation defined in VR local coordinate system,
//! oriented as Y-up, X-right and -Z-forward
//! @return transformation defining orientation of XR pose in world space
gp_Trsf PoseXRToWorld (const gp_Trsf& thePoseXR) const
return aTrsfCS * thePoseXR;
}
+ //! Returns view direction in the world space based on XR pose.
+ //! @param thePoseXR [in] transformation defined in VR local coordinate system,
+ //! oriented as Y-up, X-right and -Z-forward
+ gp_Ax1 ViewAxisInWorld (const gp_Trsf& thePoseXR) const
+ {
+ return gp_Ax1 (gp::Origin(), -gp::DZ()).Transformed (PoseXRToWorld (thePoseXR));
+ }
+
//! Recomputes PosedXRCamera() based on BaseXRCamera() and head orientation.
Standard_EXPORT void SynchronizeXRBaseToPosedCamera();
{
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
- myToUpdateTolerance = Standard_True;
}
}
{
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
- myToUpdateTolerance = Standard_True;
}
}
const gp_Pnt& theSegPnt2,
SelectBasics_PickResult& thePickResult) const
{
- gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ();
- gp_XYZ aV = myAxis.Direction().XYZ();
- gp_XYZ aW = theSegPnt1.XYZ() - myAxis.Location().XYZ();
-
- gp_XYZ anUVNormVec = aV.Crossed (anU);
- gp_XYZ anUWNormVec = aW.Crossed (anU);
- if (anUVNormVec.Modulus() <= Precision::Confusion() ||
- anUWNormVec.Modulus() <= Precision::Confusion())
+ const gp_XYZ anU = theSegPnt2.XYZ() - theSegPnt1.XYZ();
+ const gp_XYZ aV = myAxis.Direction().XYZ();
+ const gp_XYZ aW = theSegPnt1.XYZ() - myAxis.Location().XYZ();
+
+ const gp_XYZ anUVNormVec = aV.Crossed (anU);
+ const Standard_Real anUVNormVecMod = anUVNormVec.Modulus();
+ if (anUVNormVecMod <= Precision::Confusion())
{
// Lines have no intersection
thePickResult.Invalidate();
return false;
}
- Standard_Real aParam = anUWNormVec.Dot (anUVNormVec) / anUVNormVec.SquareModulus();
+ const gp_XYZ anUWNormVec = aW.Crossed (anU);
+ const Standard_Real anUWNormVecMod = anUWNormVec.Modulus();
+ if (anUWNormVecMod <= Precision::Confusion())
+ {
+ // Lines have no intersection
+ thePickResult.Invalidate();
+ return false;
+ }
+
+ const Standard_Real aParam = anUWNormVec.Dot (anUVNormVec) / anUVNormVecMod;
if (aParam < 0.0)
{
// Intersection is out of axis start point
return false;
}
- gp_XYZ anIntersectPnt = myAxis.Location().XYZ() + aV * aParam;
- if ((anIntersectPnt - theSegPnt1.XYZ()).SquareModulus() +
- (anIntersectPnt - theSegPnt2.XYZ()).SquareModulus() >
- anU.SquareModulus() + Precision::Confusion())
+ const gp_XYZ anIntersectPnt = myAxis.Location().XYZ() + aV * aParam;
+ if ((anIntersectPnt - theSegPnt1.XYZ()).Modulus() +
+ (anIntersectPnt - theSegPnt2.XYZ()).Modulus() >
+ anU.Modulus() + Precision::Confusion())
{
// Intersection point doesn't lie on the segment
thePickResult.Invalidate();
}
}
thePickResult.SetSurfaceNormal (aTriangleNormal);
- return !theClipRange.IsClipped (thePickResult.Depth());
+ return thePickResult.IsValid()
+ && !theClipRange.IsClipped (thePickResult.Depth());
}
// check if intersection point belongs to triangle's interior part
}
}
- return !theClipRange.IsClipped (thePickResult.Depth());
+ return thePickResult.IsValid()
+ && !theClipRange.IsClipped (thePickResult.Depth());
}
//=======================================================================
{
mySelector->myTolerances.Decrement (aPrevSens);
mySelector->myTolerances.Add (theNewSens);
- mySelector->myToUpdateTolerance = Standard_True;
}
}
: myDepthTolerance (0.0),
myDepthTolType (SelectMgr_TypeOfDepthTolerance_SensitivityFactor),
myToPreferClosest (Standard_True),
- myToUpdateTolerance (Standard_True),
myCameraScale (1.0),
myToPrebuildBVH (Standard_False),
myIsLeftChildQueuedFirst (Standard_False)
{
return;
}
-
- myToUpdateTolerance = Standard_True;
if (theTolerance < 0)
{
myTolerances.ResetDefaults();
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
- myToUpdateTolerance = Standard_True;
}
}
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
- myToUpdateTolerance = Standard_True;
}
}
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
{
- SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset =
- static_cast<SelectMgr_SelectableObjectSet::BVHSubset> (aBVHSetIt);
-
+ const SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset )aBVHSetIt;
if (mySelectableObjects.IsEmpty (aBVHSubset))
{
continue;
}
+ if (aCamera.IsNull()
+ && aBVHSubset != SelectMgr_SelectableObjectSet::BVHSubset_3d)
+ {
+ continue;
+ }
gp_GTrsf aTFrustum;
-
SelectMgr_SelectingVolumeManager aMgr;
- // for 2D space selection transform selecting volumes to perform overap testing
+ // for 2D space selection transform selecting volumes to perform overlap testing
// directly in camera's eye space omitting the camera position, which is not
// needed there at all
if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent)
{
- if (aCamera.IsNull())
- {
- continue;
- }
const Graphic3d_Mat4d& aMat = mySelectingVolumeMgr.WorldViewMatrix();
aTFrustum.SetValue (1, 1, aMat.GetValue (0, 0));
aTFrustum.SetValue (1, 2, aMat.GetValue (0, 1));
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToPreferClosest)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToUpdateTolerance)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mystored.Extent())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &mySelectingVolumeMgr)
Standard_Real myDepthTolerance;
SelectMgr_TypeOfDepthTolerance myDepthTolType;
Standard_Boolean myToPreferClosest;
- Standard_Boolean myToUpdateTolerance;
SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
mutable SelectMgr_SelectableObjectSet mySelectableObjects;
static_cast<Standard_Real> (theYPix));
mySelectingVolumeMgr.InitPointSelectingVolume (aMousePos);
- if(myToUpdateTolerance)
- {
- mySelectingVolumeMgr.SetPixelTolerance (myTolerances.Tolerance());
- myToUpdateTolerance = Standard_False;
- }
+ mySelectingVolumeMgr.SetPixelTolerance (myTolerances.Tolerance());
mySelectingVolumeMgr.SetCamera (theView->Camera());
Standard_Integer aWidth = 0, aHeight = 0;
theView->Window()->Size (aWidth, aHeight);
--- /dev/null
+puts "========"
+puts "0032338: Visualization - provide straightforward interface for ray-picking"
+puts "========"
+puts ""
+
+pload MODELING VISUALIZATION
+box b 100 200 300
+vinit View1
+vdisplay -dispMode 1 b
+vfit
+vselmode b VERTEX 1
+vselmode b FACE 1
+set point1 [vmoveto 324 320]
+vdump ${imagedir}/${casename}_p1.png
+
+regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${point1} full p1
+checkpoint "point1" $p1 {100 200 0} 0.001
+
+vselaxis 50 -100 100 0 1 0 -display a
+vmoveto 0 0
+set point2 [vmoveto 324 320]
+vdump ${imagedir}/${casename}_p2.png
+regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${point1} full p2
+checkpoint "point2" $p2 {100 200 0} 0.001