#include <Graphic3d_Group.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Message.hxx>
+#include <Message_Messenger.hxx>
#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Standard_ErrorHandler.hxx>
+#include <StdPrs_BndBox.hxx>
#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_ToolShadedShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <StdPrs_WFShape.hxx>
#include <TopExp_Explorer.hxx>
-IMPLEMENT_STANDARD_HANDLE (AIS_TexturedShape, AIS_Shape)
-IMPLEMENT_STANDARD_RTTIEXT(AIS_TexturedShape, AIS_Shape)
+
+IMPLEMENT_STANDARD_RTTIEXT(AIS_TexturedShape,AIS_Shape)
//=======================================================================
//function : AIS_TexturedShape
}
else
{
-#ifdef OCCT_DEBUG
- std::cout << "Texture " << theTextureFileName << " doesn't exist\n";
- std::cout << "Using Texture 0 instead ...\n";
-#endif
+ Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName
+ + " is undefined! Texture 0 will be used instead.", Message_Fail);
myPredefTexture = Graphic3d_NameOfTexture2D (0);
}
myTextureFile = "";
myAspect = new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect());
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)
+ Standard_Boolean hasTexture = Standard_False;
+ if (myToMapTexture)
{
- myAspect->SetTextureMapOff();
- return;
- }
+ TCollection_AsciiString aTextureDesc;
+ if (!myTexturePixMap.IsNull())
+ {
+ myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap);
+ aTextureDesc = " (custom image)";
+ }
+ else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
+ {
+ myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
+ aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")";
+ }
+ else
+ {
+ myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
+ aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")";
+ }
- if (!myTexturePixMap.IsNull())
- {
- myTexture = new Graphic3d_Texture2Dmanual (myTexturePixMap);
+ if (myModulate)
+ {
+ myTexture->EnableModulate();
+ }
+ else
+ {
+ myTexture->DisableModulate();
+ }
+
+ if (myTexture->IsDone())
+ {
+ hasTexture = Standard_True;
+ }
+ else
+ {
+ Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc, Message_Fail);
+ }
}
- else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
+
+ myAspect->SetTextureMap (myTexture);
+ if (hasTexture)
{
- myTexture = new Graphic3d_Texture2Dmanual (myPredefTexture);
+ myAspect->SetTextureMapOn();
}
else
{
- myTexture = new Graphic3d_Texture2Dmanual (myTextureFile.ToCString());
- }
-
- 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)
- myTexture->EnableModulate();
- else
- myTexture->DisableModulate();
-
if (myToShowTriangles)
- myAspect->SetEdgeOn();
- else
- myAspect->SetEdgeOff();
-
- // manage back face culling in consistent way (as in StdPrs_ShadedShape::Add())
- if (StdPrs_ToolShadedShape::IsClosed (myshape))
{
- myAspect->SuppressBackFace();
+ myAspect->SetEdgeOn();
}
else
{
- myAspect->AllowBackFace();
+ myAspect->SetEdgeOff();
}
// 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))
+ {
+ continue;
+ }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ if (aGroup->IsClosed())
+ {
+ myAspect->SuppressBackFace();
+ }
+ else
{
- aGroup->SetGroupPrimitivesAspect (myAspect);
+ myAspect->AllowBackFace();
}
+
+ aGroup->SetGroupPrimitivesAspect (myAspect);
}
}
{
case AIS_WireFrame:
{
- StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
break;
}
case AIS_Shaded:
case 3: // texture mapping on triangulation
{
- Standard_Real prevangle;
- Standard_Real newangle;
- Standard_Real prevcoeff;
- Standard_Real newcoeff;
-
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle(newangle,prevangle);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(newcoeff,prevcoeff);
- if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnDeviationAngle) ||
- ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnDeviationCoefficient)) {
- BRepTools::Clean (myshape);
- }
-
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
if (myshape.ShapeType() > TopAbs_FACE)
{
- StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
break;
}
myDrawer->SetShadingAspectGlobal (Standard_False);
if (IsInfinite())
{
- StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
break;
}
try
{
if (IsInfinite())
{
- StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
+ StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
}
else
{
- StdPrs_WFDeflectionRestrictedFace::AddBox (thePrs, BoundingBox(), myDrawer);
+ StdPrs_BndBox::Add (thePrs, BoundingBox(), myDrawer);
}
break;
}