0027721: Add possibility to read STEP file with invalid shape_representation entity.
authorika <ika@opencascade.com>
Thu, 28 Jul 2016 13:13:25 +0000 (16:13 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Aug 2016 08:22:40 +0000 (11:22 +0300)
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

src/STEPControl/STEPControl_Controller.cxx
src/STEPControl/STEPControl_Reader.cxx
tests/bugs/step/bug27721 [new file with mode: 0644]

index 4b3cbed..dc3ec17 100644 (file)
@@ -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;
   }
 
index c2d3032..0062dc4 100644 (file)
 #include <StepRepr_RepresentationMap.hxx>
 #include <StepRepr_RepresentationRelationship.hxx>
 #include <StepRepr_ShapeAspect.hxx>
+#include <StepShape_ManifoldSolidBrep.hxx>
 #include <StepShape_ShapeDefinitionRepresentation.hxx>
 #include <StepShape_ShapeRepresentation.hxx>
+#include <StepShape_ShellBasedSurfaceModel.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TColStd_Array1OfAsciiString.hxx>
 #include <TColStd_Array1OfReal.hxx>
@@ -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 (file)
index 0000000..a3c1a49
--- /dev/null
@@ -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