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

0030630: Visualization - wrong visualization of shape with mirrored transformation

Solids with mirror location are displayed, according to their normals.

vaspects -setBackFaceColor, added command to set backface color.
This commit is contained in:
ika 2019-04-04 16:07:05 +03:00 committed by bugmaster
parent 7c08e3ac6e
commit 6b9b7e3c92
5 changed files with 161 additions and 2 deletions

View File

@ -208,7 +208,7 @@ namespace
aPoint = aNodes (aNodeIter);
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
if (aFace.Orientation() == TopAbs_REVERSED)
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aNorm.Reverse();
}
@ -237,7 +237,7 @@ namespace
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
if ((aFace.Orientation() == TopAbs_REVERSED))
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}

View File

@ -1762,6 +1762,8 @@ struct ViewerTest_AspectsChangeSet
Standard_Integer ToSetColor;
Quantity_Color Color;
Standard_Integer ToSetBackFaceColor;
Quantity_Color BackFaceColor;
Standard_Integer ToSetLineWidth;
Standard_Real LineWidth;
@ -1848,6 +1850,8 @@ struct ViewerTest_AspectsChangeSet
Visibility (1),
ToSetColor (0),
Color (DEFAULT_COLOR),
ToSetBackFaceColor(0),
BackFaceColor (DEFAULT_COLOR),
ToSetLineWidth (0),
LineWidth (1.0),
ToSetTypeOfLine (0),
@ -1909,6 +1913,7 @@ struct ViewerTest_AspectsChangeSet
&& ToSetTransparency == 0
&& ToSetAlphaMode == 0
&& ToSetColor == 0
&& ToSetBackFaceColor == 0
&& ToSetMaterial == 0
&& ToSetShowFreeBoundary == 0
&& ToSetFreeBoundaryColor == 0
@ -2143,6 +2148,15 @@ struct ViewerTest_AspectsChangeSet
theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
}
}
if (ToSetBackFaceColor != 0)
{
if (ToSetBackFaceColor != -1
|| theDrawer->HasOwnShadingAspect())
{
toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
theDrawer->ShadingAspect()->SetColor (BackFaceColor, Aspect_TOFM_BACK_SIDE);
}
}
if (ToSetAlphaMode != 0)
{
if (ToSetAlphaMode != -1
@ -2675,6 +2689,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
}
else if (anArg == "-setcolor"
|| anArg == "-color"
|| anArg == "-setbackfacecolor"
|| anArg == "-backfacecolor"
|| anArg == "-setbackcolor"
|| anArg == "-backcolor"
|| anArg == "-setfaceboundarycolor"
|| anArg == "-setboundarycolor"
|| anArg == "-faceboundarycolor"
@ -2704,6 +2722,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
aChangeSet->ToSetFaceBoundaryColor = 1;
aChangeSet->FaceBoundaryColor = aColor;
}
else if (anArg == "-setbackfacecolor"
|| anArg == "-backfacecolor"
|| anArg == "-setbackcolor"
|| anArg == "-backcolor")
{
aChangeSet->ToSetBackFaceColor = 1;
aChangeSet->BackFaceColor = aColor;
}
else
{
aChangeSet->ToSetColor = 1;
@ -3218,6 +3244,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
aChangeSet->AlphaCutoff = 0.5f;
aChangeSet->ToSetColor = -1;
aChangeSet->Color = DEFAULT_COLOR;
//aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor
//aChangeSet->BackFaceColor = DEFAULT_COLOR;
aChangeSet->ToSetMaterial = -1;
aChangeSet->Material = Graphic3d_NOM_DEFAULT;
aChangeSet->ToSetShowFreeBoundary = -1;
@ -6565,6 +6593,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
"\n\t\t: [-setVisibility 0|1]"
"\n\t\t: [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
"\n\t\t: [-setBackFaceColor Color]"
"\n\t\t: [-setMaterial MatName] [-unsetMaterial]"
"\n\t\t: [-setTransparency Transp] [-unsetTransparency]"
"\n\t\t: [-setWidth LineWidth] [-unsetWidth]"

48
tests/bugs/vis/bug30630_1 Normal file
View File

@ -0,0 +1,48 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that displaying of non-solid shapes (shells) is not affected by mirror transformation"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
explode b sh
renamevar b_1 b
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_simple.png
verase b
# Box with mirror transformation
box a 1 1 1
bmirror a 0 0 0 1 0 0
explode a sh
renamevar a_1 a
vdisplay -dispMode 1 a
vaspects a -setBackFaceColor RED
vfit
box aa -0.5 0.5 0.5 0.1 0.1 0.1
vdisplay -dispMode 1 aa
vsetcolor aa BLUE1
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 300 200 rgb name] != "RED2" } { puts "Error: shell of mirrored box should show back faces" }
verase a
# Box with mirror transformation and reversed face
box c 1 1 1
bmirror c 0 0 0 1 0 0
orientation c R
explode c sh
renamevar c_1 c
vdisplay -dispMode 1 c
vaspects c -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_mirrev.png
if { [vreadpixel 300 200 rgb name] == "RED2" } { puts "Error: shell of reversed mirrored box should show front faces" }

40
tests/bugs/vis/bug30630_2 Normal file
View File

@ -0,0 +1,40 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that local transformation of visualizated object"
puts "affects only position, not material place"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
bmirror b 0 0 0 0 0 1
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
box bb 0.5 0.5 -0.5 0.1 0.1 0.1
vdisplay -dispMode 1 bb
vsetcolor bb BLUE1
vfit
vdump $imagedir/${casename}_simple.png
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
# Box with rotation transformation
vlocation b -rotate 0 0 0 1 0 0 90
vlocation bb -rotate 0 0 0 1 0 0 90
vfit
vdump $imagedir/${casename}_rotate.png
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: rotated mirrored box should look inside out" }
# Box with mirror transformation
vlocation b -reset
vlocation b -mirror 0 -0.5 0 0 1 0
vlocation bb -reset
vlocation bb -mirror 0 -0.5 0 0 1 0
vfit
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: mirrored mirrored box should look inside out" }

42
tests/bugs/vis/bug30630_3 Normal file
View File

@ -0,0 +1,42 @@
puts "=================================================================================="
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
puts "Check that solid with mirrored transformation is displayed as turned out"
puts "=================================================================================="
pload MODELING VISUALIZATION
vclear
vinit View1
vaxo
vrotate 3 0 0
vcamera -persp
# Simple box
box b 1 1 1
vdisplay -dispMode 1 b
vaspects b -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_simple.png
verase b
# Box with mirror transformation
box a 1 1 1
bmirror a 0 0 0 1 0 0
vdisplay -dispMode 1 a
vaspects a -setBackFaceColor RED
vfit
box aa -0.5 0.5 0.5 0.1 0.1 0.1
vdisplay -dispMode 1 aa
vsetcolor aa BLUE1
vdump $imagedir/${casename}_mirror.png
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
verase a
# Box with mirror transformation and reversed face
box c 1 1 1
bmirror c 0 0 0 1 0 0
orientation c R
vdisplay -dispMode 1 c
vaspects c -setBackFaceColor RED
vfit
vdump $imagedir/${casename}_mirrev.png
if { [vreadpixel 195 220 rgb name] == "BLUE2" } { puts "Error: revered mirrored box should NOT look inside out" }