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)) &&
{
edge = s_edge;
whichSec = whichSecn;
+ tolReached = tolReached_2;
}
}
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);
}
}
--- /dev/null
+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
--- /dev/null
+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