// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
+
// dcl CCI60011 : Correction of degeneratedSection
// Improvement of SameParameter Edge to treat case of failure in BRepLib::SameParameter
// dcl Thu Aug 20 09:24:49 1998
// Retrieve second PCurves
TopLoc_Location loc2;
Handle(Geom_Surface) surf2;
+
//Handle(Geom2d_Curve) c2d2, c2d21;
// Standard_Real firstOld, lastOld;
TopLoc_Location loc1;
Handle(Geom_Surface) surf1 = BRep_Tool::Surface(fac1, loc1);
+
Standard_Real first2d, last2d;
Standard_Boolean isSeam1 = ((IsUClosedSurface(surf1,edge1,loc1) || IsVClosedSurface(surf1,edge1,loc1)) &&
BRep_Tool::IsClosed(TopoDS::Edge(edge1),fac1));
}
}
- if(isResEdge)
- // Try to make the edge sameparameter
+ Standard_Real tolReached = Precision::Infinite();
+ Standard_Boolean isSamePar = Standard_False;
+ if( isResEdge)
+ {
SameParameter(edge);
-
- // Standard_Real tolReached = BRep_Tool::Tolerance(edge);
- //if (!BRep_Tool::SameParameter(edge)) return edge; //gka ????????
-
- if (firstCall && (!BRep_Tool::SameParameter(edge) || !isResEdge)) {
+ if( BRep_Tool::SameParameter(edge))
+ {
+ isSamePar = Standard_True;
+ tolReached = BRep_Tool::Tolerance(edge);
+ }
+ }
+
+
+ if (firstCall && ( !isResEdge || !isSamePar || tolReached > myTolerance)) {
Standard_Integer whichSecn = whichSec;
// Try to merge on the second section
- Standard_Boolean second_ok = Standard_True;
+ Standard_Boolean second_ok = Standard_False;
TopoDS_Edge s_edge = SameParameterEdge(edgeFirst,edgeLast,listFacesFirst,listFacesLast,
secForward,whichSecn,Standard_False);
- //if (s_edge.IsNull()) return s_edge; // gka version for free edges
- if (s_edge.IsNull()) second_ok = Standard_False;
- else if (!BRep_Tool::SameParameter(s_edge)) second_ok = Standard_False;
- else {
- edge = s_edge;
- whichSec = whichSecn;
+ if( !s_edge.IsNull())
+ {
+ Standard_Real tolReached_2 = BRep_Tool::Tolerance(s_edge);
+ second_ok = ( BRep_Tool::SameParameter(s_edge) && tolReached_2 < tolReached );
+ if( second_ok)
+ {
+ edge = s_edge;
+ whichSec = whichSecn;
+ }
}
- if (!second_ok) {
+ if (!second_ok && !edge.IsNull()) {
GeomAdaptor_Curve c3dAdapt(c3d);
Extrema_ExtPC locProj;
locProj.Initialize(GAC, first, last);
gp_Pnt pfirst = GAC.Value(first), plast = GAC.Value(last);
-
- for (Standard_Integer i1 = 1; i1 <= arrPnt.Length(); i1++) {
+ Standard_Integer find = 1;//(isConsiderEnds ? 1 : 2);
+ Standard_Integer lind = arrPnt.Length();//(isConsiderEnds ? arrPnt.Length() : arrPnt.Length() -1);
+
+ for (Standard_Integer i1 = find; i1 <= lind ; i1++) {
gp_Pnt pt = arrPnt(i1);
Standard_Real worktol = myTolerance;
Standard_Real distF2 = pfirst.SquareDistance(pt);
// Project current point on curve
locProj.Perform(pt);
if (locProj.IsDone() && locProj.NbExt() > 0) {
- Standard_Real dist2Min = Min(distF2,distL2);
+ Standard_Real dist2Min = (isConsiderEnds || i1 == find || i1 == lind ? Min(distF2,distL2) : Precision::Infinite());
Standard_Integer ind, indMin = 0;
for (ind = 1; ind <= locProj.NbExt(); ind++) {
Standard_Real dProj2 = locProj.SquareDistance(ind);
--- /dev/null
+puts "========================"
+puts "OCC24174"
+puts "========================"
+puts ""
+#######################################################################
+# [regression] BRepBuilderAPI_Sewing returns result with very high tolerance
+#######################################################################
+
+pload XSDRAW
+
+restore [locate_data_file bug24174_Comp1.brep] a
+
+explode a
+sewing result 0.1 a_1 a_2
+
+# 0
+set log_1 [tolmax a_1]
+regexp {max tol = ([-0-9.+eE]+)} ${log_1} full MaxTolerance_a_1
+set log_2 [tolmax a_2]
+regexp {max tol = ([-0-9.+eE]+)} ${log_2} full MaxTolerance_a_2
+set CMP_TOL ${MaxTolerance_a_1}
+if { ${MaxTolerance_a_2} > ${CMP_TOL} } {
+ set CMP_TOL ${MaxTolerance_a_2}
+}
+
+# 1
+checkshape result
+
+# 2
+set log_3 [tolmax result]
+regexp {max tol = ([-0-9.+eE]+)} ${log_3} full MaxTolerance_result
+if { ${MaxTolerance_result} > ${CMP_TOL} } {
+ puts "Error: invalid tolerance"
+}
+
+# 3
+freebounds ${result} 0
+set s [explode result_c e]
+
+set Number [ llength ${s} ]
+puts "Number of free edges is ${Number}"
+set Number_Free_Edges 12
+if { ${Number} != ${Number_Free_Edges} } {
+ puts "Error : Number of free edges is ${Number}"
+}
+
+set 2dviewer 1
--- /dev/null
+puts "========================"
+puts "OCC24174"
+puts "========================"
+puts ""
+#######################################################################
+# [regression] BRepBuilderAPI_Sewing returns result with very high tolerance
+#######################################################################
+
+pload XSDRAW
+
+restore [locate_data_file bug24174_stitch.brep] a
+
+sewing result 0.1 a
+
+# 0
+set log_1 [tolmax a]
+regexp {max tol = ([-0-9.+eE]+)} ${log_1} full MaxTolerance_a
+set CMP_TOL ${MaxTolerance_a}
+
+# 1
+checkshape result
+
+# 2
+set log_2 [tolmax result]
+regexp {max tol = ([-0-9.+eE]+)} ${log_2} full MaxTolerance_result
+if { ${MaxTolerance_result} > ${CMP_TOL} } {
+ puts "Error: invalid tolerance"
+}
+
+# 3
+freebounds $result 0
+set s [explode result_c e]
+
+set Number [ llength ${s} ]
+puts "Number of free edges is ${Number}"
+set Number_Free_Edges 9
+if { ${Number} != ${Number_Free_Edges} } {
+ puts "Error : Number of free edges is ${Number}"
+}
+
+set 2dviewer 1