0027060: Visualization issue with TopoDS_Vertex after call of AIS_Shape::SetColor()
[occt.git] / src / AIS / AIS_Shape.cxx
index cda29b3..c2721c5 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <AIS_Shape.ixx>
 
-
-#include <Standard_ErrorHandler.hxx>
-#include <OSD_Timer.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-#include <Quantity_Color.hxx>
-
-#include <gp_Pnt.hxx>
+#include <AIS_GraphicTool.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+#include <Aspect_TypeOfLine.hxx>
 #include <Bnd_Box.hxx>
 #include <BRep_Builder.hxx>
-#include <BRepTools_ShapeSet.hxx>
-#include <BRepTools.hxx>
 #include <BRepBndLib.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Group.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_ShapeSet.hxx>
+#include <Geom_Transformation.hxx>
+#include <gp_Pnt.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 #include <Graphic3d_SequenceOfGroup.hxx>
-
+#include <Graphic3d_Structure.hxx>
+#include <HLRBRep.hxx>
+#include <OSD_Timer.hxx>
+#include <Precision.hxx>
 #include <Prs3d.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
 #include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_IsoAspect.hxx>
-
-#include <StdPrs_WFShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_HLRShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-
+#include <StdPrs_BndBox.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
 #include <PrsMgr_ModedPresentation.hxx>
-
+#include <Quantity_Color.hxx>
+#include <Select3D_SensitiveBox.hxx>
 #include <Select3D_SensitiveEntity.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Type.hxx>
+#include <StdPrs_HLRPolyShape.hxx>
+#include <StdPrs_HLRShape.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
 #include <StdSelect.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
 #include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
 #include <StdSelect_DisplayMode.hxx>
-
-#include <AIS_GraphicTool.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <HLRBRep.hxx>
-#include <Precision.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Select3D_SensitiveBox.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
 
 static Standard_Boolean myFirstCompute;
 
@@ -149,21 +145,32 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
     }
   }
 
-  if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //not taken in account duting FITALL
-  switch (aMode) {
-  case 0:{
-    try { OCC_CATCH_SIGNALS  StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
-    catch (Standard_Failure) { 
-#ifdef OCCT_DEBUG
-      cout << "AIS_Shape::Compute()  failed"<< endl;
-      cout << "a Shape should be incorrect : No Compute can be maked on it  "<< endl;     
-#endif
-// presentation of the bounding box is calculated
-//      Compute(aPresentationManager,aPrs,2);
-    }
-    break;
+  if (IsInfinite())
+  {
+    aPrs->SetInfiniteState (Standard_True); //not taken in account duting FITALL
   }
-  case 1:
+
+  switch (aMode)
+  {
+    case AIS_WireFrame:
+    {
+      try
+      {
+        OCC_CATCH_SIGNALS
+        StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+      }
+      catch (Standard_Failure)
+      {
+      #ifdef OCCT_DEBUG
+        cout << "AIS_Shape::Compute() failed" << endl;
+        cout << "a Shape should be incorrect : No Compute can be maked on it " << endl;
+      #endif
+        // presentation of the bounding box is calculated
+        //      Compute(aPresentationManager,aPrs,2);
+      }
+      break;
+    }
+    case AIS_Shaded:
     {
       if (myDrawer->IsAutoTriangulation())
       {
@@ -177,41 +184,57 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
         }
       }
 
-      //shading only on face...
-      if ((Standard_Integer) myshape.ShapeType()>4)
-        StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-      else {
-        myDrawer->SetShadingAspectGlobal(Standard_False);
-        if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-        else {
+      if ((Standard_Integer) myshape.ShapeType() > 4)
+      {
+        StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+      }
+      else
+      {
+        myDrawer->SetShadingAspectGlobal (Standard_False);
+        if (IsInfinite())
+        {
+          StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+        }
+        else
+        {
+          try
           {
-            try {
-              OCC_CATCH_SIGNALS
-              StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-            }
-            catch (Standard_Failure) {
-#ifdef OCCT_DEBUG
-              cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
-#endif
-              StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
-            }
+            OCC_CATCH_SIGNALS
+            StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer);
+          }
+          catch (Standard_Failure)
+          {
+          #ifdef OCCT_DEBUG
+            cout << "AIS_Shape::Compute() in ShadingMode failed" << endl;
+          #endif
+            StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
           }
         }
       }
-      Standard_Real value = Transparency() ;
-      if( value > 0. ) {
-        SetTransparency( value );
+      Standard_Real aTransparency = Transparency() ;
+      if (aTransparency > 0.0)
+      {
+        SetTransparency (aTransparency);
       }
       break;
     }
-  case 2:
+
+    // Bounding box.
+    case 2:
     {
-      // bounding box
-      if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-      else StdPrs_WFDeflectionRestrictedFace::AddBox (aPrs, BoundingBox(), myDrawer);
+      if (IsInfinite())
+      {
+        StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+      }
+      else
+      {
+        StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
+      }
     }
-  } // end switch
-  aPrs->ReCompute(); // for hidden line recomputation if necessary...
+  }
+
+  // Recompute hidden line presentation (if necessary).
+  aPrs->ReCompute();
 }
 
 //=======================================================================
@@ -468,7 +491,7 @@ void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
   }
   if (!theDrawer->HasOwnPointAspect())
   {
-    theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
+    theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
     if (theDrawer->HasLink())
     {
       *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();