Clipping range has been moved from SelectMgr_RectangularFrustum to SelectMgr_SelectingVolumeManager
and passed to frustum as an argument to Overlap() methods.
This fixes an issue when Clipping is customized per-object within SelectMgr_ViewerSelector::traverseObject()
in case when shallow copy of SelectMgr_SelectingVolumeManager is created
(frustums are copied from global frustum manager by Handle).
SelectMgr_TypeOfBVHUpdate.hxx
SelectMgr_TypeOfUpdate.hxx
SelectMgr_VectorTypes.hxx
+SelectMgr_ViewClipRange.cxx
SelectMgr_ViewClipRange.hxx
SelectMgr_ViewerSelector.cxx
SelectMgr_ViewerSelector.hxx
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
const SelectMgr_Vec3& /*theBoxMax*/,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return Standard_False;
// purpose : Intersection test between defined volume and given point
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& ) const
{
return Standard_False;
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
Select3D_TypeOfSensitivity /*theSensType*/,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& ) const
{
return Standard_False;
const gp_Pnt& /*thePt2*/,
const gp_Pnt& /*thePt3*/,
Select3D_TypeOfSensitivity /*theSensType*/,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& ) const
{
return Standard_False;
//=======================================================================
Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
const gp_Pnt& /*thePnt2*/,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& ) const
{
return Standard_False;
#define _SelectMgr_BaseFrustum_HeaderFile
#include <gp_GTrsf.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pln.hxx>
-
#include <Graphic3d_Camera.hxx>
-#include <Graphic3d_ClipPlane.hxx>
-#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_WorldViewProjState.hxx>
-
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-
#include <Select3D_BndBox3d.hxx>
-#include <SelectMgr_FrustumBuilder.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
+#include <SelectMgr_FrustumBuilder.hxx>
#include <SelectMgr_VectorTypes.hxx>
-
+#include <SelectMgr_ViewClipRange.hxx>
#include <SelectBasics_PickResult.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
//! This class is an interface for different types of selecting frustums,
//! defining different selection types, like point, box or polyline
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const;
//! Intersection test between defined volume and given point
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const;
//! SAT intersection test between defined volume and given triangle. The test may
const gp_Pnt& thePt2,
const gp_Pnt& thePt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const;
//! Measures distance between 3d projection of user-picked
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const;
- //! Valid for point selection only!
- //! Computes depth range for clipping planes.
- //! @param theViewPlanes global view planes
- //! @param theObjPlanes object planes
- virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
- const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
- {
- (void )theViewPlanes;
- (void )theObjPlanes;
- }
-
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
// {i, j, k} vectors and store them to corresponding class fields
cacheVertexProjections (this);
- myViewClipRange.SetVoid();
-
myScale = 1.0;
}
// {i, j, k} vectors and store them to corresponding class fields
cacheVertexProjections (this);
- myViewClipRange.SetVoid();
-
myScale = 1.0;
}
cacheVertexProjections (aRes.get());
- aRes->myViewClipRange = myViewClipRange;
- aRes->myMousePos = myMousePos;
+ aRes->myMousePos = myMousePos;
return aRes;
}
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (!hasOverlap (theBoxMin, theBoxMax))
aDepth = aNearestPnt.Distance (myNearPickedPnt);
thePickResult.SetDepth (aDepth);
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
- if (!myViewClipRange.GetNearestDepth (aRange, aDepth))
+ if (!theClipRange.GetNearestDepth (aRange, aDepth))
{
return Standard_False;
}
// purpose : Intersection test between defined volume and given point
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (!hasOverlap (thePnt))
thePickResult.SetDepth (aDetectedPnt.Distance (myNearPickedPnt) * myScale);
thePickResult.SetPickedPoint (thePnt);
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
// =======================================================================
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (!hasOverlap (thePnt1, thePnt2))
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
// =======================================================================
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
if (aPolyNorm.Magnitude() <= Precision::Confusion())
{
// treat degenerated polygon as point
- return Overlaps (theArrayOfPnts.First(), thePickResult);
+ return Overlaps (theArrayOfPnts.First(), theClipRange, thePickResult);
}
else if (!segmentPlaneIntersection (aPolyNorm, theArrayOfPnts.First(), thePickResult))
{
}
}
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
// =======================================================================
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
- return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
+ return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
const gp_XYZ aDiff = myNearPickedPnt.XYZ() - thePnt1.XYZ();
thePickResult.SetDepth (aTriangleNormal.Dot (aDiff) * myScale);
thePickResult.SetPickedPoint (thePnt1);
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
gp_XYZ anEdge = (thePnt1.XYZ() - myNearPickedPnt.XYZ()) * (1.0 / anAlpha);
{
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
thePickResult.SetPickedPoint (aPtOnPlane);
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
gp_Pnt aPnts[3] = {thePnt1, thePnt2, thePnt3};
segmentSegmentDistance (aPnts[aNearestEdgeIdx], aPnts[(aNearestEdgeIdx + 1) % 3], thePickResult);
}
- return isViewClippingOk (thePickResult);
+ return !theClipRange.IsClipped (thePickResult.Depth());
}
// =======================================================================
return myNearPickedPnt.XYZ() + myViewRayDir.Normalized().XYZ() * theDepth / myScale;
}
-// =======================================================================
-// function : computeClippingRange
-// purpose :
-// =======================================================================
-void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
- SelectMgr_ViewClipRange& theRange) const
-{
- Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD;
- for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
- if (!aClipPlane->IsOn())
- {
- continue;
- }
-
- Bnd_Range aSubRange (RealFirst(), RealLast());
- for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
- {
- const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
- aGeomPlane.Coefficients (aPlaneA, aPlaneB, aPlaneC, aPlaneD);
-
- const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
- Standard_Real aDotProduct = myViewRayDir.XYZ().Dot (aPlaneDirXYZ);
- Standard_Real aDistance = -myNearPickedPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneD;
- Standard_Real aDistToPln = 0.0;
-
- // check whether the pick line is parallel to clip plane
- if (Abs (aDotProduct) < Precision::Angular())
- {
- if (aDistance < 0.0)
- {
- continue;
- }
- aDistToPln = RealLast();
- aDotProduct = 1.0;
- }
- else
- {
- // compute distance to point of pick line intersection with the plane
- const Standard_Real aParam = aDistance / aDotProduct;
-
- const gp_Pnt anIntersectionPnt = myNearPickedPnt.XYZ() + myViewRayDir.XYZ() * aParam;
- aDistToPln = anIntersectionPnt.Distance (myNearPickedPnt);
- if (aParam < 0.0)
- {
- // the plane is "behind" the ray
- aDistToPln = -aDistToPln;
- }
- }
-
- // change depth limits for case of opposite and directed planes
- if (!aClipPlane->IsChain())
- {
- if (aDotProduct < 0.0)
- {
- theRange.ChangeUnclipRange().TrimTo (aDistToPln);
- }
- else
- {
- theRange.ChangeUnclipRange().TrimFrom (aDistToPln);
- }
- }
- else
- {
- if (aDotProduct < 0.0)
- {
- aSubRange.TrimFrom (aDistToPln);
- }
- else
- {
- aSubRange.TrimTo (aDistToPln);
- }
- }
- }
-
- if (!aSubRange.IsVoid()
- && aClipPlane->IsChain())
- {
- theRange.AddClipSubRange (aSubRange);
- }
- }
-}
-
-// =======================================================================
-// function : SetViewClipping
-// purpose :
-// =======================================================================
-void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
- const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
-{
- myViewClipRange.SetVoid();
- if (!theViewPlanes.IsNull()
- && !theViewPlanes->IsEmpty())
- {
- computeClippingRange (*theViewPlanes, myViewClipRange);
- }
- if (!theObjPlanes.IsNull()
- && !theObjPlanes->IsEmpty())
- {
- computeClippingRange (*theObjPlanes, myViewClipRange);
- }
-}
-
-// =======================================================================
-// function : isViewClippingOk
-// purpose :
-// =======================================================================
-Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const SelectBasics_PickResult& thePickResult) const
-{
- return !myViewClipRange.IsClipped (thePickResult.Depth());
-}
-
// =======================================================================
// function : GetPlanes
// purpose :
#define _SelectMgr_RectangularFrustum_HeaderFile
#include <SelectMgr_Frustum.hxx>
-#include <SelectMgr_ViewClipRange.hxx>
//! This class contains representation of rectangular selecting frustum, created in case
//! of point and box selection, and algorithms for overlap detection between selecting
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
const SelectMgr_Vec3& theBoxMax,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Intersection test between defined volume and given point
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given triangle. The test may
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! Calculates the point on a view ray that was detected during the run of selection algo by given depth
Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
- //! Valid for point selection only!
- //! Computes depth range for clipping planes.
- //! @param theViewPlanes global view planes
- //! @param theObjPlanes object planes
- Standard_EXPORT virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
- const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes) Standard_OVERRIDE;
-
- //! Return clipping range.
- const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
-
- //! Set clipping range.
- void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
-
//! A set of helper functions that return rectangular selecting frustum data
inline const gp_Pnt* GetVertices() const { return myVertices; }
//! correspondingly) onto far view frustum plane
inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; }
+ //! Return view ray direction.
+ const gp_Vec& GetViewRayDirection() const { return myViewRayDir; }
+
//! Return mouse coordinates.
const gp_Pnt2d& GetMousePosition() const { return myMousePos; }
const gp_Pnt& thePntOnPlane,
SelectBasics_PickResult& thePickResult) const;
- //! Computes valid depth range for the given clipping planes
- Standard_EXPORT void computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
- SelectMgr_ViewClipRange& theRange) const;
-
- //! Returns false if theDepth must be clipped by current view clip range
- Standard_EXPORT Standard_Boolean isViewClippingOk (const SelectBasics_PickResult& thePickResult) const;
-
private:
void cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const;
gp_Vec myViewRayDir;
gp_Pnt2d myMousePos; //!< Mouse coordinates
Standard_Real myScale; //!< Scale factor of applied transformation, if there was any
- SelectMgr_ViewClipRange myViewClipRange;
};
aMgr.mySelectingVolumes[myActiveSelectionType / 2]->SetBuilder (theBuilder);
aMgr.myViewClipPlanes = myViewClipPlanes;
aMgr.myObjectClipPlanes = myObjectClipPlanes;
+ aMgr.myViewClipRange = myViewClipRange;
return aMgr;
}
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theBoxMin, theBoxMax, myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt,
- thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePnt, myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
- (Select3D_TypeOfSensitivity)theSensType,
- thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(), (Select3D_TypeOfSensitivity)theSensType,
+ myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
- (Select3D_TypeOfSensitivity)theSensType,
- thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts, (Select3D_TypeOfSensitivity)theSensType,
+ myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType == Unknown)
return Standard_False;
- return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1,
- thePt2,
- thePt3,
- (Select3D_TypeOfSensitivity)theSensType,
- thePickResult);
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (thePt1, thePt2, thePt3, (Select3D_TypeOfSensitivity)theSensType,
+ myViewClipRange, thePickResult);
}
//=======================================================================
if (myActiveSelectionType != Point)
return;
- mySelectingVolumes[Frustum]->SetViewClipping (theViewPlanes, theObjPlanes);
+ const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast<const SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get());
+ myViewClipRange.SetVoid();
+ if (!theViewPlanes.IsNull()
+ && !theViewPlanes->IsEmpty())
+ {
+ myViewClipRange.AddClippingPlanes (*theViewPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
+ }
+ if (!theObjPlanes.IsNull()
+ && !theObjPlanes->IsEmpty())
+ {
+ myViewClipRange.AddClippingPlanes (*theObjPlanes, gp_Ax1 (aFrustum->GetNearPnt(), aFrustum->GetViewRayDirection()));
+ }
}
//=======================================================================
//=======================================================================
void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
{
- myViewClipPlanes = theOther.ViewClipping();
- myObjectClipPlanes = theOther.ObjectClipping();
- if (myActiveSelectionType != Point)
- return;
-
- const SelectMgr_RectangularFrustum* aFrOther = reinterpret_cast<const SelectMgr_RectangularFrustum*>(theOther.mySelectingVolumes[Frustum].get());
- reinterpret_cast<SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get())->SetViewClipRanges (aFrOther->ViewClipRanges());
+ myViewClipPlanes = theOther.myViewClipPlanes;
+ myObjectClipPlanes = theOther.myObjectClipPlanes;
+ myViewClipRange = theOther.myViewClipRange;
}
//! Copy clipping planes from another volume manager.
Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
+ //! Return clipping range.
+ const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
+
+ //! Set clipping range.
+ void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
+
//! A set of helper functions that return rectangular selecting frustum data
Standard_EXPORT const gp_Pnt* GetVertices() const;
Handle(SelectMgr_BaseFrustum) mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
Handle(Graphic3d_SequenceOfHClipPlane) myViewClipPlanes; //!< view clipping planes
Handle(Graphic3d_SequenceOfHClipPlane) myObjectClipPlanes; //!< object clipping planes
+ SelectMgr_ViewClipRange myViewClipRange;
Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
};
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const SelectMgr_Vec3& theMinPt,
const SelectMgr_Vec3& theMaxPt,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasOverlap (theMinPt, theMaxPt);
// purpose : Intersection test between defined volume and given point
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasOverlap (thePnt);
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& /*theClipRange*/,
SelectBasics_PickResult& /*thePickResult*/) const
{
return hasOverlap (thePnt1, thePnt2);
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
- return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, thePickResult);
+ return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theClipRange, thePickResult);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by axis-aligned bounding box
//! Intersection test between defined volume and given point
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given ordered set of points,
//! boundary line defined by segments depending on given sensitivity type
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! SAT intersection test between defined volume and given triangle. The test may
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Nullifies the handle to corresponding builder instance to prevent memory leaks
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
- if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, thePickResult))
+ if (anIter.Value()->Overlaps (theMinPnt, theMaxPnt, theClipRange, thePickResult))
return Standard_True;
}
// purpose :
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
- if (anIter.Value()->Overlaps (thePnt, thePickResult))
+ if (anIter.Value()->Overlaps (thePnt, theClipRange, thePickResult))
return Standard_True;
}
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
- if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, thePickResult))
+ if (anIter.Value()->Overlaps (theArrayOfPts, theSensType, theClipRange, thePickResult))
return Standard_True;
}
// =======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
- if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePickResult))
+ if (anIter.Value()->Overlaps (thePnt1, thePnt2, theClipRange, thePickResult))
return Standard_True;
}
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
- if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, thePickResult))
+ if (anIter.Value()->Overlaps (thePnt1, thePnt2, thePnt3, theSensType, theClipRange, thePickResult))
return Standard_True;
}
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
Standard_Boolean* theInside) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3,
Select3D_TypeOfSensitivity theSensType,
+ const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Stores plane equation coefficients (in the following form:
--- /dev/null
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <SelectMgr_ViewClipRange.hxx>
+
+#include <gp_Ax1.hxx>
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+
+// =======================================================================
+// function : AddClippingPlanes
+// purpose :
+// =======================================================================
+void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
+ const gp_Ax1& thePickRay)
+{
+ const gp_Dir& aViewRayDir = thePickRay.Direction();
+ const gp_Pnt& aNearPnt = thePickRay.Location();
+
+ Graphic3d_Vec4d aPlaneABCD;
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ const Handle(Graphic3d_ClipPlane)& aClipPlane = aPlaneIt.Value();
+ if (!aClipPlane->IsOn())
+ {
+ continue;
+ }
+
+ Bnd_Range aSubRange (RealFirst(), RealLast());
+ for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipPlane.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get())
+ {
+ const gp_Pln aGeomPlane = aSubPlaneIter->ToPlane();
+ aGeomPlane.Coefficients (aPlaneABCD[0], aPlaneABCD[1], aPlaneABCD[2], aPlaneABCD[3]);
+
+ const gp_XYZ& aPlaneDirXYZ = aGeomPlane.Axis().Direction().XYZ();
+ Standard_Real aDotProduct = aViewRayDir.XYZ().Dot (aPlaneDirXYZ);
+ Standard_Real aDistance = -aNearPnt.XYZ().Dot (aPlaneDirXYZ) - aPlaneABCD[3];
+ Standard_Real aDistToPln = 0.0;
+
+ // check whether the pick line is parallel to clip plane
+ if (Abs (aDotProduct) < Precision::Angular())
+ {
+ if (aDistance < 0.0)
+ {
+ continue;
+ }
+ aDistToPln = RealLast();
+ aDotProduct = 1.0;
+ }
+ else
+ {
+ // compute distance to point of pick line intersection with the plane
+ const Standard_Real aParam = aDistance / aDotProduct;
+
+ const gp_Pnt anIntersectionPnt = aNearPnt.XYZ() + aViewRayDir.XYZ() * aParam;
+ aDistToPln = anIntersectionPnt.Distance (aNearPnt);
+ if (aParam < 0.0)
+ {
+ // the plane is "behind" the ray
+ aDistToPln = -aDistToPln;
+ }
+ }
+
+ // change depth limits for case of opposite and directed planes
+ if (!aClipPlane->IsChain())
+ {
+ if (aDotProduct < 0.0)
+ {
+ ChangeUnclipRange().TrimTo (aDistToPln);
+ }
+ else
+ {
+ ChangeUnclipRange().TrimFrom (aDistToPln);
+ }
+ }
+ else
+ {
+ if (aDotProduct < 0.0)
+ {
+ aSubRange.TrimFrom (aDistToPln);
+ }
+ else
+ {
+ aSubRange.TrimTo (aDistToPln);
+ }
+ }
+ }
+
+ if (!aSubRange.IsVoid()
+ && aClipPlane->IsChain())
+ {
+ AddClipSubRange (aSubRange);
+ }
+ }
+}
#include <Bnd_Range.hxx>
#include <Standard_TypeDef.hxx>
+#include <vector>
+
+class gp_Ax1;
+class Graphic3d_SequenceOfHClipPlane;
+
//! Class for handling depth clipping range.
//! It is used to perform checks in case if global (for the whole view)
//! clipping planes are defined inside of SelectMgr_RectangularFrustum class methods.
return !theRange.IsOut (theDepth);
}
+public:
+
//! Clears clipping range.
void SetVoid()
{
myUnclipRange = Bnd_Range (RealFirst(), RealLast());
}
+ //! Add clipping planes. Planes and picking ray should be defined in the same coordinate system.
+ Standard_EXPORT void AddClippingPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes,
+ const gp_Ax1& thePickRay);
+
//! Returns the main unclipped range; [-inf, inf] by default.
Bnd_Range& ChangeUnclipRange() { return myUnclipRange; }
Standard_Integer aHead = -1;
Standard_Integer aNode = 0; // a root node
SelectMgr_FrustumCache aScaledTrnsfFrustums;
- SelectMgr_SelectingVolumeManager aTmpMgr;
+ SelectMgr_SelectingVolumeManager aTmpMgr (false);
for (;;)
{
if (!aSensitivesTree->IsOuter (aNode))
--- /dev/null
+puts "============="
+puts "0030906: Visualization, SelectMgr_ViewerSelector - Object clipping planes overrides View clipping plane for next objects"
+puts "============="
+
+pload MODELING VISUALIZATION
+box b1 1 1 0 1 2 3
+box b2 3 0 0 1 2 3
+vclear
+vinit View1
+vdisplay -dispMode 1 -highMode 1 b1 b2
+vfit
+vzbufftrihedron
+vpoint p0 0 0 0
+vclipplane c1 -equation 0 1 0 1 -setOverrideGlobal b1
+vclipplane c2 -equation 0 1 0 -1 -set
+vmoveto 200 200
+if { [vreadpixel 250 200 -rgb -name] != "DARKGOLDENROD3" } { puts "Error: selection of clipped object" }
+if { [vreadpixel 150 200 -rgb -name] != "DARKTURQUOISE" } { puts "Error: object is not selected" }
+
+vdump ${imagedir}/${casename}.png