From: oan Date: Thu, 4 Aug 2016 08:25:16 +0000 (+0300) Subject: 0027583: Visualization, MeshVS - handle MeshVS_DA_SupressBackFaces flag within MeshVS... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7330772f97a2a09e78ec1b93ad4e15fb3b55ada4;p=occt-copy.git 0027583: Visualization, MeshVS - handle MeshVS_DA_SupressBackFaces flag within MeshVS_NodalColorPrsBuilder and within MeshVS_ElementalColorPrsBuilder builders. --- diff --git a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index c3b63ea345..316cee1892 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; @@ -452,6 +451,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& aFillAspect->SetEdgeOff(); aGGroup->SetPrimitivesAspect (aFillAspect); aGGroup->AddPrimitiveArray (aFaceTriangles); + aGGroup->SetClosed (toSupressBackFaces == Standard_True); if (anEdgeOn) { @@ -518,10 +518,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 ) @@ -638,6 +636,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 d83cc63628..e1264da9d5 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 "" +puts "Drawing mesh as closed object." 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] + +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 -vinit -meshfromstl aMesh [locate_data_file sh1.stl] -vsetdispmode aMesh 2 -vfront +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 + +for {set i 0} {$i < 5} {incr i} { meshclosed m$i 0 } +vdump ${imagedir}/${casename}_open.png + +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] -meshclosed aMesh 0 -vdump ${anImage1} +if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" != "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } { + puts "Error: capping color does not match" +} -meshclosed aMesh 1 -vdump ${anImage2} +vdump ${imagedir}/${casename}_closed.png