0023765: The result of section operation contains redundant vertex.
authorpkv <pkv@opencascade.com>
Wed, 17 Apr 2013 11:29:29 +0000 (15:29 +0400)
committerpkv <pkv@opencascade.com>
Wed, 17 Apr 2013 11:29:29 +0000 (15:29 +0400)
Adding test case for this fix
Modified test cases regarding to 23765

src/Draft/Draft_Modification.cxx
src/IntTools/IntTools_LineConstructor.cxx
tests/bugs/modalg_4/bug23765 [new file with mode: 0755]
tests/bugs/moddata_2/bug23576
tests/bugs/moddata_3/bug23738

index e72fe8d..6033694 100755 (executable)
@@ -58,6 +58,7 @@
 #include <Precision.hxx>
 
 #include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
 
 //=======================================================================
 //function : Draft_Modification
@@ -422,23 +423,34 @@ Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E,
              (typs == STANDARD_TYPE(Geom_ConicalSurface));
 
   if ( JeRecadre) {
-    gp_Pnt2d PF,PL;
-    BRep_Tool::UVPoints(E,F,PF,PL);
-    gp_Pnt2d NewPF = C->Value(Fp);
-    gp_Vec2d vectra(2.*M_PI,0.);
-
-    if (NewPF.Translated(vectra).SquareDistance(PF) 
-       < NewPF.SquareDistance(PF)) {
-      C->Translate(vectra);
-      
+    Standard_Boolean bTranslate;
+    Standard_Real aD2, aT1, aT2;
+    gp_Pnt2d  PF, NewPF, aP2DT;
+    gp_Vec2d aV2DT, vectra(2.*M_PI,0.);
+    Handle(Geom2d_Curve) aC2DE;
+    //
+    aC2DE=BRep_Tool::CurveOnSurface(E, F, aT1, aT2);
+    //
+    PF=aC2DE->Value(0.5*(aT1+aT2));
+    //
+    NewPF=C->Value(0.5*(Fp+Lp));
+    //
+    aD2=NewPF.SquareDistance(PF);
+    //
+    bTranslate=Standard_False;
+    if (NewPF.Translated(vectra).SquareDistance(PF) < aD2) {
+      aV2DT=vectra;
+      bTranslate=!bTranslate; //True
     }
-    else if (NewPF.Translated(-vectra).SquareDistance(PF) 
-            < NewPF.SquareDistance(PF)) {
-      C->Translate(-vectra);
-      
+    else if (NewPF.Translated(-vectra).SquareDistance(PF) < aD2) {
+      aV2DT=-vectra;
+      bTranslate=!bTranslate; //True
+    }
+    //
+    if (bTranslate) {
+      C->Translate(aV2DT);
     }
   }
-
   return Standard_True;
 }
 
index b88f063..984530e 100755 (executable)
@@ -735,6 +735,7 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
     return;
   }
   //----------------------------------------
+  Standard_Boolean bFound;
   Standard_Integer aNbVtx, aNbVtxWas, i;
   Standard_Real aTolPC, aT, aT1, aT2, aTmid, aTwoPI, aTolPC1;
   Standard_Real aU1, aV1, aU2, aV2;
@@ -747,6 +748,7 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
   aTwoPI=M_PI+M_PI;
   aTolPC=Precision::PConfusion();
   aNbVtxWas=GeomInt_LineTool::NbVertex(aLine);
+  
   aNbVtx=aNbVtxWas+2;
   //-------------------------------------2
   aTS1=myHS1->GetType();
@@ -761,7 +763,7 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
   pVtx=new IntTools_RealWithFlag [aNbVtx];
   //
   pVtx[0].SetValue(0.);
-  pVtx[1].SetValue(2.*M_PI);
+  pVtx[1].SetValue(aTwoPI);
   //
   for(i=1; i<=aNbVtxWas; ++i) {
     aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine();
@@ -775,6 +777,27 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
   //
   RejectDuplicates(aNbVtx, pVtx, aTolPC);
   //
+  if ((aType==IntPatch_Circle || aType==IntPatch_Ellipse)&& aNbVtx>2) { // zz
+    bFound=Standard_False;
+    for(i=1; i<=aNbVtxWas; ++i) {
+      aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine();
+      if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) {
+       bFound=!bFound;
+       break;
+      }
+    }
+    if (!bFound) {
+      aT=pVtx[1].Value()+aTwoPI;
+      pVtx[aNbVtx-1].SetValue(aT);
+      //
+      for(i=0; i<aNbVtx; ++i) { 
+       aT=pVtx[i+1].Value();
+       pVtx[i].SetValue(aT);
+      }
+      --aNbVtx;
+    }
+  }
+  //
   for(i=0; i<aNbVtx-1; ++i) { 
     aT1=pVtx[i].Value();
     aT2=pVtx[i+1].Value();
diff --git a/tests/bugs/modalg_4/bug23765 b/tests/bugs/modalg_4/bug23765
new file mode 100755 (executable)
index 0000000..2b32dfa
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========="
+puts "CR23765"
+puts "========="
+puts ""
+##################################################
+## The result of section operation contains redundant vertex.
+##################################################
+
+restore [locate_data_file bug23765_b1.brep] b1
+restore [locate_data_file bug23765_b2.brep] b2
+
+bop b1 b2
+bopsection result
+
+set nb_v_good 2
+
+set 2dviewer 1
index 09e98bd..d77f252 100755 (executable)
@@ -26,7 +26,7 @@ if {${rc1} < 0.} {
 } else {
   puts "Good value of parametric range rc1"
 }
-if {${rc2} > ${2_PI}} {
+if {${rc2} < ${2_PI}} {
   puts "Error: Bad value of parametric range rc2"
 } else {
   puts "Good value of parametric range rc2"
index 4bf6414..2e8fead 100644 (file)
@@ -21,14 +21,14 @@ puts "Finish boolean operation ..."
 set square 225009
 
 # Analysis of "nbshapes result"
-set nb_v_good 8
-set nb_e_good 12
+set nb_v_good 6
+set nb_e_good 10
 set nb_w_good 8
 set nb_f_good 6
 set nb_sh_good 1
 set nb_sol_good 0
 set nb_compsol_good 0
 set nb_compound_good 1
-set nb_shape_good 36
+set nb_shape_good 32
 
 set 3dviewer 1