From 1d441d1ac7633be161c180f7a96ecb43cabc870d Mon Sep 17 00:00:00 2001 From: skl Date: Mon, 10 Dec 2018 14:08:09 +0300 Subject: [PATCH] 0030402: Data Exchange - exported VRML file has broken location information --- src/VrmlData/VrmlData_ShapeConvert.cxx | 15 +++++--- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 3 ++ tests/bugs/xde/bug29597 | 2 +- tests/bugs/xde/bug30402 | 47 ++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 tests/bugs/xde/bug30402 diff --git a/src/VrmlData/VrmlData_ShapeConvert.cxx b/src/VrmlData/VrmlData_ShapeConvert.cxx index c3c8077a0a..eb717f0145 100644 --- a/src/VrmlData/VrmlData_ShapeConvert.cxx +++ b/src/VrmlData/VrmlData_ShapeConvert.cxx @@ -296,7 +296,8 @@ void VrmlData_ShapeConvert::Convert (const Standard_Boolean theExtractFaces, Handle(VrmlData_Group) aTrans = new VrmlData_Group (myScene, 0L, Standard_True); gp_Trsf aTrsf (aLoc); - if (fabs(myScale - 1.) > Precision::Confusion()) { + if (fabs(myScale - 1.) > Precision::Confusion()) + { const gp_XYZ aTransl = aTrsf.TranslationPart() * myScale; aTrsf.SetTranslationPart (aTransl); } @@ -704,7 +705,8 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent, gp_Trsf aTrsf(aLoc); if (fabs(myScale - 1.) > Precision::Confusion()) { - aTrsf.SetScaleFactor(myScale); + const gp_XYZ aTransl = aTrsf.TranslationPart() * myScale; + aTrsf.SetTranslationPart(aTransl); } aTrans->SetTransform(aTrsf); myScene.AddNode(aTrans, Standard_False); @@ -741,8 +743,10 @@ void VrmlData_ShapeConvert::addInstance (const Handle(VrmlData_Group)& theParent // Create a Transform grouping node aTrans = new VrmlData_Group(myScene, 0L, Standard_True); gp_Trsf aTrsf(aLoc); - if (fabs(myScale - 1.) > Precision::Confusion()) { - aTrsf.SetScaleFactor(myScale); + if (fabs(myScale - 1.) > Precision::Confusion()) + { + const gp_XYZ aTransl = aTrsf.TranslationPart() * myScale; + aTrsf.SetTranslationPart(aTransl); } aTrans->SetTransform(aTrsf); myScene.AddNode(aTrans, theParent.IsNull()); @@ -802,7 +806,8 @@ void VrmlData_ShapeConvert::addAssembly (const Handle(VrmlData_Group)& theParent if (!aLoc.IsIdentity()) { gp_Trsf aTrsf(aLoc); - if (fabs(myScale - 1.) > Precision::Confusion()) { + if (fabs(myScale - 1.) > Precision::Confusion()) + { const gp_XYZ aTransl = aTrsf.TranslationPart() * myScale; aTrsf.SetTranslationPart(aTransl); } diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index c42e9314c8..5f332bcea0 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -239,6 +240,8 @@ static Standard_Integer loadvrml } VrmlData_Scene aScene; + Standard_Real anOCCUnit = UnitsMethods::GetCasCadeLengthUnit(); + aScene.SetLinearScale(1000. / anOCCUnit); aScene.SetVrmlDir (aVrmlDir); aScene << aStream; diff --git a/tests/bugs/xde/bug29597 b/tests/bugs/xde/bug29597 index 867f742980..e8f2fde036 100644 --- a/tests/bugs/xde/bug29597 +++ b/tests/bugs/xde/bug29597 @@ -11,7 +11,7 @@ vdisplay -dispMode 1 v vfit set anArea [triarea v] -checkreal "Triangulation area" [lindex $anArea 0] 5341500. 1. 1e-6 +checkreal "Triangulation area" [lindex $anArea 0] 5341500. 1. 1e+6 checktrinfo v -tri 12 -nod 24 #vdump $::imagedir/${::casename}.png diff --git a/tests/bugs/xde/bug30402 b/tests/bugs/xde/bug30402 new file mode 100644 index 0000000000..c1a0c902be --- /dev/null +++ b/tests/bugs/xde/bug30402 @@ -0,0 +1,47 @@ +puts "=========" +puts "OCC30402" +puts "=========" +puts "" +############################################################################ +# Data Exchange - exported VRML file has broken location information +############################################################################ + +set filename bug26657 +param xstep.cascade.unit MM +ReadStep D [locate_data_file bug26657.stp] +XGetOneShape a D +incmesh a 0.001 +vinit Driver1/Viewer1/View1 +vdisplay a +vfit +vdump ${imagedir}/${test_image}_1.png + +file delete -force ${imagedir}/${filename}.wrl +WriteVrml D ${imagedir}/${filename}.wrl +loadvrml b ${imagedir}/${filename}.wrl +vinit Driver1/Viewer2/View1 +vdisplay b +vfit +vdump ${imagedir}/${test_image}_2.png + +set sprops_a [sprops a] +regexp {Mass\s*:\s*([0-9.e+-]+)} $sprops_a prop_s res_a_Area +regexp {X += +([-0-9.+eE]+)} $sprops_a full res_a_X +regexp {Y += +([-0-9.+eE]+)} $sprops_a full res_a_Y +regexp {Z += +([-0-9.+eE]+)} $sprops_a full res_a_Z + +set sprops_b [sprops b] +regexp {Mass\s*:\s*([0-9.e+-]+)} $sprops_b prop_s res_b_Area +regexp {X += +([-0-9.+eE]+)} $sprops_b full res_b_X +regexp {Y += +([-0-9.+eE]+)} $sprops_b full res_b_Y +regexp {Z += +([-0-9.+eE]+)} $sprops_b full res_b_Z + +if { ([expr abs($res_a_Area - $res_b_Area)] > 1.e-4) } { + puts "Error: Bad area of face" +} + +if { ([expr abs($res_a_X - $res_b_X)] > 1.e-4) || + ([expr abs($res_a_Y - $res_b_Y)] > 1.e-4) || + ([expr abs($res_a_Z - $res_b_Z)] > 1.e-4) } { + puts "Error: Location problem" +} -- 2.39.5