1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0024070: OpenGL capped object-level clipping planes

Graphical clipping:
- Use "Graphic3d_ClipPlane" to defined clipping for PrsMgr_PresentableObject (local clipping), for V3d_View (global clipping).

Get rid of old implementations:
- Remove Visual3d_ClipPlane.
- Port V3d_Plane to Graphic3d_ClipPlane core.

Selection Sensitives:
- Port "Matches" method to add full set of arguments (SelectBasics_PickArgs), including min-max depth coming from selector.
- Get rid of transient data for pair Matches -> ComputeDepth.
- Extend SelectMgr_ViewerSelector::LoadResult to work with local clipping, add virtual callbacks to compute globa/local depth clipping for picking.

Capping rendering algorithm:
- Recursive rendering algorithm for OpenGl_Groups.
- Introduced Rendering filter for groups.

Clipping plane management in TKOpenGl:
- Added OpenGl_ClippingState to OpenGl_Context.

DRAWEXE commands:
- Ported "vclipplane" command for new approach.
- Added "vsettexturemode" command for changing texture details in views (enable / disable textures).

Correct DownCast syntax (compilation error)

Fix new compiler warnings

tests/bugs/vis/bug22906 migrated to the new vclipplane syntax
This commit is contained in:
apl
2013-09-19 16:58:00 +04:00
committed by bugmaster
parent 788cbaf4c4
commit 4269bd1b11
111 changed files with 4168 additions and 2293 deletions

View File

@@ -0,0 +1,171 @@
// Created on: 2013-08-15
// Created by: Anton POLETAEV
// Copyright (c) 2013 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Vec.hxx>
#include <Precision.hxx>
IMPLEMENT_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_CappingPlaneResource, OpenGl_Resource)
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
: myOrientation (OpenGl_IdentityMatrix),
myAspect (NULL),
myPlaneRoot (thePlane),
myEquationMod (0),
myAspectMod (0)
{}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
{
Release (NULL);
}
// =======================================================================
// function : Update
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theContext)
{
UpdateTransform();
UpdateAspect (theContext);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Release (const OpenGl_Context* theContext)
{
OpenGl_Element::Destroy (theContext, myAspect);
myEquationMod = 0;
myAspectMod = 0;
}
// =======================================================================
// function : UpdateAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::UpdateAspect (const Handle(OpenGl_Context)& theContext)
{
Handle(Graphic3d_AspectFillArea3d) aCappingAsp = myPlaneRoot->CappingAspect();
if (myAspect != NULL && !aCappingAsp.IsNull())
{
if (myAspectMod == myPlaneRoot->MCountAspect())
return; // noting to update
myAspect->Init (theContext, aCappingAsp);
myAspectMod = myPlaneRoot->MCountAspect();
return;
}
// no more used
if (myAspect != NULL && aCappingAsp.IsNull())
{
OpenGl_Element::Destroy (theContext, myAspect);
myAspectMod = myPlaneRoot->MCountAspect();
return;
}
// first created
if (myAspect == NULL && !aCappingAsp.IsNull())
{
myAspect = new OpenGl_AspectFace();
myAspect->Init (theContext, aCappingAsp);
myAspectMod = myPlaneRoot->MCountAspect();
}
}
// =======================================================================
// function : UpdateTransform
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::UpdateTransform()
{
const Graphic3d_ClipPlane::Equation& anEquation = myPlaneRoot->GetEquation();
if (myEquationMod == myPlaneRoot->MCountEquation())
{
return; // nothing to update
}
// re-evaluate infinite plane transformation matrix
Standard_ShortReal N[3] =
{ (Standard_ShortReal)anEquation[0],
(Standard_ShortReal)anEquation[1],
(Standard_ShortReal)anEquation[2] };
Standard_ShortReal T[3] =
{ (Standard_ShortReal)(anEquation[0] * -anEquation[3]),
(Standard_ShortReal)(anEquation[1] * -anEquation[3]),
(Standard_ShortReal)(anEquation[2] * -anEquation[3]) };
Standard_ShortReal L[3] = { 0.0f, 0.0f, 0.0f };
Standard_ShortReal F[3] = { 0.0f, 0.0f, 0.0f };
// project plane normal onto OX to find left vector
Standard_ShortReal aConfusion = (Standard_ShortReal)Precision::Confusion();
Standard_ShortReal aProjLen =
sqrt ( (Standard_ShortReal)(anEquation[0] * anEquation[0])
+ (Standard_ShortReal)(anEquation[2] * anEquation[2]));
if (aProjLen < aConfusion)
{
L[0] = 1.0f;
}
else
{
L[0] = N[2] / aProjLen;
L[2] = -N[0] / aProjLen;
}
// (-aLeft) x aNorm
F[0] = (-L[1])*N[2] - (-L[2])*N[1];
F[1] = (-L[2])*N[0] - (-L[0])*N[2];
F[2] = (-L[0])*N[1] - (-L[1])*N[0];
myOrientation.mat[0][0] = L[0];
myOrientation.mat[0][1] = L[1];
myOrientation.mat[0][2] = L[2];
myOrientation.mat[0][3] = 0.0f;
myOrientation.mat[1][0] = N[0];
myOrientation.mat[1][1] = N[1];
myOrientation.mat[1][2] = N[2];
myOrientation.mat[1][3] = 0.0f;
myOrientation.mat[2][0] = F[0];
myOrientation.mat[2][1] = F[1];
myOrientation.mat[2][2] = F[2];
myOrientation.mat[2][3] = 0.0f;
myOrientation.mat[3][0] = T[0];
myOrientation.mat[3][1] = T[1];
myOrientation.mat[3][2] = T[2];
myOrientation.mat[3][3] = 1.0f;
myEquationMod = myPlaneRoot->MCountEquation();
}