From cde2e2f0ca17eafe20b8de6d186d874de9a87e4d Mon Sep 17 00:00:00 2001 From: kgv Date: Sat, 30 Jul 2016 17:05:32 +0300 Subject: [PATCH] 0027583: Visualization, MeshVS - handle MeshVS_DA_SupressBackFaces flag within MeshVS_NodalColorPrsBuilder and within MeshVS_ElementalColorPrsBuilder builders. --- .../MeshVS_ElementalColorPrsBuilder.cxx | 19 +++--- src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx | 7 +- tests/bugs/vis/bug26028 | 66 +++++++++++++------ 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index c246e845c7..ec08c90d56 100644 --- a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx @@ -185,6 +185,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Quantity_Color anEdgeColor, aLineColor; Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False, IsMeshSmoothShading = Standard_False; + Standard_Boolean toSupressBackFaces = Standard_False; aDrawer->GetColor ( MeshVS_DA_InteriorColor, anInteriorColor ); aDrawer->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor ); @@ -194,6 +195,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& aDrawer->GetBoolean( MeshVS_DA_ShowEdges, anEdgeOn ); aDrawer->GetBoolean( MeshVS_DA_ColorReflection, IsReflect ); aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading ); + aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces); if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) ) anEdgeType = (Aspect_TypeOfLine) anEdgeInt; @@ -256,12 +258,9 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& TColStd_PackedMapOfInteger aCustomElements; - Prs3d_Root::NewGroup ( Prs ); - Handle ( Graphic3d_Group ) aGGroup = Prs3d_Root::CurrentGroup ( Prs ); - Prs3d_Root::NewGroup ( Prs ); - Handle ( Graphic3d_Group ) aLGroup = Prs3d_Root::CurrentGroup ( Prs ); - Prs3d_Root::NewGroup ( Prs ); - Handle ( Graphic3d_Group ) aSGroup = Prs3d_Root::CurrentGroup ( Prs ); + Handle(Graphic3d_Group) aGGroup = Prs3d_Root::NewGroup (Prs); + Handle(Graphic3d_Group) aLGroup = Prs3d_Root::NewGroup (Prs); + Handle(Graphic3d_Group) aSGroup = Prs3d_Root::NewGroup (Prs); Standard_Integer aNbFacePrimitives = 0; Standard_Integer aNbVolmPrimitives = 0; @@ -448,6 +447,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& { aGGroup->SetPrimitivesAspect (aFillAspect); aGGroup->AddPrimitiveArray (aFaceTriangles); + aGGroup->SetClosed (toSupressBackFaces == Standard_True); if (anEdgeOn) { @@ -508,10 +508,8 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger aColIter2 ( aTwoColorsOfElements ); aColIter2.More(); aColIter2.Next() ) { - Prs3d_Root::NewGroup ( Prs ); - Handle ( Graphic3d_Group ) aGroup2 = Prs3d_Root::CurrentGroup ( Prs ); - Prs3d_Root::NewGroup ( Prs ); - Handle ( Graphic3d_Group ) aGroup3 = Prs3d_Root::CurrentGroup ( Prs ); + Handle(Graphic3d_Group) aGroup2 = Prs3d_Root::NewGroup (Prs); + Handle(Graphic3d_Group) aGroup3 = Prs3d_Root::NewGroup (Prs); Standard_Integer aSize = aColIter2.Value().Extent(); if ( aSize<=0 ) @@ -628,6 +626,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& } } + aGroup2->SetClosed (toSupressBackFaces == Standard_True); aGroup2->AddPrimitiveArray (aFaceTriangles); aGroup2->SetGroupPrimitivesAspect (anAsp); aGroup3->AddPrimitiveArray (anEdgeSegments); diff --git a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index e582c5470e..13593a8b4e 100644 --- a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -473,8 +473,11 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, Handle(Graphic3d_AspectLine3d) anLAsp = new Graphic3d_AspectLine3d( anEdgeColor, anEdgeType, anEdgeWidth ); - Prs3d_Root::NewGroup ( Prs ); - Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::CurrentGroup ( Prs ); + Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::NewGroup (Prs); + + Standard_Boolean toSupressBackFaces = Standard_False; + aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces); + aGroup1->SetClosed (toSupressBackFaces == Standard_True); aGroup1->SetPrimitivesAspect( anAsp ); aGroup1->AddPrimitiveArray( aFaceTriangles /*aCPolyArr*/ ); diff --git a/tests/bugs/vis/bug26028 b/tests/bugs/vis/bug26028 index 0c4f4292be..dd2f7a30c5 100644 --- a/tests/bugs/vis/bug26028 +++ b/tests/bugs/vis/bug26028 @@ -1,31 +1,55 @@ puts "=============" +puts "Drawing mesh as closed object." +puts "=============" puts "" -puts "=============" -puts "" - -############################################################################## -## Drawing mesh as closed object. -############################################################################## pload XDE -set anImage1 $imagedir/${casename}_Opened.png -set anImage2 $imagedir/${casename}_Closed.png +set aMeshFile [locate_data_file sh1.stl] -vinit -meshfromstl aMesh [locate_data_file sh1.stl] -vsetdispmode aMesh 2 -vfront +vclear +vinit View1 +vaxo + +meshfromstl m0 "$aMeshFile" +vsetdispmode m0 2 + +vsetlocation -noupdate m0 -100 0 0 +meshfromstl m1 "$aMeshFile" +meshcolors m1 elem1 0 +vsetlocation -noupdate m1 0 0 0 + +meshfromstl m2 "$aMeshFile" +meshcolors m2 elem2 0 +vsetlocation -noupdate m2 100 0 0 + +meshfromstl m3 "$aMeshFile" +meshcolors m3 nodal 1 +vsetlocation -noupdate m3 0 0 100 + +meshfromstl m4 "$aMeshFile" +meshcolors m4 nodaltex 1 +vsetlocation -noupdate m4 100 0 100 vfit -vclipplane create aClipPlane -vclipplane change aClipPlane equation 0 1 0 0 -vclipplane change aClipPlane capping on -vclipplane change aClipPlane capping color 0.9 0.9 0.9 -vclipplane set aClipPlane object aMesh +vclipplane create p +vclipplane change p equation 0 1 0 0 +vclipplane change p capping on +vclipplane change p capping color 0.9 0.9 0.9 +vclipplane set p view Driver1/Viewer1/View1 -meshclosed aMesh 0 -vdump ${anImage1} +for {set i 0} {$i < 5} {incr i} { meshclosed m$i 0 } +vdump ${imagedir}/${casename}_open.png -meshclosed aMesh 1 -vdump ${anImage2} +for {set i 0} {$i < 5} {incr i} { meshclosed m$i 1 } +set aColor0 [vreadpixel 125 200 rgb name] +set aColor1 [vreadpixel 225 300 rgb name] +set aColor2 [vreadpixel 325 325 rgb name] +set aColor3 [vreadpixel 225 150 rgb name] +set aColor4 [vreadpixel 325 200 rgb name] + +if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" != "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } { + puts "Error: capping color does not match" +} + +vdump ${imagedir}/${casename}_closed.png