From 3e98579a83407ad735edb508446ff3ed761e3c8c Mon Sep 17 00:00:00 2001 From: jgv Date: Mon, 19 Oct 2020 04:18:16 +0300 Subject: [PATCH] 0031855: Modeling Algorithms - regression of the unifysamedom command. Transformation of 2d-curves on elementary surfaces has been corrected. --- .../ShapeUpgrade_UnifySameDomain.cxx | 47 ++++++++++++++----- tests/bugs/heal/bug31855_1 | 19 ++++++++ tests/bugs/heal/bug31855_2 | 19 ++++++++ tests/bugs/heal/bug31855_3 | 19 ++++++++ 4 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 tests/bugs/heal/bug31855_1 create mode 100644 tests/bugs/heal/bug31855_2 create mode 100644 tests/bugs/heal/bug31855_3 diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index 86b2527d5b..c18089346e 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -854,9 +854,13 @@ static void TransformPCurves(const TopoDS_Face& theRefFace, SurfFace = (Handle(Geom_RectangularTrimmedSurface)::DownCast(SurfFace))->BasisSurface(); Standard_Boolean ToModify = Standard_False, - ToTranslate = Standard_False, Y_Reverse = Standard_False, ToProject = Standard_False; + ToTranslate = Standard_False, + ToRotate = Standard_False, + X_Reverse = Standard_False, + Y_Reverse = Standard_False, + ToProject = Standard_False; - gp_Vec2d Translation(0.,0.); + Standard_Real aTranslation = 0., anAngle = 0.; //Get axes of surface of face and of surface of RefFace Handle(Geom_ElementarySurface) ElemSurfFace = Handle(Geom_ElementarySurface)::DownCast(SurfFace); @@ -872,27 +876,37 @@ static void TransformPCurves(const TopoDS_Face& theRefFace, Standard_Real aParam = ElCLib::LineParameter(AxisOfSurfFace.Axis(), OriginRefSurf); if (Abs(aParam) > Precision::PConfusion()) - Translation.SetY(-aParam); + aTranslation = -aParam; gp_Dir VdirSurfFace = AxisOfSurfFace.Direction(); gp_Dir VdirRefSurf = AxisOfRefSurf.Direction(); gp_Dir XdirSurfFace = AxisOfSurfFace.XDirection(); gp_Dir XdirRefSurf = AxisOfRefSurf.XDirection(); - Standard_Real anAngle = XdirRefSurf.AngleWithRef(XdirSurfFace, VdirRefSurf); - if (!AxisOfRefSurf.Direct()) - anAngle *= -1; - - if (Abs(anAngle) > Precision::PConfusion()) - Translation.SetX(anAngle); + gp_Dir CrossProd1 = AxisOfRefSurf.XDirection() ^ AxisOfRefSurf.YDirection(); + gp_Dir CrossProd2 = AxisOfSurfFace.XDirection() ^ AxisOfSurfFace.YDirection(); + if (CrossProd1 * CrossProd2 < 0.) + X_Reverse = Standard_True; Standard_Real ScalProd = VdirSurfFace * VdirRefSurf; if (ScalProd < 0.) Y_Reverse = Standard_True; - ToTranslate = !(Translation.XY().IsEqual(gp_XY(0.,0.), Precision::PConfusion())); + if (!X_Reverse && !Y_Reverse) + { + gp_Dir DirRef = VdirRefSurf; + if (!AxisOfRefSurf.Direct()) + DirRef.Reverse(); + anAngle = XdirRefSurf.AngleWithRef(XdirSurfFace, DirRef); + } + else + anAngle = XdirRefSurf.Angle(XdirSurfFace); - ToModify = ToTranslate || Y_Reverse; + ToRotate = (Abs(anAngle) > Precision::PConfusion()); + + ToTranslate = (Abs(aTranslation) > Precision::PConfusion()); + + ToModify = ToTranslate || ToRotate || X_Reverse || Y_Reverse; } else { @@ -933,9 +947,16 @@ static void TransformPCurves(const TopoDS_Face& theRefFace, aNewPCurve = Handle(Geom2d_Curve)::DownCast(aPCurve->Copy()); } if (ToTranslate) - aNewPCurve->Translate(Translation); + aNewPCurve->Translate(gp_Vec2d(0., aTranslation)); if (Y_Reverse) aNewPCurve->Mirror(gp::OX2d()); + if (X_Reverse) + { + aNewPCurve->Mirror(gp::OY2d()); + aNewPCurve->Translate(gp_Vec2d(2*M_PI, 0.)); + } + if (ToRotate) + aNewPCurve->Translate(gp_Vec2d(anAngle, 0.)); theMapEdgesWithTemporaryPCurves.Add(anEdge); @@ -2256,7 +2277,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape // surface and location to construct result TopLoc_Location aBaseLocation; - Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); + Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace); aBaseSurface = ClearRts(aBaseSurface); TopAbs_Orientation RefFaceOrientation = aFace.Orientation(); diff --git a/tests/bugs/heal/bug31855_1 b/tests/bugs/heal/bug31855_1 new file mode 100644 index 0000000000..724cbdc703 --- /dev/null +++ b/tests/bugs/heal/bug31855_1 @@ -0,0 +1,19 @@ +puts "=================================================" +puts "OCC31855: Regression of the unifysamedom command." +puts "=================================================" +puts "" + +restore [locate_data_file bug31855_1.brep] a +unifysamedom result a + +checkshape result + +checknbshapes result -vertex 89 -edge 134 -wire 47 -face 47 -shell 1 -solid 1 + +set tolres [checkmaxtol result] + +if { ${tolres} > 0.0006} { + puts "Error: bad tolerance of result" +} + +checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/heal/bug31855_2 b/tests/bugs/heal/bug31855_2 new file mode 100644 index 0000000000..33d2aa97ea --- /dev/null +++ b/tests/bugs/heal/bug31855_2 @@ -0,0 +1,19 @@ +puts "=================================================" +puts "OCC31855: Regression of the unifysamedom command." +puts "=================================================" +puts "" + +restore [locate_data_file bug31855_2.brep] a +unifysamedom result a + +checkshape result + +checknbshapes result -vertex 664 -edge 996 -wire 484 -face 406 -shell 1 -solid 1 + +set tolres [checkmaxtol result] + +if { ${tolres} > 2.e-7} { + puts "Error: bad tolerance of result" +} + +checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/heal/bug31855_3 b/tests/bugs/heal/bug31855_3 new file mode 100644 index 0000000000..f8517e43dd --- /dev/null +++ b/tests/bugs/heal/bug31855_3 @@ -0,0 +1,19 @@ +puts "=================================================" +puts "OCC31855: Regression of the unifysamedom command." +puts "=================================================" +puts "" + +restore [locate_data_file bug31855_3.brep] a +unifysamedom result a + +checkshape result + +checknbshapes result -vertex 272 -edge 408 -wire 150 -face 143 -shell 1 -solid 1 + +set tolres [checkmaxtol result] + +if { ${tolres} > 2.e-7} { + puts "Error: bad tolerance of result" +} + +checkview -display result -2d -path ${imagedir}/${test_image}.png