diff --git a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx index 2553dddfbd..1d1dffa582 100644 --- a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx @@ -1060,6 +1060,13 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, theFillAsp->Values( aStyle, anIntColor, aBackColor, anEdgeColor, aType, aWidth ); + Standard_Boolean isSupressBackFaces = Standard_False; + Handle(MeshVS_Drawer) aDrawer = GetDrawer(); + if (!aDrawer.IsNull()) + { + aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, isSupressBackFaces); + } + if ( IsPolygons && theFillAsp->FrontMaterial().Transparency()<0.01 ) { Prs3d_Root::NewGroup ( Prs ); @@ -1075,26 +1082,21 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, else theFillAsp->SetDistinguishOff(); + aGroup->SetClosed (isSupressBackFaces); + Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->())); + if (isSupressBackFaces) + { + aFillAsp->SuppressBackFace(); + } + aGroup->SetPrimitivesAspect (aFillAsp); + if( IsFacePolygons ) { - aGroup->SetPrimitivesAspect ( theFillAsp ); aGroup->AddPrimitiveArray ( thePolygons ); } if( IsVolumePolygons ) { - Handle( Graphic3d_AspectFillArea3d ) aCullFillAsp = - new Graphic3d_AspectFillArea3d( *( theFillAsp.operator->() ) ); - - Standard_Boolean isSupressBackFaces = Standard_False; - Handle( MeshVS_Drawer ) aDrawer = GetDrawer(); - if (!aDrawer.IsNull()) - aDrawer->GetBoolean ( MeshVS_DA_SupressBackFaces, isSupressBackFaces ); - - if (isSupressBackFaces) - aCullFillAsp->SuppressBackFace(); - - aGroup->SetPrimitivesAspect ( aCullFillAsp ); aGroup->AddPrimitiveArray ( theVolumesInShad ); } } @@ -1145,26 +1147,21 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, else theFillAsp->SetDistinguishOff(); + aGroup->SetClosed (isSupressBackFaces); + Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->())); + if (isSupressBackFaces) + { + aFillAsp->SuppressBackFace(); + } + aGroup->SetPrimitivesAspect (aFillAsp); + if( IsFacePolygons ) { - aGroup->SetPrimitivesAspect ( theFillAsp ); aGroup->AddPrimitiveArray ( thePolygons ); } if( IsVolumePolygons ) { - Handle( Graphic3d_AspectFillArea3d ) aCullFillAsp = - new Graphic3d_AspectFillArea3d( *( theFillAsp.operator->() ) ); - - Standard_Boolean isSupressBackFaces = Standard_False; - Handle( MeshVS_Drawer ) aDrawer = GetDrawer(); - if (!aDrawer.IsNull()) - aDrawer->GetBoolean ( MeshVS_DA_SupressBackFaces, isSupressBackFaces ); - - if (isSupressBackFaces) - aCullFillAsp->SuppressBackFace(); - - aGroup->SetPrimitivesAspect ( aCullFillAsp ); aGroup->AddPrimitiveArray ( theVolumesInShad ); } } diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 548e029b11..9cdfc22efd 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -472,6 +472,36 @@ static Standard_Integer shrink } return 0; } + +//----------------------------------------------------------------------------- +static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv) +{ + if (theArgc < 3) + { + theDI << "Wrong number of parameters." << "\n"; + } + else + { + Handle(MeshVS_Mesh) aMesh = getMesh (theArgv[1], theDI); + if (!aMesh.IsNull()) + { + Standard_Integer aFlag = Draw::Atoi (theArgv[2]); + aMesh->GetDrawer()->SetBoolean (MeshVS_DA_SupressBackFaces, aFlag); + + Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + theDI << "The context is null" << "\n"; + } + else + { + aContext->Redisplay (aMesh); + } + } + } + return 0; +} + //----------------------------------------------------------------------------- static Standard_Integer mdisplay @@ -1219,6 +1249,7 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands) theCommands.Add ("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, g ); theCommands.Add ("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, g ); theCommands.Add ("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, g ); + theCommands.Add ("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g); theCommands.Add ("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, g ); theCommands.Add ("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, g ); theCommands.Add ("meshhidesel", "hide selected entities", __FILE__, hidesel, g ); diff --git a/tests/bugs/vis/bug26028 b/tests/bugs/vis/bug26028 new file mode 100644 index 0000000000..07c0e763ba --- /dev/null +++ b/tests/bugs/vis/bug26028 @@ -0,0 +1,31 @@ +puts "=============" +puts "" +puts "=============" +puts "" + +############################################################################## +## Drawing mesh as closed object. +############################################################################## + +pload XDE + +set anImage1 $imagedir/${casename}_Opened.png +set anImage2 $imagedir/${casename}_Closed.png + +vinit +meshfromstl aMesh [locate_data_file sh1.stl] +vsetdispmode aMesh 2 +vright +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 + +meshclosed aMesh 0 +vdump ${anImage1} + +meshclosed aMesh 1 +vdump ${anImage2}