From 50b830a09b86922078523f4f50ead50fbb599a25 Mon Sep 17 00:00:00 2001 From: san Date: Thu, 9 Oct 2014 13:37:56 +0400 Subject: [PATCH] 0025142: Visualization breaks triangulation on shared solids in composite solid model 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 | 41 +++++++++++---------------- src/StdPrs/StdPrs_ShadedShape.cxx | 1 - tests/bugs/mesh/bug25142 | 47 +++++++++++++++++++++++++++++++ tests/bugs/mesh/parse.rules | 1 + tests/mesh/data/standard/M1 | 2 -- 5 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 tests/bugs/mesh/bug25142 create mode 100644 tests/bugs/mesh/parse.rules diff --git a/src/AIS/AIS_TexturedShape.cxx b/src/AIS/AIS_TexturedShape.cxx index d8659bc6c1..49d7af1336 100644 --- a/src/AIS/AIS_TexturedShape.cxx +++ b/src/AIS/AIS_TexturedShape.cxx @@ -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; - } } } diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index 2d47c6b4bd..cfbb5eb6cf 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -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 index 0000000000..462f19ac81 --- /dev/null +++ b/tests/bugs/mesh/bug25142 @@ -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 index 0000000000..b3cb21b22b --- /dev/null +++ b/tests/bugs/mesh/parse.rules @@ -0,0 +1 @@ +FAILED /Not connected mesh inside face/ disconnected mesh diff --git a/tests/mesh/data/standard/M1 b/tests/mesh/data/standard/M1 index 7b8db42a61..4599a50ab8 100755 --- a/tests/mesh/data/standard/M1 +++ b/tests/mesh/data/standard/M1 @@ -1,3 +1 @@ set TheFileName shading_109.brep -set bug_cross "OCC22687" -set nbcross(All) 4