mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0024672: Visualization - AIS_TexturedShape does not activate back face culling aspect
This commit is contained in:
parent
f376ac72de
commit
8e3ebc7a63
@ -30,6 +30,7 @@
|
|||||||
#include <PrsMgr_PresentationManager3d.hxx>
|
#include <PrsMgr_PresentationManager3d.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx>
|
#include <Standard_ErrorHandler.hxx>
|
||||||
#include <StdPrs_ShadedShape.hxx>
|
#include <StdPrs_ShadedShape.hxx>
|
||||||
|
#include <StdPrs_ToolShadedShape.hxx>
|
||||||
#include <StdPrs_WFDeflectionShape.hxx>
|
#include <StdPrs_WFDeflectionShape.hxx>
|
||||||
#include <StdPrs_WFShape.hxx>
|
#include <StdPrs_WFShape.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
@ -193,10 +194,28 @@ void AIS_TexturedShape::DisableTextureModulate()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void AIS_TexturedShape::UpdateAttributes()
|
void AIS_TexturedShape::UpdateAttributes()
|
||||||
|
{
|
||||||
|
updateAttributes (Presentation());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : updateAttributes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& thePrs)
|
||||||
{
|
{
|
||||||
Prs3d_ShadingAspect aDummy;
|
Prs3d_ShadingAspect aDummy;
|
||||||
myAspect = aDummy.Aspect();
|
myAspect = aDummy.Aspect();
|
||||||
Handle(Prs3d_Presentation) aPrs = Presentation();
|
if (HasPolygonOffsets())
|
||||||
|
{
|
||||||
|
// Issue 23115: copy polygon offset settings passed through myDrawer
|
||||||
|
Standard_Integer aMode;
|
||||||
|
Standard_ShortReal aFactor, aUnits;
|
||||||
|
PolygonOffsets (aMode, aFactor, aUnits);
|
||||||
|
myAspect->SetPolygonOffsets (aMode, aFactor, aUnits);
|
||||||
|
}
|
||||||
|
|
||||||
if (!myToMapTexture)
|
if (!myToMapTexture)
|
||||||
{
|
{
|
||||||
myAspect->SetTextureMapOff();
|
myAspect->SetTextureMapOff();
|
||||||
@ -217,11 +236,11 @@ void AIS_TexturedShape::UpdateAttributes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
myAspect->SetTextureMapOn();
|
myAspect->SetTextureMapOn();
|
||||||
|
|
||||||
myAspect->SetTextureMap (myTexture);
|
myAspect->SetTextureMap (myTexture);
|
||||||
if (!myTexture->IsDone())
|
if (!myTexture->IsDone())
|
||||||
{
|
{
|
||||||
std::cout << "An error occurred while building texture \n";
|
std::cout << "An error occurred while building texture\n";
|
||||||
|
myAspect->SetTextureMapOff();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +249,20 @@ void AIS_TexturedShape::UpdateAttributes()
|
|||||||
else
|
else
|
||||||
myAspect->SetEdgeOff();
|
myAspect->SetEdgeOff();
|
||||||
|
|
||||||
Prs3d_Root::CurrentGroup (aPrs)->SetGroupPrimitivesAspect (myAspect);
|
// manage back face culling in consistent way (as in StdPrs_ShadedShape::Add())
|
||||||
|
if (StdPrs_ToolShadedShape::IsClosed (myshape))
|
||||||
|
{
|
||||||
|
myAspect->SuppressBackFace();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myAspect->AllowBackFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!thePrs.IsNull())
|
||||||
|
{
|
||||||
|
Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (myAspect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -328,62 +360,6 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
|
|||||||
{
|
{
|
||||||
BRepTools::Clean (myshape);
|
BRepTools::Clean (myshape);
|
||||||
BRepTools::Update (myshape);
|
BRepTools::Update (myshape);
|
||||||
|
|
||||||
{
|
|
||||||
Handle(Prs3d_ShadingAspect) aPrs3d_ShadingAspect = new Prs3d_ShadingAspect();
|
|
||||||
myAspect = aPrs3d_ShadingAspect->Aspect();
|
|
||||||
|
|
||||||
// Issue 23115: copy polygon offset settings passed through myDrawer
|
|
||||||
if (HasPolygonOffsets())
|
|
||||||
{
|
|
||||||
Standard_Integer aMode;
|
|
||||||
Standard_ShortReal aFactor, aUnits;
|
|
||||||
PolygonOffsets(aMode, aFactor, aUnits);
|
|
||||||
myAspect->SetPolygonOffsets(aMode, aFactor, aUnits);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!myToMapTexture)
|
|
||||||
{
|
|
||||||
myAspect->SetTextureMapOff();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myAspect->SetTextureMapOn();
|
|
||||||
|
|
||||||
if (!myTexturePixMap.IsNull())
|
|
||||||
{
|
|
||||||
myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap);
|
|
||||||
}
|
|
||||||
else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
|
|
||||||
{
|
|
||||||
myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!myTexture->IsDone())
|
|
||||||
{
|
|
||||||
std::cout << "An error occurred while building texture \n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myModulate)
|
|
||||||
myTexture->EnableModulate();
|
|
||||||
else
|
|
||||||
myTexture->DisableModulate();
|
|
||||||
|
|
||||||
myAspect->SetTextureMap (myTexture);
|
|
||||||
if (myToShowTriangles)
|
|
||||||
myAspect->SetEdgeOn();
|
|
||||||
else
|
|
||||||
myAspect->SetEdgeOff();
|
|
||||||
|
|
||||||
if (myToRepeat)
|
|
||||||
myTexture->EnableRepeat();
|
|
||||||
else
|
|
||||||
myTexture->DisableRepeat();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
@ -392,12 +368,12 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
|
|||||||
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0),
|
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0),
|
||||||
myUVRepeat,
|
myUVRepeat,
|
||||||
myToScale ? myUVScale : gp_Pnt2d (1.0, 1.0));
|
myToScale ? myUVScale : gp_Pnt2d (1.0, 1.0));
|
||||||
// within primitive arrays - object should be in one group of primitives
|
|
||||||
Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (myAspect);
|
updateAttributes (thePrs);
|
||||||
}
|
}
|
||||||
catch (Standard_Failure)
|
catch (Standard_Failure)
|
||||||
{
|
{
|
||||||
std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n";
|
std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed\n";
|
||||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -171,6 +171,8 @@ protected: //! @name overridden methods
|
|||||||
const Handle(Prs3d_Presentation)& thePrs,
|
const Handle(Prs3d_Presentation)& thePrs,
|
||||||
const Standard_Integer theMode);
|
const Standard_Integer theMode);
|
||||||
|
|
||||||
|
Standard_EXPORT void updateAttributes (const Handle(Prs3d_Presentation)& thePrs);
|
||||||
|
|
||||||
protected: //! @name presentation fields
|
protected: //! @name presentation fields
|
||||||
|
|
||||||
Handle(Graphic3d_Texture2Dmanual) myTexture;
|
Handle(Graphic3d_Texture2Dmanual) myTexture;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user