From: jgv Date: Thu, 30 Jan 2014 12:07:12 +0000 (+0400) Subject: 0024573: Wrong result of 2d-offset algorithm on customer's shape X-Git-Tag: HYDRO-2014-01-31~4 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=8a6db25a620e30222640932166dac8fe909e79c6;hp=e226a50679987fd3e428a42790b753b040f60fd6 0024573: Wrong result of 2d-offset algorithm on customer's shape Test cases for issue CR24573 --- diff --git a/src/Bisector/Bisector_BisecAna.cxx b/src/Bisector/Bisector_BisecAna.cxx index 6220427131..0dbb8f185c 100644 --- a/src/Bisector/Bisector_BisecAna.cxx +++ b/src/Bisector/Bisector_BisecAna.cxx @@ -808,7 +808,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // Bissectrice point - circle. + //============================================================================= case 1 : { - GccAna_CircPnt2dBisec Bisector(circle,asecondpoint->Pnt2d()); + GccAna_CircPnt2dBisec Bisector(circle, asecondpoint->Pnt2d(), tolerance); Standard_Real distancemini = Precision::Infinite(); if (Bisector.IsDone()) { Standard_Integer nbsolution = Bisector.NbSolutions(); diff --git a/src/GccAna/GccAna_CircPnt2dBisec.cdl b/src/GccAna/GccAna_CircPnt2dBisec.cdl index ddbb3ac619..e51f318524 100644 --- a/src/GccAna/GccAna_CircPnt2dBisec.cdl +++ b/src/GccAna/GccAna_CircPnt2dBisec.cdl @@ -46,6 +46,18 @@ Create(Circle1 : Circ2d from gp; ---Purpose: Constructs bisecting curves between the circle Circle1 and the point Point2. +Create(Circle1 : Circ2d from gp; + Point2 : Pnt2d from gp; + Tolerance : Real from Standard) returns CircPnt2dBisec; + + ---Purpose: Constructs bisecting curves between the circle Circle1 and the point Point2. + -- Tolerance is used. + +DefineSolutions(me: in out) +is private; + ---Purpose: Defines the number and the type of solutions + -- depending on input data + IsDone(me) returns Boolean from Standard is static; ---Purpose: Returns true (this construction algorithm never fails). @@ -84,4 +96,6 @@ fields -- theposition = 0 when the point is on the circle. -- theposition = -1 when the point is inside the circle. + myTolerance : Real from Standard; + end CircPnt2dBisec; diff --git a/src/GccAna/GccAna_CircPnt2dBisec.cxx b/src/GccAna/GccAna_CircPnt2dBisec.cxx index 1492efba77..b4c9f31cbe 100644 --- a/src/GccAna/GccAna_CircPnt2dBisec.cxx +++ b/src/GccAna/GccAna_CircPnt2dBisec.cxx @@ -36,39 +36,49 @@ GccAna_CircPnt2dBisec:: GccAna_CircPnt2dBisec (const gp_Circ2d& Circle , - const gp_Pnt2d& Point ): - - circle(Circle), - point(Point) { + const gp_Pnt2d& Point ) +{ + circle = Circle; + point = Point; + myTolerance = 1.e-10; + DefineSolutions(); +} -//========================================================================= -// Initialization of fields : + -// - circle ( first argument.) + -// - line ( second argument.) + -// - theposition (Integer showing the position of Point + -// correspondingly to Circle.) + -// - NbrSol (Integer showing the number of solutions.) + -// - WellDone (Booleen showing the success or failure of the algorithm). + -//========================================================================= +GccAna_CircPnt2dBisec:: + GccAna_CircPnt2dBisec (const gp_Circ2d& Circle , + const gp_Pnt2d& Point, + const Standard_Real Tolerance) +{ + circle = Circle; + point = Point; + myTolerance = 1.e-10; + if (myTolerance < Tolerance) + myTolerance = Tolerance; + + DefineSolutions(); +} - Standard_Real dist = Circle.Radius()-Point.Distance(Circle.Location()); -// if (Abs(dist) < gp::Resolution()) - if (Abs(dist) < 1.E-10) - { - theposition = 0; - NbrSol = 1; - } - else if (dist > 0.0) - { - theposition = -1; - NbrSol = 1; - } - else { - theposition = 1; - NbrSol = 2; - } - WellDone = Standard_True; - } +void GccAna_CircPnt2dBisec::DefineSolutions() +{ + Standard_Real dist = circle.Radius() - point.Distance(circle.Location()); + + if (Abs(dist) < myTolerance) + { + theposition = 0; + NbrSol = 1; + } + else if (dist > 0.0) + { + theposition = -1; + NbrSol = 1; + } + else { + theposition = 1; + NbrSol = 2; + } + + WellDone = Standard_True; +} //========================================================================= // Processing. + @@ -99,8 +109,8 @@ Handle(GccInt_Bisec) GccAna_CircPnt2dBisec:: Standard_Real ycencir = circle.Location().Y(); Standard_Real R1 = circle.Radius(); Standard_Real dist = point.Distance(circle.Location()); - // if (dist < gp::Resolution()) - if (dist < 1.E-10) + + if (dist < myTolerance) { gp_Circ2d biscirpnt1(gp_Ax2d(point,gp_Dir2d(1.0,0.0)),R1/2.); bissol = new GccInt_BCirc(biscirpnt1); diff --git a/tests/bugs/modalg_5/bug24573 b/tests/bugs/modalg_5/bug24573 new file mode 100755 index 0000000000..5a9b19a07a --- /dev/null +++ b/tests/bugs/modalg_5/bug24573 @@ -0,0 +1,32 @@ +puts "============" +puts "OCC24573" +puts "============" +puts "" +####################################################################### +# Wrong result of 2d-offset algorithm on customer's shape +####################################################################### + +set BugNumber OCC24573 + +puts "Load shape ..." +restore [locate_data_file bug24573_Wire.brep] ww + +if [catch { mkoffset resoffset ww 1 12.5 } ] { + puts "Faulty ${BugNumber} : mkoffset is wrong" +} else { + renamevar resoffset_1 result + + set length 178.54 + + set nb_v_good 10 + set nb_e_good 10 + set nb_w_good 1 + set nb_f_good 0 + set nb_sh_good 0 + set nb_sol_good 0 + set nb_compsol_good 0 + set nb_compound_good 0 + set nb_shape_good 21 +} + +set 2dviewer 1 diff --git a/tests/offset/wire_closed_inside_0_005/B4 b/tests/offset/wire_closed_inside_0_005/B4 old mode 100644 new mode 100755 index ae910a6e1a..7c5f61a9ab --- a/tests/offset/wire_closed_inside_0_005/B4 +++ b/tests/offset/wire_closed_inside_0_005/B4 @@ -1,5 +1,10 @@ -puts "TODO OCC23068 ALL: Error : big tolerance of shape result" -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_2" +puts "TODO ?OCC23068 ALL: Error : big tolerance of shape result" +puts "TODO ?OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" + +puts "TODO OCC23068 ALL: Standard_Failure: BRepFill_OffsetWire::FixHoles" +puts "TODO OCC23068 ALL: Error: Offset is not done" +puts "TODO OCC23068 ALL: Error : The offset cannot be built" + restore [locate_data_file offset_wire_018.brep] s set length 24.8301 diff --git a/tests/offset/wire_closed_inside_0_025/B4 b/tests/offset/wire_closed_inside_0_025/B4 old mode 100644 new mode 100755 index a0090fe579..6d63b09140 --- a/tests/offset/wire_closed_inside_0_025/B4 +++ b/tests/offset/wire_closed_inside_0_025/B4 @@ -1,5 +1,9 @@ -puts "TODO OCC23068 ALL: Error : big tolerance of shape result" -puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_3" +puts "TODO ?OCC23068 ALL: Error : big tolerance of shape result" +puts "TODO OCC23068 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO OCC23068 ALL: Error : result_1 is NOT a closed wire" +puts "TODO OCC23068 ALL: Error : The length of the resulting shape is" +puts "TODO OCC23068 ALL: Error : The resulting shape is WRONG because it must contain" + restore [locate_data_file offset_wire_018.brep] s set length 23.8673 diff --git a/tests/offset/wire_closed_inside_0_075/B4 b/tests/offset/wire_closed_inside_0_075/B4 old mode 100644 new mode 100755 index c9265df564..377a08c55b --- a/tests/offset/wire_closed_inside_0_075/B4 +++ b/tests/offset/wire_closed_inside_0_075/B4 @@ -3,6 +3,10 @@ puts "TODO ?OCC23068 ALL: Error : The offset cannot be built." puts "TODO ?OCC23068 ALL: An exception was caught" puts "TODO ?OCC23068 ALL: \\*\\* Exception \\*\\*.*" puts "TODO ?OCC23748 ALL: Error: Offset is not done." +puts "TODO ?OCC23748 ALL: Error : result is NOT a closed wire" +puts "TODO ?OCC23748 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO ?OCC23748 ALL: Error : The length of the resulting shape is" +puts "TODO ?OCC23748 ALL: Error : The resulting shape is WRONG" restore [locate_data_file offset_wire_018.brep] s