From: gka Date: Thu, 28 Nov 2013 06:30:32 +0000 (+0400) Subject: 0024390: Sewing produces the result with huge tolerance X-Git-Tag: V6_7_0~46 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=0221b126ee4161f037fbf1de791299e0c7bb6982 0024390: Sewing produces the result with huge tolerance Test cases for issue CR24390 --- diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx b/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx index 3631e8155c..115049b602 100755 --- a/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx +++ b/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx @@ -738,10 +738,11 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs if (whichSec == 1) itf2.Initialize(listFacesLast); else itf2.Initialize(listFacesFirst); Standard_Boolean isResEdge = Standard_False; + TopoDS_Face fac2; for (; itf2.More(); itf2.Next()) { Handle(Geom2d_Curve) c2d2, c2d21; Standard_Real firstOld, lastOld; - const TopoDS_Face& fac2 = TopoDS::Face(itf2.Value()); + fac2 = TopoDS::Face(itf2.Value()); surf2 = BRep_Tool::Surface(fac2, loc2); Standard_Boolean isSeam2 = ((IsUClosedSurface(surf2,edge2,loc2) || IsVClosedSurface(surf2,edge2,loc2)) && @@ -899,6 +900,7 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs { edge = s_edge; whichSec = whichSecn; + tolReached = tolReached_2; } } @@ -907,30 +909,42 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs GeomAdaptor_Curve c3dAdapt(c3d); // Discretize edge curve - Standard_Integer i, j, nbp = 15; + Standard_Integer i, j, nbp = 23; Standard_Real deltaT = (last3d - first3d) / (nbp + 1); TColgp_Array1OfPnt c3dpnt(1,nbp); - for (i = 1; i <= nbp; i++) c3dpnt(i) = c3dAdapt.Value(first3d + i*deltaT); + for (i = 1; i <= nbp; i++) + c3dpnt(i) = c3dAdapt.Value(first3d + i*deltaT); - Standard_Real u, v, dist, maxTol = -1.0; + Standard_Real dist = 0., maxTol = -1.0; Standard_Boolean more = Standard_True; + Standard_Boolean useFace = Standard_False; for (j = 1; more; j++) { Handle(Geom2d_Curve) c2d2; BRep_Tool::CurveOnSurface(edge, c2d2, surf2, loc2, first, last, j); + more = !c2d2.IsNull(); if (more) { + Handle(Geom_Surface) aS = surf2; + if(!loc2.IsIdentity()) + aS = Handle(Geom_Surface)::DownCast(surf2->Transformed ( loc2 )); + Standard_Real dist2 = 0.; deltaT = (last - first) / (nbp + 1); for (i = 1; i <= nbp; i++) { - c2d2->Value(first + i*deltaT).Coord(u,v); - dist = surf2->Value(u,v).Distance(c3dpnt(i)); - if (dist > maxTol) maxTol = dist; + gp_Pnt2d aP2d = c2d2->Value(first + i*deltaT); + gp_Pnt aP2(0.,0.,0.); + aS->D0(aP2d.X(),aP2d.Y(), aP2); + gp_Pnt aP1 = c3dpnt(i); + dist = aP2.SquareDistance(aP1); + if (dist > dist2) + dist2 = dist; } + maxTol = Max(sqrt(dist2), Precision::Confusion()); } } - - if (maxTol >= 0.) aBuilder.UpdateEdge(edge, maxTol); + if(maxTol >= 0. && maxTol < tolReached) + aBuilder.UpdateEdge(edge, maxTol); aBuilder.SameParameter(edge,Standard_True); } } diff --git a/tests/bugs/modalg_5/bug24390_1 b/tests/bugs/modalg_5/bug24390_1 new file mode 100755 index 0000000000..5d67f9c3ce --- /dev/null +++ b/tests/bugs/modalg_5/bug24390_1 @@ -0,0 +1,44 @@ +puts "========================" +puts "OCC24390" +puts "========================" +puts "" +####################################################################### +# Sewing produces the result with huge tolerance +####################################################################### + +pload XSDRAW + +restore [locate_data_file bug24390_face_0.brep] f1 +restore [locate_data_file bug24390_face_1.brep] f2 +restore [locate_data_file bug24390_face_2.brep] f3 +restore [locate_data_file bug24390_face_3.brep] f4 +restore [locate_data_file bug24390_face_4.brep] f5 +restore [locate_data_file bug24390_face_5.brep] f6 + +sewing result f1 f2 f3 f4 f5 f6 + +checkshape result + +set tolmax_f [tolmax f1] +regexp {max tol = ([-0-9.+eE]+)} ${tolmax_f} full CMP_TOL + +set face_list {f2 f3 f4 f5 f6} +foreach f ${face_list} { + set tolmax_f [tolmax ${f}] + regexp {max tol = ([-0-9.+eE]+)} ${tolmax_f} full FaceMaxTolerance + if { ${FaceMaxTolerance} > ${CMP_TOL} } { + set CMP_TOL ${FaceMaxTolerance} + } +} + +set CMP_TOL [expr 5. * ${CMP_TOL}] +puts "CMP_TOL=${CMP_TOL}" + +set tolmaxres [tolmax result] +regexp {max tol = ([-0-9.+eE]+)} ${tolmaxres} full MaxTolerance +puts "MaxTolerance=${MaxTolerance}" +if { ${MaxTolerance} > ${CMP_TOL} } { + puts "Error: invalid tolerance" +} + +set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug24390_2 b/tests/bugs/modalg_5/bug24390_2 new file mode 100755 index 0000000000..1fd96fccc8 --- /dev/null +++ b/tests/bugs/modalg_5/bug24390_2 @@ -0,0 +1,40 @@ +puts "========================" +puts "OCC24390" +puts "========================" +puts "" +####################################################################### +# Sewing produces the result with huge tolerance +####################################################################### + +pload XSDRAW + +restore [locate_data_file bug24390_face1.brep] f1 +restore [locate_data_file bug24390_face2.brep] f2 + +sewing result f1 f2 + +checkshape result + +set tolmax_f [tolmax f1] +regexp {max tol = ([-0-9.+eE]+)} ${tolmax_f} full CMP_TOL + +set face_list {f2} +foreach f ${face_list} { + set tolmax_f [tolmax ${f}] + regexp {max tol = ([-0-9.+eE]+)} ${tolmax_f} full FaceMaxTolerance + if { ${FaceMaxTolerance} > ${CMP_TOL} } { + set CMP_TOL ${FaceMaxTolerance} + } +} + +set CMP_TOL [expr 5. * ${CMP_TOL}] +puts "CMP_TOL=${CMP_TOL}" + +set tolmaxres [tolmax result] +regexp {max tol = ([-0-9.+eE]+)} ${tolmaxres} full MaxTolerance +puts "MaxTolerance=${MaxTolerance}" +if { ${MaxTolerance} > ${CMP_TOL} } { + puts "Error: invalid tolerance" +} + +set 2dviewer 1