mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-09 18:50:54 +03:00
Add SelectMgr_BaseIntersector class as base intersector that can have any geometry not only frustum. Remove cached static array of selecting volumes from selecting volume manager. Keep only one the latest active selection volume. Change initialization interface of active volume frustum inside of selecting volume manager: Init*SelectingVolume(), set required parameters, BuildSelectingVolume(). Mark existing BuildSelectingVolume() methods as deprecated. Use SelectMgr_SelectionType instead of SelectBasics_SelectingVolumeManager::SelectionType (the last one is marked as deprecated). Add interface GetViewRayDirection() to selecting volume manager to get view ray direction (instead of computation it as vector from near to far point). Add interface IsScalableActiveVolume() to selecting volume manager to check possibility of scaling of current active selecting volume.
123 lines
6.9 KiB
C++
123 lines
6.9 KiB
C++
// Created on: 2014-05-22
|
|
// Created by: Varvara POSKONINA
|
|
// Copyright (c) 2005-2014 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.
|
|
|
|
#ifndef _SelectMgr_TriangularFrustumSet_HeaderFile
|
|
#define _SelectMgr_TriangularFrustumSet_HeaderFile
|
|
|
|
#include <SelectMgr_TriangularFrustum.hxx>
|
|
#include <TColgp_HArray1OfPnt2d.hxx>
|
|
|
|
typedef NCollection_List<Handle(SelectMgr_TriangularFrustum)> SelectMgr_TriangFrustums;
|
|
typedef NCollection_List<Handle(SelectMgr_TriangularFrustum)>::Iterator SelectMgr_TriangFrustumsIter;
|
|
|
|
//! This class is used to handle polyline selection. The main principle of polyline selection
|
|
//! algorithm is to split the polygon defined by polyline onto triangles. Than each of
|
|
//! them is considered as a base for triangular frustum building. In other
|
|
//! words, each triangle vertiex will be projected from 2d screen space to 3d world space
|
|
//! onto near and far view frustum planes. Thus, the projected triangles make up the bases of
|
|
//! selecting frustum. When the set of such frustums is created, the function determining
|
|
//! selection iterates through triangular frustum set and searches for overlap with any
|
|
//! frustum.
|
|
class SelectMgr_TriangularFrustumSet : public SelectMgr_BaseFrustum
|
|
{
|
|
public:
|
|
|
|
//! Auxiliary structure to define selection polyline
|
|
struct SelectionPolyline
|
|
{
|
|
Handle(TColgp_HArray1OfPnt2d) Points;
|
|
};
|
|
|
|
SelectMgr_TriangularFrustumSet();
|
|
|
|
~SelectMgr_TriangularFrustumSet() {};
|
|
|
|
//! Initializes set of triangular frustums by polyline
|
|
Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& thePoints);
|
|
|
|
//! Meshes polygon bounded by polyline. Than organizes a set of triangular frustums,
|
|
//! where each triangle's projection onto near and far view frustum planes is
|
|
//! considered as a frustum base
|
|
//! NOTE: it should be called after Init() method
|
|
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
|
|
|
|
//! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given
|
|
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale,
|
|
const gp_GTrsf& theTrsf,
|
|
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
|
|
|
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,
|
|
const SelectMgr_Vec3& theMaxPnt,
|
|
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;
|
|
|
|
//! 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;
|
|
|
|
//! Stores plane equation coefficients (in the following form:
|
|
//! Ax + By + Cz + D = 0) to the given vector
|
|
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
|
|
|
|
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
|
|
//! mark both included and overlapped entities as matched
|
|
Standard_EXPORT virtual void SetAllowOverlapDetection (const Standard_Boolean theIsToAllow);
|
|
|
|
//! Dumps the content of me into the stream
|
|
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
|
|
|
private:
|
|
|
|
//! Checks whether the segment intersects with the boundary of the current volume selection
|
|
Standard_EXPORT Standard_Boolean isIntersectBoundary (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2) const;
|
|
|
|
//! Checks whether the triangle intersects with a segment
|
|
Standard_EXPORT Standard_Boolean segmentTriangleIntersection (const gp_Pnt &theOrig, const gp_Vec& theDir,
|
|
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3) const;
|
|
|
|
private:
|
|
|
|
SelectMgr_TriangFrustums myFrustums; //!< set of triangular frustums
|
|
SelectionPolyline mySelPolyline; //!< parameters of selection polyline (it is used to build triangle frustum set)
|
|
TColgp_Array1OfPnt myBoundaryPoints; //!< boundary points
|
|
Standard_Boolean myToAllowOverlap; //!< flag to detect only fully included sensitives or not
|
|
};
|
|
|
|
#endif // _SelectMgr_TriangularFrustumSet_HeaderFile
|