Fixed selection of sewing pairs of edges.
Mistake fix
Adding test case for this fix
         ProjectPointsOnCurve(ptsRef,c3d,first,last,arrDist,arrPara,arrProj,Standard_False);
       for( j = 1; j <= npt; j++ )
       {
-        if(arrDist(j) < 0. || arrDist(j) > myTolerance)
+        if(arrDist(j) < 0.)
           continue;
         if(dist < arrDist(j))
           dist = arrDist(j);
               }
             }
           }
-          if (distProj2 < worktol * worktol) {
+          if (distProj2 < worktol * worktol || !isConsiderEnds) {
             arrDist(i1) = sqrt (distProj2);
             arrPara(i1) = paramProj;
             arrProj(i1) = ptProj;
 
--- /dev/null
+puts "========================"
+puts "OCC23375"
+puts "========================" 
+puts ""
+#######################################################################
+# (OCC 6.5.3 regression) BRepBuilderAPI_Sewing returns wrong result
+#######################################################################
+
+restore [locate_data_file bug23375_Volute1.brep] v
+
+explode v
+sewing result 0.01 v_1 v_2
+
+checkshape result
+
+set tolmaxres [tolmax result]
+regexp {max tol = ([-0-9.+eE]+)} $tolmaxres full MaxTolerance
+set CMP_TOL 1.e-4
+if { ${MaxTolerance} > ${CMP_TOL} } {
+   puts "Error: invalid tolerance"
+}
+
+set 2dviewer 1
 
--- /dev/null
+puts "========================"
+puts "OCC23375"
+puts "========================" 
+puts ""
+#######################################################################
+# (OCC 6.5.3 regression) BRepBuilderAPI_Sewing returns wrong result
+#######################################################################
+
+restore [locate_data_file bug23375_Pump1.brep] p
+
+sewing result 0.1 p
+
+checkshape result
+
+set whatis_result [whatis result]
+
+if { [regexp {SHELL} ${whatis_result}] != 1 } {
+  puts "Error: invalid result shape; SHELL"
+}
+if { [regexp {FORWARD} ${whatis_result}] != 1 } {
+  puts "Error: invalid result shape; FORWARD"
+}
+if { [regexp {Modified} ${whatis_result}] != 1 } {
+  puts "Error: invalid result shape; Modified"
+}
+if { [regexp {Orientable} ${whatis_result}] != 1 } {
+  puts "Error: invalid result shape; Orientable"
+}
+if { [regexp {Closed} ${whatis_result}] != 1 } {
+  puts "Error: invalid result shape; Closed"
+}
+
+set 2dviewer 1