From: ika Date: Thu, 28 Jul 2016 13:13:25 +0000 (+0300) Subject: 0027721: Add possibility to read STEP file with invalid shape_representation entity. X-Git-Tag: V7_1_0_beta~229 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=c6f530b8d9cb720692274922f13cff3fcf779777 0027721: Add possibility to read STEP file with invalid shape_representation entity. Add special parameter, which allow reading of all top level (not shared by any other entities) solids (manifold_solid_brep) and shells (shell_based_surface_model). The examples how to use a new parameter: DRAW: switch on a parameter: param read.step.all.shapes On update model to apply new parameter value: newmodel read as usual: stepread test.stp res * // each top level solid or shell will be read as res_i shape. or ReadStep Doc test.stp CXX Code: switch on a parameter: Interface_Static::SetIVal("read.step.all.shapes", 1); read as usual --- diff --git a/src/STEPControl/STEPControl_Controller.cxx b/src/STEPControl/STEPControl_Controller.cxx index 4b3cbed3fb..dc3ec175a0 100644 --- a/src/STEPControl/STEPControl_Controller.cxx +++ b/src/STEPControl/STEPControl_Controller.cxx @@ -191,6 +191,14 @@ STEPControl_Controller::STEPControl_Controller () Interface_Static::Init ("XSTEP","write.step.sequence",'t',"ToSTEP"); Interface_Static::Init ("XSTEP","read.step.sequence",'t',"FromSTEP"); + // ika 28.07.16: Paremeter to read all top level solids and shells, + // should be used only in case of invalid shape_representation without links to shapes. + Interface_Static::Init("step", "read.step.all.shapes", 'e', ""); + Interface_Static::Init("step", "read.step.all.shapes", '&', "enum 0"); + Interface_Static::Init("step", "read.step.all.shapes", '&', "eval Off"); + Interface_Static::Init("step", "read.step.all.shapes", '&', "eval On"); + Interface_Static::SetIVal("read.step.all.shapes", 0); + init = Standard_True; } diff --git a/src/STEPControl/STEPControl_Reader.cxx b/src/STEPControl/STEPControl_Reader.cxx index c2d3032267..0062dc44eb 100644 --- a/src/STEPControl/STEPControl_Reader.cxx +++ b/src/STEPControl/STEPControl_Reader.cxx @@ -53,8 +53,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -123,6 +125,23 @@ Standard_Integer STEPControl_Reader::NbRootsForTransfer() Standard_Integer nb = Model()->NbEntities(); for (Standard_Integer i = 1; i <= nb; i ++) { Handle(Standard_Transient) ent = Model()->Value(i); + if (Interface_Static::IVal("read.step.all.shapes") == 1) { + // Special case to read invalid shape_representation without links to shapes. + if (ent->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) { + Interface_EntityIterator aShareds = WS()->Graph().Sharings(ent); + if (!aShareds.More()) { + theroots.Append(ent); + WS()->TransferReader()->TransientProcess()->RootsForTransfer()->Append(ent); + } + } + if (ent->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) { + Interface_EntityIterator aShareds = WS()->Graph().Sharings(ent); + if (!aShareds.More()) { + theroots.Append(ent); + WS()->TransferReader()->TransientProcess()->RootsForTransfer()->Append(ent); + } + } + } if(ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) { // PTV 31.01.2003 TRJ11 exclude Product Definition With Associated Document from roots if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) { diff --git a/tests/bugs/step/bug27721 b/tests/bugs/step/bug27721 new file mode 100644 index 0000000000..a3c1a49ad0 --- /dev/null +++ b/tests/bugs/step/bug27721 @@ -0,0 +1,19 @@ +puts "========" +puts "OCC27721" +puts "========" +puts "" +############################################################################## +# Add possibility to read STEP file with invalid shape_representation entity. +############################################################################## + +param read.step.all.shapes 1 +newmodel + +ReadStep D [locate_data_file bug27721.stp] + +XGetOneShape result D + +checknbshapes result -solid 1 -shell 2 -shape 43 + +param read.step.all.shapes 0 +newmodel