]> OCCT Git - occt-copy.git/commitdiff
0023501: Redundant triangulation cleaning/generation (1) in AIS_Shape.cxx
authorPawel <pawel-kowalski@wp.pl>
Thu, 6 Jun 2013 06:13:30 +0000 (10:13 +0400)
committerPawel <pawel-kowalski@wp.pl>
Thu, 6 Jun 2013 06:13:30 +0000 (10:13 +0400)
Cleaning triangulation only if the AIS_Shape has either (1) OwnDeviationAngle and
the values 'newangle' and 'prevangle' are different or (2) OwnDeviationCoefficient and the values 'newcoeff' and 'prevcoeff' are different
Found similar problems in further code portions and corrected them.
The same faulty condition found in XCAFPrs_AISObject.cxx

src/AIS/AIS_Shape.cxx
src/AIS/AIS_TexturedShape.cxx
src/XCAFPrs/XCAFPrs_AISObject.cxx

index 01cf77f01a0576e6853d92033ef2fd05b5c984d5..1c4327b405272ca716dcb7748486443d64c11a2b 100755 (executable)
@@ -225,18 +225,17 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
       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;
-          cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
+        cout << "AIS_Shape : compute"<<endl;
+        cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
+        cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
 #endif
-          BRepTools::Clean(myshape);
-        }
+        BRepTools::Clean(myshape);
+      }
       
       //shading only on face...
       if ((Standard_Integer) myshape.ShapeType()>4)
@@ -326,9 +325,10 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
 // coefficients for calculation
 
   Standard_Real prevangle, newangle ,prevcoeff,newcoeff ; 
-  if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
-    if (Abs (newangle - prevangle) > Precision::Angular() ||
-        Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+  Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle(newangle,prevangle);
+  Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
+  if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
+      ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
 #ifdef DEB
       cout << "AIS_Shape : compute"<<endl;
       cout << "newangle  : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
index 600eef83ff67c7ad7a062afdf7fa2765c02f0b4a..a7bdc87a229f2eebab90b19c41e1972b3cb7ddc4 100755 (executable)
@@ -273,12 +273,11 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
       Standard_Real prevcoeff;
       Standard_Real newcoeff;
 
-      if (OwnDeviationAngle (newangle, prevangle) || OwnDeviationCoefficient (newcoeff, prevcoeff))
-      {
-        if (Abs (newangle - prevangle) > Precision::Angular() || Abs (newcoeff - prevcoeff) > Precision::Confusion())
-        {
-          BRepTools::Clean (myshape);
-        }
+      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);
       }
       if (myshape.ShapeType() > TopAbs_FACE)
       {
index 4e579b928f1874b88b8fc481ff4122c75b1f3e4c..69ed2045c0eda750aac035de7bb0cbf0a2f120d0 100755 (executable)
@@ -260,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;