0025861: Wrong result obtained by projection algorithm.
authoraml <aml@opencascade.com>
Thu, 5 Mar 2015 11:56:28 +0000 (14:56 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 5 Mar 2015 12:48:45 +0000 (15:48 +0300)
Handling of trimmed analytical surfaces added in extrema PS.

New draw-command and test case for issue CR25861

Correction of test case for issue CR25861

src/Extrema/Extrema_ExtPS.cxx
src/QABugs/QABugs_19.cxx
tests/bugs/moddata_3/bug25861 [new file with mode: 0644]

index e845275..37926ae 100644 (file)
@@ -110,10 +110,22 @@ void Extrema_ExtPS::TreatSolution (const Extrema_POnSurf& PS,
   Standard_Real U, V;
   PS.Parameter(U, V);
   if (myS->IsUPeriodic()) {
-    U = ElCLib::InPeriod(U, myuinf, myuinf+myS->UPeriod());
+    U = ElCLib::InPeriod(U, myuinf, myuinf + myS->UPeriod());
+    
+    // Handle trimmed surfaces.
+    if (U > myusup + mytolu)
+      U -= myS->UPeriod();
+    if (U < myuinf - mytolu)
+      U += myS->UPeriod();
   }
   if (myS->IsVPeriodic()) {
-    V = ElCLib::InPeriod(V, myvinf, myvinf+myS->VPeriod());
+    V = ElCLib::InPeriod(V, myvinf, myvinf + myS->VPeriod());
+
+    // Handle trimmed surfaces.
+    if (V > myvsup + mytolv)
+      V -= myS->VPeriod();
+    if (V < myvinf - mytolv)
+      V += myS->VPeriod();
   }
   if ((myuinf-U) <= mytolu && (U-myusup) <= mytolu &&
       (myvinf-V) <= mytolv && (V-myvsup) <= mytolv) {
index bac962b..ad9b45d 100755 (executable)
@@ -3551,6 +3551,57 @@ static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg ,
   return 0;
 }
 
+#include <IntTools_Context.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+
+//=======================================================================
+//function : xprojponf
+//purpose  : 
+//=======================================================================
+Standard_Integer xprojponf (Draw_Interpretor& di, 
+                            Standard_Integer n, 
+                            const char** a)
+{
+  if (n!=3) {
+    di<<" use xprojponf p f \n";
+    return 0;
+  }
+  // 
+  gp_Pnt aP, aPS;
+  TopoDS_Shape aS;
+  TopoDS_Face aF;
+  Handle(IntTools_Context) aCtx;
+  //
+  DrawTrSurf::GetPoint(a[1], aP);
+  aS=DBRep::Get(a[2]);
+  //
+  if (aS.IsNull()) {
+    di<<" null shape is not allowed\n";
+    return 0;
+  }
+  //
+  if (aS.ShapeType()!=TopAbs_FACE) {
+    di << a[2] << " not a face\n";
+    return 0;
+  }
+  //
+  aCtx=new IntTools_Context;
+  //
+  aF=TopoDS::Face(aS);
+  GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
+  //
+  aPPS.Perform(aP);
+  if (!aPPS.IsDone()) {
+    di<<" projection failed\n";
+    return 0;
+  }
+  //
+  aPS=aPPS.NearestPoint();
+  di<< " point px " << aPS.X() << " " << aPS.Y() << " " <<  aPS.Z() << "\n";
+  //
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3619,5 +3670,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
                    __FILE__, OCC25545, group);
   theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
   theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
+  theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
   return;
 }
diff --git a/tests/bugs/moddata_3/bug25861 b/tests/bugs/moddata_3/bug25861
new file mode 100644 (file)
index 0000000..a09e567
--- /dev/null
@@ -0,0 +1,34 @@
+puts "================"
+puts "OCC25861"
+puts "================"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+pload QAcommands
+
+restore [locate_data_file bug25861_f3.brep] f3
+
+point p 6.9184976310066668 -24.127668568051799 8.6427835999999978
+
+set info [xprojponf p f3]
+
+if { [regexp {point px +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} ${info} string x2 y2 z2] != 1 } {
+    puts "Error: Wrong result obtained by projection algorithm"
+} else {
+    puts "OK: Good result obtained by projection algorithm"
+
+    vertex v1 p
+    vertex v2 ${x2} ${y2} ${z2}
+
+    set CMP_TOL 1.0e-7
+    distmini res v1 v2
+    set distmin [dval res_val]
+    if { [expr abs(${distmin})] > ${CMP_TOL} } {
+       puts "Error: Wrong projection point"
+    } else {
+       puts "OK: Good projection point"
+    }
+
+}