diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 17e4290e58..ba6df41a0d 100755 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -145,6 +145,7 @@ #include #include #include +#include //#include @@ -1888,13 +1889,17 @@ Standard_Boolean STEPCAFControl_Reader::ReadMaterials(const Handle(XSControl_Wor for(Standard_Integer i=1; i<=SeqPDS->Length(); i++) { Handle(StepRepr_ProductDefinitionShape) PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(SeqPDS->Value(i)); - if(PDS.IsNull()) continue; + if(PDS.IsNull()) + continue; + Handle(StepBasic_ProductDefinition) aProdDef = PDS->Definition().ProductDefinition(); + if(aProdDef.IsNull()) + continue; Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(""); Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(""); Handle(TCollection_HAsciiString) aDensName = new TCollection_HAsciiString(""); Handle(TCollection_HAsciiString) aDensValType = new TCollection_HAsciiString(""); Standard_Real aDensity=0; - Interface_EntityIterator subs = graph.Sharings(PDS); + Interface_EntityIterator subs = graph.Sharings( aProdDef); for(subs.Start(); subs.More(); subs.Next()) { Handle(StepRepr_PropertyDefinition) PropD = Handle(StepRepr_PropertyDefinition)::DownCast(subs.Value()); diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 89cba321c5..2e71c3fa6b 100755 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -157,7 +157,7 @@ #include #include #include - +#include //======================================================================= //function : GetLabelName @@ -2365,6 +2365,10 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W Handle(Standard_Transient) ent = seqRI.Value(1); FindPDSforRI(aGraph,ent,PDS,RC); if(PDS.IsNull()) continue; + Handle(StepBasic_ProductDefinition) aProdDef = + PDS->Definition().ProductDefinition(); + if(aProdDef.IsNull()) + continue; // write material entities TDF_Label MatL = Node->Father()->Label(); Handle(TCollection_HAsciiString) aName; @@ -2429,7 +2433,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W } // write chain PDS---(DRI,MRI) StepRepr_CharacterizedDefinition CD1; - CD1.SetValue(PDS); + CD1.SetValue(aProdDef); Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; PropD1->Init(new TCollection_HAsciiString("material property"),Standard_True, new TCollection_HAsciiString("material name"),CD1); @@ -2441,7 +2445,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteMaterials (const Handle(XSControl_W PDR1->Init(RD1,RepDRI); Model->AddWithRefs(PDR1); StepRepr_CharacterizedDefinition CD2; - CD2.SetValue(PDS); + CD2.SetValue(aProdDef); Handle(StepRepr_PropertyDefinition) PropD2 = new StepRepr_PropertyDefinition; PropD2->Init(new TCollection_HAsciiString("material property"),Standard_True, new TCollection_HAsciiString("density"),CD2);