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

0027751: Visualization, Graphic3d_ClipPlane - add option to inherit material from object

Graphic3d_ClipPlane - Graphic3d_AspectFillArea3d is now stored as class field.
OpenGl_CappingAlgo::RenderCapping() now handles special mode
preserving material from rendered object.

MeshVS_ElementalColorPrsBuilder::Build() now creates single primitives group
for triangles, thus Closed flag is correctly applied.

Redundant methods OpenGl_Structure::DrawGroups() and ::renderClosedGeometry()
have been removed.

Draw Harness, ViewerTest - vaspects now preserves display mode
and location when assigning sub-shape aspects.
The syntax of command vclipplane has been revised
(preserving compatibility with old syntax):
- Use "-param" style syntax for all arguments.
- Eliminate redundant arguments "change", "view", "object".
- Allow passing multiple parameters withing single call.
- Do not require "create" command - create new plane implicitly.
- "maxplanes" argument does not require view name anymore.
- "delete" does not throws TCL exception for non-existing plane.
- "view" argument without list now applies to active view.
- Handle * and ALL withing "delete" to remove all defined planes.

update test case bugs/vis/bug26028
This commit is contained in:
kgv
2016-08-08 19:51:40 +03:00
committed by bugmaster
parent 89a929ea26
commit 3e05329c4c
21 changed files with 990 additions and 657 deletions

View File

@@ -37,6 +37,7 @@ Graphic3d_Buffer.hxx
Graphic3d_BufferType.hxx
Graphic3d_Camera.cxx
Graphic3d_Camera.hxx
Graphic3d_CappingFlags.hxx
Graphic3d_CLight.hxx
Graphic3d_ClipPlane.cxx
Graphic3d_ClipPlane.hxx

View File

@@ -0,0 +1,29 @@
// Created on: 2016-08-04
// Copyright (c) 2016 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 _Graphic3d_CappingFlags_HeaderFile
#define _Graphic3d_CappingFlags_HeaderFile
//! Enumeration of capping flags.
enum Graphic3d_CappingFlags
{
Graphic3d_CappingFlags_None = 0x0000, //!< no flags
Graphic3d_CappingFlags_ObjectMaterial = 0x0001, //!< use object material
Graphic3d_CappingFlags_ObjectTexture = 0x0002, //!< use object texture
Graphic3d_CappingFlags_ObjectShader = 0x0008, //!< use object GLSL program
Graphic3d_CappingFlags_ObjectAspect =
Graphic3d_CappingFlags_ObjectMaterial | Graphic3d_CappingFlags_ObjectTexture | Graphic3d_CappingFlags_ObjectShader //!< use entire fill area aspect from object
};
#endif // _Graphic3d_CappingFlags_HeaderFile

View File

@@ -14,16 +14,29 @@
// commercial license or contractual agreement.
#include <Graphic3d_ClipPlane.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <gp_Pln.hxx>
#include <Standard_Atomic.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
namespace
{
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
{
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (aMaterial);
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetInteriorColor (aMaterial.Color());
anAspect->SetSuppressBackFaces (false);
return anAspect;
}
}
// =======================================================================
@@ -31,17 +44,15 @@ namespace
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
: myEquation (0.0, 0.0, 1.0, 0.0),
: myAspect (defaultAspect()),
myEquation (0.0, 0.0, 1.0, 0.0),
myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
myMaterial (Graphic3d_NOM_DEFAULT),
myHatch (Aspect_HS_HORIZONTAL),
myHatchOn (Standard_False),
myId(),
myEquationMod(0),
myAspectMod(0)
{
MakeId();
makeId();
}
// =======================================================================
@@ -49,17 +60,15 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
: myEquation (theEquation),
: myAspect (defaultAspect()),
myEquation (theEquation),
myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
myMaterial (Graphic3d_NOM_DEFAULT),
myHatch (Aspect_HS_HORIZONTAL),
myHatchOn (Standard_False),
myId(),
myEquationMod(0),
myAspectMod(0)
{
MakeId();
makeId();
}
// =======================================================================
@@ -68,18 +77,16 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
: Standard_Transient(theOther),
myAspect (defaultAspect()),
myEquation (theOther.myEquation),
myFlags (theOther.myFlags),
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping),
myMaterial (theOther.myMaterial),
myTexture (theOther.myTexture),
myHatch (theOther.myHatch),
myHatchOn (theOther.myHatchOn),
myId(),
myEquationMod (0),
myAspectMod (0)
{
MakeId();
makeId();
*myAspect = *theOther.CappingAspect();
}
// =======================================================================
@@ -87,17 +94,15 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
: myEquation (),
: myAspect (defaultAspect()),
myEquation (),
myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
myMaterial (Graphic3d_NOM_DEFAULT),
myHatch (Aspect_HS_HORIZONTAL),
myHatchOn (Standard_False),
myId(),
myEquationMod(0),
myAspectMod(0)
{
MakeId();
makeId();
SetEquation (thePlane);
}
@@ -169,8 +174,9 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
// =======================================================================
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
{
myMaterial = theMat;
myAspectMod++;
myAspect->SetFrontMaterial (theMat);
myAspect->SetInteriorColor (theMat.Color());
++myAspectMod;
}
// =======================================================================
@@ -179,8 +185,16 @@ void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& th
// =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
{
myTexture = theTexture;
myAspectMod++;
myAspect->SetTextureMap (theTexture);
if (!theTexture.IsNull())
{
myAspect->SetTextureMapOn();
}
else
{
myAspect->SetTextureMapOff();
}
++myAspectMod;
}
// =======================================================================
@@ -189,8 +203,8 @@ void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)&
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
{
myHatch = theStyle;
myAspectMod++;
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
@@ -199,8 +213,8 @@ void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOn()
{
myHatchOn = Standard_True;
myAspectMod++;
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
++myAspectMod;
}
// =======================================================================
@@ -209,41 +223,43 @@ void Graphic3d_ClipPlane::SetCappingHatchOn()
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOff()
{
myHatchOn = Standard_False;
myAspectMod++;
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
++myAspectMod;
}
// =======================================================================
// function : MakeId
// function : SetCappingAspect
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::MakeId()
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
myAspect = theAspect;
++myAspectMod;
}
// =======================================================================
// function : setCappingFlag
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
{
if (theToUse)
{
myFlags |= theFlag;
}
else
{
myFlags &= ~(theFlag);
}
++myAspectMod;
}
// =======================================================================
// function : makeId
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::makeId()
{
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
}
// =======================================================================
// function : CappingAspect
// purpose :
// =======================================================================
Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
{
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (myMaterial);
anAspect->SetTextureMap (myTexture);
anAspect->SetHatchStyle (myHatch);
anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
anAspect->SetInteriorColor (myMaterial.Color());
anAspect->SetSuppressBackFaces (false);
if (!myTexture.IsNull())
{
anAspect->SetTextureMapOn();
}
else
{
anAspect->SetTextureMapOff();
}
return anAspect;
}

View File

@@ -20,12 +20,12 @@
#include <Standard_TypeDef.hxx>
#include <Standard_Transient.hxx>
#include <NCollection_Vec4.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_CappingFlags.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Aspect_HatchStyle.hxx>
class gp_Pln;
class Graphic3d_AspectFillArea3d;
//! Container for properties describing graphic driver clipping planes.
//! It is up to application to create instances of this class and specify its
@@ -132,30 +132,21 @@ public: // @name user-defined graphical attributes
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
//! @return capping material.
const Graphic3d_MaterialAspect& CappingMaterial() const
{
return myMaterial;
}
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
//! Set texture to be applied on capping surface.
//! @param theTexture [in] the texture.
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
//! @return capping texture map.
const Handle(Graphic3d_TextureMap)& CappingTexture() const
{
return myTexture;
}
const Handle(Graphic3d_TextureMap)& CappingTexture() const { return myAspect->TextureMap(); }
//! Set hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch style.
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
//! @return hatching style.
Aspect_HatchStyle CappingHatch() const
{
return myHatch;
}
Aspect_HatchStyle CappingHatch() const { return myAspect->HatchStyle(); }
//! Turn on hatching.
Standard_EXPORT void SetCappingHatchOn();
@@ -164,10 +155,7 @@ public: // @name user-defined graphical attributes
Standard_EXPORT void SetCappingHatchOff();
//! @return True if hatching mask is turned on.
Standard_Boolean IsHatchOn() const
{
return myHatchOn;
}
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
//! This ID is used for managing associated resources in graphical driver.
//! The clip plane can be assigned within a range of IO which can be
@@ -181,9 +169,38 @@ public: // @name user-defined graphical attributes
return myId;
}
//! Compute and return capping aspect from the graphical attributes.
public:
//! Return capping aspect.
//! @return capping surface rendering aspect.
Standard_EXPORT Handle(Graphic3d_AspectFillArea3d) CappingAspect() const;
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
//! Assign capping aspect.
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
//! Flag indicating whether material for capping plane should be taken from object.
//! Default value: FALSE (use dedicated capping plane material).
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
//! Set flag for controlling the source of capping plane material.
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
//! Flag indicating whether texture for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
//! Set flag for controlling the source of capping plane texture.
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
//! Flag indicating whether shader program for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
//! Set flag for controlling the source of capping plane shader program.
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
//! Return true if some fill area aspect properties should be taken from object.
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
public: // @name modification counters
@@ -201,20 +218,22 @@ public: // @name modification counters
private:
void MakeId();
//! Generate unique object id for OpenGL graphic resource manager.
void makeId();
//! Set capping flag.
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
private:
Equation myEquation; //!< Plane equation vector.
Standard_Boolean myIsOn; //!< State of the clipping plane.
Standard_Boolean myIsCapping; //!< State of graphic driver capping.
Graphic3d_MaterialAspect myMaterial; //!< Capping surface material.
Handle(Graphic3d_TextureMap) myTexture; //!< Capping surface texture.
Aspect_HatchStyle myHatch; //!< Capping surface hatch mask.
Standard_Boolean myHatchOn; //!< Capping surface hatching flag.
TCollection_AsciiString myId; //!< Resource id.
unsigned int myEquationMod; //!< Modification counter for equation.
unsigned int myAspectMod; //!< Modification counter of aspect.
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
TCollection_AsciiString myId; //!< resource id
Equation myEquation; //!< plane equation vector
unsigned int myFlags; //!< capping flags
Standard_Boolean myIsOn; //!< state of the clipping plane
Standard_Boolean myIsCapping; //!< state of graphic driver capping
unsigned int myEquationMod; //!< modification counter for equation
unsigned int myAspectMod; //!< modification counter of aspect
public: