1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0026028: Option for drawing MeshVS_Mesh as closed object

MeshVS_MeshPrsBuilder::DrawArrays now sets IsClosed flag to group according to MeshVS_DA_SupressBackFaces attribute in MeshVS_Drawer
This commit is contained in:
dbv 2015-04-16 18:59:44 +03:00 committed by bugmaster
parent 74f91efccd
commit c3715b7477
3 changed files with 85 additions and 26 deletions

View File

@ -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 );
}
}

View File

@ -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 );

31
tests/bugs/vis/bug26028 Normal file
View File

@ -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}