0023501: Redundant triangulation cleaning/generation (1) in AIS_Shape.cxx
[occt.git] / src / XCAFPrs / XCAFPrs_AISObject.cxx
index a7bf6ce..69ed204 100755 (executable)
@@ -37,7 +37,6 @@
 #include <StdPrs_ShadedShape.hxx>
 #include <StdPrs_WFShape.hxx>
 #include <AIS_Drawer.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Quantity_Color.hxx>
 #include <Aspect_TypeOfLine.hxx>
@@ -261,10 +260,10 @@ void XCAFPrs_AISObject::AddStyledItem (const XCAFPrs_Style &style,
       Standard_Real prevcoeff ;
       Standard_Real newcoeff  ; 
       
-      if (OwnDeviationAngle(newangle,prevangle) ||
-         OwnDeviationCoefficient(newcoeff,prevcoeff))
-       if (Abs (newangle - prevangle) > Precision::Angular() ||
-           Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+      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)) { 
 #ifdef DEB
          cout << "AIS_Shape : compute"<<endl;
          cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
@@ -434,9 +433,7 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
   // dispatch (sub)shapes by their styles
   XCAFPrs_DataMapOfStyleShape items;
   XCAFPrs_Style DefStyle;
-  Quantity_Color White ( Quantity_NOC_WHITE );
-  DefStyle.SetColorSurf ( White );
-  DefStyle.SetColorCurv ( White );
+  DefaultStyle (DefStyle);
   XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle );
 #ifdef DEB
   //cout << "Dispatch done" << endl;
@@ -457,6 +454,7 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
     //i++;
 #endif
     if (! s.IsVisible() ) continue;
+    Prs3d_Root::NewGroup(aPrs);
     AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode );
   }
   
@@ -474,3 +472,14 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
   
   aPrs->ReCompute(); // for hidden line recomputation if necessary...
 }
+
+//=======================================================================
+//function : DefaultStyle
+//purpose  : DefaultStyle() can be redefined by subclasses in order to set custom default style
+//=======================================================================
+void XCAFPrs_AISObject::DefaultStyle (XCAFPrs_Style& aStyle) const
+{
+  static const Quantity_Color White ( Quantity_NOC_WHITE );
+  aStyle.SetColorSurf ( White );
+  aStyle.SetColorCurv ( White );
+}