1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-07 18:30:55 +03:00

0026027: Visualization, AIS_TexturedShape - back face culling option should not be overridden by texturing aspect

This commit is contained in:
kgv 2015-04-07 12:17:25 +03:00 committed by bugmaster
parent 42f8ba5632
commit 124ee9c962

View File

@ -23,6 +23,8 @@
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_StructureManager.hxx> #include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Texture2Dmanual.hxx> #include <Graphic3d_Texture2Dmanual.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Prs3d_Drawer.hxx> #include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
@ -78,10 +80,8 @@ void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTe
} }
else else
{ {
#ifdef OCCT_DEBUG Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName
std::cout << "Texture " << theTextureFileName << " doesn't exist\n"; + " is undefined! Texture 0 will be used instead.", Message_Fail);
std::cout << "Using Texture 0 instead ...\n";
#endif
myPredefTexture = Graphic3d_NameOfTexture2D (0); myPredefTexture = Graphic3d_NameOfTexture2D (0);
} }
myTextureFile = ""; myTextureFile = "";
@ -314,55 +314,80 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
myAspect = new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect()); myAspect = new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect());
if (HasPolygonOffsets()) if (HasPolygonOffsets())
{ {
// Issue 23115: copy polygon offset settings passed through myDrawer
Standard_Integer aMode; Standard_Integer aMode;
Standard_ShortReal aFactor, aUnits; Standard_ShortReal aFactor, aUnits;
PolygonOffsets (aMode, aFactor, aUnits); PolygonOffsets (aMode, aFactor, aUnits);
myAspect->SetPolygonOffsets (aMode, aFactor, aUnits); myAspect->SetPolygonOffsets (aMode, aFactor, aUnits);
} }
if (!myToMapTexture) Standard_Boolean hasTexture = Standard_False;
if (myToMapTexture)
{ {
myAspect->SetTextureMapOff(); TCollection_AsciiString aTextureDesc;
return;
}
if (!myTexturePixMap.IsNull()) if (!myTexturePixMap.IsNull())
{ {
myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap); myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap);
aTextureDesc = " (custom image)";
} }
else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN) else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
{ {
myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture); myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")";
} }
else else
{ {
myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString()); myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
} aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")";
myAspect->SetTextureMapOn();
myAspect->SetTextureMap (myTexture);
if (!myTexture->IsDone())
{
#ifdef OCCT_DEBUG
std::cout << "An error occurred while building texture\n";
#endif
myAspect->SetTextureMapOff();
return;
} }
if (myModulate) if (myModulate)
{
myTexture->EnableModulate(); myTexture->EnableModulate();
}
else else
{
myTexture->DisableModulate(); myTexture->DisableModulate();
}
if (myTexture->IsDone())
{
hasTexture = Standard_True;
}
else
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc, Message_Fail);
}
}
myAspect->SetTextureMap (myTexture);
if (hasTexture)
{
myAspect->SetTextureMapOn();
}
else
{
myAspect->SetTextureMapOff();
}
if (myToShowTriangles) if (myToShowTriangles)
{
myAspect->SetEdgeOn(); myAspect->SetEdgeOn();
}
else else
{
myAspect->SetEdgeOff(); myAspect->SetEdgeOff();
}
// manage back face culling in consistent way (as in StdPrs_ShadedShape::Add()) // Go through all groups to change fill aspect for all primitives
if (StdPrs_ToolShadedShape::IsClosed (myshape)) for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (!aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
continue;
}
if (aGroup->IsClosed())
{ {
myAspect->SuppressBackFace(); myAspect->SuppressBackFace();
} }
@ -371,16 +396,8 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
myAspect->AllowBackFace(); myAspect->AllowBackFace();
} }
// Go through all groups to change fill aspect for all primitives
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (myAspect); aGroup->SetGroupPrimitivesAspect (myAspect);
} }
}
} }
//======================================================================= //=======================================================================