Open CASCADE Technology 7.8.2.dev
Graphic3d_CullingTool Class Reference

Graphic3d_CullingTool class provides a possibility to store parameters of view volume, such as its vertices and equations, and contains methods detecting if given AABB overlaps view volume. More...

#include <Graphic3d_CullingTool.hxx>

Data Structures

struct  CullingContext
 Auxiliary structure holding non-persistent culling options. More...
 
struct  Plane
 Auxiliary structure representing 3D plane. More...
 

Public Member Functions

 Graphic3d_CullingTool ()
 Creates an empty selector object with parallel projection type by default.
 
void SetViewVolume (const Handle< Graphic3d_Camera > &theCamera, const Graphic3d_Mat4d &theModelWorld=Graphic3d_Mat4d())
 Retrieves view volume's planes equations and its vertices from projection and world-view matrices.
 
void SetViewportSize (Standard_Integer theViewportWidth, Standard_Integer theViewportHeight, Standard_Real theResolutionRatio)
 
void SetCullingDistance (CullingContext &theCtx, Standard_Real theDistance) const
 Setup distance culling.
 
void SetCullingSize (CullingContext &theCtx, Standard_Real theSize) const
 Setup size culling.
 
void CacheClipPtsProjections ()
 Caches view volume's vertices projections along its normals and AABBs dimensions. Must be called at the beginning of each BVH tree traverse loop.
 
bool IsCulled (const CullingContext &theCtx, const Graphic3d_Vec3d &theMinPnt, const Graphic3d_Vec3d &theMaxPnt, Standard_Boolean *theIsInside=NULL) const
 Checks whether given AABB should be entirely culled or not.
 
const Handle< Graphic3d_Camera > & Camera () const
 Return the camera definition.
 
const Graphic3d_Mat4dProjectionMatrix () const
 Returns current projection matrix.
 
const Graphic3d_Mat4dWorldViewMatrix () const
 Returns current world view transformation matrix.
 
Standard_Integer ViewportWidth () const
 
Standard_Integer ViewportHeight () const
 
const Graphic3d_WorldViewProjStateWorldViewProjState () const
 Returns state of current world view projection transformation matrices.
 
const Graphic3d_Vec3dCameraEye () const
 Returns camera eye position.
 
const Graphic3d_Vec3dCameraDirection () const
 Returns camera direction.
 
Standard_Real SignedPlanePointDistance (const Graphic3d_Vec4d &theNormal, const Graphic3d_Vec4d &thePnt)
 Calculates signed distance from plane to point.
 
bool IsOutFrustum (const Graphic3d_Vec3d &theMinPnt, const Graphic3d_Vec3d &theMaxPnt, Standard_Boolean *theIsInside=NULL) const
 Detects if AABB overlaps view volume using separating axis theorem (SAT).
 
bool IsTooDistant (const CullingContext &theCtx, const Graphic3d_Vec3d &theMinPnt, const Graphic3d_Vec3d &theMaxPnt, Standard_Boolean *theIsInside=NULL) const
 Returns TRUE if given AABB should be discarded by distance culling criterion.
 
bool IsTooSmall (const CullingContext &theCtx, const Graphic3d_Vec3d &theMinPnt, const Graphic3d_Vec3d &theMaxPnt) const
 Returns TRUE if given AABB should be discarded by size culling criterion.
 

Protected Types

enum  {
  Plane_Left , Plane_Right , Plane_Bottom , Plane_Top ,
  Plane_Near , Plane_Far , PlanesNB
}
 Enumerates planes of view volume. More...
 

Protected Attributes

Plane myClipPlanes [PlanesNB]
 Planes.
 
NCollection_Array1< Graphic3d_Vec3dmyClipVerts
 Vertices.
 
Handle< Graphic3d_CameramyCamera
 camera definition
 
Standard_Real myMaxClipProjectionPts [PlanesNB]
 Max view volume's vertices projections onto its normals.
 
Standard_Real myMinClipProjectionPts [PlanesNB]
 Min view volume's vertices projections onto its normals.
 
Standard_Real myMaxOrthoProjectionPts [3]
 Max view volume's vertices projections onto normalized dimensions of AABB.
 
Standard_Real myMinOrthoProjectionPts [3]
 Min view volume's vertices projections onto normalized dimensions of AABB.
 
Standard_Boolean myIsProjectionParallel
 
Graphic3d_Mat4d myProjectionMat
 
Graphic3d_Mat4d myWorldViewMat
 
Standard_Integer myViewportWidth
 
Standard_Integer myViewportHeight
 
Graphic3d_WorldViewProjState myWorldViewProjState
 State of world view projection matrices.
 
Graphic3d_Vec3d myCamEye
 camera eye position for distance culling
 
Graphic3d_Vec3d myCamDir
 camera direction for size culling
 
Standard_Real myCamScale
 camera scale for size culling
 
Standard_Real myPixelSize
 pixel size for size culling
 

Detailed Description

Graphic3d_CullingTool class provides a possibility to store parameters of view volume, such as its vertices and equations, and contains methods detecting if given AABB overlaps view volume.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected

Enumerates planes of view volume.

Enumerator
Plane_Left 
Plane_Right 
Plane_Bottom 
Plane_Top 
Plane_Near 
Plane_Far 
PlanesNB 

Constructor & Destructor Documentation

◆ Graphic3d_CullingTool()

Graphic3d_CullingTool::Graphic3d_CullingTool ( )

Creates an empty selector object with parallel projection type by default.

Member Function Documentation

◆ CacheClipPtsProjections()

void Graphic3d_CullingTool::CacheClipPtsProjections ( )

Caches view volume's vertices projections along its normals and AABBs dimensions. Must be called at the beginning of each BVH tree traverse loop.

◆ Camera()

const Handle< Graphic3d_Camera > & Graphic3d_CullingTool::Camera ( ) const
inline

Return the camera definition.

◆ CameraDirection()

const Graphic3d_Vec3d & Graphic3d_CullingTool::CameraDirection ( ) const
inline

Returns camera direction.

◆ CameraEye()

const Graphic3d_Vec3d & Graphic3d_CullingTool::CameraEye ( ) const
inline

Returns camera eye position.

◆ IsCulled()

bool Graphic3d_CullingTool::IsCulled ( const CullingContext & theCtx,
const Graphic3d_Vec3d & theMinPnt,
const Graphic3d_Vec3d & theMaxPnt,
Standard_Boolean * theIsInside = NULL ) const
inline

Checks whether given AABB should be entirely culled or not.

Parameters
theCtx[in] culling properties
theMinPnt[in] maximum point of AABB
theMaxPnt[in] minimum point of AABB
theIsInside[out] flag indicating if AABB is fully inside; initial value should be set to TRUE
Returns
TRUE if AABB is completely outside of view frustum or culled by size/distance; FALSE in case of partial or complete overlap (use theIsInside to distinguish)

◆ IsOutFrustum()

bool Graphic3d_CullingTool::IsOutFrustum ( const Graphic3d_Vec3d & theMinPnt,
const Graphic3d_Vec3d & theMaxPnt,
Standard_Boolean * theIsInside = NULL ) const
inline

Detects if AABB overlaps view volume using separating axis theorem (SAT).

Parameters
theMinPnt[in] maximum point of AABB
theMaxPnt[in] minimum point of AABB
theIsInside[out] flag indicating if AABB is fully inside; initial value should be set to TRUE
Returns
TRUE if AABB is completely outside of view frustum; FALSE in case of partial or complete overlap (use theIsInside to distinguish)
See also
SelectMgr_Frustum::hasOverlap()

◆ IsTooDistant()

bool Graphic3d_CullingTool::IsTooDistant ( const CullingContext & theCtx,
const Graphic3d_Vec3d & theMinPnt,
const Graphic3d_Vec3d & theMaxPnt,
Standard_Boolean * theIsInside = NULL ) const
inline

Returns TRUE if given AABB should be discarded by distance culling criterion.

Parameters
theMinPnt[in] maximum point of AABB
theMaxPnt[in] minimum point of AABB
theIsInside[out] flag indicating if AABB is fully inside; initial value should be set to TRUE
Returns
TRUE if AABB is completely behind culling distance; FALSE in case of partial or complete overlap (use theIsInside to distinguish)

◆ IsTooSmall()

bool Graphic3d_CullingTool::IsTooSmall ( const CullingContext & theCtx,
const Graphic3d_Vec3d & theMinPnt,
const Graphic3d_Vec3d & theMaxPnt ) const
inline

Returns TRUE if given AABB should be discarded by size culling criterion.

◆ ProjectionMatrix()

const Graphic3d_Mat4d & Graphic3d_CullingTool::ProjectionMatrix ( ) const
inline

Returns current projection matrix.

◆ SetCullingDistance()

void Graphic3d_CullingTool::SetCullingDistance ( CullingContext & theCtx,
Standard_Real theDistance ) const

Setup distance culling.

◆ SetCullingSize()

void Graphic3d_CullingTool::SetCullingSize ( CullingContext & theCtx,
Standard_Real theSize ) const

Setup size culling.

◆ SetViewportSize()

void Graphic3d_CullingTool::SetViewportSize ( Standard_Integer theViewportWidth,
Standard_Integer theViewportHeight,
Standard_Real theResolutionRatio )

◆ SetViewVolume()

void Graphic3d_CullingTool::SetViewVolume ( const Handle< Graphic3d_Camera > & theCamera,
const Graphic3d_Mat4d & theModelWorld = Graphic3d_Mat4d() )

Retrieves view volume's planes equations and its vertices from projection and world-view matrices.

Parameters
theCamera[in] camera definition
theModelWorld[in] optional object transformation for computing frustum in object local coordinate system

◆ SignedPlanePointDistance()

Standard_Real Graphic3d_CullingTool::SignedPlanePointDistance ( const Graphic3d_Vec4d & theNormal,
const Graphic3d_Vec4d & thePnt )

Calculates signed distance from plane to point.

Parameters
theNormal[in] the plane's normal.
thePnt[in]

◆ ViewportHeight()

Standard_Integer Graphic3d_CullingTool::ViewportHeight ( ) const
inline

◆ ViewportWidth()

Standard_Integer Graphic3d_CullingTool::ViewportWidth ( ) const
inline

◆ WorldViewMatrix()

const Graphic3d_Mat4d & Graphic3d_CullingTool::WorldViewMatrix ( ) const
inline

Returns current world view transformation matrix.

◆ WorldViewProjState()

const Graphic3d_WorldViewProjState & Graphic3d_CullingTool::WorldViewProjState ( ) const
inline

Returns state of current world view projection transformation matrices.

Field Documentation

◆ myCamDir

Graphic3d_Vec3d Graphic3d_CullingTool::myCamDir
protected

camera direction for size culling

◆ myCamera

Handle< Graphic3d_Camera > Graphic3d_CullingTool::myCamera
protected

camera definition

◆ myCamEye

Graphic3d_Vec3d Graphic3d_CullingTool::myCamEye
protected

camera eye position for distance culling

◆ myCamScale

Standard_Real Graphic3d_CullingTool::myCamScale
protected

camera scale for size culling

◆ myClipPlanes

Plane Graphic3d_CullingTool::myClipPlanes[PlanesNB]
protected

Planes.

◆ myClipVerts

NCollection_Array1<Graphic3d_Vec3d> Graphic3d_CullingTool::myClipVerts
protected

Vertices.

◆ myIsProjectionParallel

Standard_Boolean Graphic3d_CullingTool::myIsProjectionParallel
protected

◆ myMaxClipProjectionPts

Standard_Real Graphic3d_CullingTool::myMaxClipProjectionPts[PlanesNB]
protected

Max view volume's vertices projections onto its normals.

◆ myMaxOrthoProjectionPts

Standard_Real Graphic3d_CullingTool::myMaxOrthoProjectionPts[3]
protected

Max view volume's vertices projections onto normalized dimensions of AABB.

◆ myMinClipProjectionPts

Standard_Real Graphic3d_CullingTool::myMinClipProjectionPts[PlanesNB]
protected

Min view volume's vertices projections onto its normals.

◆ myMinOrthoProjectionPts

Standard_Real Graphic3d_CullingTool::myMinOrthoProjectionPts[3]
protected

Min view volume's vertices projections onto normalized dimensions of AABB.

◆ myPixelSize

Standard_Real Graphic3d_CullingTool::myPixelSize
protected

pixel size for size culling

◆ myProjectionMat

Graphic3d_Mat4d Graphic3d_CullingTool::myProjectionMat
protected

◆ myViewportHeight

Standard_Integer Graphic3d_CullingTool::myViewportHeight
protected

◆ myViewportWidth

Standard_Integer Graphic3d_CullingTool::myViewportWidth
protected

◆ myWorldViewMat

Graphic3d_Mat4d Graphic3d_CullingTool::myWorldViewMat
protected

◆ myWorldViewProjState

Graphic3d_WorldViewProjState Graphic3d_CullingTool::myWorldViewProjState
protected

State of world view projection matrices.


The documentation for this class was generated from the following file: