From 7f0b39bec9aa01a1716d27e8c44c6acc245bef5a Mon Sep 17 00:00:00 2001 From: ika Date: Thu, 19 Mar 2015 15:43:17 +0300 Subject: [PATCH] 0025843: Wire containing degenerated edge is not written to IGES / STEP add check for edges with null 2D and 3D curves for STEP, for IGES problem exists only with wires, where non-invalid edge is only one, and it is not the last in wire(fixed). Test case for issue CR25843 --- src/BRepToIGES/BRepToIGES_BRWire.cxx | 6 ++--- .../TopoDSToStep_WireframeBuilder.cxx | 14 +++++++++-- tests/bugs/iges/bug25843_iges | 23 +++++++++++++++++++ tests/bugs/step/bug25843_step | 23 +++++++++++++++++++ 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100755 tests/bugs/iges/bug25843_iges create mode 100755 tests/bugs/step/bug25843_step diff --git a/src/BRepToIGES/BRepToIGES_BRWire.cxx b/src/BRepToIGES/BRepToIGES_BRWire.cxx index c08a959da6..39153cc20b 100644 --- a/src/BRepToIGES/BRepToIGES_BRWire.cxx +++ b/src/BRepToIGES/BRepToIGES_BRWire.cxx @@ -525,8 +525,8 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRWire ::TransferWire AddWarning(mywire, "an Edge is a null entity"); } else { - ent = TransferEdge(E, Standard_False); - if (!ent.IsNull()) Seq->Append(ent); + ent = TransferEdge(E, Standard_False); + if (!ent.IsNull()) Seq->Append(ent); } } } @@ -537,7 +537,7 @@ Handle(IGESData_IGESEntity) BRepToIGES_BRWire ::TransferWire Standard_Integer nbedges = Seq->Length(); Handle(IGESData_HArray1OfIGESEntity) Tab; if ( nbedges == 1 ) { - res = ent; + res = GetCasted(IGESData_IGESEntity, Seq->Value(1)); } else if ( nbedges >= 2) { Tab = new IGESData_HArray1OfIGESEntity(1,nbedges); diff --git a/src/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx b/src/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx index 8cb10cdb78..ae41d0ee42 100644 --- a/src/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx +++ b/src/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx @@ -54,6 +54,9 @@ #include #include +#include +#include + #include #include #include @@ -178,8 +181,15 @@ Standard_Boolean TopoDSToStep_WireframeBuilder:: //?? curveList->Append(Gpms); return Standard_True; } - - BRepAdaptor_Curve CA ( anEdge ); + + BRepAdaptor_Curve CA; + try { + OCC_CATCH_SIGNALS + CA.Initialize (anEdge); + } + catch (Standard_NullObject) { + return Standard_False; + } // Vertices TopoDS_Vertex Vfirst, Vlast; diff --git a/tests/bugs/iges/bug25843_iges b/tests/bugs/iges/bug25843_iges new file mode 100755 index 0000000000..975cc04f1c --- /dev/null +++ b/tests/bugs/iges/bug25843_iges @@ -0,0 +1,23 @@ +puts "============" +puts "OCC25843" +puts "============" +puts "" +####################################################################### +# Wire containing degenerated edge is not written to IGES / STEP +####################################################################### + +restore [locate_data_file bug25843_onewire.brep] w + +set aFile ${imagedir}/bug25843_onewire.igs + +file delete ${aFile} + +brepiges w ${aFile} + +if { ![file exists ${aFile}] } { + puts "Error: Wire containing degenerated edge is not written to IGES file" +} else { + puts "OK: Wire containing degenerated edge is written to IGES file" +} + +catch {exec chmod 777 ${aFile}} diff --git a/tests/bugs/step/bug25843_step b/tests/bugs/step/bug25843_step new file mode 100755 index 0000000000..73cb424d1c --- /dev/null +++ b/tests/bugs/step/bug25843_step @@ -0,0 +1,23 @@ +puts "============" +puts "OCC25843" +puts "============" +puts "" +####################################################################### +# Wire containing degenerated edge is not written to IGES / STEP +####################################################################### + +restore [locate_data_file bug25843_onewire.brep] w + +set aFile ${imagedir}/bug25843_onewire.stp + +catch { file delete ${aFile} } + +stepwrite 0 w ${aFile} + +if { ![file exists ${aFile}] } { + puts "Error: Wire containing degenerated edge is not written to STEP file" +} else { + puts "OK: Wire containing degenerated edge is written to STEP file" +} + +catch {exec chmod 777 ${aFile}}