1) Zoom persistence mode now fixes object in pixel coordinates and is independent on view size
2) Used gp_GTrsf instead of gp_Trsf SelectMgr_ViewerSelector to store Graphic3d_Mat4d
3) Zoom persisted objects changed behavior (become bigger) therefore test cases were updated according to new state.
4) Corrected scale for rectangular frustum
Updated test for manipulator
}
// Prevent zooming.
- if ((Flags & Graphic3d_TMF_ZoomPers) || (Flags == Graphic3d_TMF_TriedronPers))
+ if (Flags & Graphic3d_TMF_ZoomPers)
+ {
+ const T aDet00 = (2.0f / theViewportWidth) / theProjection.GetValue(0, 0);
+ const T aDet11 = (2.0f / theViewportHeight) / theProjection.GetValue(1, 1);
+ const T aDet2 = Max (aDet00, aDet11);
+
+ theProjection.ChangeValue(0, 0) *= aDet00;
+ theProjection.ChangeValue(1, 1) *= aDet11;
+ theProjection.ChangeValue(2, 2) *= aDet2;
+ }
+
+ if (Flags == Graphic3d_TMF_TriedronPers)
{
// Compute fixed-zoom multiplier. Actually function works ugly with TelPerspective!
const T aDet2 = static_cast<T> (0.002) / Max (theProjection.GetValue (1, 1), theProjection.GetValue (0, 0));
+
theProjection.ChangeValue (0, 0) *= aDet2;
theProjection.ChangeValue (1, 1) *= aDet2;
theProjection.ChangeValue (2, 2) *= aDet2;
//function : InvInitLocation
//purpose :
//=======================================================================
-inline gp_Trsf MeshVS_DummySensitiveEntity::InvInitLocation() const
+inline gp_GTrsf MeshVS_DummySensitiveEntity::InvInitLocation() const
{
- return gp_Trsf();
+ return gp_GTrsf();
}
Standard_EXPORT virtual Standard_Boolean HasInitLocation() const Standard_OVERRIDE;
- Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE;
+ Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(MeshVS_DummySensitiveEntity,SelectBasics_SensitiveEntity)
};
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >&
OpenGl_BVHClipPrimitiveTrsfPersSet::BVH (const OpenGl_Mat4& theProjectionMatrix,
const OpenGl_Mat4& theWorldViewMatrix,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight,
const Graphic3d_WorldViewProjState& theWVPState)
{
if (!myIsDirty
HBndBox4f aBoundingBox = new Graphic3d_BndBox4f;
*aBoundingBox = aStructure->BoundingBox();
- aStructure->TransformPersistence.Apply (theProjectionMatrix, theWorldViewMatrix, 0, 0, *aBoundingBox);
+ aStructure->TransformPersistence.Apply (theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, *aBoundingBox);
myStructBoxes.Add (aBoundingBox);
}
//! Returns BVH tree for the given world view projection (builds it if necessary).
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >& BVH (const OpenGl_Mat4& theProjectionMatrix,
const OpenGl_Mat4& theWorldViewMatrix,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight,
const Graphic3d_WorldViewProjState& theWVPState);
private:
}
}
+// =======================================================================
+// function : SetViewportSize
+// purpose :
+// =======================================================================
+void OpenGl_BVHTreeSelector::SetViewportSize (const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight)
+{
+ myViewportHeight = theViewportHeight;
+ myViewportWidth = theViewportWidth;
+}
+
// =======================================================================
// function : SignedPlanePointDistance
// purpose :
//! Retrieves view volume's planes equations and its vertices from projection and world-view matrices.
Standard_EXPORT void SetViewVolume (const Handle(Graphic3d_Camera)& theCamera);
+ Standard_EXPORT void SetViewportSize (const Standard_Integer theViewportWidth, const Standard_Integer theViewportHeight);
+
//! Detects if AABB overlaps view volume using separating axis theorem (SAT).
//! @param theMinPt [in] maximum point of AABB.
//! @param theMaxPt [in] minimum point of AABB.
return myWorldViewMat;
}
+ Standard_Integer ViewportWidth() const
+ {
+ return myViewportWidth;
+ }
+
+ Standard_Integer ViewportHeight() const
+ {
+ return myViewportHeight;
+ }
+
//! Returns state of current world view projection transformation matrices.
const Graphic3d_WorldViewProjState& WorldViewProjState() const
{
OpenGl_Mat4 myProjectionMat;
OpenGl_Mat4 myWorldViewMat;
+ Standard_Integer myViewportWidth;
+ Standard_Integer myViewportHeight;
+
Graphic3d_WorldViewProjState myWorldViewProjState; //!< State of world view projection matrices.
};
const OpenGl_Mat4& aProjection = theSelector.ProjectionMatrix();
const OpenGl_Mat4& aWorldView = theSelector.WorldViewMatrix();
const Graphic3d_WorldViewProjState& aWVPState = theSelector.WorldViewProjState();
- aBVHTree = myBVHPrimitivesTrsfPers.BVH (aProjection, aWorldView, aWVPState);
+ const Standard_Integer aViewportWidth = theSelector.ViewportWidth();
+ const Standard_Integer aViewportHeight = theSelector.ViewportHeight();
+
+ aBVHTree = myBVHPrimitivesTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
}
else
{
// Update states of OpenGl_BVHTreeSelector (frustum culling algorithm).
myBVHSelector.SetViewVolume (myCamera);
+ myBVHSelector.SetViewportSize (myWindow->Width(), myWindow->Height());
const Handle(OpenGl_ShaderManager)& aManager = aContext->ShaderManager();
if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState)
#include <Standard_Boolean.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <PrsMgr_PresentableObjectPointer.hxx>
+#include <gp_GTrsf.hxx>
#include <gp_Trsf.hxx>
#include <PrsMgr_ListOfPresentableObjects.hxx>
#include <MMgt_TShared.hxx>
const gp_Trsf& Transformation() const;
- const gp_Trsf& InversedTransformation() const;
+ const gp_GTrsf& InversedTransformation() const;
//! resets local transformation to identity.
Standard_EXPORT virtual void ResetTransformation();
PrsMgr_PresentableObjectPointer myParent;
gp_Trsf myLocalTransformation;
gp_Trsf myTransformation;
- gp_Trsf myInvTransformation;
+ gp_GTrsf myInvTransformation;
gp_Trsf myCombinedParentTransform;
PrsMgr_ListOfPresentableObjects myChildren;
return myTransformation;
}
-inline const gp_Trsf& PrsMgr_PresentableObject::InversedTransformation() const
+inline const gp_GTrsf& PrsMgr_PresentableObject::InversedTransformation() const
{
return myInvTransformation;
}
// purpose : Returns inversed location transformation matrix if the shape corresponding
// to this entity has init location set. Otherwise, returns identity matrix.
//=======================================================================
-gp_Trsf Select3D_SensitiveEntity::InvInitLocation() const
+gp_GTrsf Select3D_SensitiveEntity::InvInitLocation() const
{
- return gp_Trsf();
+ return gp_GTrsf();
}
//! Returns inversed location transformation matrix if the shape corresponding
//! to this entity has init location set. Otherwise, returns identity matrix.
- Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE;
+ Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveEntity,SelectBasics_SensitiveEntity)
//! Returns inversed location transformation matrix if the shape corresponding
//! to this entity has init location set. Otherwise, returns identity matrix.
- virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE
+ virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE
{
return myInvInitLocation;
}
gp_Pnt myCDG3D; //!< Center of the whole triangulation
Select3D_BVHIndexBuffer myBvhIndices; //!< Indexes of edges or triangles for BVH tree
mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole triangulation
- gp_Trsf myInvInitLocation;
+ gp_GTrsf myInvInitLocation;
Standard_Real myMinDepthElem; //!< the depth of nearest detected element
Standard_Real myMinDepthNode; //!< the depth of nearest detected node
Standard_Real myMinDepthEdge; //!< the depth of nearest detected edge
//function : InvInitLocation
//purpose :
//=======================================================================
-gp_Trsf Select3D_SensitiveTriangulation::InvInitLocation() const
+gp_GTrsf Select3D_SensitiveTriangulation::InvInitLocation() const
{
return myInvInitLocation;
}
//! Returns inversed location transformation matrix if the shape corresponding
//! to this entity has init location set. Otherwise, returns identity matrix.
- Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE;
+ Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE;
inline const TopLoc_Location& GetInitLocation() const;
Standard_Integer myPrimitivesNb; //!< Amount of free edges or triangles depending on sensitivity type
Handle(TColStd_HArray1OfInteger) myBVHPrimIndexes; //!< Indexes of edges or triangles for BVH build
mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole triangulation
- gp_Trsf myInvInitLocation;
+ gp_GTrsf myInvInitLocation;
};
DEFINE_STANDARD_HANDLE(Select3D_SensitiveTriangulation, Select3D_SensitiveSet)
#ifndef _SelectBasics_SensitiveEntity_HeaderFile
#define _SelectBasics_SensitiveEntity_HeaderFile
+#include <gp_GTrsf.hxx>
#include <gp_Trsf.hxx>
#include <Standard.hxx>
//! Returns inversed location transformation matrix if the shape corresponding
//! to this entity has init location set. Otherwise, returns identity matrix.
- virtual gp_Trsf InvInitLocation() const = 0;
+ virtual gp_GTrsf InvInitLocation() const = 0;
DEFINE_STANDARD_RTTIEXT(SelectBasics_SensitiveEntity,MMgt_TShared)
myBuilder->SetWindowSize (theWidth, theHeight);
}
+//=======================================================================
+// function : WindowSize
+// purpose :
+//=======================================================================
+void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth,
+ Standard_Integer& theHeight)
+{
+ myBuilder->WindowSize (theWidth, theHeight);
+}
+
//=======================================================================
// function : SetBuilder
// purpose :
#ifndef _SelectMgr_BaseFrustum_HeaderFile
#define _SelectMgr_BaseFrustum_HeaderFile
+#include <gp_GTrsf.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth,
const Standard_Integer theHeight);
+ Standard_EXPORT void WindowSize (Standard_Integer& theWidth,
+ Standard_Integer& theHeight);
+
//! Passes viewport parameters to builder
Standard_EXPORT void SetViewport (const Standard_Real theX,
const Standard_Real theY,
//! There are no default parameters, but in case if:
//! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
//! - scale only is needed: @theTrsf must be set to gp_Identity.
- virtual NCollection_Handle<SelectMgr_BaseFrustum> ScaleAndTransform (const Standard_Integer /*theScaleFactor*/,
- const gp_Trsf& /*theTrsf*/) { return NULL; }
+ Standard_EXPORT virtual NCollection_Handle<SelectMgr_BaseFrustum> ScaleAndTransform (const Standard_Integer /*theScaleFactor*/,
+ const gp_GTrsf& /*theTrsf*/) { return NULL; }
//! SAT intersection test between defined volume and given axis-aligned box
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
myIsViewportSet = Standard_True;
}
+//=======================================================================
+// function : WindowSize
+// purpose :
+//=======================================================================
+void SelectMgr_FrustumBuilder::WindowSize (Standard_Integer& theWidth,
+ Standard_Integer& theHeight)
+{
+ theWidth = myWidth;
+ theHeight = myHeight;
+}
+
//=======================================================================
// function : InvalidateViewport
// purpose :
Standard_EXPORT void InvalidateViewport();
+ Standard_EXPORT void WindowSize (Standard_Integer& theWidth,
+ Standard_Integer& theHeight);
+
//! Calculates signed distance between plane with equation
//! theEq and point thePnt
Standard_EXPORT Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq,
// - scale only is needed: @theTrsf must be set to gp_Identity.
// =======================================================================
NCollection_Handle<SelectMgr_BaseFrustum> SelectMgr_RectangularFrustum::ScaleAndTransform (const Standard_Integer theScaleFactor,
- const gp_Trsf& theTrsf)
+ const gp_GTrsf& theTrsf)
{
Standard_ASSERT_RAISE (theScaleFactor > 0,
"Error! Pixel tolerance for selection should be greater than zero");
if (isToTrsf)
{
- aRes->myNearPickedPnt = aRef->myNearPickedPnt.Transformed (theTrsf);
- aRes->myFarPickedPnt = aRef->myFarPickedPnt.Transformed (theTrsf);
+ const Standard_Real aRefScale = aRef->myFarPickedPnt.SquareDistance (aRef->myNearPickedPnt);
+
+ gp_Pnt aPoint = aRef->myNearPickedPnt;
+ theTrsf.Transforms (aPoint.ChangeCoord());
+ aRes->myNearPickedPnt = aPoint;
+
+ aPoint.SetXYZ (aRef->myFarPickedPnt.XYZ());
+ theTrsf.Transforms (aPoint.ChangeCoord());
+ aRes->myFarPickedPnt = aPoint;
+
aRes->myViewRayDir = aRes->myFarPickedPnt.XYZ() - aRes->myNearPickedPnt.XYZ();
- // LeftTopNear
- aRes->myVertices[0] = aRef->myVertices[0].Transformed (theTrsf);
- // LeftTopFar
- aRes->myVertices[1] = aRef->myVertices[1].Transformed (theTrsf);
- // LeftBottomNear
- aRes->myVertices[2] = aRef->myVertices[2].Transformed (theTrsf);
- // LeftBottomFar
- aRes->myVertices[3] = aRef->myVertices[3].Transformed (theTrsf);
- // RightTopNear
- aRes->myVertices[4] = aRef->myVertices[4].Transformed (theTrsf);
- // RightTopFar
- aRes->myVertices[5] = aRef->myVertices[5].Transformed (theTrsf);
- // RightBottomNear
- aRes->myVertices[6] = aRef->myVertices[6].Transformed (theTrsf);
- // RightBottomFar
- aRes->myVertices[7] = aRef->myVertices[7].Transformed (theTrsf);
+ for (Standard_Integer anIt = 0; anIt < 8; anIt++)
+ {
+ aPoint = aRef->myVertices[anIt];
+ theTrsf.Transforms (aPoint.ChangeCoord());
+ aRes->myVertices[anIt] = aPoint;
+ }
// Horizontal
aRes->myEdgeDirs[0] = aRes->myVertices[4].XYZ() - aRes->myVertices[0].XYZ();
// RightUpper
aRes->myEdgeDirs[5] = aRes->myVertices[4].XYZ() - aRes->myVertices[5].XYZ();
- aRes->myScale = 1.0 / theTrsf.ScaleFactor();
+ // Compute scale to transform depth from local coordinate system to world coordinate system
+ aRes->myScale = Sqrt (aRefScale / aRes->myFarPickedPnt.SquareDistance (aRes->myNearPickedPnt));
}
// compute frustum normals
//! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
//! - scale only is needed: @theTrsf must be set to gp_Identity.
Standard_EXPORT virtual NCollection_Handle<SelectMgr_BaseFrustum> ScaleAndTransform (const Standard_Integer theScaleFactor,
- const gp_Trsf& theTrsf) Standard_OVERRIDE;
+ const gp_GTrsf& theTrsf) Standard_OVERRIDE;
// SAT Tests for different objects
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >&
SelectMgr_SelectableObjectTrsfPersSet::BVH (const Graphic3d_Mat4d& theProjectionMatrix,
const Graphic3d_Mat4d& theWorldViewMatrix,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight,
const Graphic3d_WorldViewProjState& theWVPState)
{
if (!myIsDirty && (myObjectBoxesState.IsValid() && !myObjectBoxesState.IsChanged(theWVPState)))
anObject->BoundingBox (aBoundingBox);
if (!aBoundingBox.IsVoid())
{
- anObject->TransformPersistence().Apply (theProjectionMatrix, theWorldViewMatrix, 0, 0, aBoundingBox);
+ anObject->TransformPersistence().Apply (theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, aBoundingBox);
}
}
//! Returns BVH tree for the given world view projection (builds it if necessary).
Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& BVH (const Graphic3d_Mat4d& theProjectionMatrix,
const Graphic3d_Mat4d& theWorldViewMatrix,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight,
const Graphic3d_WorldViewProjState& theWVPState);
private:
// - scale only is needed: @theTrsf must be set to gp_Identity.
//=======================================================================
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTransform (const Standard_Integer theScaleFactor,
- const gp_Trsf& theTrsf)
+ const gp_GTrsf& theTrsf)
{
SelectMgr_SelectingVolumeManager aMgr (Standard_False);
return mySelectingVolumes[Frustum]->WorldViewProjState();
}
+//=======================================================================
+// function : WindowSize
+// purpose :
+//=======================================================================
+void SelectMgr_SelectingVolumeManager::WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight)
+{
+ mySelectingVolumes[Frustum]->WindowSize (theWidth, theHeight);
+}
+
//=======================================================================
// function : SetCamera
// purpose : Updates viewport in all selecting volumes
//! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
//! - scale only is needed: @theTrsf must be set to gp_Identity.
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager ScaleAndTransform (const Standard_Integer theScaleFactor,
- const gp_Trsf& theTrsf);
+ const gp_GTrsf& theTrsf);
Standard_EXPORT virtual Standard_Integer GetActiveSelectionType() const Standard_OVERRIDE;
//! @return current world view transformation common for all selecting volumes
Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const;
+ Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight);
+
//! @return current camera world view projection transformation state common for all selecting volumes
Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const;
// - scale only is needed: @theTrsf must be set to gp_Identity.
//=======================================================================
NCollection_Handle<SelectMgr_BaseFrustum> SelectMgr_TriangularFrustum::ScaleAndTransform (const Standard_Integer /*theScale*/,
- const gp_Trsf& theTrsf)
+ const gp_GTrsf& theTrsf)
{
SelectMgr_TriangularFrustum* aRes = new SelectMgr_TriangularFrustum();
- // V0_Near
- aRes->myVertices[0] = myVertices[0].Transformed (theTrsf);
- // V1_Near
- aRes->myVertices[1] = myVertices[1].Transformed (theTrsf);
- // V2_Near
- aRes->myVertices[2] = myVertices[2].Transformed (theTrsf);
- // V0_Far
- aRes->myVertices[3] = myVertices[3].Transformed (theTrsf);
- // V1_Far
- aRes->myVertices[4] = myVertices[4].Transformed (theTrsf);
- // V2_Far
- aRes->myVertices[5] = myVertices[5].Transformed (theTrsf);
+ for (Standard_Integer anIt = 0; anIt < 6; anIt++)
+ {
+ gp_Pnt aPoint = myVertices[anIt];
+ theTrsf.Transforms (aPoint.ChangeCoord());
+ aRes->myVertices[anIt] = aPoint;
+ }
aRes->myIsOrthographic = myIsOrthographic;
//! Returns a copy of the frustum transformed according to the matrix given
Standard_EXPORT virtual NCollection_Handle<SelectMgr_BaseFrustum> ScaleAndTransform (const Standard_Integer theScale,
- const gp_Trsf& theTrsf) Standard_OVERRIDE;
+ const gp_GTrsf& theTrsf) Standard_OVERRIDE;
// SAT Tests for different objects
// - scale only is needed: @theTrsf must be set to gp_Identity.
// =======================================================================
NCollection_Handle<SelectMgr_BaseFrustum> SelectMgr_TriangularFrustumSet::ScaleAndTransform (const Standard_Integer theScale,
- const gp_Trsf& theTrsf)
+ const gp_GTrsf& theTrsf)
{
SelectMgr_TriangularFrustumSet* aRes = new SelectMgr_TriangularFrustumSet();
//! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given
Standard_EXPORT virtual NCollection_Handle<SelectMgr_BaseFrustum> ScaleAndTransform (const Standard_Integer theScale,
- const gp_Trsf& theTrsf) Standard_OVERRIDE;
+ const gp_GTrsf& theTrsf) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt,
const SelectMgr_Vec3& theMaxPnt,
// AGV OCT/23/03 : Optimize the method SortResult() (OCC4201)
#include <BVH_Tree.hxx>
+#include <gp_GTrsf.hxx>
#include <gp_Pnt.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
// necessary calculations
//=======================================================================
void SelectMgr_ViewerSelector::computeFrustum (const Handle(SelectBasics_SensitiveEntity)& theEnt,
- const gp_Trsf& theInvTrsf,
+ const gp_GTrsf& theInvTrsf,
SelectMgr_FrustumCache& theCachedMgrs,
SelectMgr_SelectingVolumeManager& theResMgr)
{
Standard_Integer aScale = isToScaleFrustum (theEnt) ? sensitivity (theEnt) : 1;
- const gp_Trsf aTrsfMtr = theEnt->HasInitLocation() ? theEnt->InvInitLocation() * theInvTrsf : theInvTrsf;
+ const gp_GTrsf aTrsfMtr = theEnt->HasInitLocation() ? theEnt->InvInitLocation() * theInvTrsf : theInvTrsf;
const Standard_Boolean toScale = aScale != 1;
const Standard_Boolean toTransform = aTrsfMtr.Form() != gp_Identity;
if (toScale && toTransform)
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
- gp_Trsf aInversedTrsf;
+ gp_GTrsf aInversedTrsf;
if (theObject->HasTransformation() || theObject->TransformPersistence().Flags)
{
{
const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix();
const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix();
-
- gp_Trsf aTPers;
- Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (aProjection, aWorldView, 0, 0);
- aTPers.SetValues (aMat.GetValue (0, 0), aMat.GetValue (0, 1), aMat.GetValue (0, 2), aMat.GetValue (0, 3),
- aMat.GetValue (1, 0), aMat.GetValue (1, 1), aMat.GetValue (1, 2), aMat.GetValue (1, 3),
- aMat.GetValue (2, 0), aMat.GetValue (2, 1), aMat.GetValue (2, 2), aMat.GetValue (2, 3));
-
- aInversedTrsf = (aTPers * theObject->Transformation()).Inverted();
+ Standard_Integer aViewportWidth;
+ Standard_Integer aViewportHeight;
+ mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
+
+ gp_GTrsf aTPers;
+ Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (aProjection, aWorldView, aViewportWidth, aViewportHeight);
+ aTPers.SetValue (1, 1, aMat.GetValue (0, 0));
+ aTPers.SetValue (1, 2, aMat.GetValue (0, 1));
+ aTPers.SetValue (1, 3, aMat.GetValue (0, 2));
+ aTPers.SetValue (2, 1, aMat.GetValue (1, 0));
+ aTPers.SetValue (2, 2, aMat.GetValue (1, 1));
+ aTPers.SetValue (2, 3, aMat.GetValue (1, 2));
+ aTPers.SetValue (3, 1, aMat.GetValue (2, 0));
+ aTPers.SetValue (3, 2, aMat.GetValue (2, 1));
+ aTPers.SetValue (3, 3, aMat.GetValue (2, 2));
+ aTPers.SetTranslationPart (gp_XYZ (aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3)));
+
+ aInversedTrsf = (aTPers * gp_GTrsf (theObject->Transformation())).Inverted();
}
}
const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix();
const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix();
const Graphic3d_WorldViewProjState& aWVPState = mySelectingVolumeMgr.WorldViewProjState();
- aBVHTree = mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aWVPState);
+ Standard_Integer aViewportWidth;
+ Standard_Integer aViewportHeight;
+ mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
+ aBVHTree = mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
}
else
{
const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix();
const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix();
const Graphic3d_WorldViewProjState& aWVPState = mySelectingVolumeMgr.WorldViewProjState();
+ Standard_Integer aViewportWidth;
+ Standard_Integer aViewportHeight;
+ mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
mySelectableObjects.BVH();
- mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aWVPState);
+ mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
}
}
//! needs to be scaled and transformed for the entity and performs
//! necessary calculations
void computeFrustum (const Handle(SelectBasics_SensitiveEntity)& theEnt,
- const gp_Trsf& theInvTrsf,
+ const gp_GTrsf& theInvTrsf,
SelectMgr_FrustumCache& theCachedMgrs,
SelectMgr_SelectingVolumeManager& theResMgr);
+
protected:
Standard_Boolean preferclosest;
const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->DetectedEntity();
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- gp_Trsf anInvTrsf;
+ gp_GTrsf anInvTrsf;
if (anObj->TransformPersistence().Flags)
{
const Graphic3d_Mat4d& aProjection = aMgr.ProjectionMatrix();
const Graphic3d_Mat4d& aWorldView = aMgr.WorldViewMatrix();
-
- Graphic3d_Mat4d aMat = anObj->TransformPersistence().Compute (aProjection, aWorldView, 0, 0);
- anInvTrsf.SetValues (aMat.GetValue (0, 0), aMat.GetValue (0, 1), aMat.GetValue (0, 2), aMat.GetValue (0, 3),
- aMat.GetValue (1, 0), aMat.GetValue (1, 1), aMat.GetValue (1, 2), aMat.GetValue (1, 3),
- aMat.GetValue (2, 0), aMat.GetValue (2, 1), aMat.GetValue (2, 2), aMat.GetValue (2, 3));
+ Standard_Integer aViewportWidth = 0;
+ Standard_Integer aViewportHeight = 0;
+ aMgr.WindowSize (aViewportWidth, aViewportHeight);
+
+ Graphic3d_Mat4d aMat = anObj->TransformPersistence().Compute (aProjection, aWorldView, aViewportWidth, aViewportHeight);
+
+ anInvTrsf.SetValue (1, 1, aMat.GetValue (0, 0));
+ anInvTrsf.SetValue (1, 2, aMat.GetValue (0, 1));
+ anInvTrsf.SetValue (1, 3, aMat.GetValue (0, 2));
+ anInvTrsf.SetValue (2, 1, aMat.GetValue (1, 0));
+ anInvTrsf.SetValue (2, 2, aMat.GetValue (1, 1));
+ anInvTrsf.SetValue (2, 3, aMat.GetValue (1, 2));
+ anInvTrsf.SetValue (3, 1, aMat.GetValue (2, 0));
+ anInvTrsf.SetValue (3, 2, aMat.GetValue (2, 1));
+ anInvTrsf.SetValue (3, 3, aMat.GetValue (2, 2));
+ anInvTrsf.SetTranslationPart (gp_XYZ(aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3)));
anInvTrsf.Invert();
}
if (anObj->HasTransformation())
: aMgr;
SelectBasics_PickResult aResult;
anEntity->Matches (anEntMgr, aResult);
- gp_Pnt aDetectedPnt = anInvTrsf.Form() == gp_Identity ?
- anEntMgr.DetectedPoint (aResult.Depth()) : anEntMgr.DetectedPoint (aResult.Depth()).Transformed (anInvTrsf.Inverted());
+
+ gp_Pnt aDetectedPnt = anEntMgr.DetectedPoint (aResult.Depth());
+
+ if (anInvTrsf.Form() != gp_Identity)
+ {
+ anInvTrsf.Inverted().Transforms (aDetectedPnt.ChangeCoord());
+ }
TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
aName.LeftJustify (20, ' ');
set anImage2 $imagedir/${casename}_2.png
vinit
box b1 -1 -1 -1 3 3 3
-box b2 4 4 4 30 20 20
+box b2 4 4 4 15 10 10
vdisplay b1
vdisplay b2 -trsfPers zoom -trsfPersPos 0 0 0
vfit
vtrihedron tri
vpan 50 50
-box b1 50 50 50
-box b2 50 50 50
+box b1 25 25 25
+box b2 25 25 25
box b3 100 100 100
box b4 100 100 100
box b5 100 100 100
vdisplay b1 -trsfPers zoom -trsfPersPos 200 200 200
vdisplay b2 -trsfPers zoom -trsfPersPos 200 200 200
-vsetlocation b2 -50 -50 -50
+vsetlocation b2 -25 -25 -25
vmoveto 384 78
if { ![checkcolor 384 78 0 1 1] } {
restore [locate_data_file face1.brep] f
vdisplay f
-box b1 50 50 50
+box b1 25 25 25
vdisplay b1 -trsfPers zoom -trsfPersPos 0 0 0
vviewparams -scale 588.7 -proj 0.69 -0.64 -0.38
# with dynamic highlight color, check that the face is
# not highlighted
vmoveto 280 290
-if {[vreadpixel 290 297 name] != "CYAN1 1"} {
+if {[vreadpixel 297 297 name] != "CYAN1 1"} {
puts "ERROR: zoom persistent box is not highlighted dynamically!"
}
if {[vreadpixel 372 210 name] != "GOLDENROD1 1"} {
# move to a point on the box and check if it
# will be highlighted dynamically
vmoveto 264 135
-if {[vreadpixel 276 142 name] != "CYAN1 1"} {
+
+if {[vreadpixel 275 142 name] != "CYAN1 1"} {
puts "ERROR: zoom persistent box is not highlighted dynamically in precision test!"
}
if {[vreadpixel 243 123 name] != "LIGHTGOLDENROD1 1"} {
# move to a point on the face and check if it
# will be highlighted dynamically
-vmoveto 263 135
-if {[vreadpixel 276 142 name] != "GOLDENROD2 1"} {
+vmoveto 259 135
+if {[vreadpixel 275 142 name] != "GOLDENROD3 1"} {
puts "ERROR: zoom persistent box is highlighted instead in precision test!"
}
if {[vreadpixel 243 123 name] != "CYAN1 1"} {
vtrihedron tri
vpan 50 50
-box b1 50 50 50
-box b2 50 50 50
+box b1 20.3 20.3 20.3
+box b2 20.3 20.3 20.3
box b3 150 150 150 100 100 100
vpoint p1 200 200 200
vdisplay b1 -trsfPers zoom -trsfPersPos 200 200 200
vdisplay b2 -trsfPers zoom -trsfPersPos 200 200 200
-vsetlocation b2 -50 -50 -50
+vsetlocation b2 -20.3 -20.3 -20.3
vdisplay b3
vsetdispmode 1
vclear
vaxo
-box b 100 100 100
+box b 50 50 50
vdisplay b -trsfPers zoom
vzoom 0.01
vzfit
checkcolor 204 184 1.0 1.0 0.0
-checkcolor 232 205 1.0 1.0 0.0
-checkcolor 262 182 1.0 1.0 0.0
-checkcolor 233 184 1.0 1.0 0.0
+checkcolor 238 205 1.0 1.0 0.0
+checkcolor 275 182 1.0 1.0 0.0
+checkcolor 239 184 1.0 1.0 0.0
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
--- /dev/null
+puts "========"
+puts "OCC27536"
+puts "========"
+puts ""
+##################################################################
+puts "Visualization - incorrect behavior of zoom persisted objects"
+##################################################################
+
+set anImage1 $imagedir/${casename}_1.png
+set anImage2 $imagedir/${casename}_2.png
+
+vinit
+vclear
+vaxo
+
+box b -50 -50 -50 100 100 100
+vdisplay b -trsfPers zoom -trsfPersPos 0 0 0 -dispmode 1
+
+vdump $anImage1
+
+vinit View2 w=200 h=400
+vaxo
+vfit
+
+# Check that box was't resized in small view
+if {[vreadpixel 165 200 name] != "DARKGOLDENROD3 1"} {
+ puts "ERROR: zoom persistent box is resized on view sizes changed!"
+}
+
+vdump $anImage2
# attach manipulator
# ------------------
-vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
# ----------------------------------------------------
# test rotation around x axis (object reference frame)
vaxo
vfit
-vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vmanipulator m -followRotation 0
# ---------------------------------------------------
# attach manipulator
# ------------------
-vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
# --------------------------
# test hilight and detection
# attach manipulator
# ------------------
-vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vmanipulator m -followRotation 1
vmanipulator m -followTranslation 1
# attach manipulator and rotate around z axis
# -------------------------------------------
-vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1
+vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
vmanipulator m -followRotation 1
vmanipulator m -followTranslation 1
vfit
-vmanipulator m2 -attach b2 -adjustPosition 1 -adjustSize 0 -enableModes 1 -zoomable 0 -size 100
+vmanipulator m2 -attach b2 -adjustPosition 1 -adjustSize 0 -enableModes 1 -zoomable 0 -size 40
set mouse_pick_1 {341 283}
set mouse_pick_2 {277 246}