]> OCCT Git - occt.git/commitdiff
0027570: Unacceptable performance during reading large STEP files
authorika <ika@opencascade.com>
Wed, 15 Jun 2016 11:29:32 +0000 (14:29 +0300)
committerapn <apn@opencascade.com>
Thu, 27 Oct 2016 14:22:41 +0000 (17:22 +0300)
Improvement of translating assemblies from STEP.

src/STEPConstruct/STEPConstruct_Assembly.cxx
src/STEPConstruct/STEPConstruct_Assembly.hxx
src/STEPControl/STEPControl_ActorRead.cxx
src/STEPSelections/STEPSelections_Counter.cxx
src/STEPSelections/STEPSelections_SelectInstances.cxx
tests/bugs/step/bug27570 [new file with mode: 0644]

index 08be352c67a8d914e0a10d42ae58734643e58e47..74d212bbc45e5c4b4566c9795e494ac56bf945d0 100644 (file)
@@ -15,6 +15,8 @@
 // :j4 16.03.99 gka S4134
 // abv 18.11.99 renamed from StepPDR_MakeItem
 
+#include <Interface_EntityIterator.hxx>
+#include <Interface_Graph.hxx>
 #include <Interface_InterfaceModel.hxx>
 #include <Standard_Transient.hxx>
 #include <StepBasic_ApplicationContext.hxx>
@@ -179,7 +181,7 @@ Handle(StepRepr_NextAssemblyUsageOccurrence) STEPConstruct_Assembly::GetNAUO ()
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean STEPConstruct_Assembly::CheckSRRReversesNAUO(const Handle(Interface_InterfaceModel) &Model,
+Standard_Boolean STEPConstruct_Assembly::CheckSRRReversesNAUO(const Interface_Graph& theGraph,
                                                              const Handle(StepShape_ContextDependentShapeRepresentation) &CDSR)
 {
   Handle(StepRepr_NextAssemblyUsageOccurrence) nauo = 
@@ -191,26 +193,35 @@ Standard_Boolean STEPConstruct_Assembly::CheckSRRReversesNAUO(const Handle(Inter
 #endif
     return Standard_False;
   }
-  
+
   Handle(StepBasic_ProductDefinition) pd1, pd2;
   Handle(StepRepr_Representation) rep1 = CDSR->RepresentationRelation()->Rep1();
   Handle(StepRepr_Representation) rep2 = CDSR->RepresentationRelation()->Rep2();
   
   // find SDRs corresponding to Rep1 and Rep2 and remember their PDs
   Handle(Standard_Type) tSDR = STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation);
-  Standard_Integer nb = Model->NbEntities();
-  for (Standard_Integer i = 1; i <= nb; i ++) {
-    Handle(Standard_Transient) enti = Model->Value(i);
+  Interface_EntityIterator anIter = theGraph.Sharings(rep1);
+  for (; anIter.More() && pd1.IsNull(); anIter.Next()) {
+      Handle(Standard_Transient) enti = anIter.Value();
     if (enti->DynamicType() == tSDR) {
       Handle(StepShape_ShapeDefinitionRepresentation) SDR =
-       Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(enti);
+        Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(enti);
       if ( SDR->UsedRepresentation() == rep1 ) 
-       pd1 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
-      if ( SDR->UsedRepresentation() == rep2 ) 
-       pd2 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
+        pd1 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
     }
   }
   
+  anIter = theGraph.Sharings(rep2);
+  for (; anIter.More() && pd2.IsNull(); anIter.Next()) {
+      Handle(Standard_Transient) enti = anIter.Value();
+    if (enti->DynamicType() == tSDR) {
+      Handle(StepShape_ShapeDefinitionRepresentation) SDR =
+        Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(enti);
+      if ( SDR->UsedRepresentation() == rep2 ) 
+        pd2 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
+    }
+  }
+
   // checks..
   
   if ( pd1 == nauo->RelatedProductDefinition() && // OK
index ef3e4ed8a0ce57cb9203c0ef6db1966bd98db009..9f321b14ae69bb2e47a90b01f1c7a5bc1e9fffd1 100644 (file)
@@ -29,6 +29,7 @@ class StepGeom_Axis2Placement3d;
 class StepRepr_NextAssemblyUsageOccurrence;
 class Interface_InterfaceModel;
 class StepShape_ContextDependentShapeRepresentation;
+class Interface_Graph;
 
 
 //! This operator creates and checks an item of an assembly, from its
@@ -70,7 +71,7 @@ public:
   
   //! Checks whether SRR's definition of assembly and component contradicts
   //! with NAUO definition or not, according to model schema (AP214 or AP203)
-  Standard_EXPORT static Standard_Boolean CheckSRRReversesNAUO (const Handle(Interface_InterfaceModel)& Model, const Handle(StepShape_ContextDependentShapeRepresentation)& CDSR);
+  Standard_EXPORT static Standard_Boolean CheckSRRReversesNAUO (const Interface_Graph& theGraph, const Handle(StepShape_ContextDependentShapeRepresentation)& CDSR);
 
 
 
index f0564511925a06588d7806fd9c46584d9cec824b..42b2ca0fd399409b8cf76cdcf85b7cffcee0e08e 100644 (file)
@@ -679,7 +679,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
       IsDepend=Standard_True;
       Handle(StepRepr_RepresentationRelationship) RR = CDSR->RepresentationRelation();
       if (RR.IsNull()) continue;
-      SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( TP->Model(), CDSR );
+      SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph, CDSR );
       Handle(StepRepr_Representation) rep = ( SRRReversed ? RR->Rep2() : RR->Rep1() );
       iatrsf = ComputeSRRWT ( RR, TP, Trsf );
       // find real ProductDefinition used rep
@@ -928,7 +928,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
   //DeclareAndCast(StepRepr_RepresentationRelationship,SRR,CDSR->RepresentationRelation());
   if ( SRR.IsNull() ) return shbinder;
   
-  Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( TP->Model(), CDSR );
+  Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( TP->Graph(), CDSR );
   Handle(StepRepr_Representation) rep1 = ( SRRReversed ? SRR->Rep2() : SRR->Rep1() );
   Handle(StepShape_ShapeRepresentation) rep = Handle(StepShape_ShapeRepresentation)::DownCast(rep1);
 
index ae2936c20408ac1839f0ce77f03868e756ec5fec..4d086536081ff33782253c7a53cfb959a049194b 100644 (file)
@@ -181,7 +181,7 @@ void STEPSelections_Counter::Count(const Interface_Graph& graph,
     if ( SRR.IsNull() ) return ;
     
     Handle(StepRepr_Representation) rep;
-    Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph.Model(), CDSR );
+    Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph, CDSR );
     if(SRRReversed)
       rep = SRR->Rep2();
     else
index bc4e8ea15acfed13548aca5ca59e90e7f4080ec8..2dd5d52197d0781db037596e8eb69aecccf965fa 100644 (file)
@@ -106,7 +106,7 @@ static void AddInstances(const Handle(Standard_Transient)& start,
     if ( SRR.IsNull() ) return ;
     
     Handle(StepRepr_Representation) rep;
-    Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph.Model(), CDSR );
+    Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph, CDSR );
     if(SRRReversed)
       rep = SRR->Rep2();
     else
diff --git a/tests/bugs/step/bug27570 b/tests/bugs/step/bug27570
new file mode 100644 (file)
index 0000000..1ce0feb
--- /dev/null
@@ -0,0 +1,27 @@
+puts "========"
+puts "OCC27570"
+puts "========"
+puts ""
+###########################################################
+# Unacceptable performance during reading large STEP files
+###########################################################
+
+set max_time 8
+
+dchrono cr reset
+dchrono cr start
+ReadStep D [locate_data_file bug27570.stp]
+dchrono cr stop
+
+# check time
+set chrono_info [dchrono cr show]
+regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
+if { $CPU_time > ${max_time} } {
+  puts "CPU user time of STEP translation is more than ${max_time} seconds - Error"
+} else {
+  puts "CPU user time of STEP translation is less than ${max_time} seconds - OK"
+}
+
+# check number of shapes
+XGetOneShape result D
+checknbshapes result -solid 1000 -compound 1111