0022962: Invalid realization of reading and writing material in STEP.
authorGKA <>
Fri, 3 Feb 2012 12:35:42 +0000 (12:35 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:32:19 +0000 (19:32 +0400)
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx

index 17e4290..ba6df41 100755 (executable)
 #include <StepShape_SolidModel.hxx>
 #include <StepShape_ShellBasedSurfaceModel.hxx>
 #include <StepShape_GeometricSet.hxx>
+#include <StepBasic_ProductDefinition.hxx>
 
 //#include <BRepTools.hxx>
 
@@ -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());
index 89cba32..2e71c3f 100755 (executable)
 #include <StepBasic_HArray1OfDerivedUnitElement.hxx>
 #include <StepBasic_DerivedUnit.hxx>
 #include <StepRepr_MeasureRepresentationItem.hxx>
-
+#include <StepBasic_ProductDefinition.hxx>
 
 //=======================================================================
 //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);