0025142: Visualization breaks triangulation on shared solids in composite solid model
authorsan <san@opencascade.com>
Thu, 9 Oct 2014 09:37:56 +0000 (13:37 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 9 Oct 2014 09:39:25 +0000 (13:39 +0400)
Test case for 0025142: Visualization breaks triangulation on shared solids in composite solid model

Do not clean the triangulation in StdPrs_ShadedShape::Tessellate() and
let the triangulation tool process the sub-shapes properly.
Treat triangulation consistently in all AIS classes (AIS_Shape, AIS_TexturedShape).

Test cases for issue CR25142

src/AIS/AIS_TexturedShape.cxx
src/StdPrs/StdPrs_ShadedShape.cxx
tests/bugs/mesh/bug25142 [new file with mode: 0644]
tests/bugs/mesh/parse.rules [new file with mode: 0644]
tests/mesh/data/standard/M1

index d8659bc..49d7af1 100644 (file)
@@ -423,23 +423,26 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
       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 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)
       {
         StdPrs_WFDeflectionShape::Add (thePrs, myshape, myDrawer);
         break;
       }
+
       myDrawer->SetShadingAspectGlobal (Standard_False);
       if (IsInfinite())
       {
@@ -449,7 +452,19 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
       try
       {
         OCC_CATCH_SIGNALS
-        StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer);
+        if (theMode == AIS_Shaded)
+        {
+          StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer);
+        }
+        else
+        {
+          StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
+                                   Standard_True,
+                                   myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0),
+                                   myUVRepeat,
+                                   myToScale        ? myUVScale  : gp_Pnt2d (1.0, 1.0));
+          updateAttributes (thePrs);
+        }
       }
       catch (Standard_Failure)
       {
@@ -470,27 +485,5 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
       }
       break;
     }
-    case 3: // texture mapping on triangulation
-    {
-      BRepTools::Clean  (myshape);
-      BRepTools::Update (myshape);
-      try
-      {
-        OCC_CATCH_SIGNALS
-        StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
-                                 Standard_True,
-                                 myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0),
-                                 myUVRepeat,
-                                 myToScale        ? myUVScale  : gp_Pnt2d (1.0, 1.0));
-
-        updateAttributes (thePrs);
-      }
-      catch (Standard_Failure)
-      {
-        std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed\n";
-        StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
-      }
-      break;
-    }
   }
 }
index 2d47c6b..cfbb5eb 100644 (file)
@@ -459,7 +459,6 @@ void StdPrs_ShadedShape::Tessellate (const TopoDS_Shape&          theShape,
   }
 
   // retrieve meshing tool from Factory
-  BRepTools::Clean (theShape);
   Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
                                                                                    aDeflection,
                                                                                    theDrawer->HLRAngle());
diff --git a/tests/bugs/mesh/bug25142 b/tests/bugs/mesh/bug25142
new file mode 100644 (file)
index 0000000..462f19a
--- /dev/null
@@ -0,0 +1,47 @@
+puts "============"
+puts "CR25142"
+puts "============"
+puts ""
+###################################################################################
+# Visualization breaks triangulation on shared solids in composite solid model
+###################################################################################
+
+# make two adjacent boxes share their common face
+box b1 20 10 10
+box b2 10 10 10 
+
+bclear
+baddobjects b1 b2
+bfillds
+bbuild r
+explode r
+
+nbshapes r
+
+# do all possible checks of validity
+tolerance r
+checkshape r
+bopargcheck r #F
+bopargcheck r_1 r_2 -F #F
+
+# mesh one-by-one
+incmesh r_1 0.1
+tricheck r_1
+
+# note it will be Ok if we use the same deflection here, and bad otherwise...
+incmesh r_2 0.1
+tricheck r_2
+
+# now check again mesh on r_1
+tricheck r_1
+
+# now vdisplay solids separately causing their automatic re-mesh
+tclean r
+vinit View1
+vsetdispmode 1
+vdisplay r_1
+vdisplay r_2
+tricheck r_1
+
+vfit
+set only_screen 1
diff --git a/tests/bugs/mesh/parse.rules b/tests/bugs/mesh/parse.rules
new file mode 100644 (file)
index 0000000..b3cb21b
--- /dev/null
@@ -0,0 +1 @@
+FAILED /Not connected mesh inside face/ disconnected mesh
index 7b8db42..4599a50 100755 (executable)
@@ -1,3 +1 @@
 set TheFileName shading_109.brep
-set bug_cross "OCC22687"
-set nbcross(All) 4