1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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

@@ -42,7 +42,7 @@ package Visual3d
-- The visualiser manages the structures, the views, the
-- light sources, and object picking.
---Keywords: View, Light, Plane, Pick
---Keywords: View, Light, Pick
---Warning:
---References:
@@ -205,11 +205,6 @@ is
-- Category: The classes
------------------------
class ClipPlane;
---Purpose: This class allows the creation and update of a
-- clipping plane in the space model.
---Category: The classes
class ContextPick;
---Purpose: This class allows the creation and update of a
-- pick context for one view of the viewer.
@@ -317,15 +312,6 @@ is
(PickPath from Visual3d, SequenceOfPickPath);
---Category: Instantiated classes
class SetOfClipPlane instantiates
Set from TCollection (ClipPlane from Visual3d);
---Category: Instantiated classes
class HSetOfClipPlane instantiates
HSet from TCollection
(ClipPlane from Visual3d, SetOfClipPlane);
---Category: Instantiated classes
class SetOfLight instantiates
Set from TCollection (Light from Visual3d);
---Category: Instantiated classes

View File

@@ -1,119 +0,0 @@
-- Created on: 1991-09-06
-- Created by: NW,JPB,CAL
-- Copyright (c) 1991-1999 Matra Datavision
-- Copyright (c) 1999-2012 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.
class ClipPlane from Visual3d inherits TShared
---Version:
---Purpose: This class allows the definition and update
-- of clipping planes in the space model.
---Keywords: Clipping Plane, Model Clipping
---Warning:
---References:
uses
CPlane from Graphic3d
is
Create ( ACoefA : Real from Standard;
ACoefB : Real from Standard;
ACoefC : Real from Standard;
ACoefD : Real from Standard )
returns mutable ClipPlane from Visual3d;
---Level: Internal
---Purpose: Creates a clipping plane from the equation :
-- <ACoefA>*X + <ACoefB>*Y + <ACoefC>*Z + <ACoefD> = 0.0
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
SetPlane ( me : mutable;
ACoefA : Real from Standard;
ACoefB : Real from Standard;
ACoefC : Real from Standard;
ACoefD : Real from Standard )
is static;
---Level: Internal
---Purpose: Modifies the plane equation.
---Category: Methods to modify the class definition
--------------------------
-- Category: Class methods
--------------------------
Limit ( myclass )
returns Integer from Standard;
---Level: Internal
---Purpose: Maximum number of activatable clipping planes.
---Category: Class methods
----------------------------
-- Category: Inquire methods
----------------------------
Plane ( me;
ACoefA : out Real from Standard;
ACoefB : out Real from Standard;
ACoefC : out Real from Standard;
ACoefD : out Real from Standard )
is static;
---Level: Internal
---Purpose: Returns the values of the clipping plane <me>.
---Category: Inquire methods
----------------------------
-- Category: Private methods
----------------------------
Identification ( me )
returns Integer from Standard
is static private;
---Level: Internal
---Purpose: Returns the plane identification.
---Category: Private methods
--
fields
--
-- Class : Visual3d_ClipPlane
--
-- Purpose : Declaration of variables specific to the
-- clipping plane model
--
-- Reminders : A clipping plane is defined by its equation
-- Equation : A*X + B*Y + C*Z + D = 0
--
-- the associated C structure
MyCPlane : CPlane from Graphic3d;
friends
class View from Visual3d
end ClipPlane;

View File

@@ -1,103 +0,0 @@
// Created by: NW,JPB,CAL
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2012 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.
//-Version
//-Design Declaration des variables specifiques aux plans de
// clipping modele
//-Warning Un plan de clipping est defini par son equation ou
// par un point et sa normale
// Equation : A*X + B*Y + C*Z + D = 0
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <Visual3d_ClipPlane.ixx>
#include <Graphic3d_GraphicDriver.hxx>
//-Aliases
//-Global data definitions
//-Constructors
//-Destructors
//-Methods, in order
Visual3d_ClipPlane::Visual3d_ClipPlane (const Standard_Real ACoefA, const Standard_Real ACoefB, const Standard_Real ACoefC, const Standard_Real ACoefD) {
MyCPlane.WsId = -1;
MyCPlane.ViewId = 0; /* not used */
MyCPlane.CoefA = float (ACoefA);
MyCPlane.CoefB = float (ACoefB);
MyCPlane.CoefC = float (ACoefC);
MyCPlane.CoefD = float (ACoefD);
MyCPlane.PlaneId =
Graphic3d_GraphicDriver::Plane (MyCPlane, Standard_False);
}
void Visual3d_ClipPlane::SetPlane (const Standard_Real ACoefA, const Standard_Real ACoefB, const Standard_Real ACoefC, const Standard_Real ACoefD) {
MyCPlane.CoefA = float (ACoefA);
MyCPlane.CoefB = float (ACoefB);
MyCPlane.CoefC = float (ACoefC);
MyCPlane.CoefD = float (ACoefD);
MyCPlane.PlaneId =
Graphic3d_GraphicDriver::Plane (MyCPlane, Standard_True);
}
void Visual3d_ClipPlane::Plane (Standard_Real& ACoefA, Standard_Real& ACoefB, Standard_Real& ACoefC, Standard_Real& ACoefD) const {
ACoefA = Standard_Real (MyCPlane.CoefA);
ACoefB = Standard_Real (MyCPlane.CoefB);
ACoefC = Standard_Real (MyCPlane.CoefC);
ACoefD = Standard_Real (MyCPlane.CoefD);
}
Standard_Integer Visual3d_ClipPlane::Limit () {
#ifdef GER61454
return 4; // Obsolete method, calls instead myView->PlaneLimit()
#else
// Old method, replaced by GraphicDriver::InquirePlaneLimit ()
return 0;
#endif
}
Standard_Integer Visual3d_ClipPlane::Identification () const {
return (Standard_Integer (MyCPlane.PlaneId));
}

View File

@@ -39,14 +39,14 @@ class ContextView from Visual3d
uses
SequenceOfAddress from TColStd,
ClipPlane from Visual3d,
Light from Visual3d,
HSetOfLight from Visual3d,
HSetOfClipPlane from Visual3d,
TypeOfModel from Visual3d,
TypeOfVisualization from Visual3d,
TypeOfSurfaceDetail from Visual3d,
TextureEnv from Graphic3d
TextureEnv from Graphic3d,
SetOfHClipPlane from Graphic3d
raises
@@ -147,19 +147,14 @@ is
-- Clip Plane
---------------------------------------------------
SetClipPlaneOn ( me : in out;
AClipPlane : ClipPlane from Visual3d )
is static;
---Level: Internal
---Purpose: Activates the clipping plane <AClipPlane>
---Category: Methods to modify the class definition
SetClipPlanes (me : in out; thePlanes : SetOfHClipPlane from Graphic3d);
---Purpose: Set list of clip planes to the view context.
-- @param thePlanes [in] the clip planes to set.
SetClipPlaneOff ( me : in out;
AClipPlane : ClipPlane from Visual3d )
is static;
---Level: Internal
---Purpose: Deactivates the clipping plane <AClipPlane>
---Category: Methods to modify the class definition
GetClipPlanes (me) returns SetOfHClipPlane from Graphic3d;
---C++: return const&
---Purpose: Get clip planes.
-- @return sequence of clip planes.
---------------------------------------------------
-- Category: Methods to modify the class definition
@@ -285,29 +280,6 @@ is
-- Category: Inquire methods
----------------------------
ActivatedClipPlanes ( me )
returns HSetOfClipPlane from Visual3d
is static;
---Level: Internal
---Purpose: Returns the group of active clipping planes
-- in the view of context <me>.
---Category: Inquire methods
NumberOfActivatedClipPlanes ( me )
returns Integer from Standard
is static;
---Level: Internal
---Purpose: Returns the number of active clipping planes
-- in the view of context <me>.
---Category: Inquire methods
ActivatedClipPlane ( me;
AnIndex : Integer from Standard )
returns ClipPlane from Visual3d
is static;
---Level: Internal
---Category: Inquire methods
ActivatedLights ( me )
returns HSetOfLight from Visual3d
is static;
@@ -465,11 +437,9 @@ fields
-- the light sources activated
MyLights : SequenceOfAddress from TColStd;
-- the clipping planes activated
MyClipPlanes : SequenceOfAddress from TColStd;
MyTextureEnv : TextureEnv from Graphic3d;
MySurfaceDetail : TypeOfSurfaceDetail from Visual3d;
myClipPlanes : SetOfHClipPlane from Graphic3d;
end ContextView;

View File

@@ -60,9 +60,9 @@ MyDepthCueingBackPlane (Standard_ShortReal (0.0)),
MyModel (Visual3d_TOM_NONE),
MyVisual (Visual3d_TOV_WIREFRAME),
MyLights (),
MyClipPlanes (),
MyTextureEnv(),
MySurfaceDetail(Visual3d_TOD_NONE)
MySurfaceDetail(Visual3d_TOD_NONE),
myClipPlanes()
{
}
@@ -311,65 +311,6 @@ Handle(Visual3d_Light) Visual3d_ContextView::ActivatedLight (const Standard_Inte
}
void Visual3d_ContextView::SetClipPlaneOn (const Handle(Visual3d_ClipPlane)& AClipPlane) {
Standard_Integer LengthC = MyClipPlanes.Length ();
Standard_Integer indexC = 0;
// Find plane <AClipPlane> in the
// sequence of already active planes
for (Standard_Integer i=1; i<=LengthC && indexC==0; i++)
if ((void *) (MyClipPlanes.Value (i)) ==
(void *) (AClipPlane.operator->())) indexC = i;
// This is the activation of a new plane
if (indexC == 0)
MyClipPlanes.Append ((void *) AClipPlane.operator->());
}
void Visual3d_ContextView::SetClipPlaneOff (const Handle(Visual3d_ClipPlane)& AClipPlane) {
Standard_Integer LengthC = MyClipPlanes.Length ();
Standard_Integer indexC = 0;
// Find plane <AClipPlane> in the
// sequence of already active planes
for (Standard_Integer i=1; i<=LengthC && indexC==0; i++)
if ((void *) (MyClipPlanes.Value (i)) ==
(void *) (AClipPlane.operator->())) indexC = i;
// This is an active plane
if (indexC != 0) MyClipPlanes.Remove (indexC);
}
Handle(Visual3d_HSetOfClipPlane) Visual3d_ContextView::ActivatedClipPlanes () const {
Handle(Visual3d_HSetOfClipPlane) SG = new Visual3d_HSetOfClipPlane ();
Standard_Integer Length = MyClipPlanes.Length ();
for (Standard_Integer i=1; i<=Length; i++)
SG->Add ((Visual3d_ClipPlane *) (MyClipPlanes.Value (i)));
return (SG);
}
Standard_Integer Visual3d_ContextView::NumberOfActivatedClipPlanes () const {
Standard_Integer Length = MyClipPlanes.Length ();
return (Length);
}
Handle(Visual3d_ClipPlane) Visual3d_ContextView::ActivatedClipPlane (const Standard_Integer AnIndex) const {
return (Visual3d_ClipPlane *) (MyClipPlanes.Value (AnIndex));
}
void Visual3d_ContextView::SetSurfaceDetail(const Visual3d_TypeOfSurfaceDetail TOSD)
{
MySurfaceDetail = TOSD;
@@ -392,3 +333,13 @@ Visual3d_TypeOfSurfaceDetail Visual3d_ContextView::SurfaceDetail() const
{
return MySurfaceDetail;
}
void Visual3d_ContextView::SetClipPlanes (const Graphic3d_SetOfHClipPlane& thePlanes)
{
myClipPlanes = thePlanes;
}
const Graphic3d_SetOfHClipPlane& Visual3d_ContextView::GetClipPlanes() const
{
return myClipPlanes;
}

View File

@@ -90,10 +90,8 @@ uses
MapOfStructure from Graphic3d,
ContextView from Visual3d,
ClipPlane from Visual3d,
Layer from Visual3d,
Light from Visual3d,
SetOfClipPlane from Visual3d,
SetOfLight from Visual3d,
TypeOfAnswer from Visual3d,
ViewMapping from Visual3d,

View File

@@ -147,11 +147,6 @@
#include <Visual3d_HSetOfLight.hxx>
#include <Visual3d_SetIteratorOfSetOfLight.hxx>
#include <Visual3d_ClipPlane.hxx>
#include <Visual3d_SetOfClipPlane.hxx>
#include <Visual3d_HSetOfClipPlane.hxx>
#include <Visual3d_SetIteratorOfSetOfClipPlane.hxx>
#include <Visual3d_SetIteratorOfSetOfView.hxx>
#include <Graphic3d_TextureEnv.hxx>
@@ -198,10 +193,6 @@ Standard_Integer i, j;
MyCView.DefWindow.IsDefined = 0;
MyCView.Context.NbActiveLight = 0;
MyCView.Context.NbActivePlane = 0;
#ifdef GER61454
MyCView.Context.ActivePlane = NULL;
#endif
for (i=0; i<=3; i++)
for (j=0; j<=3; j++)
@@ -311,10 +302,6 @@ Standard_Integer i, j;
MyCView.DefWindow.IsDefined = 0;
MyCView.Context.NbActiveLight = 0;
MyCView.Context.NbActivePlane = 0;
#ifdef GER61454
MyCView.Context.ActivePlane = NULL;
#endif
for (i=0; i<=3; i++)
for (j=0; j<=3; j++)
@@ -863,64 +850,14 @@ Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
}
void Visual3d_View::UpdatePlanes () {
Standard_Integer i, j;
CALL_DEF_PLANE *planes=NULL;
i = MyContext.NumberOfActivatedClipPlanes ();
j = MyGraphicDriver->InquirePlaneLimit ();
MyCView.Context.NbActivePlane = (i > j ? j : i);
if (MyCView.Context.NbActivePlane > 0) {
// Dynamic Allocation
#ifdef GER61454 //Keep the plane address for the next Update !
if( !MyCView.Context.ActivePlane )
MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
planes = MyCView.Context.ActivePlane;
#else
planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
MyCView.Context.ActivePlane = planes;
#endif
Standard_Real A, B, C, D;
// Parcing of clipping planes
for (j=0; j<MyCView.Context.NbActivePlane; j++) {
planes[j].WsId = MyCView.ViewId;
planes[j].ViewId = MyCView.ViewId;
planes[j].Active = 1;
planes[j].PlaneId =
int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
(MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
planes[j].CoefA = float (A);
planes[j].CoefB = float (B);
planes[j].CoefC = float (C);
planes[j].CoefD = float (D);
}
}
// Management of planes of clipping model
if (! IsDeleted ())
if (IsDefined ())
MyGraphicDriver->SetPlane (MyCView);
// Dynamic allocation
#ifdef GER61454
if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
) {
delete [] MyCView.Context.ActivePlane;
MyCView.Context.ActivePlane = NULL;
}
#else
if (MyCView.Context.NbActivePlane > 0) delete [] planes;
#endif
void Visual3d_View::UpdatePlanes()
{
MyCView.Context.ClipPlanes = MyContext.GetClipPlanes();
if (IsDeleted() || !IsDefined())
return;
MyGraphicDriver->SetClipPlanes (MyCView);
}
void Visual3d_View::SetBackground (const Aspect_Background& ABack) {