From c31e0defd7f4bd5998ea54b86e256565e596af88 Mon Sep 17 00:00:00 2001 From: vro Date: Thu, 15 Jan 2015 14:47:07 +0300 Subject: [PATCH] 0025634: Checking of compliance of vertices and pcurve fails A fix + a checkedge draw-command to check the fix. Test case for issue CR25634 --- src/SWDRAW/SWDRAW_ShapeAnalysis.cxx | 76 ++++++++++++++++++++++++ src/ShapeAnalysis/ShapeAnalysis_Edge.cxx | 4 ++ tests/bugs/heal/bug25634 | 21 +++++++ 3 files changed, 101 insertions(+) create mode 100644 tests/bugs/heal/bug25634 diff --git a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx index 99c356d623..8a3e40b6d2 100644 --- a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx +++ b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx @@ -900,6 +900,81 @@ static Standard_Integer checkselfintersection return 0; } +static Standard_Integer checkedge(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 2) + { + di<<"Call please \"checkedge edge [face]\""<<"\n"; + return 1; + } + + // Get edge. + const char* arg1 = argv[1]; + TopoDS_Shape edge = DBRep::Get(arg1); + if (edge.IsNull() || edge.ShapeType() != TopAbs_EDGE) + { + di<<"A null shape or not an edge is used."<<"\n"; + return 2; + } + + // Get face. + TopoDS_Shape face; + if (argc == 3) + { + const char* arg2 = argv[2]; + face = DBRep::Get(arg2); + if (face.IsNull() || face.ShapeType() != TopAbs_FACE) + { + di<<"A null shape or not a face is used."<<"\n"; + return 3; + } + } + + // Analysis of the edge. + ShapeAnalysis_Edge analyser; + Standard_Boolean isOk(Standard_True); + + // Curve 3D. + if (analyser.HasCurve3d(TopoDS::Edge(edge))) + { + // Check vertices. + if (analyser.CheckVerticesWithCurve3d(TopoDS::Edge(edge))) + { + isOk = Standard_False; + di<<"Vertices of the edge don't coincide with start/end points of 3d-curve (using tolerance of the vertices).\n"; + } + } + else + { + isOk = Standard_False; + di<<"Edge doesn't have a 3d-curve\n"; + } + + if (!face.IsNull()) + { + // Curve 2D. + if (analyser.HasPCurve(TopoDS::Edge(edge), TopoDS::Face(face))) + { + // Check vertices. + if (analyser.CheckVerticesWithPCurve(TopoDS::Edge(edge), TopoDS::Face(face))) + { + isOk = Standard_False; + di<<"Vertices of the edge don't coincide with start/end points of 2d-curve (using tolerance of the vertices).\n"; + } + } + else + { + isOk = Standard_False; + di<<"Edge doesn't have a 2d-curve on this face\n"; + } + } + + if (isOk) + di<<"Edge seems OK.\n"; + + return 0; +} + //======================================================================= //function : InitCommands //purpose : @@ -937,4 +1012,5 @@ static Standard_Integer checkselfintersection theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold); theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g); + theCommands.Add ("checkedge","edge [face]", __FILE__,checkedge,g); } diff --git a/src/ShapeAnalysis/ShapeAnalysis_Edge.cxx b/src/ShapeAnalysis/ShapeAnalysis_Edge.cxx index 09a5386988..c2931d5270 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Edge.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Edge.cxx @@ -565,6 +565,8 @@ Standard_Boolean ShapeAnalysis_Edge::CheckVerticesWithPCurve (const TopoDS_Edge& if (vtx != 2) { // 1er VTX gp_Pnt2d p1uv = c2d->Value (cf); gp_Pnt p12d = surf->Value (p1uv.X(), p1uv.Y()); + if (!loc.IsIdentity()) + p12d.Transform(loc.Transformation()); // szv#4:S4163:12Mar99 optimized if ( p1v.Distance(p12d) > (preci < 0 ? BRep_Tool::Tolerance (V1) : preci) ) myStatus |= ShapeExtend_DONE1; @@ -573,6 +575,8 @@ Standard_Boolean ShapeAnalysis_Edge::CheckVerticesWithPCurve (const TopoDS_Edge& if (vtx != 1) { // 2me VTX gp_Pnt2d p2uv = c2d->Value (cl); gp_Pnt p22d = surf->Value (p2uv.X(), p2uv.Y()); + if (!loc.IsIdentity()) + p22d.Transform(loc.Transformation()); // szv#4:S4163:12Mar99 optimized if ( p2v.Distance(p22d) > (preci < 0 ? BRep_Tool::Tolerance (V2) : preci) ) myStatus |= ShapeExtend_DONE2; diff --git a/tests/bugs/heal/bug25634 b/tests/bugs/heal/bug25634 new file mode 100644 index 0000000000..112e72f325 --- /dev/null +++ b/tests/bugs/heal/bug25634 @@ -0,0 +1,21 @@ +puts "============" +puts "OCC25634" +puts "============" +puts "" +###################################################### +# Checking of compliance of vertices and pcurve fails +###################################################### + +restore [locate_data_file bug25634_shape3.brep] s + +explode s e + +set info [checkedge s_1 s] + +# Resume +puts "" +if { [regexp {Edge seems OK.} ${info}] } { + puts "OK: Checking is good" +} else { + puts "Error: Checking is bad" +}