From 9bba178dce6786767b1f7af79613a5990e1b14f8 Mon Sep 17 00:00:00 2001 From: ika Date: Wed, 15 Jun 2016 14:29:32 +0300 Subject: [PATCH] 0027570: Unacceptable performance during reading large STEP files Improvement of translating assemblies from STEP. --- src/STEPConstruct/STEPConstruct_Assembly.cxx | 29 +++++++++++++------ src/STEPConstruct/STEPConstruct_Assembly.hxx | 3 +- src/STEPControl/STEPControl_ActorRead.cxx | 4 +-- src/STEPSelections/STEPSelections_Counter.cxx | 2 +- .../STEPSelections_SelectInstances.cxx | 2 +- tests/bugs/step/bug27570 | 27 +++++++++++++++++ 6 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 tests/bugs/step/bug27570 diff --git a/src/STEPConstruct/STEPConstruct_Assembly.cxx b/src/STEPConstruct/STEPConstruct_Assembly.cxx index 08be352c67..74d212bbc4 100644 --- a/src/STEPConstruct/STEPConstruct_Assembly.cxx +++ b/src/STEPConstruct/STEPConstruct_Assembly.cxx @@ -15,6 +15,8 @@ // :j4 16.03.99 gka S4134 // abv 18.11.99 renamed from StepPDR_MakeItem +#include +#include #include #include #include @@ -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 diff --git a/src/STEPConstruct/STEPConstruct_Assembly.hxx b/src/STEPConstruct/STEPConstruct_Assembly.hxx index ef3e4ed8a0..9f321b14ae 100644 --- a/src/STEPConstruct/STEPConstruct_Assembly.hxx +++ b/src/STEPConstruct/STEPConstruct_Assembly.hxx @@ -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); diff --git a/src/STEPControl/STEPControl_ActorRead.cxx b/src/STEPControl/STEPControl_ActorRead.cxx index f056451192..42b2ca0fd3 100644 --- a/src/STEPControl/STEPControl_ActorRead.cxx +++ b/src/STEPControl/STEPControl_ActorRead.cxx @@ -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); diff --git a/src/STEPSelections/STEPSelections_Counter.cxx b/src/STEPSelections/STEPSelections_Counter.cxx index ae2936c204..4d08653608 100644 --- a/src/STEPSelections/STEPSelections_Counter.cxx +++ b/src/STEPSelections/STEPSelections_Counter.cxx @@ -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 diff --git a/src/STEPSelections/STEPSelections_SelectInstances.cxx b/src/STEPSelections/STEPSelections_SelectInstances.cxx index bc4e8ea15a..2dd5d52197 100644 --- a/src/STEPSelections/STEPSelections_SelectInstances.cxx +++ b/src/STEPSelections/STEPSelections_SelectInstances.cxx @@ -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 index 0000000000..1ce0febca4 --- /dev/null +++ b/tests/bugs/step/bug27570 @@ -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