1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

#265 Possibility to display materials by different hatching style when we make clipping

This commit is contained in:
apl 2017-04-28 09:17:05 +03:00 committed by ema
parent 0f1bc56d6c
commit 7dc7bda859
38 changed files with 2383 additions and 1147 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -618,6 +618,9 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{ {
aShadedGroup = Prs3d_Root::NewGroup (thePrs); aShadedGroup = Prs3d_Root::NewGroup (thePrs);
aShadedGroup->SetClosed (isClosed); aShadedGroup->SetClosed (isClosed);
if (isClosed
&& !myCappingStyle.IsNull())
aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle);
} }
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect()); aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
aShadedGroup->AddPrimitiveArray (aTriangles); aShadedGroup->AddPrimitiveArray (aTriangles);

View File

@ -21,6 +21,7 @@
#include <Aspect_PolygonOffsetMode.hxx> #include <Aspect_PolygonOffsetMode.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx> #include <Graphic3d_AspectText3d.hxx>
@ -277,6 +278,37 @@ void AIS_InteractiveObject::UnsetMaterial()
hasOwnMaterial = Standard_False; hasOwnMaterial = Standard_False;
} }
//=======================================================================
//function : SetCappingStyle
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
myCappingStyle = theStyle;
// Modify existing presentations
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
if (!aPrs3d.IsNull())
{
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
if (!aStruct.IsNull())
{
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (aGrp.IsNull())
continue;
aGrp->SetGroupPrimitivesAspect (theStyle);
}
}
}
}
}
//======================================================================= //=======================================================================
//function : SetTransparency //function : SetTransparency
//purpose : //purpose :
@ -621,10 +653,11 @@ void AIS_InteractiveObject::SynchronizeAspects()
continue; continue;
} }
Handle(Graphic3d_AspectLine3d) aLineAspect = aGrp->LineAspect(); Handle(Graphic3d_AspectLine3d) aLineAspect = aGrp->LineAspect();
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = aGrp->FillAreaAspect(); Handle(Graphic3d_AspectFillArea3d) aFaceAspect = aGrp->FillAreaAspect();
Handle(Graphic3d_AspectMarker3d) aMarkerAspect = aGrp->MarkerAspect(); Handle(Graphic3d_AspectFillCapping) aCappingAspect = aGrp->FillCappingAspect();
Handle(Graphic3d_AspectText3d) aTextAspect = aGrp->TextAspect(); Handle(Graphic3d_AspectMarker3d) aMarkerAspect = aGrp->MarkerAspect();
Handle(Graphic3d_AspectText3d) aTextAspect = aGrp->TextAspect();
if (!aLineAspect.IsNull()) if (!aLineAspect.IsNull())
{ {
aGrp->SetGroupPrimitivesAspect (aLineAspect); aGrp->SetGroupPrimitivesAspect (aLineAspect);
@ -633,6 +666,10 @@ void AIS_InteractiveObject::SynchronizeAspects()
{ {
aGrp->SetGroupPrimitivesAspect (aFaceAspect); aGrp->SetGroupPrimitivesAspect (aFaceAspect);
} }
if (!aCappingAspect.IsNull())
{
aGrp->SetGroupPrimitivesAspect (aCappingAspect);
}
if (!aMarkerAspect.IsNull()) if (!aMarkerAspect.IsNull())
{ {
aGrp->SetGroupPrimitivesAspect (aMarkerAspect); aGrp->SetGroupPrimitivesAspect (aMarkerAspect);
@ -641,6 +678,7 @@ void AIS_InteractiveObject::SynchronizeAspects()
{ {
aGrp->SetGroupPrimitivesAspect (aTextAspect); aGrp->SetGroupPrimitivesAspect (aTextAspect);
} }
} }
} }
} }

View File

@ -306,10 +306,16 @@ public:
//! Material aspect determines shading aspect, color and //! Material aspect determines shading aspect, color and
//! transparency of visible entities. //! transparency of visible entities.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName); Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName);
//! Removes the setting for material. //! Removes the setting for material.
Standard_EXPORT virtual void UnsetMaterial(); Standard_EXPORT virtual void UnsetMaterial();
//! Set style of filling capping section created by clipping planes.
Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
//! Returns style for filling capping section created by clipping planes.
const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; }
//! Attributes a setting aValue for transparency. //! Attributes a setting aValue for transparency.
//! The transparency value should be between 0.0 and 1.0. //! The transparency value should be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent. //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
@ -416,7 +422,7 @@ protected:
Standard_Boolean hasOwnColor; Standard_Boolean hasOwnColor;
Standard_Boolean hasOwnMaterial; Standard_Boolean hasOwnMaterial;
Standard_Boolean myRecomputeEveryPrs; Standard_Boolean myRecomputeEveryPrs;
Handle(Graphic3d_AspectFillCapping) myCappingStyle;
}; };
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)

View File

@ -186,10 +186,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
try try
{ {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle);
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
} }
catch (Standard_Failure) catch (Standard_Failure)
{ {

View File

@ -20,6 +20,8 @@ Graphic3d_ArrayOfTriangleStrips.cxx
Graphic3d_ArrayOfTriangleStrips.hxx Graphic3d_ArrayOfTriangleStrips.hxx
Graphic3d_AspectFillArea3d.cxx Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx Graphic3d_AspectFillArea3d.hxx
Graphic3d_AspectFillCapping.cxx
Graphic3d_AspectFillCapping.hxx
Graphic3d_AspectLine3d.cxx Graphic3d_AspectLine3d.cxx
Graphic3d_AspectLine3d.hxx Graphic3d_AspectLine3d.hxx
Graphic3d_AspectMarker3d.cxx Graphic3d_AspectMarker3d.cxx
@ -38,7 +40,6 @@ Graphic3d_BufferType.hxx
Graphic3d_Camera.cxx Graphic3d_Camera.cxx
Graphic3d_Camera.hxx Graphic3d_Camera.hxx
Graphic3d_CameraTile.hxx Graphic3d_CameraTile.hxx
Graphic3d_CappingFlags.hxx
Graphic3d_CLight.hxx Graphic3d_CLight.hxx
Graphic3d_ClipPlane.cxx Graphic3d_ClipPlane.cxx
Graphic3d_ClipPlane.hxx Graphic3d_ClipPlane.hxx

View File

@ -0,0 +1,110 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 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.
#include <Graphic3d_AspectFillCapping.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectFillCapping
// purpose :
// =======================================================================
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
: myFlags (Flags_None),
myHatchingState (0)
{
Graphic3d_MaterialAspect aMaterial;
aMaterial.SetColor (Quantity_NOC_BLACK);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
SetHatchStyle (Aspect_HS_HORIZONTAL);
SetHatchMaterial (aMaterial);
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
{
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myStippleHatch = theStyle;
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
{
myStippleHatch.Nullify();
myTextureHatch = theTexture;
myHatchingState++;
}
// =======================================================================
// function : SetHatchMaterial
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
myHatchMaterial = theMaterial;
myHatchingState++;
}
// =======================================================================
// function : SetToDrawHatch
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
{
setFlag (theToDraw, Flags_DrawHatching);
myHatchingState++;
}
// =======================================================================
// function : SetHatchZoomPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchZoomPersistent);
myHatchingState++;
}
// =======================================================================
// function : SetHatchRotationPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchRotationPersistent);
myHatchingState++;
}

View File

@ -0,0 +1,163 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 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_AspectFillCapping_HeaderFile
#define _Graphic3d_AspectFillCapping_HeaderFile
#include <Aspect_HatchStyle.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Standard_Transient.hxx>
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
class Graphic3d_AspectFillCapping : public Standard_Transient
{
public:
//! Default constructor.
Standard_EXPORT Graphic3d_AspectFillCapping();
public:
//! Sets material for filling section created by clipping.
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
//! Returns material for filling section created by clipping.
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
//! Sets texture for filling section created by clipping.
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
//! Returns texture for filling section created by clipping.
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
//! Sets OpenGL/GLSL shader program.
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
//! Returns OpenGL/GLSL shader program.
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
public:
//! Sets style of hatch defined by predefined stipple mask.
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
//! Sets style of hatch defined by custom stipple mask.
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
//! Sets material style for hatch lines (texture).
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
//! Returns material style for hatch lines (texture).
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on zooming.
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
//! Returns true if hatch is defined by texture.
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
//! Returns texture map defining the hatch.
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
//! Returns true if hatch is defined by stipple mask.
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
//! Returns the stipple mask.
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
//! Returns modification counter for hatching state.
Standard_Size HatchingState() const { return myHatchingState; }
private:
enum Flags
{
Flags_None = 0x00, //!< no flags
Flags_UseObjectMaterial = 0x01, //!< use object material
Flags_UseObjectTexture = 0x02, //!< use object texture
Flags_UseObjectShader = 0x04, //!< use object GLSL program
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
Flags_DrawHatching = 0x20, //!< draw hatching
Flags_UseObjectProperties = //!< use entire fill area aspect from object
Flags_UseObjectMaterial
| Flags_UseObjectTexture
| Flags_UseObjectShader
};
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
{
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
}
private:
Graphic3d_MaterialAspect myMaterial;
Handle(Graphic3d_TextureMap) myTexture;
Handle(Graphic3d_ShaderProgram) myShader;
Handle(Graphic3d_HatchStyle) myStippleHatch;
Handle(Graphic3d_TextureMap) myTextureHatch;
Graphic3d_MaterialAspect myHatchMaterial;
unsigned int myFlags;
Standard_Size myHatchingState;
public:
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
};
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Standard_Transient)
#endif // _Graphic3d_AspectFillCapping_HeaderFile

View File

@ -1,29 +0,0 @@
// 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

@ -19,24 +19,11 @@
#include <gp_Pln.hxx> #include <gp_Pln.hxx>
#include <Standard_Atomic.hxx> #include <Standard_Atomic.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane, Standard_Transient)
namespace namespace
{ {
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0; 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;
}
} }
// ======================================================================= // =======================================================================
@ -44,69 +31,40 @@ namespace
// purpose : // purpose :
// ======================================================================= // =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane() Graphic3d_ClipPlane::Graphic3d_ClipPlane()
: myAspect (defaultAspect()),
myPlane (0.0, 0.0, 1.0, 0.0),
myEquation (0.0, 0.0, 1.0, 0.0),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{ {
makeId(); init();
} }
// ======================================================================= // =======================================================================
// function : Graphic3d_ClipPlane // function : Graphic3d_ClipPlane
// purpose : // purpose :
// ======================================================================= // =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation) Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Equation& theEquation)
: myAspect (defaultAspect()),
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
myEquation (theEquation),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{ {
makeId(); init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
} }
// ======================================================================= // =======================================================================
// function : Graphic3d_ClipPlane // function : Graphic3d_ClipPlane
// purpose : // purpose :
// ======================================================================= // =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther) Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
: Standard_Transient(theOther), : Standard_Transient (theOther)
myAspect (defaultAspect()),
myPlane (theOther.myPlane),
myEquation (theOther.myEquation),
myFlags (theOther.myFlags),
myEquationMod(0),
myAspectMod (0),
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping)
{ {
makeId(); init (theOther.myPlane,
*myAspect = *theOther.CappingAspect(); theOther.myIsOn,
theOther.myIsCapping,
theOther.ToOverrideCappingAspect(),
theOther.CappingSectionStyle());
} }
// ======================================================================= // =======================================================================
// function : Graphic3d_ClipPlane // function : Graphic3d_ClipPlane
// purpose : // purpose :
// ======================================================================= // =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane) Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
: myAspect (defaultAspect()),
myPlane (thePlane),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{ {
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]); init (thePlane);
makeId();
} }
// ======================================================================= // =======================================================================
@ -115,23 +73,20 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
// ======================================================================= // =======================================================================
void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation) void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
{ {
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()); myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
myEquation = theEquation; myEquation = theEquation;
myEquationMod++; myOrientationDirty = Standard_True;
} }
// ======================================================================= // =======================================================================
// function : SetPlane // function : SetEquation
// purpose : // purpose :
// ======================================================================= // =======================================================================
void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane) void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
{ {
myPlane = thePlane; myPlane = thePlane;
thePlane.Coefficients (myEquation[0], thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
myEquation[1], myOrientationDirty = Standard_True;
myEquation[2],
myEquation[3]);
myEquationMod++;
} }
// ======================================================================= // =======================================================================
@ -162,117 +117,100 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
} }
// ======================================================================= // =======================================================================
// function : SetCappingMaterial // function : SetCappingSectionStyle
// purpose : // purpose :
// ======================================================================= // =======================================================================
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat) void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{ {
myAspect->SetFrontMaterial (theMat); mySectionStyle = theStyle;
myAspect->SetInteriorColor (theMat.Color());
++myAspectMod;
} }
// ======================================================================= // =======================================================================
// function : SetCappingTexture // function : OrientationMatrix
// purpose : // purpose :
// ======================================================================= // =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture) const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
{ {
if (!theTexture.IsNull()) if (myOrientationDirty)
{ {
myAspect->SetTextureMapOn(); const Standard_ShortReal aDirection[] = {
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet(); static_cast<Standard_ShortReal> (myEquation[0]),
if (aTextureSet.IsNull() || aTextureSet->Size() != 1) static_cast<Standard_ShortReal> (myEquation[1]),
static_cast<Standard_ShortReal> (myEquation[2])
};
const Standard_ShortReal aTranslate[] = {
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
};
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
if (aMagintude < ShortRealSmall())
{ {
aTextureSet = new Graphic3d_TextureSet (theTexture); aSide1[0] = 1.0f;
} }
else else
{ {
aTextureSet->SetFirst (theTexture); aSide1[0] = aDirection[2] / aMagintude;
aSide1[2] = -aDirection[0] / aMagintude;
} }
myAspect->SetTextureSet (aTextureSet);
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
myOrientationMat.SetValue (0, 0, aSide1[0]);
myOrientationMat.SetValue (1, 0, aSide1[1]);
myOrientationMat.SetValue (2, 0, aSide1[2]);
myOrientationMat.SetValue (3, 0, 0.0F);
myOrientationMat.SetValue (0, 1, aDirection[0]);
myOrientationMat.SetValue (1, 1, aDirection[1]);
myOrientationMat.SetValue (2, 1, aDirection[2]);
myOrientationMat.SetValue (3, 1, 0.0F);
myOrientationMat.SetValue (0, 2, aSide2[0]);
myOrientationMat.SetValue (1, 2, aSide2[1]);
myOrientationMat.SetValue (2, 2, aSide2[2]);
myOrientationMat.SetValue (3, 2, 0.0F);
myOrientationMat.SetValue (0, 3, aTranslate[0]);
myOrientationMat.SetValue (1, 3, aTranslate[1]);
myOrientationMat.SetValue (2, 3, aTranslate[2]);
myOrientationMat.SetValue (3, 3, 1.0F);
myOrientationDirty = Standard_False;
} }
else
return myOrientationMat;
}
// =======================================================================
// function : init
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
const Standard_Boolean theIsOn,
const Standard_Boolean theIsCapping,
const Standard_Boolean theOverrideStyle,
const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
if (myEntityUID.IsEmpty())
{ {
myAspect->SetTextureMapOff(); myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)()); + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
} }
++myAspectMod;
}
// ======================================================================= myPlane = thePlane;
// function : SetCappingHatch myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
// purpose : myIsOn = theIsOn;
// ======================================================================= myIsCapping = theIsCapping;
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle) myOverrideObjectStyle = theOverrideStyle;
{ mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
myAspect->SetHatchStyle (theStyle); myOrientationDirty = Standard_True;
++myAspectMod;
}
// =======================================================================
// function : SetCappingCustomHatch
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOn
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOn()
{
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOff
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOff()
{
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
++myAspectMod;
}
// =======================================================================
// function : SetCappingAspect
// purpose :
// =======================================================================
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));
} }

View File

@ -17,14 +17,16 @@
#define _Graphic3d_ClipPlane_HeaderFile #define _Graphic3d_ClipPlane_HeaderFile
#include <Aspect_HatchStyle.hxx> #include <Aspect_HatchStyle.hxx>
#include <gp_Pln.hxx>
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_CappingFlags.hxx> #include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_Mat4.hxx>
#include <Graphic3d_TextureMap.hxx> #include <Graphic3d_TextureMap.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_Vec4.hxx> #include <NCollection_Vec4.hxx>
#include <Standard_Macro.hxx> #include <Standard_Macro.hxx>
#include <Standard_TypeDef.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <Standard_TypeDef.hxx>
#include <gp_Pln.hxx>
//! Container for properties describing graphic driver clipping planes. //! Container for properties describing graphic driver clipping planes.
//! It is up to application to create instances of this class and specify its //! It is up to application to create instances of this class and specify its
@ -45,6 +47,8 @@ public:
typedef NCollection_Vec4<Standard_Real> Equation; typedef NCollection_Vec4<Standard_Real> Equation;
public:
//! Default constructor. //! Default constructor.
//! Initializes clip plane container with the following properties: //! Initializes clip plane container with the following properties:
//! - Equation (0.0, 0.0, 1.0, 0) //! - Equation (0.0, 0.0, 1.0, 0)
@ -58,7 +62,7 @@ public:
//! Copy constructor. //! Copy constructor.
//! @param theOther [in] the copied plane. //! @param theOther [in] the copied plane.
Standard_EXPORT Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther); Standard_EXPORT Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther);
//! Construct clip plane for the passed equation. //! Construct clip plane for the passed equation.
//! By default the plane is on, capping is turned off. //! By default the plane is on, capping is turned off.
@ -82,37 +86,17 @@ public:
//! Get 4-component equation vector for clipping plane. //! Get 4-component equation vector for clipping plane.
//! @return clipping plane equation vector. //! @return clipping plane equation vector.
const Equation& GetEquation() const const Equation& GetEquation() const { return myEquation; }
{
return myEquation;
}
//! Check that the clipping plane is turned on. //! Check that the clipping plane is turned on.
//! @return boolean flag indicating whether the plane is in on or off state. //! @return boolean flag indicating whether the plane is in on or off state.
Standard_Boolean IsOn() const Standard_Boolean IsOn() const { return myIsOn; }
{
return myIsOn;
}
//! Change state of the clipping plane. //! Change state of the clipping plane.
//! @param theIsOn [in] the flag specifying whether the graphic driver //! @param theIsOn [in] the flag specifying whether the graphic driver
//! clipping by this plane should be turned on or off. //! clipping by this plane should be turned on or off.
Standard_EXPORT void SetOn(const Standard_Boolean theIsOn); Standard_EXPORT void SetOn(const Standard_Boolean theIsOn);
//! Change state of capping surface rendering.
//! @param theIsOn [in] the flag specifying whether the graphic driver should
//! perform rendering of capping surface produced by this plane. The graphic
//! driver produces this surface for convex graphics by means of stencil-test
//! and multi-pass rendering.
Standard_EXPORT void SetCapping(const Standard_Boolean theIsOn);
//! Check state of capping surface rendering.
//! @return true (turned on) or false depending on the state.
Standard_Boolean IsCapping() const
{
return myIsCapping;
}
//! Get geometrical definition. //! Get geometrical definition.
//! @return geometrical definition of clipping plane //! @return geometrical definition of clipping plane
const gp_Pln& ToPlane() const { return myPlane; } const gp_Pln& ToPlane() const { return myPlane; }
@ -123,47 +107,6 @@ public:
//! @return new instance of clipping plane with same properties and attributes. //! @return new instance of clipping plane with same properties and attributes.
Standard_EXPORT virtual Handle(Graphic3d_ClipPlane) Clone() const; Standard_EXPORT virtual Handle(Graphic3d_ClipPlane) Clone() const;
public: // @name user-defined graphical attributes
//! Set material for rendering capping surface.
//! @param theMat [in] the material.
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
//! @return capping material.
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.
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
? myAspect->TextureSet()->First()
: Handle(Graphic3d_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 (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
//! Set custom hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch pattern.
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
//! @return hatching style.
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
//! Turn on hatching.
Standard_EXPORT void SetCappingHatchOn();
//! Turn off hatching.
Standard_EXPORT void SetCappingHatchOff();
//! @return True if hatching mask is turned on.
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
//! This ID is used for managing associated resources in graphical driver. //! 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 //! The clip plane can be assigned within a range of IO which can be
//! displayed in separate OpenGl contexts. For each of the context an associated //! displayed in separate OpenGl contexts. For each of the context an associated
@ -171,81 +114,61 @@ public: // @name user-defined graphical attributes
//! The resources are stored in graphical driver for each of individual groups //! The resources are stored in graphical driver for each of individual groups
//! of shared context under the clip plane identifier. //! of shared context under the clip plane identifier.
//! @return clip plane resource identifier string. //! @return clip plane resource identifier string.
const TCollection_AsciiString& GetId() const const TCollection_AsciiString& GetId() const { return myEntityUID; }
{
return myId;
}
public: public:
//! Return capping aspect. //! Change state of capping surface rendering.
//! @return capping surface rendering aspect. //! @param theIsOn [in] the flag specifying whether the graphic driver should
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; } //! perform rendering of capping surface produced by this plane. The graphic
//! driver produces this surface for convex graphics by means of stencil-test
//! and multi-pass rendering.
Standard_EXPORT void SetCapping(const Standard_Boolean theIsOn);
//! Assign capping aspect. //! Check state of capping surface rendering.
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect); //! @return true (turned on) or false depending on the state.
Standard_Boolean IsCapping() const { return myIsCapping; }
//! Flag indicating whether material for capping plane should be taken from object. //! Sets clipping section filling aspect.
//! Default value: FALSE (use dedicated capping plane material). Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
//! Set flag for controlling the source of capping plane material. //! Returns style used for drawing capping section.
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); } const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
//! Flag indicating whether texture for capping plane should be taken from object. //! Flag indicating whether section style of the plane should overrides similar property of object presentation.
//! Default value: FALSE. //! Default value: FALSE (use dedicated presentation aspect style).
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; } bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
//! Set flag for controlling the source of capping plane texture. //! Sets flag for controlling the preference of using section style between clip plane and object.
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); } void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
//! Flag indicating whether shader program for capping plane should be taken from object. //! Returns plane's orientation matrix.
//! Default value: FALSE. Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
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
//! @return modification counter for equation.
unsigned int MCountEquation() const
{
return myEquationMod;
}
//! @return modification counter for aspect.
unsigned int MCountAspect() const
{
return myAspectMod;
}
private: private:
//! Generate unique object id for OpenGL graphic resource manager. //! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
void makeId(); void init (const gp_Pln& thePlane = gp_Pln(),
const Standard_Boolean theIsOn = Standard_True,
//! Set capping flag. const Standard_Boolean theIsCapping = Standard_False,
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag); const Standard_Boolean theOverrideStyle = Standard_False,
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
private: private:
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
TCollection_AsciiString myId; //!< resource id gp_Pln myPlane; //!< Plane definition
gp_Pln myPlane; //!< plane definition Equation myEquation; //!< Plane equation vector
Equation myEquation; //!< plane equation vector Standard_Boolean myIsOn; //!< State of the clipping plane
unsigned int myFlags; //!< capping flags Standard_Boolean myIsCapping; //!< State of graphic driver capping
unsigned int myEquationMod; //!< modification counter for equation Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
unsigned int myAspectMod; //!< modification counter of aspect Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
Standard_Boolean myIsOn; //!< state of the clipping plane mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
Standard_Boolean myIsCapping; //!< state of graphic driver capping mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
public: public:
DEFINE_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient) DEFINE_STANDARD_RTTIEXT (Graphic3d_ClipPlane, Standard_Transient)
}; };
DEFINE_STANDARD_HANDLE (Graphic3d_ClipPlane, Standard_Transient) DEFINE_STANDARD_HANDLE (Graphic3d_ClipPlane, Standard_Transient)

View File

@ -231,10 +231,11 @@ Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_Gr
// function : GroupPrimitivesAspect // function : GroupPrimitivesAspect
// purpose : // purpose :
// ======================================================================= // =======================================================================
void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine, void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText, const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker, const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspCapping) const
{ {
if (!theAspLine.IsNull()) if (!theAspLine.IsNull())
{ {
@ -271,6 +272,15 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
*theAspFill.operator->() = *aFillAspect; *theAspFill.operator->() = *aFillAspect;
} }
} }
if (!theAspCapping.IsNull())
{
Handle(Graphic3d_AspectFillCapping) aCappingAspect = FillCappingAspect();
if (!aCappingAspect.IsNull())
{
*theAspCapping.operator->() = *aCappingAspect;
}
}
} }
// ======================================================================= // =======================================================================

View File

@ -17,30 +17,30 @@
#ifndef _Graphic3d_Group_HeaderFile #ifndef _Graphic3d_Group_HeaderFile
#define _Graphic3d_Group_HeaderFile #define _Graphic3d_Group_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Standard_Boolean.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectText3d.hxx> #include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Standard_Transient.hxx> #include <Graphic3d_AspectText3d.hxx>
#include <Standard_Real.hxx> #include <Graphic3d_BndBox4f.hxx>
#include <Standard_CString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_BoundBuffer.hxx> #include <Graphic3d_BoundBuffer.hxx>
#include <Standard_Address.hxx> #include <Graphic3d_Buffer.hxx>
#include <Graphic3d_GroupAspect.hxx> #include <Graphic3d_GroupAspect.hxx>
#include <gp_Ax2.hxx> #include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <MMgt_TShared.hxx>
#include <Standard.hxx>
#include <Standard_Address.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx> #include <TCollection_ExtendedString.hxx>
#include <gp_Ax2.hxx>
class Graphic3d_Structure; class Graphic3d_Structure;
class Graphic3d_ArrayOfPrimitives; class Graphic3d_ArrayOfPrimitives;
@ -56,7 +56,7 @@ class Graphic3d_ArrayOfPrimitives;
//! 1) Non-modifiable, or unbounded, group ('black box'). //! 1) Non-modifiable, or unbounded, group ('black box').
//! Developers can repeat a sequence of //! Developers can repeat a sequence of
//! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times //! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times
//! to define arbitrary number of primitive "blocks" each having individual apect values. //! to define arbitrary number of primitive "blocks" each having individual aspect values.
//! Any modification of such a group is forbidden, as aspects and primitives are mixed //! Any modification of such a group is forbidden, as aspects and primitives are mixed
//! in memory without any high-level logical structure, and any modification is very likely to result //! in memory without any high-level logical structure, and any modification is very likely to result
//! in corruption of the group internal data. //! in corruption of the group internal data.
@ -75,14 +75,14 @@ class Graphic3d_ArrayOfPrimitives;
//! with aspects and primitives and choose the group usage model beforehand out of application needs. //! with aspects and primitives and choose the group usage model beforehand out of application needs.
//! Note that some Graphic3d_Group class virtual methods contain only base implementation //! Note that some Graphic3d_Group class virtual methods contain only base implementation
//! that is extended by the descendant class in OpenGl package. //! that is extended by the descendant class in OpenGl package.
class Graphic3d_Group : public Standard_Transient class Graphic3d_Group : public MMgt_TShared
{ {
friend class Graphic3d_Structure; friend class Graphic3d_Structure;
DEFINE_STANDARD_RTTIEXT(Graphic3d_Group,Standard_Transient) DEFINE_STANDARD_RTTIEXT(Graphic3d_Group,MMgt_TShared)
public: public:
//! Supress all primitives and attributes of <me>. //! Suppress all primitives and attributes of <me>.
//! To clear group without update in Graphic3d_StructureManager //! To clear group without update in Graphic3d_StructureManager
//! pass Standard_False as <theUpdateStructureMgr>. This //! pass Standard_False as <theUpdateStructureMgr>. This
//! used on context and viewer destruction, when the pointer //! used on context and viewer destruction, when the pointer
@ -91,13 +91,13 @@ public:
//! cross-reference); //! cross-reference);
Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True); Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True);
//! Supress the group <me> in the structure. //! Suppress the group <me> in the structure.
Standard_EXPORT virtual ~Graphic3d_Group(); Standard_EXPORT virtual ~Graphic3d_Group();
//! Supress the group <me> in the structure. //! Suppress the group <me> in the structure.
//! Warning: No more graphic operations in <me> after this call. //! Warning: No more graphic operations in <me> after this call.
//! Modifies the current modelling transform persistence (pan, zoom or rotate) //! Modifies the current modeling transform persistence (pan, zoom or rotate)
//! Get the current modelling transform persistence (pan, zoom or rotate) //! Get the current modeling transform persistence (pan, zoom or rotate)
Standard_EXPORT void Remove(); Standard_EXPORT void Remove();
public: public:
@ -126,6 +126,12 @@ public:
//! Modifies the context for all the marker primitives of the group. //! Modifies the context for all the marker primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0; virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
//! Returns style of filling clipping sections on closed shell primitives.
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
//! Modifies the context for filling clipping section for all closed shell primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect) = 0;
//! Modifies the current context of the group to give //! Modifies the current context of the group to give
//! another aspect for all the line primitives created //! another aspect for all the line primitives created
//! after this call in the group. //! after this call in the group.
@ -153,15 +159,17 @@ public:
Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine, Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText, const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker, const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const; const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspFillCapping) const;
//! Returns the last inserted context in the group for each kind of primitives. //! Returns the last inserted context in the group for each kind of primitives.
void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine, void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText, const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker, const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspFillCapping) const
{ {
GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill); GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill, theAspFillCapping);
} }
public: public:
@ -312,6 +320,6 @@ protected:
}; };
DEFINE_STANDARD_HANDLE(Graphic3d_Group, Standard_Transient) DEFINE_STANDARD_HANDLE(Graphic3d_Group, MMgt_TShared)
#endif // _Graphic3d_Group_HeaderFile #endif // _Graphic3d_Group_HeaderFile

View File

@ -21,13 +21,15 @@
//! - ASPECT_LINE: aspect for line primitives; //! - ASPECT_LINE: aspect for line primitives;
//! - ASPECT_TEXT: aspect for text primitives; //! - ASPECT_TEXT: aspect for text primitives;
//! - ASPECT_MARKER: aspect for marker primitives; //! - ASPECT_MARKER: aspect for marker primitives;
//! - ASPECT_FILL_AREA: aspect for face primitives. //! - ASPECT_FILL_AREA: aspect for face primitives;
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
enum Graphic3d_GroupAspect enum Graphic3d_GroupAspect
{ {
Graphic3d_ASPECT_LINE, Graphic3d_ASPECT_LINE,
Graphic3d_ASPECT_TEXT, Graphic3d_ASPECT_TEXT,
Graphic3d_ASPECT_MARKER, Graphic3d_ASPECT_MARKER,
Graphic3d_ASPECT_FILL_AREA Graphic3d_ASPECT_FILL_AREA,
Graphic3d_ASPECT_FILL_CAPPING
}; };
#endif // _Graphic3d_GroupAspect_HeaderFile #endif // _Graphic3d_GroupAspect_HeaderFile

View File

@ -291,7 +291,7 @@ public:
//! Compute per-element multiplication. //! Compute per-element multiplication.
//! @param theFactor [in] the scale factor. //! @param theFactor [in] the scale factor.
//! @return the result of multiplicaton. //! @return the result of multiplication.
NCollection_Mat4 operator* (const Element_t theFactor) const NCollection_Mat4 operator* (const Element_t theFactor) const
{ {
return Multiplied (theFactor); return Multiplied (theFactor);
@ -299,7 +299,7 @@ public:
//! Compute per-element multiplication. //! Compute per-element multiplication.
//! @param theFactor [in] the scale factor. //! @param theFactor [in] the scale factor.
//! @return the result of multiplicaton. //! @return the result of multiplication.
NCollection_Mat4 Multiplied (const Element_t theFactor) const NCollection_Mat4 Multiplied (const Element_t theFactor) const
{ {
NCollection_Mat4 aTempMat (*this); NCollection_Mat4 aTempMat (*this);

View File

@ -7,6 +7,8 @@ OpenGl_ArbTBO.hxx
OpenGl_ArbTexBindless.hxx OpenGl_ArbTexBindless.hxx
OpenGl_AspectFace.cxx OpenGl_AspectFace.cxx
OpenGl_AspectFace.hxx OpenGl_AspectFace.hxx
OpenGl_AspectFillCapping.cxx
OpenGl_AspectFillCapping.hxx
OpenGl_AspectLine.cxx OpenGl_AspectLine.cxx
OpenGl_AspectLine.hxx OpenGl_AspectLine.hxx
OpenGl_AspectMarker.cxx OpenGl_AspectMarker.cxx
@ -66,10 +68,8 @@ OpenGl_BVHClipPrimitiveTrsfPersSet.cxx
OpenGl_BVHClipPrimitiveTrsfPersSet.hxx OpenGl_BVHClipPrimitiveTrsfPersSet.hxx
OpenGl_BVHTreeSelector.cxx OpenGl_BVHTreeSelector.cxx
OpenGl_BVHTreeSelector.hxx OpenGl_BVHTreeSelector.hxx
OpenGl_CappingAlgo.cxx OpenGl_CappingRenderer.cxx
OpenGl_CappingAlgo.hxx OpenGl_CappingRenderer.hxx
OpenGl_CappingPlaneResource.cxx
OpenGl_CappingPlaneResource.hxx
OpenGl_Caps.cxx OpenGl_Caps.cxx
OpenGl_Caps.hxx OpenGl_Caps.hxx
OpenGl_Clipping.cxx OpenGl_Clipping.cxx

View File

@ -0,0 +1,247 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 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.
#include <OpenGl_AspectFillCapping.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Workspace.hxx>
namespace
{
Handle(Graphic3d_AspectFillArea3d) defaultMaterial()
{
Handle(Graphic3d_AspectFillArea3d) anAspect;
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (aMaterial);
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetInteriorColor (aMaterial.Color());
anAspect->SetSuppressBackFaces (false);
return anAspect;
}
}
// =======================================================================
// function : OpenGl_AspectFillCapping
// purpose :
// =======================================================================
OpenGl_AspectFillCapping::OpenGl_AspectFillCapping (const Handle(Graphic3d_AspectFillCapping)& theAspect)
: myCappingAspect (defaultMaterial()),
myHatchingAspect (defaultMaterial()),
myHatchingState (0)
{
SetAspect (theAspect);
}
// =======================================================================
// function : ~OpenGl_AspectFillCapping
// purpose :
// =======================================================================
OpenGl_AspectFillCapping::~OpenGl_AspectFillCapping()
{
//
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_AspectFillCapping::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
myAspect = theAspect;
if (theAspect.IsNull())
{
return;
}
if (!theAspect->ToUseObjectMaterial()
|| !theAspect->ToUseObjectTexture()
|| !theAspect->ToUseObjectShader())
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
if (!theAspect->ToUseObjectMaterial())
{
aFillAspect->SetFrontMaterial (theAspect->Material());
aFillAspect->SetInteriorColor (theAspect->Material().Color());
}
if (!theAspect->ToUseObjectTexture())
{
aFillAspect->SetTextureMap (theAspect->Texture());
if (!theAspect->Texture().IsNull())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
else
{
aFillAspect->SetTextureMap (Handle(Graphic3d_TextureMap)());
aFillAspect->SetTextureMapOff();
}
if (!theAspect->ToUseObjectShader())
{
aFillAspect->SetShaderProgram (theAspect->Shader());
}
myCappingAspect.SetAspect (aFillAspect);
}
if (theAspect->ToDrawHatch()
&& (theAspect->IsTextureHatch()
|| theAspect->IsStippleHatch()))
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
aFillAspect->SetHatchStyle (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
aFillAspect->SetTextureMap (theAspect->IsTextureHatch() ? theAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
aFillAspect->SetFrontMaterial (theAspect->HatchMaterial());
aFillAspect->SetInteriorColor (theAspect->HatchMaterial().Color());
if (theAspect->IsTextureHatch())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
myHatchingAspect.SetAspect (aFillAspect);
myHatchingState = theAspect->HatchingState();
}
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectFillCapping::Release (OpenGl_Context* theContext)
{
myCappingAspect .Release (theContext);
myHatchingAspect.Release (theContext);
}
// =======================================================================
// function : CappingFaceAspect
// purpose :
// =======================================================================
const OpenGl_AspectFace* OpenGl_AspectFillCapping::CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const
{
if (myAspect.IsNull())
{
return NULL;
}
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
{
// only front material currently supported by capping rendering
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
}
else
{
aFillAspect->SetFrontMaterial (myAspect->Material());
aFillAspect->SetInteriorColor (myAspect->Material().Color());
}
if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
{
if (theObjectAspect->Aspect()->ToMapTexture())
{
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
else
{
aFillAspect->SetTextureMap (myAspect->Texture());
if (!myAspect->Texture().IsNull())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
{
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
}
else
{
aFillAspect->SetShaderProgram (myAspect->Shader());
}
myCappingAspect.SetAspect (aFillAspect);
return &myCappingAspect;
}
// =======================================================================
// function : HatchingFaceAspect
// purpose :
// =======================================================================
const OpenGl_AspectFace* OpenGl_AspectFillCapping::HatchingFaceAspect() const
{
if (myAspect.IsNull())
{
return NULL;
}
const Standard_Size aHatchingState = myAspect->HatchingState();
if (myHatchingState != aHatchingState)
{
if (myAspect->ToDrawHatch())
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
aFillAspect->SetHatchStyle (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
aFillAspect->SetTextureMap (myAspect->IsTextureHatch() ? myAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
aFillAspect->SetFrontMaterial (myAspect->HatchMaterial());
aFillAspect->SetInteriorColor (myAspect->HatchMaterial().Color());
if (myAspect->IsTextureHatch())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
myHatchingAspect.SetAspect (aFillAspect);
myHatchingState = aHatchingState;
}
}
return &myHatchingAspect;
}

View File

@ -0,0 +1,70 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 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 _OpenGl_AspectFillCapping_Header
#define _OpenGl_AspectFillCapping_Header
#include <Graphic3d_AspectFillCapping.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Resource.hxx>
//! Gl resource holding particular aspects for filling capping.
class OpenGl_AspectFillCapping : public OpenGl_Resource
{
public:
//! Create and assign style.
Standard_EXPORT OpenGl_AspectFillCapping (const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Destructor.
Standard_EXPORT ~OpenGl_AspectFillCapping();
//! Assign section style.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Returns section style parameters.
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myAspect; }
//! Release any allocated GL resources.
Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
//! Returns true if capping should draw hatch layer.
Standard_Boolean ToDrawHatch() const
{
return myAspect->ToDrawHatch()
&& (myAspect->IsStippleHatch()
|| myAspect->IsTextureHatch());
}
//! Returns the shading aspect for drawing face of a clipping section itself.
//! @param theObjectAspect [in] the aspect of an object if it requires combining.
Standard_EXPORT const OpenGl_AspectFace* CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const;
//! Returns the shading aspect for drawing hatch layer of a section.
Standard_EXPORT const OpenGl_AspectFace* HatchingFaceAspect() const;
protected:
Handle(Graphic3d_AspectFillCapping) myAspect; //!< Section style settings from application's level.
mutable OpenGl_AspectFace myCappingAspect; //!< GL aspect for shading base layer of a capping section.
mutable OpenGl_AspectFace myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
mutable Standard_Size myHatchingState;
public:
DEFINE_STANDARD_ALLOC
};
#endif //_OpenGl_AspectFillCapping_Header

View File

@ -19,6 +19,7 @@
#include <Aspect_GradientFillMethod.hxx> #include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx> #include <Aspect_FillMethod.hxx>
#include <Graphic3d_TypeOfBackground.hxx> #include <Graphic3d_TypeOfBackground.hxx>
#include <Graphic3d_TransformPers.hxx>
#include <OpenGl_AspectFace.hxx> #include <OpenGl_AspectFace.hxx>
#include <OpenGl_PrimitiveArray.hxx> #include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Vec.hxx> #include <OpenGl_Vec.hxx>

View File

@ -1,235 +0,0 @@
// Created on: 2013-09-05
// Created by: Anton POLETAEV
// Copyright (c) 2013-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.
#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_ShaderManager.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_CappingAlgoFilter,OpenGl_RenderFilter)
namespace
{
//! Render infinite capping plane.
//! @param theWorkspace [in] the GL workspace, context state.
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
const Handle(OpenGl_CappingPlaneResource)& thePlane,
const OpenGl_AspectFace* theAspectFace)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
thePlane->Update (aContext, theAspectFace != NULL ? theAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
const OpenGl_AspectFace* aFaceAspect = theWorkspace->AspectFace();
theWorkspace->SetAspectFace (thePlane->AspectFace());
// set identity model matrix
aContext->ModelWorldState.Push();
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
aContext->ApplyModelViewMatrix();
thePlane->Primitives().Render (theWorkspace);
aContext->ModelWorldState.Pop();
aContext->ApplyModelViewMatrix();
theWorkspace->SetAspectFace (aFaceAspect);
}
//! Render capping for specific structure.
static void renderCappingForStructure (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure,
const OpenGl_ClippingIterator& thePlaneIter,
const Handle(OpenGl_CappingPlaneResource)& thePlane)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value()->IsClosed())
{
continue;
}
// enable only the rendering plane to generate stencil mask
aContext->ChangeClipping().DisableAllExcept (aContext, thePlaneIter);
aContext->ShaderManager()->UpdateClippingState();
glClear (GL_STENCIL_BUFFER_BIT);
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// override aspects, disable culling
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
theWorkspace->ApplyAspectFace();
// evaluate number of pair faces
if (theWorkspace->UseZBuffer())
{
glDisable (GL_DEPTH_TEST);
}
if (theWorkspace->UseDepthWrite())
{
glDepthMask (GL_FALSE);
}
glStencilFunc (GL_ALWAYS, 1, 0x01);
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
// render closed primitives
if (aRenderPlane->ToUseObjectProperties())
{
aGroupIter.Value()->Render (theWorkspace);
}
else
{
for (; aGroupIter.More(); aGroupIter.Next())
{
if (aGroupIter.Value()->IsClosed())
{
aGroupIter.Value()->Render (theWorkspace);
}
}
}
// override material, cull back faces
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
theWorkspace->ApplyAspectFace();
// enable all clip plane except the rendered one
aContext->ChangeClipping().EnableAllExcept (aContext, thePlaneIter);
aContext->ShaderManager()->UpdateClippingState();
// render capping plane using the generated stencil mask
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
if (theWorkspace->UseDepthWrite())
{
glDepthMask (GL_TRUE);
}
glStencilFunc (GL_EQUAL, 1, 0x01);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
if (theWorkspace->UseZBuffer())
{
glEnable (GL_DEPTH_TEST);
}
renderPlane (theWorkspace, thePlane, aRenderPlane->ToUseObjectProperties()
? aGroupIter.Value()->AspectFace()
: NULL);
// turn on the current plane to restore initial state
aContext->ChangeClipping().SetEnabled (aContext, thePlaneIter, Standard_True);
aContext->ShaderManager()->RevertClippingState();
aContext->ShaderManager()->RevertClippingState();
}
if (theStructure.InstancedStructure() != NULL)
{
renderCappingForStructure (theWorkspace, *theStructure.InstancedStructure(), thePlaneIter, thePlane);
}
}
}
// =======================================================================
// function : RenderCapping
// purpose :
// =======================================================================
void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
if (!aContext->Clipping().IsCappingOn())
{
// do not perform algorithm if there is nothing to render
return;
}
// remember current aspect face defined in workspace
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
// replace primitive groups rendering filter
Handle(OpenGl_RenderFilter) aRenderFilter = theWorkspace->GetRenderFilter();
Handle(OpenGl_CappingAlgoFilter) aCappingFilter = theWorkspace->DefaultCappingAlgoFilter();
aCappingFilter->SetPreviousFilter (aRenderFilter);
theWorkspace->SetRenderFilter (aCappingFilter);
// prepare for rendering the clip planes
glEnable (GL_STENCIL_TEST);
// remember current state of depth
// function and change its value
GLint aDepthFuncPrev;
glGetIntegerv (GL_DEPTH_FUNC, &aDepthFuncPrev);
glDepthFunc (GL_LESS);
// generate capping for every clip plane
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
{
// get plane being rendered
const Handle(Graphic3d_ClipPlane)& aRenderPlane = aCappingIt.Value();
if (!aRenderPlane->IsCapping()
|| aCappingIt.IsDisabled())
{
continue;
}
// get resource for the plane
const TCollection_AsciiString& aResId = aRenderPlane->GetId();
Handle(OpenGl_CappingPlaneResource) aPlaneRes;
if (!aContext->GetResource (aResId, aPlaneRes))
{
// share and register for release once the resource is no longer used
aPlaneRes = new OpenGl_CappingPlaneResource (aRenderPlane);
aContext->ShareResource (aResId, aPlaneRes);
}
renderCappingForStructure (theWorkspace, theStructure, aCappingIt, aPlaneRes);
// set delayed resource release
aPlaneRes.Nullify();
aContext->ReleaseResource (aResId, Standard_True);
}
// restore previous application state
glClear (GL_STENCIL_BUFFER_BIT);
glDepthFunc (aDepthFuncPrev);
glStencilFunc (GL_ALWAYS, 0, 0xFF);
glDisable (GL_STENCIL_TEST);
// restore rendering aspects
theWorkspace->SetAspectFace (aFaceAsp);
theWorkspace->SetRenderFilter (aRenderFilter);
}
// =======================================================================
// function : CanRender
// purpose :
// =======================================================================
Standard_Boolean OpenGl_CappingAlgoFilter::ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Element* theGlElement)
{
if (!myFilter.IsNull() && !myFilter->ShouldRender (theWorkspace, theGlElement))
{
return Standard_False;
}
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theGlElement);
return aPArray != NULL
&& aPArray->DrawMode() >= OpenGl_PrimitiveArray::THE_FILLPRIM_FROM
&& aPArray->DrawMode() <= OpenGl_PrimitiveArray::THE_FILLPRIM_TO;
}

View File

@ -1,71 +0,0 @@
// Created on: 2013-09-05
// Created by: Anton POLETAEV
// Copyright (c) 2013-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 _OpenGl_CappingAlgo_H__
#define _OpenGl_CappingAlgo_H__
#include <OpenGl_RenderFilter.hxx>
#include <OpenGl_Group.hxx>
// Forward declaration
class OpenGl_CappingAlgoFilter;
class OpenGl_CappingPlaneResource;
class OpenGl_Structure;
DEFINE_STANDARD_HANDLE (OpenGl_CappingAlgoFilter, OpenGl_RenderFilter)
//! Capping surface rendering algorithm.
class OpenGl_CappingAlgo
{
public:
//! Draw capping surfaces by OpenGl for the clipping planes enabled in current context state.
//! Depth buffer must be generated for the passed groups.
//! @param theWorkspace [in] the GL workspace, context state
//! @param theStructure [in] the structure to be capped
Standard_EXPORT static void RenderCapping (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure);
};
//! Graphical capping rendering algorithm filter.
//! Filters out everything except shaded primitives.
class OpenGl_CappingAlgoFilter : public OpenGl_RenderFilter
{
public:
//! Default constructor.
OpenGl_CappingAlgoFilter() {}
//! Sets the current active filter in workspace.
//! @param thePrevFilter [in] the previously active filter that should have additive effect.
void SetPreviousFilter (const Handle(OpenGl_RenderFilter)& thePrevFitler) { myFilter = thePrevFitler; }
//! Checks whether the element can be rendered or not.
//! @param theElement [in] the element to check.
//! @return True if element can be rendered.
virtual Standard_Boolean ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Element* theGlElement) Standard_OVERRIDE;
private:
Handle(OpenGl_RenderFilter) myFilter; //!< Previous active filter that should be combined.
public:
DEFINE_STANDARD_RTTIEXT(OpenGl_CappingAlgoFilter,OpenGl_RenderFilter)
};
#endif

View File

@ -1,244 +0,0 @@
// Created on: 2013-08-15
// Created by: Anton POLETAEV
// Copyright (c) 2013-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.
#include <NCollection_AlignedAllocator.hxx>
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Vec.hxx>
#include <Precision.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_CappingPlaneResource,OpenGl_Resource)
namespace
{
//! 12 plane vertices, interleaved:
//! - 4 floats, position
//! - 4 floats, normal
//! - 4 floats, UV texture coordinates
static const GLfloat THE_CAPPING_PLN_VERTS[12 * (4 + 4 + 4)] =
{
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f
};
static const OpenGl_Matrix OpenGl_IdentityMatrix =
{
// mat[4][4]
{ { 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f } }
};
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
: myPrimitives (NULL),
myOrientation (OpenGl_IdentityMatrix),
myAspect (NULL),
myPlaneRoot (thePlane),
myEquationMod ((unsigned int )-1),
myAspectMod ((unsigned int )-1)
{
// Fill primitive array
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
Graphic3d_Attribute anAttribInfo[] =
{
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_NORM, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_UV, Graphic3d_TOD_VEC4 }
};
if (anAttribs->Init (12, anAttribInfo, 3))
{
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
}
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
{
Release (NULL);
}
// =======================================================================
// function : Update
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
updateTransform();
updateAspect (theObjAspect);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
{
OpenGl_Element::Destroy (theContext, myAspect);
myPrimitives.Release (theContext);
myEquationMod = (unsigned int )-1;
myAspectMod = (unsigned int )-1;
}
// =======================================================================
// function : updateAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
if (myAspect == NULL)
{
myAspect = new OpenGl_AspectFace();
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
}
if (theObjAspect.IsNull())
{
if (myAspectMod != myPlaneRoot->MCountAspect())
{
myAspect->SetAspect (myPlaneRoot->CappingAspect());
myAspectMod = myPlaneRoot->MCountAspect();
}
return;
}
if (myFillAreaAspect.IsNull())
{
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
}
if (myAspectMod != myPlaneRoot->MCountAspect())
{
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
}
if (myPlaneRoot->ToUseObjectMaterial())
{
// only front material currently supported by capping rendering
myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
}
if (myPlaneRoot->ToUseObjectTexture())
{
myFillAreaAspect->SetTextureSet (theObjAspect->TextureSet());
if (theObjAspect->ToMapTexture())
{
myFillAreaAspect->SetTextureMapOn();
}
else
{
myFillAreaAspect->SetTextureMapOff();
}
}
if (myPlaneRoot->ToUseObjectShader())
{
myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
}
myAspect->SetAspect (myFillAreaAspect);
}
// =======================================================================
// 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 aProjLen =
sqrt ( (Standard_ShortReal)(anEquation[0] * anEquation[0])
+ (Standard_ShortReal)(anEquation[2] * anEquation[2]));
if (aProjLen < ShortRealSmall())
{
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();
}

View File

@ -1,93 +0,0 @@
// Created on: 2013-08-15
// Created by: Anton POLETAEV
// Copyright (c) 2013-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 _OpenGl_CappingPlaneResource_H__
#define _OpenGl_CappingPlaneResource_H__
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Resource.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Matrix.hxx>
#include <Graphic3d_ClipPlane.hxx>
class OpenGl_CappingPlaneResource;
DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
//! Container of graphical resources for rendering capping plane
//! associated to graphical clipping plane.
//! This resource holds data necessary for OpenGl_CappingAlgo.
//! This object is implemented as OpenGl resource for the following reasons:
//! - one instance should be shared between contexts.
//! - instance associated to Graphic3d_ClipPlane data by id.
//! - should created and released within context (owns OpenGl elements and resources).
class OpenGl_CappingPlaneResource : public OpenGl_Resource
{
public:
//! Constructor.
//! Create capping plane presentation associated to clipping plane data.
//! @param thePlane [in] the plane data.
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Destroy object.
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
//! Update resource data in the passed context.
//! @param theContext [in] the context
//! @param theObjAspect [in] object aspect
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Return parent clipping plane structure.
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
//! @return aspect face for rendering capping surface.
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
//! @return primitive array of vertices to render infinite plane.
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
private:
//! Update precomputed plane orientation matrix.
void updateTransform();
//! Update resources.
void updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_AspectFace* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.
public:
DEFINE_STANDARD_RTTIEXT(OpenGl_CappingPlaneResource,OpenGl_Resource) // Type definition
};
#endif

View File

@ -0,0 +1,447 @@
// Created on: 2013-09-05
// Created by: Anton POLETAEV
// Copyright (c) 2013-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.
#include <OpenGl_CappingRenderer.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectFillCapping.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Resource.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_Camera.hxx>
#include <NCollection_AlignedAllocator.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_CappingRenderFilter, OpenGl_RenderFilter)
namespace
{
//! interleaved (4x position, 4x normals, 4x (u,v) coordinates).
//! o ----o
//! representing | \ / |
//! these | o |
//! triangles: | / \ |
//! o --- o
static const GLfloat THE_CAPPING_PLN_VERTS[12 * (4 + 4 + 4)] =
{
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
-1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f
};
class OpenGl_SharedElement : public OpenGl_Resource
{
public:
OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
{
OpenGl_Element::Destroy (theGlCtx, myGlElement);
}
OpenGl_Element* GlElement() const { return myGlElement; }
private:
OpenGl_Element* myGlElement;
public:
DEFINE_STANDARD_RTTI_INLINE (OpenGl_SharedElement, OpenGl_Resource)
};
static const TCollection_AsciiString THE_QUAD_PARRAY = "OpenGl_CappingRenderer_Quad";
static const TCollection_AsciiString THE_PLANE_STYLE = "OpenGl_CappingRenderer_CappingStyle_";
static const OpenGl_AspectFillCapping THE_DEFAULT_ASPECT = OpenGl_AspectFillCapping (new Graphic3d_AspectFillCapping);
}
// =======================================================================
// function : Render
// purpose : Renders capping surfaces for enabled clipping planes.
// =======================================================================
void OpenGl_CappingRenderer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
if (!aContext->Clipping().IsCappingOn())
{
return;
}
const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
if (!aCappingQuad)
{
return;
}
const OpenGl_AspectFace* aPrevAspect = theWorkspace->AspectFace();
Handle(OpenGl_RenderFilter) aPrevFilter = theWorkspace->GetRenderFilter();
Handle(OpenGl_CappingRenderFilter) aCappingFilter = theWorkspace->CappingRenderFilter();
aCappingFilter->SetPreviousFilter (aPrevFilter);
theWorkspace->SetRenderFilter (aCappingFilter);
GLint aDepthFuncPrev;
glGetIntegerv (GL_DEPTH_FUNC, &aDepthFuncPrev);
glDepthFunc (GL_LESS);
glEnable (GL_STENCIL_TEST);
GLboolean aPrevBlend = glIsEnabled (GL_BLEND);
GLint aPrevBlendSrc = GL_ONE;
GLint aPrevBlendDst = GL_ZERO;
if (aPrevBlend == GL_TRUE)
{
glGetIntegerv (GL_BLEND_SRC_ALPHA, &aPrevBlendSrc);
glGetIntegerv (GL_BLEND_DST_ALPHA, &aPrevBlendDst);
glDisable (GL_BLEND);
}
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
{
const Handle(Graphic3d_ClipPlane)& aPlane = aCappingIt.Value();
if (!aPlane->IsCapping()
|| aCappingIt.IsDisabled())
{
continue;
}
Handle(OpenGl_AspectFillCapping) anAspect;
TCollection_AsciiString aSharedStyleId;
if (!aPlane->CappingSectionStyle().IsNull())
{
aSharedStyleId = THE_PLANE_STYLE + aPlane->GetId();
if (!aContext->GetResource (aSharedStyleId, anAspect))
{
anAspect = new OpenGl_AspectFillCapping (aPlane->CappingSectionStyle());
aContext->ShareResource (aSharedStyleId, anAspect);
}
}
renderOne (theWorkspace, theStructure, aCappingIt, anAspect.get(), aCappingQuad);
if (!aSharedStyleId.IsEmpty())
{
// schedule release of resource if not used
aContext->ReleaseResource (aSharedStyleId, Standard_True);
}
}
glClear (GL_STENCIL_BUFFER_BIT);
glDepthFunc (aDepthFuncPrev);
glStencilFunc (GL_ALWAYS, 0, 0xFF);
glDisable (GL_STENCIL_TEST);
if (aPrevBlend == GL_TRUE)
{
glEnable (GL_BLEND);
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
}
theWorkspace->SetRenderFilter (aPrevFilter);
theWorkspace->SetAspectFace (aPrevAspect);
}
// =======================================================================
// function : renderOne
// purpose : method to render capping section of one given plane for a structure.
// =======================================================================
void OpenGl_CappingRenderer::renderOne (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure,
const OpenGl_ClippingIterator& thePlaneIter,
const OpenGl_AspectFillCapping* thePlaneAspectCapping,
const OpenGl_PrimitiveArray* theQuad)
{
const Handle(Graphic3d_ClipPlane)& aPlane = thePlaneIter.Value();
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View() != NULL
? theWorkspace->View()->Camera()
: Handle(Graphic3d_Camera)();
const OpenGl_Mat4& aPlaneMat = OpenGl_Mat4::Map (aPlane->OrientationMatrix());
Standard_ShortReal aRotateAngle = 0.0;
Standard_ShortReal aViewScale = ShortRealLast();
OpenGl_Mat4 aRotateZoomMat;
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value()->IsClosed())
{
continue;
}
// enable only the rendering plane to generate stencil mask
aContext->ChangeClipping().DisableAllExcept (aContext, thePlaneIter);
aContext->ShaderManager()->UpdateClippingState();
glClear (GL_STENCIL_BUFFER_BIT);
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// override aspects, disable culling
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
theWorkspace->ApplyAspectFace();
// evaluate number of pair faces
if (theWorkspace->UseZBuffer())
{
glDisable (GL_DEPTH_TEST);
}
if (theWorkspace->UseDepthWrite())
{
glDepthMask (GL_FALSE);
}
glStencilFunc (GL_ALWAYS, 1, 0x01);
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
aGroupIter.Value()->Render (theWorkspace);
// override material, cull back faces
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
theWorkspace->ApplyAspectFace();
// enable all clip plane except the rendered one
aContext->ChangeClipping().EnableAllExcept (aContext, thePlaneIter);
aContext->ShaderManager()->UpdateClippingState();
// render capping plane using the generated stencil mask
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
if (theWorkspace->UseDepthWrite())
{
glDepthMask (GL_TRUE);
}
glStencilFunc (GL_EQUAL, 1, 0x01);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
if (theWorkspace->UseZBuffer())
{
glEnable (GL_DEPTH_TEST);
}
const OpenGl_AspectFace* aGroupAspectFace = aGroupIter.Value()->AspectFace();
const OpenGl_AspectFillCapping* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
const OpenGl_AspectFillCapping* anAspectCapping =
thePlaneAspectCapping && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
? thePlaneAspectCapping
: aGroupAspectCapping;
if (anAspectCapping == NULL)
{
anAspectCapping = &THE_DEFAULT_ASPECT;
}
const OpenGl_AspectFace* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
const OpenGl_AspectFace* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
const Standard_Boolean hasTextureHatch = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
const Standard_Boolean isRotatePers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
const Standard_Boolean isZoomPers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
Standard_ShortReal aHatchScale = 1.0;
Standard_ShortReal aHatchAngle = 0.0;
if (isRotatePers || isZoomPers)
{
if (isRotatePers)
{
if (aRotateAngle == 0.0)
{
const gp_Dir aPlaneSide (aPlaneMat.GetValue (0, 0), aPlaneMat.GetValue (1, 0), aPlaneMat.GetValue (2, 0));
const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2));
const gp_Dir& aCameraUp = aCamera->Up();
const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp;
const gp_Dir& aCameraDir = aCamera->Direction();
aRotateAngle = static_cast<Standard_ShortReal> (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0);
}
aHatchAngle = aRotateAngle;
}
if (isZoomPers)
{
if (aViewScale == ShortRealLast())
{
const Standard_Real aFocus = aCamera->IsOrthographic()
? aCamera->Distance()
: (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
? Standard_Real(aCamera->ZFocus() * aCamera->Distance())
: Standard_Real(aCamera->ZFocus()));
const gp_XYZ aViewDim = aCamera->ViewDimensions (aFocus);
aViewScale = static_cast<Standard_ShortReal> (aViewDim.Y() / aContext->Viewport()[3]);
}
aHatchScale = 1.0f / (aViewScale * anAspectHatching->TextureRes (aContext)->SizeY());
}
}
renderSection (theWorkspace, theQuad, anAspectFace, hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL, aPlaneMat, aHatchScale, aHatchAngle);
// turn on the current plane to restore initial state
aContext->ChangeClipping().SetEnabled (aContext, thePlaneIter, Standard_True);
aContext->ShaderManager()->RevertClippingState();
aContext->ShaderManager()->RevertClippingState();
}
if (theStructure.InstancedStructure() != NULL)
{
renderOne (theWorkspace, *theStructure.InstancedStructure(), thePlaneIter, thePlaneAspectCapping, theQuad);
}
}
// =======================================================================
// function : renderSection
// purpose :
// =======================================================================
void OpenGl_CappingRenderer::renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_PrimitiveArray* theQuad,
const OpenGl_AspectFace* theCappingAspect,
const OpenGl_AspectFace* theHatchAspect,
const OpenGl_Mat4& theCappingMatrix,
const Standard_ShortReal theHatchScale,
const Standard_ShortReal theHatchRotate)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const Standard_Boolean isTextureHatch =
theHatchAspect != NULL
&& theHatchAspect->Aspect()->TextureMapState();
aContext->ModelWorldState.Push();
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
aContext->ApplyModelViewMatrix();
theWorkspace->SetAspectFace (theCappingAspect);
theWorkspace->ApplyAspectFace();
theQuad->Render (theWorkspace);
if (theHatchAspect != NULL)
{
Graphic3d_Vec2 aPrevScale;
Standard_ShortReal aPrevRotate = 0.0;
if (isTextureHatch)
{
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
{
const Handle(Graphic3d_TextureParams)& aTexParams = theHatchAspect->TextureParams();
aPrevScale = aTexParams->Scale();
aPrevRotate = aTexParams->Rotation();
const Standard_Boolean isMirror = aPrevScale.x() * aPrevScale.y() < 0.0;
aTexParams->SetScale (aPrevScale * theHatchScale);
aTexParams->SetRotation (isMirror ? aPrevRotate - theHatchRotate : aPrevRotate + theHatchRotate);
}
}
theWorkspace->SetAspectFace (theHatchAspect);
theWorkspace->ApplyAspectFace();
glDepthFunc (GL_LEQUAL);
theQuad->Render (theWorkspace);
glDepthFunc (GL_LESS);
if (isTextureHatch)
{
glDisable (GL_BLEND);
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
{
const Handle(Graphic3d_TextureParams)& aTexParams = theHatchAspect->TextureParams();
aTexParams->SetScale (aPrevScale);
aTexParams->SetRotation (aPrevRotate);
}
}
}
aContext->ModelWorldState.Pop();
aContext->ApplyModelViewMatrix();
}
// =======================================================================
// function : initQuad
// purpose : initializes and returns vertex buffer for plane section
// =======================================================================
OpenGl_PrimitiveArray* OpenGl_CappingRenderer::initQuad (const Handle(OpenGl_Context)& theContext)
{
Handle(OpenGl_SharedElement) aSharedResource;
if (!theContext->GetResource (THE_QUAD_PARRAY, aSharedResource))
{
OpenGl_PrimitiveArray* aPArray = NULL;
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
Graphic3d_Attribute anAttribInfo[] =
{
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_NORM, Graphic3d_TOD_VEC4 },
{ Graphic3d_TOA_UV, Graphic3d_TOD_VEC4 }
};
if (anAttribs->Init (12, anAttribInfo, 3))
{
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof (THE_CAPPING_PLN_VERTS));
aPArray = new OpenGl_PrimitiveArray (NULL);
aPArray->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
}
aSharedResource = new OpenGl_SharedElement (aPArray);
theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
}
return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
}
// =======================================================================
// function : CanRender
// purpose :
// =======================================================================
Standard_Boolean OpenGl_CappingRenderFilter::ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Element* theGlElement)
{
if (!myFilter.IsNull() && !myFilter->ShouldRender (theWorkspace, theGlElement))
{
return Standard_False;
}
const OpenGl_PrimitiveArray* aPArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theGlElement);
return aPArray != NULL
&& aPArray->DrawMode() >= OpenGl_PrimitiveArray::THE_FILLPRIM_FROM
&& aPArray->DrawMode() <= OpenGl_PrimitiveArray::THE_FILLPRIM_TO;
}

View File

@ -0,0 +1,120 @@
// Created on: 2013-09-05
// Created by: Anton POLETAEV
// Copyright (c) 2013-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 _OpenGl_CappingRenderer_H__
#define _OpenGl_CappingRenderer_H__
#include <OpenGl_RenderFilter.hxx>
#include <OpenGl_Vec.hxx>
// Forward declaration
class OpenGl_AspectFace;
class OpenGl_AspectFillCapping;
class OpenGl_AspectSection;
class OpenGl_CappingStyle;
class OpenGl_ClippingIterator;
class OpenGl_Context;
class OpenGl_Element;
class OpenGl_PrimitiveArray;
class OpenGl_Structure;
class OpenGl_Texture;
class OpenGl_Workspace;
//! Class implementing an OpenGL rasterization algorithm for drawing capping planes over clipped geometry.
class OpenGl_CappingRenderer
{
public:
//! Renders capping surfaces for enabled clipping planes.
//! @note Depth buffer must be generated for the passed groups.
//! @param theWorkspace [in] the GL workspace, context state
//! @param theStructure [in] the structure to be capped
Standard_EXPORT static void Render (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure);
private:
//! Method to render capping section of one given plane for a structure.
static void renderOne (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure,
const OpenGl_ClippingIterator& thePlaneIter,
const OpenGl_AspectFillCapping* thePlaneAspectCapping,
const OpenGl_PrimitiveArray* theQuad);
//! Render section plane using the given aspects.
static void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_PrimitiveArray* theQuad,
const OpenGl_AspectFace* theCappingAspect,
const OpenGl_AspectFace* theHatchAspect,
const OpenGl_Mat4& theCappingMatrix,
const Standard_ShortReal theHatchScale,
const Standard_ShortReal theHatchRotate);
//! Initializes and returns face draw element for rendering section plane.
//! @note once initialized, context will hold resource until destroyed.
static OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext);
//! Set rotation persistence components for the matrix to support persistent texturing.
//! @param theWorkspace [in] the GL workspace, context state.
//! @param thePlane [in] the plane.
//! @param theRotateScaleMat [in/out] the matrix combining rotation and scaling persistence components.
static void computePersistence (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_ClippingIterator& thePlane,
const Handle(OpenGl_Texture)& theTexture,
const bool theRotatePers,
const bool theZoomPers,
OpenGl_Mat4& theRotateScaleMat);
//! Set zoom persistence components for the matrix to support persistent texturing.
//! @param theWorkspace [in] the GL workspace, context state.
//! @param thePlane [in] the plane.
//! @param theTexture [in] the texture.
//! @param theRotateScaleMat [in/out] the matrix combining rotation and scaling persistence components.
static void setZoomPersistence (const Handle(OpenGl_Workspace)& theWorkspace,
const Handle(OpenGl_Texture)& theTexture,
OpenGl_Mat4& theRotateScaleMat);
};
//! Filters out everything except face primitives of solids.
class OpenGl_CappingRenderFilter : public OpenGl_RenderFilter
{
public:
//! Default constructor.
OpenGl_CappingRenderFilter() {}
//! Sets the current active filter in workspace.
//! @param thePrevFilter [in] the previously active filter that should have additive effect.
void SetPreviousFilter (const Handle(OpenGl_RenderFilter)& thePrevFitler) { myFilter = thePrevFitler; }
//! Checks whether the element can be rendered or not.
//! @param theElement [in] the element to check.
//! @return True if element can be rendered.
Standard_EXPORT virtual
Standard_Boolean ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Element* theGlElement) Standard_OVERRIDE;
private:
Handle(OpenGl_RenderFilter) myFilter; //!< Previous active filter that should be combined.
public:
DEFINE_STANDARD_RTTIEXT (OpenGl_CappingRenderFilter, OpenGl_RenderFilter)
};
DEFINE_STANDARD_HANDLE (OpenGl_CappingRenderFilter, OpenGl_RenderFilter)
#endif

View File

@ -63,7 +63,7 @@ public:
//! @param theWorkspace [in] the rendering workspace. //! @param theWorkspace [in] the rendering workspace.
//! @param theFilter [in] the rendering filter to check whether the element //! @param theFilter [in] the rendering filter to check whether the element
//! should be rendered or not. //! should be rendered or not.
//! @return True if element passes the check and renders, //! @return True if element passes the filtering check and is rendered.
inline Standard_Boolean inline Standard_Boolean
RenderFiltered (const Handle(OpenGl_Workspace)& theWorkspace, RenderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
const Handle(OpenGl_RenderFilter)& theFilter) const const Handle(OpenGl_RenderFilter)& theFilter) const

View File

@ -242,6 +242,28 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
Update(); Update();
} }
// =======================================================================
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
if (IsDeleted())
{
return;
}
if (myAspectFillCapping == NULL)
{
myAspectFillCapping = new OpenGl_AspectFillCapping (theAspect);
}
else
{
myAspectFillCapping->SetAspect (theAspect);
}
Update();
}
// ======================================================================= // =======================================================================
// function : AddPrimitiveArray // function : AddPrimitiveArray
// purpose : // purpose :

View File

@ -22,6 +22,7 @@
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
#include <OpenGl_AspectLine.hxx> #include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx> #include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectFillCapping.hxx>
#include <OpenGl_AspectMarker.hxx> #include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx> #include <OpenGl_AspectText.hxx>
#include <OpenGl_Element.hxx> #include <OpenGl_Element.hxx>
@ -103,6 +104,17 @@ public:
//! Append text aspect as an element. //! Append text aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE; Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
//! Update section style aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect) Standard_OVERRIDE;
//! Returns section style aspect.
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const Standard_OVERRIDE
{
return myAspectFillCapping != NULL
? myAspectFillCapping->Aspect()
: Handle(Graphic3d_AspectFillCapping)();
}
//! Add primitive array element //! Add primitive array element
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_IndexBuffer)& theIndices,
@ -153,6 +165,9 @@ public:
//! Returns OpenGL face aspect. //! Returns OpenGL face aspect.
const OpenGl_AspectFace* AspectFace() const { return myAspectFace; } const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
//! Returns OpenGL capping filling aspect.
const OpenGl_AspectFillCapping* AspectFillCapping() const { return myAspectFillCapping; }
//! Is the group ray-tracable (contains ray-tracable elements)? //! Is the group ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const { return myIsRaytracable; } Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
@ -162,10 +177,11 @@ protected:
protected: protected:
OpenGl_AspectLine* myAspectLine; OpenGl_AspectLine* myAspectLine;
OpenGl_AspectFace* myAspectFace; OpenGl_AspectFace* myAspectFace;
OpenGl_AspectMarker* myAspectMarker; OpenGl_AspectMarker* myAspectMarker;
OpenGl_AspectText* myAspectText; OpenGl_AspectText* myAspectText;
OpenGl_AspectFillCapping* myAspectFillCapping;
OpenGl_ElementNode* myFirst; OpenGl_ElementNode* myFirst;
OpenGl_ElementNode* myLast; OpenGl_ElementNode* myLast;

View File

@ -1136,11 +1136,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
EOL"}"; EOL"}";
TCollection_AsciiString TCollection_AsciiString
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st).a; }"; aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, TexCoord.st).a; }";
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 == NULL) if (myContext->core11 == NULL)
{ {
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st).r; }"; aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, TexCoord.st).r; }";
} }
#endif #endif
@ -1243,8 +1243,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
} }
myContext->BindProgram (myBlitProgram); myContext->BindProgram (myBlitProgram);
myBlitProgram->SetSampler (myContext, "uColorSampler", Graphic3d_TextureUnit_0); myBlitProgram->SetSampler (myContext, "uColorSampler", 0);
myBlitProgram->SetSampler (myContext, "uDepthSampler", Graphic3d_TextureUnit_1); myBlitProgram->SetSampler (myContext, "uDepthSampler", 1);
myContext->BindProgram (NULL); myContext->BindProgram (NULL);
return Standard_True; return Standard_True;
} }
@ -1331,8 +1331,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing (const St
} }
myContext->BindProgram (aProgram); myContext->BindProgram (aProgram);
aProgram->SetSampler (myContext, "uAccumTexture", Graphic3d_TextureUnit_0); aProgram->SetSampler (myContext, "uAccumTexture", 0);
aProgram->SetSampler (myContext, "uWeightTexture", Graphic3d_TextureUnit_1); aProgram->SetSampler (myContext, "uWeightTexture", 1);
myContext->BindProgram (Handle(OpenGl_ShaderProgram)()); myContext->BindProgram (Handle(OpenGl_ShaderProgram)());
return Standard_True; return Standard_True;
} }
@ -1343,12 +1343,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing (const St
// ======================================================================= // =======================================================================
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc (const Standard_Integer theBits) TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc (const Standard_Integer theBits)
{ {
TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").a; }"; TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ").a; }";
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 == NULL if (myContext->core11 == NULL
&& (theBits & OpenGl_PO_TextureA) != 0) && (theBits & OpenGl_PO_TextureA) != 0)
{ {
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").r; }"; aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ").r; }";
} }
#else #else
(void )theBits; (void )theBits;
@ -1391,7 +1391,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad
if ((theBits & OpenGl_PO_TextureRGB) != 0) if ((theBits & OpenGl_PO_TextureRGB) != 0)
{ {
aSrcFragGetColor = aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord "); }"; EOL"vec4 getColor(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord "); }";
} }
if (textureUsed (theBits)) if (textureUsed (theBits))
@ -1429,7 +1429,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad
aSrcVertExtraMain += THE_VARY_TexCoord_Trsf; aSrcVertExtraMain += THE_VARY_TexCoord_Trsf;
aSrcFragGetColor = aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w); }"; EOL"vec4 getColor(void)"
EOL"{"
EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * occColor;"
EOL"}";
} }
else if ((theBits & OpenGl_PO_TextureEnv) != 0) else if ((theBits & OpenGl_PO_TextureEnv) != 0)
{ {
@ -1446,7 +1449,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad
EOL" TexCoord = vec4(aReflect.xy * inversesqrt (dot (aReflect, aReflect)) * 0.5 + vec2 (0.5), 0.0, 1.0);"; EOL" TexCoord = vec4(aReflect.xy * inversesqrt (dot (aReflect, aReflect)) * 0.5 + vec2 (0.5), 0.0, 1.0);";
aSrcFragGetColor = aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D (occSamplerBaseColor, TexCoord.st); }"; EOL"vec4 getColor(void) { return occTexture2D (occActiveSampler, TexCoord.st); }";
} }
} }
if ((theBits & OpenGl_PO_VertColor) != 0) if ((theBits & OpenGl_PO_VertColor) != 0)
@ -1605,7 +1608,7 @@ TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc (const TColl
EOL"vec4 getColor(void)" EOL"vec4 getColor(void)"
EOL"{" EOL"{"
EOL" vec4 aColor = " + theBaseColorSrc + ";" EOL" vec4 aColor = " + theBaseColorSrc + ";"
EOL" aColor = occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ") * aColor;" EOL" aColor = occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ") * aColor;"
EOL" if (aColor.a <= 0.1) discard;" EOL" if (aColor.a <= 0.1) discard;"
EOL" return aColor;" EOL" return aColor;"
EOL"}"; EOL"}";
@ -1745,7 +1748,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
EOL"vec4 getColor(void)" EOL"vec4 getColor(void)"
EOL"{" EOL"{"
EOL" vec4 aColor = gl_FrontFacing ? FrontColor : BackColor;" EOL" vec4 aColor = gl_FrontFacing ? FrontColor : BackColor;"
EOL" return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w) * aColor;" EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * aColor;"
EOL"}"; EOL"}";
} }
} }
@ -1886,7 +1889,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
EOL"vec4 getColor(void)" EOL"vec4 getColor(void)"
EOL"{" EOL"{"
EOL" vec4 aColor = " thePhongCompLight ";" EOL" vec4 aColor = " thePhongCompLight ";"
EOL" return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w) * aColor;" EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * aColor;"
EOL"}"; EOL"}";
} }
} }
@ -2200,8 +2203,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
} }
myContext->BindProgram (theProgram); myContext->BindProgram (theProgram);
theProgram->SetSampler (myContext, "uLeftSampler", Graphic3d_TextureUnit_0); theProgram->SetSampler (myContext, "uLeftSampler", 0);
theProgram->SetSampler (myContext, "uRightSampler", Graphic3d_TextureUnit_1); theProgram->SetSampler (myContext, "uRightSampler", 1);
myContext->BindProgram (NULL); myContext->BindProgram (NULL);
return Standard_True; return Standard_True;
} }

View File

@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <OpenGl_CappingAlgo.hxx> #include <OpenGl_CappingRenderer.hxx>
#include <OpenGl_Context.hxx> #include <OpenGl_Context.hxx>
#include <OpenGl_GlCore11.hxx> #include <OpenGl_GlCore11.hxx>
#include <OpenGl_GraphicDriver.hxx> #include <OpenGl_GraphicDriver.hxx>
@ -657,10 +657,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
} }
// Render capping for structure groups // Render capping for structure groups
if (hasClosedPrims if (hasClosedPrims && aCtx->Clipping().IsCappingOn())
&& aCtx->Clipping().IsCappingOn())
{ {
OpenGl_CappingAlgo::RenderCapping (theWorkspace, *this); OpenGl_CappingRenderer::Render (theWorkspace, *this);
} }
// Revert structure clippings // Revert structure clippings

View File

@ -16,18 +16,14 @@
#include <OpenGl_Workspace.hxx> #include <OpenGl_Workspace.hxx>
#include <OpenGl_ArbFBO.hxx> #include <OpenGl_ArbFBO.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx> #include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx> #include <OpenGl_Element.hxx>
#include <OpenGl_FrameBuffer.hxx> #include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_GlCore15.hxx> #include <OpenGl_GlCore15.hxx>
#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_Sampler.hxx> #include <OpenGl_Sampler.hxx>
#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_ShaderManager.hxx> #include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_Texture.hxx> #include <OpenGl_Texture.hxx>
#include <OpenGl_View.hxx> #include <OpenGl_View.hxx>
#include <OpenGl_Window.hxx> #include <OpenGl_Window.hxx>
@ -167,7 +163,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
#endif #endif
} }
myDefaultCappingAlgoFilter = new OpenGl_CappingAlgoFilter(); myCappingRenderFilter = new OpenGl_CappingRenderFilter();
myNoneCulling .Aspect()->SetSuppressBackFaces (false); myNoneCulling .Aspect()->SetSuppressBackFaces (false);
myNoneCulling .Aspect()->SetDrawEdges (false); myNoneCulling .Aspect()->SetDrawEdges (false);

View File

@ -17,9 +17,13 @@
#define _OpenGl_Workspace_Header #define _OpenGl_Workspace_Header
#include <Graphic3d_BufferType.hxx> #include <Graphic3d_BufferType.hxx>
#include <Graphic3d_PresentationAttributes.hxx>
#include <OpenGl_AspectFace.hxx> #include <OpenGl_AspectFace.hxx>
#include <OpenGl_CappingAlgo.hxx> #include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_CappingRenderer.hxx>
#include <OpenGl_FrameBuffer.hxx> #include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Material.hxx> #include <OpenGl_Material.hxx>
#include <OpenGl_Matrix.hxx> #include <OpenGl_Matrix.hxx>
@ -264,9 +268,9 @@ public:
const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; } const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; }
//! Returns capping algorithm rendering filter. //! Returns capping algorithm rendering filter.
const Handle(OpenGl_CappingAlgoFilter)& DefaultCappingAlgoFilter() const const Handle(OpenGl_CappingRenderFilter)& CappingRenderFilter() const
{ {
return myDefaultCappingAlgoFilter; return myCappingRenderFilter;
} }
//! Returns face aspect for none culling mode. //! Returns face aspect for none culling mode.
@ -289,14 +293,14 @@ public:
protected: //! @name protected fields protected: //! @name protected fields
OpenGl_View* myView; OpenGl_View* myView;
Handle(OpenGl_Window) myWindow; Handle(OpenGl_Window) myWindow;
Handle(OpenGl_Context) myGlContext; Handle(OpenGl_Context) myGlContext;
Standard_Boolean myUseZBuffer; Standard_Boolean myUseZBuffer;
Standard_Boolean myUseDepthWrite; Standard_Boolean myUseDepthWrite;
Handle(OpenGl_CappingAlgoFilter) myDefaultCappingAlgoFilter; Handle(OpenGl_CappingRenderFilter) myCappingRenderFilter;
OpenGl_AspectFace myNoneCulling; OpenGl_AspectFace myNoneCulling;
OpenGl_AspectFace myFrontCulling; OpenGl_AspectFace myFrontCulling;
protected: //! @name fields related to status protected: //! @name fields related to status

View File

@ -276,14 +276,15 @@ namespace
} }
//! Prepare shaded presentation for specified shape //! Prepare shaded presentation for specified shape
static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape, static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Handle(Prs3d_Drawer)& theDrawer, const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Boolean theHasTexels, const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const gp_Pnt2d& theUVOrigin, const Standard_Boolean theHasTexels,
const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVScale, const gp_Pnt2d& theUVRepeat,
const bool theIsClosed) const gp_Pnt2d& theUVScale,
const bool theIsClosed)
{ {
Handle(Graphic3d_ArrayOfTriangles) aPArray = fillTriangles (theShape, theHasTexels, theUVOrigin, theUVRepeat, theUVScale); Handle(Graphic3d_ArrayOfTriangles) aPArray = fillTriangles (theShape, theHasTexels, theUVOrigin, theUVRepeat, theUVScale);
if (aPArray.IsNull()) if (aPArray.IsNull())
@ -294,6 +295,9 @@ namespace
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs); Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
aGroup->SetClosed (theIsClosed); aGroup->SetClosed (theIsClosed);
aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect());
if (!theCappingStyle.IsNull())
aGroup->SetGroupPrimitivesAspect (theCappingStyle);
aGroup->AddPrimitiveArray (aPArray); aGroup->AddPrimitiveArray (aPArray);
return Standard_True; return Standard_True;
} }
@ -496,28 +500,30 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
// function : Add // function : Add
// purpose : // purpose :
// ======================================================================= // =======================================================================
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs, void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer, const Handle(Prs3d_Drawer)& theDrawer,
const StdPrs_Volume theVolume) const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const StdPrs_Volume theVolume)
{ {
gp_Pnt2d aDummy; gp_Pnt2d aDummy;
StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer, StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
Standard_False, aDummy, aDummy, aDummy, theVolume); Standard_False, aDummy, aDummy, aDummy, theCappingStyle, theVolume);
} }
// ======================================================================= // =======================================================================
// function : Add // function : Add
// purpose : // purpose :
// ======================================================================= // =======================================================================
void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs, void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const Handle (Prs3d_Drawer)& theDrawer, const Handle (Prs3d_Drawer)& theDrawer,
const Standard_Boolean theHasTexels, const Standard_Boolean theHasTexels,
const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVRepeat,
const gp_Pnt2d& theUVScale, const gp_Pnt2d& theUVScale,
const StdPrs_Volume theVolume) const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const StdPrs_Volume theVolume)
{ {
if (theShape.IsNull()) if (theShape.IsNull())
{ {
@ -555,21 +561,21 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
TopoDS_Iterator aShapeIter (aClosed); TopoDS_Iterator aShapeIter (aClosed);
if (aShapeIter.More()) if (aShapeIter.More())
{ {
shadeFromShape (aClosed, thePrs, theDrawer, shadeFromShape (aClosed, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true); theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true);
} }
aShapeIter.Initialize (anOpened); aShapeIter.Initialize (anOpened);
if (aShapeIter.More()) if (aShapeIter.More())
{ {
shadeFromShape (anOpened, thePrs, theDrawer, shadeFromShape (anOpened, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false); theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false);
} }
} }
else else
{ {
// if the shape type is not compound, composolid or solid, use autodetection back-facing filled // if the shape type is not compound, composolid or solid, use autodetection back-facing filled
shadeFromShape (theShape, thePrs, theDrawer, shadeFromShape (theShape, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
theVolume == StdPrs_Volume_Closed); theVolume == StdPrs_Volume_Closed);
} }

View File

@ -43,13 +43,25 @@ public:
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face //! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes) //! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
//! or to perform Autodetection (would split input shape into two groups) //! or to perform Autodetection (would split input shape into two groups)
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection); Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
//! Shades <theShape> with texture coordinates. //! Shades <theShape> with texture coordinates.
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face //! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes) //! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
//! or to perform Autodetection (would split input shape into two groups) //! or to perform Autodetection (would split input shape into two groups)
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection); Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Boolean theHasTexels,
const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVRepeat,
const gp_Pnt2d& theUVScale,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
//! Searches closed and unclosed subshapes in shape structure and puts them //! Searches closed and unclosed subshapes in shape structure and puts them
//! into two compounds for separate processing of closed and unclosed sub-shapes //! into two compounds for separate processing of closed and unclosed sub-shapes

View File

@ -1618,17 +1618,17 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
//! Auxiliary structure for VAspects //! Auxiliary structure for VAspects
struct ViewerTest_AspectsChangeSet struct ViewerTest_AspectsChangeSet
{ {
Standard_Integer ToSetVisibility; Standard_Integer ToSetVisibility;
Standard_Integer Visibility; Standard_Integer Visibility;
Standard_Integer ToSetColor; Standard_Integer ToSetColor;
Quantity_Color Color; Quantity_Color Color;
Standard_Integer ToSetLineWidth; Standard_Integer ToSetLineWidth;
Standard_Real LineWidth; Standard_Real LineWidth;
Standard_Integer ToSetTypeOfLine; Standard_Integer ToSetTypeOfLine;
Aspect_TypeOfLine TypeOfLine; Aspect_TypeOfLine TypeOfLine;
Standard_Integer ToSetTypeOfMarker; Standard_Integer ToSetTypeOfMarker;
Aspect_TypeOfMarker TypeOfMarker; Aspect_TypeOfMarker TypeOfMarker;
@ -1640,30 +1640,60 @@ struct ViewerTest_AspectsChangeSet
Standard_Integer ToSetTransparency; Standard_Integer ToSetTransparency;
Standard_Real Transparency; Standard_Real Transparency;
Standard_Integer ToSetMaterial; Standard_Integer ToSetMaterial;
Graphic3d_NameOfMaterial Material; Graphic3d_NameOfMaterial Material;
TCollection_AsciiString MatName; TCollection_AsciiString MatName;
NCollection_Sequence<TopoDS_Shape> SubShapes; NCollection_Sequence<TopoDS_Shape> SubShapes;
Standard_Integer ToSetShowFreeBoundary; Standard_Integer ToSetShowFreeBoundary;
Standard_Integer ToSetFreeBoundaryWidth; Standard_Integer ToSetFreeBoundaryWidth;
Standard_Real FreeBoundaryWidth; Standard_Real FreeBoundaryWidth;
Standard_Integer ToSetFreeBoundaryColor; Standard_Integer ToSetFreeBoundaryColor;
Quantity_Color FreeBoundaryColor; Quantity_Color FreeBoundaryColor;
Standard_Integer ToEnableIsoOnTriangulation; Standard_Integer ToEnableIsoOnTriangulation;
Standard_Integer ToSetMaxParamValue; Standard_Integer ToSetMaxParamValue;
Standard_Real MaxParamValue; Standard_Real MaxParamValue;
Standard_Integer ToSetSensitivity; Standard_Integer ToSetSensitivity;
Standard_Integer SelectionMode; Standard_Integer SelectionMode;
Standard_Integer Sensitivity; Standard_Integer Sensitivity;
Standard_Integer ToSetHatch; Standard_Integer ToSetHatch;
Standard_Integer StdHatchStyle; Standard_Integer StdHatchStyle;
TCollection_AsciiString PathToHatchPattern; TCollection_AsciiString PathToHatchPattern;
Standard_Integer ToSetCappingUseObjMaterial;
Standard_Integer ToSetCappingUseObjTexture;
Standard_Integer ToSetCappingUseObjShader;
Standard_Integer ToSetCappingHatchZoomPers;
Standard_Integer ToSetCappingHatchRotatePers;
Standard_Integer ToSetCappingHatchEnabled;
Standard_Boolean ToSetCappingColor;
Quantity_Color CappingColor;
Standard_Boolean ToSetCappingTexture;
Handle(Graphic3d_TextureMap) CappingTexture;
Standard_Boolean ToSetCappingTexScale;
Graphic3d_Vec2 CappingTexScale;
Standard_Boolean ToSetCappingTexOrigin;
Graphic3d_Vec2 CappingTexOrigin;
Standard_Boolean ToSetCappingTexRotate;
Standard_ShortReal CappingTexRotate;
Standard_Boolean ToSetCappingStippleHatch;
Handle(Graphic3d_HatchStyle) CappingHatchStipple;
Standard_Boolean ToSetCappingHatchColor;
Quantity_Color CappingHatchColor;
Standard_Boolean ToSetCappingTextureHatch;
Handle(Graphic3d_TextureMap) CappingHatchTexture;
Standard_Boolean ToSetCappingHatchTexScale;
Graphic3d_Vec2 CappingHatchTexScale;
Standard_Boolean ToSetCappingHatchTexOrigin;
Graphic3d_Vec2 CappingHatchTexOrigin;
Standard_Boolean ToSetCappingHatchTexRotate;
Standard_ShortReal CappingHatchTexRotate;
Standard_Boolean ToUnsetCapping;
//! Empty constructor //! Empty constructor
ViewerTest_AspectsChangeSet() ViewerTest_AspectsChangeSet()
@ -1695,7 +1725,26 @@ struct ViewerTest_AspectsChangeSet
SelectionMode (-1), SelectionMode (-1),
Sensitivity (-1), Sensitivity (-1),
ToSetHatch (0), ToSetHatch (0),
StdHatchStyle (-1) StdHatchStyle (-1),
ToSetCappingUseObjMaterial (-1),
ToSetCappingUseObjTexture (-1),
ToSetCappingUseObjShader (-1),
ToSetCappingHatchZoomPers (-1),
ToSetCappingHatchRotatePers (-1),
ToSetCappingHatchEnabled (-1),
ToSetCappingColor (Standard_False),
ToSetCappingTexture (Standard_False),
ToSetCappingTexScale (Standard_False),
ToSetCappingTexOrigin (Standard_False),
ToSetCappingTexRotate (Standard_False),
ToSetCappingStippleHatch (Standard_False),
ToSetCappingHatchColor (Standard_False),
ToSetCappingTextureHatch (Standard_False),
ToSetCappingHatchTexScale (Standard_False),
ToSetCappingHatchTexOrigin (Standard_False),
ToSetCappingHatchTexRotate (Standard_False),
CappingTexRotate (0.F),
ToUnsetCapping (Standard_False)
{} {}
//! @return true if no changes have been requested //! @return true if no changes have been requested
@ -1711,7 +1760,30 @@ struct ViewerTest_AspectsChangeSet
&& ToSetFreeBoundaryWidth == 0 && ToSetFreeBoundaryWidth == 0
&& ToSetMaxParamValue == 0 && ToSetMaxParamValue == 0
&& ToSetSensitivity == 0 && ToSetSensitivity == 0
&& ToSetHatch == 0; && ToSetHatch == 0
&& !ToSetCapping();
}
Standard_Boolean ToSetCapping() const
{
return ToSetCappingUseObjMaterial != -1
|| ToSetCappingUseObjTexture != -1
|| ToSetCappingUseObjShader != -1
|| ToSetCappingHatchZoomPers != -1
|| ToSetCappingHatchRotatePers != -1
|| ToSetCappingHatchEnabled != -1
|| ToSetCappingColor
|| ToSetCappingTexture
|| ToSetCappingTexScale
|| ToSetCappingTexOrigin
|| ToSetCappingTexRotate
|| ToSetCappingStippleHatch
|| ToSetCappingHatchColor
|| ToSetCappingTextureHatch
|| ToSetCappingHatchTexScale
|| ToSetCappingHatchTexOrigin
|| ToSetCappingHatchTexRotate
|| ToUnsetCapping;
} }
//! @return true if properties are valid //! @return true if properties are valid
@ -1768,9 +1840,109 @@ struct ViewerTest_AspectsChangeSet
std::cout << "Error: hatch style must be specified\n"; std::cout << "Error: hatch style must be specified\n";
isOk = Standard_False; isOk = Standard_False;
} }
if (ToUnsetCapping && ToSetCapping())
{
std::cout << "Error: not possible to set capping attribute with -unsetCapping specified\n";
isOk = Standard_False;
}
return isOk; return isOk;
} }
void ApplyToCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
if (ToSetCappingUseObjMaterial != -1)
{
theStyle->SetUseObjectMaterial (ToSetCappingUseObjMaterial != 0);
}
if (ToSetCappingUseObjTexture != -1)
{
theStyle->SetUseObjectTexture (ToSetCappingUseObjTexture != 0);
}
if (ToSetCappingUseObjShader != -1)
{
theStyle->SetUseObjectShader (ToSetCappingUseObjShader != 0);
}
if (ToSetCappingHatchZoomPers != -1)
{
theStyle->SetHatchZoomPeristent (ToSetCappingHatchZoomPers != 0);
}
if (ToSetCappingHatchRotatePers != -1)
{
theStyle->SetHatchRotationPeristent (ToSetCappingHatchRotatePers != 0);
}
if (ToSetCappingHatchEnabled != -1)
{
theStyle->SetToDrawHatch (ToSetCappingHatchEnabled != 0);
}
if (ToSetCappingColor)
{
Graphic3d_MaterialAspect aMat = theStyle->Material();
aMat.SetAmbientColor (CappingColor);
aMat.SetDiffuseColor (CappingColor);
theStyle->SetMaterial (aMat);
}
if (ToSetCappingTexture)
{
theStyle->SetTexture (CappingTexture);
}
if (ToSetCappingTexScale)
{
if (!theStyle->Texture().IsNull())
{
theStyle->Texture()->GetParams()->SetScale (CappingTexScale);
}
}
if (ToSetCappingTexOrigin)
{
if (!theStyle->Texture().IsNull())
{
theStyle->Texture()->GetParams()->SetTranslation (CappingTexOrigin);
}
}
if (ToSetCappingTexRotate)
{
if (!theStyle->Texture().IsNull())
{
theStyle->Texture()->GetParams()->SetRotation (CappingTexRotate);
}
}
if (ToSetCappingStippleHatch)
{
theStyle->SetHatchStyle (CappingHatchStipple);
}
if (ToSetCappingHatchColor)
{
Graphic3d_MaterialAspect aMat = theStyle->HatchMaterial();
aMat.SetAmbientColor (CappingHatchColor);
aMat.SetDiffuseColor (CappingHatchColor);
theStyle->SetHatchMaterial (aMat);
}
if (ToSetCappingTextureHatch)
{
theStyle->SetHatchStyle (CappingHatchTexture);
}
if (ToSetCappingHatchTexScale)
{
if (!theStyle->TextureHatch().IsNull())
{
theStyle->TextureHatch()->GetParams()->SetScale (CappingHatchTexScale);
}
}
if (ToSetCappingHatchTexOrigin)
{
if (!theStyle->TextureHatch().IsNull())
{
theStyle->TextureHatch()->GetParams()->SetTranslation (CappingHatchTexOrigin);
}
}
if (ToSetCappingHatchTexRotate)
{
if (!theStyle->TextureHatch().IsNull())
{
theStyle->TextureHatch()->GetParams()->SetRotation (CappingHatchTexRotate);
}
}
}
}; };
//============================================================================== //==============================================================================
@ -1825,6 +1997,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges; NCollection_Sequence<ViewerTest_AspectsChangeSet> aChanges;
aChanges.Append (ViewerTest_AspectsChangeSet()); aChanges.Append (ViewerTest_AspectsChangeSet());
ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast(); ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
Standard_Boolean toEnable = Standard_False;
// parse syntax of legacy commands // parse syntax of legacy commands
if (aCmdName == "vsetwidth") if (aCmdName == "vsetwidth")
@ -1944,6 +2117,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
} }
for (; anArgIter < theArgNb; ++anArgIter) for (; anArgIter < theArgNb; ++anArgIter)
{ {
const char** aChangeArgs = theArgVec + anArgIter;
Standard_Integer aNbChangeArgs = theArgNb - anArgIter;
TCollection_AsciiString anArg = theArgVec[anArgIter]; TCollection_AsciiString anArg = theArgVec[anArgIter];
anArg.LowerCase(); anArg.LowerCase();
if (anArg == "-setwidth" if (anArg == "-setwidth"
@ -2389,12 +2564,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
return 1; return 1;
} }
if (aNames.IsEmpty())
{
std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
return 1;
}
aChangeSet->ToSetHatch = 1; aChangeSet->ToSetHatch = 1;
TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]); TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]);
if (anArgHatch.Length() <= 2) if (anArgHatch.Length() <= 2)
@ -2413,6 +2582,382 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
aChangeSet->PathToHatchPattern = anArgHatch; aChangeSet->PathToHatchPattern = anArgHatch;
} }
} }
else if (anArg == "-setcappinguseobjmaterial")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingUseObjMaterial need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingUseObjMaterial = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappinguseobjtexture")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingUseObjTexture need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingUseObjTexture = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappinguseobjshader")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingUseObjShader need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingUseObjShader = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappingcolor")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
Quantity_Color aColor;
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
aChangeArgs + 1,
aColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error: -setCappingColor need more arguments.\n";
return 1;
}
anArgIter += aNbParsed;
aChangeSet->ToSetCappingColor = Standard_True;
aChangeSet->CappingColor = aColor;
}
else if (anArg == "-setcappingtexture")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingTexture need more arguments.\n";
return 1;
}
TCollection_AsciiString aTextureName (aChangeArgs[1]);
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (!aTexture->IsDone())
{
aChangeSet->CappingTexture = Handle(Graphic3d_TextureMap)();
}
else
{
aTexture->EnableModulate();
aTexture->EnableRepeat();
aChangeSet->CappingTexture = aTexture.get();
}
aChangeSet->ToSetCappingTexture = Standard_True;
anArgIter += 1;
}
else if (anArg == "-setcappingtexscale")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: -setCappingTexScale need more arguments.\n";
return 1;
}
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aChangeSet->ToSetCappingTexScale = Standard_True;
aChangeSet->CappingTexScale = Graphic3d_Vec2 (aSx, aSy);
anArgIter += 2;
}
else if (anArg == "-setcappingtexorigin")
{
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: -setCappingTexOrigin need more arguments.\n";
return 1;
}
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aChangeSet->ToSetCappingTexOrigin = Standard_True;
aChangeSet->CappingTexOrigin = Graphic3d_Vec2 (aTx, aTy);
anArgIter += 2;
}
else if (anArg == "-setcappingtexrotate")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingTexRotate need more arguments.\n";
return 1;
}
aChangeSet->ToSetCappingTexRotate = Standard_True;
aChangeSet->CappingTexRotate = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
anArgIter += 1;
}
else if (anArg == "-setcappinghatchzoompers")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatchZoomPers need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingHatchZoomPers = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappinghatchrotatepers")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatchRotatePers need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingHatchRotatePers = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappinghatch")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatch need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aChangeSet->ToSetCappingHatchEnabled = toEnable ? 1 : 0;
anArgIter += 1;
}
}
else if (anArg == "-setcappinghatchstipple")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatchStipple need more arguments.\n";
return 1;
}
TCollection_AsciiString anArg = aChangeArgs[1];
if (anArg.IsIntegerValue())
{
aChangeSet->ToSetCappingStippleHatch = Standard_True;
aChangeSet->CappingHatchStipple = new Graphic3d_HatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
}
else
{
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
if (!anImage->Load (anArg))
{
std::cout << "Syntax error: -setCappingHatchStipple image " << anArg << " could not be loaded.\n";
return 1;
}
aChangeSet->ToSetCappingStippleHatch = Standard_True;
aChangeSet->CappingHatchStipple = new Graphic3d_HatchStyle (anImage);
}
anArgIter += 1;
}
else if (anArg == "-setcappinghatchcolor")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
Quantity_Color aColor;
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
aChangeArgs + 1,
aColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error: -setCappingHatchColor need more arguments.\n";
return 1;
}
aChangeSet->ToSetCappingHatchColor = Standard_True;
aChangeSet->CappingHatchColor = aColor;
anArgIter += aNbParsed;
}
else if (anArg == "-setcappinghatchtexture")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatchTexture need more arguments.\n";
return 1;
}
TCollection_AsciiString aTextureName (aChangeArgs[1]);
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (aTexture->IsDone())
{
aTexture->EnableModulate();
aTexture->EnableRepeat();
}
aChangeSet->ToSetCappingTextureHatch = Standard_True;
aChangeSet->CappingHatchTexture = aTexture->IsDone() ? aTexture : Handle(Graphic3d_TextureMap)();
anArgIter += 1;
}
else if (anArg == "-setcappinghatchtexscale")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: -setCappingHatchTexScale need more arguments.\n";
return 1;
}
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aChangeSet->ToSetCappingHatchTexScale = Standard_True;
aChangeSet->CappingHatchTexScale = Graphic3d_Vec2 (aSx, aSy);
anArgIter += 2;
}
else if (anArg == "-setcappinghatchtexorigin")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: -setCappingHatchTexOrigin need more arguments.\n";
return 1;
}
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aChangeSet->ToSetCappingHatchTexOrigin = Standard_True;
aChangeSet->CappingHatchTexOrigin = Graphic3d_Vec2 (aTx, aTy);
anArgIter += 2;
}
else if (anArg == "-setcappinghatchtexrotate")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: -setCappingHatchTexRotate need more arguments.\n";
return 1;
}
aChangeSet->ToSetCappingHatchTexRotate = Standard_True;
aChangeSet->CappingHatchTexRotate = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
anArgIter += 1;
}
else if (anArg == "-unsetcappingstyle")
{
if (isDefaults)
{
std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
return 1;
}
if (isDefaults)
{
std::cout << "Error: wrong syntax. -unsetCappingStyle can not be used together with -defaults call!\n";
return 1;
}
aChangeSet->ToUnsetCapping = Standard_True;
}
else else
{ {
std::cout << "Error: wrong syntax at " << anArg << "\n"; std::cout << "Error: wrong syntax at " << anArg << "\n";
@ -2699,6 +3244,27 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
} }
toRedisplay = Standard_True; toRedisplay = Standard_True;
} }
if (aChangeSet->ToSetCapping())
{
Handle(Graphic3d_AspectFillCapping) aCappingStyle = aPrs->CappingStyle();
if (aCappingStyle.IsNull())
{
aCappingStyle = new Graphic3d_AspectFillCapping;
}
aChangeSet->ApplyToCappingStyle (aCappingStyle);
aPrs->SetCappingStyle (aCappingStyle);
toRedisplay = Standard_True;
}
if (aChangeSet->ToUnsetCapping != 0)
{
aPrs->SetCappingStyle (Handle(Graphic3d_AspectFillCapping)());
toRedisplay = Standard_True;
}
} }
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next()) for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
@ -6229,6 +6795,24 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"\n\t\t: [-setMaxParamValue {value}]" "\n\t\t: [-setMaxParamValue {value}]"
"\n\t\t: [-setSensitivity {selection_mode} {value}]" "\n\t\t: [-setSensitivity {selection_mode} {value}]"
"\n\t\t: [-setHatch HatchStyle]" "\n\t\t: [-setHatch HatchStyle]"
"\n\t\t: [-setCappingUseObjMaterial {off/on | 0/1}]"
"\n\t\t: [-setCappingUseObjTexture {off/on | 0/1}]"
"\n\t\t: [-setCappingUseObjShader {off/on | 0/1}]"
"\n\t\t: [-setCappingColor R G B]"
"\n\t\t: [-setCappingTexture texture]"
"\n\t\t: [-setCappingTexScale SX SY]"
"\n\t\t: [-setCappingTexOrigin TX TY]"
"\n\t\t: [-setCappingTexRotate Angle]"
"\n\t\t: [-setCappingHatch {off/on | 0/1}]"
"\n\t\t: [-setCappingHatchColor R G B]"
"\n\t\t: [-setCappingHatchStipple maskID]"
"\n\t\t: [-setCappingHatchTexture Texture]"
"\n\t\t: [-setCappingHatchTexScale SX SY]"
"\n\t\t: [-setCappingHatchTexOrigin TX TY]"
"\n\t\t: [-setCappingHatchTexRotate Angle]"
"\n\t\t: [-setCappingHatchZoomPers {off/on | 0/1}]"
"\n\t\t: [-setCappingHatchRotatePers {off/on | 0/1}]"
"\n\t\t: [-unsetCappingStyle]"
"\n\t\t: Manage presentation properties of all, selected or named objects." "\n\t\t: Manage presentation properties of all, selected or named objects."
"\n\t\t: When -subshapes is specified than following properties will be" "\n\t\t: When -subshapes is specified than following properties will be"
"\n\t\t: assigned to specified sub-shapes." "\n\t\t: assigned to specified sub-shapes."

View File

@ -8225,6 +8225,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{ {
aClipPlane->SetCapping (toEnable); aClipPlane->SetCapping (toEnable);
anArgIter += 1; anArgIter += 1;
} }
else else
@ -8245,7 +8246,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{ {
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True); aClipPlane->CappingSectionStyle()->SetUseObjectMaterial (toEnable == Standard_True);
anArgIter += 1; anArgIter += 1;
} }
} }
@ -8262,7 +8263,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{ {
aClipPlane->SetUseObjectTexture (toEnable == Standard_True); aClipPlane->CappingSectionStyle()->SetUseObjectTexture (toEnable == Standard_True);
anArgIter += 1; anArgIter += 1;
} }
} }
@ -8277,7 +8278,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{ {
aClipPlane->SetUseObjectShader (toEnable == Standard_True); aClipPlane->CappingSectionStyle()->SetUseObjectShader (toEnable == Standard_True);
anArgIter += 1; anArgIter += 1;
} }
} }
@ -8294,14 +8295,29 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
return 1; return 1;
} }
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial(); Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
aMat.SetAmbientColor (aColor); aMat.SetAmbientColor (aColor);
aMat.SetDiffuseColor (aColor); aMat.SetDiffuseColor (aColor);
aClipPlane->SetCappingMaterial (aMat); aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
anArgIter += aNbParsed; anArgIter += aNbParsed;
} }
else if (aChangeArg == "-texname" else if (aChangeArg == "-overrideaspect"
|| aChangeArg == "texname") || aChangeArg == "overrideaspect")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetToOverrideCappingAspect (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-texture"
|| aChangeArg == "texture")
{ {
if (aNbChangeArgs < 2) if (aNbChangeArgs < 2)
{ {
@ -8313,20 +8329,22 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (!aTexture->IsDone()) if (!aTexture->IsDone())
{ {
aClipPlane->SetCappingTexture (NULL); aClipPlane->CappingSectionStyle()->SetTexture (Handle(Graphic3d_TextureMap)());
} }
else else
{ {
aTexture->EnableModulate(); aTexture->EnableModulate();
aTexture->EnableRepeat(); aTexture->EnableRepeat();
aClipPlane->SetCappingTexture (aTexture); aClipPlane->CappingSectionStyle()->SetTexture (aTexture.get());
} }
anArgIter += 1; anArgIter += 1;
} }
else if (aChangeArg == "-texscale" else if (aChangeArg == "-texscale"
|| aChangeArg == "texscale") || aChangeArg == "texscale")
{ {
if (aClipPlane->CappingTexture().IsNull()) const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{ {
std::cout << "Error: no texture is set.\n"; std::cout << "Error: no texture is set.\n";
return 1; return 1;
@ -8340,13 +8358,15 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
anArgIter += 2; anArgIter += 2;
} }
else if (aChangeArg == "-texorigin" else if (aChangeArg == "-texorigin"
|| aChangeArg == "texorigin") // texture origin || aChangeArg == "texorigin") // texture origin
{ {
if (aClipPlane->CappingTexture().IsNull()) const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{ {
std::cout << "Error: no texture is set.\n"; std::cout << "Error: no texture is set.\n";
return 1; return 1;
@ -8361,13 +8381,15 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
anArgIter += 2; anArgIter += 2;
} }
else if (aChangeArg == "-texrotate" else if (aChangeArg == "-texrotate"
|| aChangeArg == "texrotate") // texture rotation || aChangeArg == "texrotate") // texture rotation
{ {
if (aClipPlane->CappingTexture().IsNull()) const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{ {
std::cout << "Error: no texture is set.\n"; std::cout << "Error: no texture is set.\n";
return 1; return 1;
@ -8380,7 +8402,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
} }
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot); aHatchTexture->GetParams()->SetRotation (aRot);
anArgIter += 1; anArgIter += 1;
} }
else if (aChangeArg == "-hatch" else if (aChangeArg == "-hatch"
@ -8392,22 +8414,165 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
return 1; return 1;
} }
TCollection_AsciiString aHatchStr (aChangeArgs[1]); if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
aHatchStr.LowerCase();
if (aHatchStr == "on")
{ {
aClipPlane->SetCappingHatchOn(); aClipPlane->CappingSectionStyle()->SetToDrawHatch (toEnable == Standard_True);
anArgIter += 1;
} }
else if (aHatchStr == "off") }
else if (aChangeArg == "-hatchtexture"
|| aChangeArg == "hatchtexture")
{
if (aNbChangeArgs < 2)
{ {
aClipPlane->SetCappingHatchOff(); std::cout << "Syntax error: need more arguments.\n";
return 1;
}
TCollection_AsciiString aTextureName (aChangeArgs[1]);
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (!aTexture->IsDone())
{
aClipPlane->CappingSectionStyle()->SetHatchStyle (Handle(Graphic3d_TextureMap)());
} }
else else
{ {
aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1])); aTexture->EnableModulate();
aTexture->EnableRepeat();
aClipPlane->CappingSectionStyle()->SetHatchStyle (aTexture.get());
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
} }
anArgIter += 1; anArgIter += 1;
} }
else if (aChangeArg == "-hatchstipple"
|| aChangeArg == "hatchstipple")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
aClipPlane->CappingSectionStyle()->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
anArgIter += 1;
}
else if (aChangeArg == "-hatchcolor"
|| aChangeArg == "hatchcolor")
{
Quantity_Color aColor;
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
aChangeArgs + 1,
aColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->HatchMaterial();
aMat.SetAmbientColor (aColor);
aMat.SetDiffuseColor (aColor);
aClipPlane->CappingSectionStyle()->SetHatchMaterial (aMat);
anArgIter += aNbParsed;
}
else if (aChangeArg == "-hatchscale"
|| aChangeArg == "hatchscale")
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
anArgIter += 2;
}
else if (aChangeArg == "-hatchorigin"
|| aChangeArg == "hatchorigin") // texture origin
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
anArgIter += 2;
}
else if (aChangeArg == "-hatchrotate"
|| aChangeArg == "hatchrotate") // texture rotation
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
aHatchTexture->GetParams()->SetRotation (aRot);
anArgIter += 1;
}
else if (aChangeArg == "-hatchzoompers"
|| aChangeArg == "hatchzoompers")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->CappingSectionStyle()->SetHatchZoomPeristent (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-hatchrotatepers"
|| aChangeArg == "hatchrotatepers")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->CappingSectionStyle()->SetHatchRotationPeristent (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-delete" else if (aChangeArg == "-delete"
|| aChangeArg == "delete") || aChangeArg == "delete")
{ {
@ -11835,11 +12000,18 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-set|-unset [objects|views]]" "\n\t\t: [-set|-unset [objects|views]]"
"\n\t\t: [-maxPlanes]" "\n\t\t: [-maxPlanes]"
"\n\t\t: [-capping {0|1}]" "\n\t\t: [-capping {0|1}]"
"\n\t\t: [-color R G B] [-hatch {on|off|ID}]" "\n\t\t: [-overrideAspect {0|1}]"
"\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]" "\n\t\t: [-color R G B]"
"\n\t\t: [-texRotate Angle]" "\n\t\t: [-texture Texture] [-texScale SX SY]"
"\n\t\t: [-texOrigin TX TY] [-texRotate Angle]"
"\n\t\t: [-hatch {on|off}] [-hatchStipple mask]"
"\n\t\t: [-hatchColor R G B] [-hatchTexture texture]"
"\n\t\t: [-hatchScale SX SY] [-hatchOrigin TX TY]"
"\n\t\t: [-hatchRotate Angle]"
"\n\t\t: [-hatchZoomPers {0|1}]"
"\n\t\t: [-hatchRotatePers {0|1}]"
"\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]" "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
"\n\t\t: [-useObjShader {0|1}]" "\n\t\t: [-useObjShader {0|1}]"
"\n\t\t: Clipping planes management:" "\n\t\t: Clipping planes management:"
"\n\t\t: -maxPlanes print plane limit for view" "\n\t\t: -maxPlanes print plane limit for view"
"\n\t\t: -delete delete plane with given name" "\n\t\t: -delete delete plane with given name"
@ -11850,12 +12022,21 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: -clone SourcePlane NewPlane clone the plane definition." "\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
"\n\t\t: Capping options:" "\n\t\t: Capping options:"
"\n\t\t: -capping {off|on|0|1} turn capping on/off" "\n\t\t: -capping {off|on|0|1} turn capping on/off"
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
"\n\t\t: -color R G B set capping color" "\n\t\t: -color R G B set capping color"
"\n\t\t: -texName Texture set capping texture" "\n\t\t: -texture Texture set capping texture"
"\n\t\t: -texScale SX SY set capping tex scale" "\n\t\t: -texScale SX SY set capping tex scale"
"\n\t\t: -texOrigin TX TY set capping tex origin" "\n\t\t: -texOrigin TX TY set capping tex origin"
"\n\t\t: -texRotate Angle set capping tex rotation" "\n\t\t: -texRotate Angle set capping tex rotation"
"\n\t\t: -hatch {on|off|ID} set capping hatching mask" "\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
"\n\t\t: -hatchColor R G B set color for hatch material"
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
"\n\t\t: -hatchScale SX SY set hatch texture scale"
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object" "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object" "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object", "\n\t\t: -useObjShader {off|on|0|1} use shader program of object",

View File

@ -46,6 +46,7 @@ vclipplane change pln2 equation -0.707 0.707 0 -25
vclipplane change pln2 capping on vclipplane change pln2 capping on
vclipplane change pln2 capping color 0.5 0.5 0.9 vclipplane change pln2 capping color 0.5 0.5 0.9
vclipplane change pln2 capping hatch on vclipplane change pln2 capping hatch on
vclipplane change pln2 capping hatchStipple 7
vclipplane set pln2 object b3 vclipplane set pln2 object b3
checkcolor $x3_coord $y3_coord 0.5 0.5 0.9 checkcolor $x3_coord $y3_coord 0.5 0.5 0.9

View File

@ -72,5 +72,5 @@ vdisplay pp1 pp2
vzoom 0.8 vzoom 0.8
puts "Enable capping planes" puts "Enable capping planes"
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -texname $aHatch -texscale 0.02 -0.02 -useObjMaterial 1 vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -hatchtexture $aHatch -hatchscale 0.02 -0.02 -useObjMaterial 1
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -texname $aHatch -texscale 0.02 -0.02 vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -hatchtexture $aHatch -hatchscale 0.02 -0.02