]> OCCT Git - occt.git/commitdiff
Data Exchange, STEP Export - General Attributes (#634) IR master
authorPetras Vestartas <petrasvestartas@gmail.com>
Tue, 12 Aug 2025 08:29:47 +0000 (10:29 +0200)
committerGitHub <noreply@github.com>
Tue, 12 Aug 2025 08:29:47 +0000 (09:29 +0100)
- Adds metadata writing capability through new `MetadataMode` flag and `writeMetadata` method
- Exports string metadata as STEP `property_definition` entities linked to product definitions
- Integrates metadata writing into the main transfer workflow alongside existing property writing

15 files changed:
src/DataExchange/TKDESTEP/DESTEP/DESTEP_ConfigurationNode.cxx
src/DataExchange/TKDESTEP/DESTEP/DESTEP_Parameters.hxx
src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.cxx
src/DataExchange/TKDESTEP/STEPCAFControl/STEPCAFControl_Writer.hxx
tests/de_wrapper/configuration/A3
tests/de_wrapper/configuration/A4
tests/metadata/step/A1
tests/metadata/step/A2
tests/metadata/step/A3
tests/metadata/step/A4
tests/metadata/step/A5
tests/metadata/step/A6
tests/metadata/step/A7
tests/metadata/step/A8
tests/metadata/step/end

index be25e53a7986f5c83dcc2501f3130149ef1ff134..ed460f445a681aefa112a19394c1a222bcf8dff8 100644 (file)
@@ -190,6 +190,8 @@ bool DESTEP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
     theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
   InternalParameters.WriteProps =
     theResource->BooleanVal("write.props", InternalParameters.WriteProps, aScope);
+  InternalParameters.WriteMetadata =
+    theResource->BooleanVal("write.metadata", InternalParameters.WriteMetadata, aScope);
   InternalParameters.WriteMaterial =
     theResource->BooleanVal("write.material", InternalParameters.WriteMaterial, aScope);
   InternalParameters.WriteVisMaterial =
@@ -562,6 +564,13 @@ TCollection_AsciiString DESTEP_ConfigurationNode::Save() const
   aResult += aScope + "write.props :\t " + InternalParameters.WriteProps + "\n";
   aResult += "!\n";
 
+  aResult += "!\n";
+  aResult += "!Setting up the write.metadata parameter which is used to indicate "
+             "write Metadata or not\n";
+  aResult += "!Default value: +. Available values: \"-\", \"+\"\n";
+  aResult += aScope + "write.metadata :\t " + InternalParameters.WriteMetadata + "\n";
+  aResult += "!\n";
+
   aResult += "!\n";
   aResult += "!Setting up the write.material parameter which is used to indicate write "
              "Material properties or not\n";
index 16f702309c0e61683b37c6260d302bfa3afb7d28..c7b10eb784020f84afaeb7f4851d589ab8c73959 100644 (file)
@@ -199,6 +199,7 @@ public:
   bool WriteName = true; //<! NameMode is used to indicate write Name or not
   bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
   bool WriteProps = true; //<! PropsMode is used to indicate write Validation properties or not
+  bool WriteMetadata = true; //<! MetadataMode is used to indicate write metadata properties or not.
   bool WriteMaterial = true;  //<! MaterialMode is used to indicate write Material or not
   bool WriteVisMaterial = false;  //<! VisMaterialMode is used to indicate write Visual Material or not
   STEPControl_StepModelType WriteModelType = STEPControl_AsIs; //<! Gives you the choice of translation mode for an Open CASCADE shape that is being translated to STEP
index cfbf513b047630c46625c426d46069a17f87e1a9..9d89fd2d3dba3c7bf72b4efc5d80972f156cf5da 100644 (file)
@@ -38,6 +38,8 @@
 #include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
 #include <StepBasic_DerivedUnit.hxx>
 #include <StepBasic_DerivedUnitElement.hxx>
+#include <StepBasic_GeneralProperty.hxx>
+#include <StepBasic_GeneralPropertyAssociation.hxx>
 #include <StepBasic_HArray1OfDerivedUnitElement.hxx>
 #include <StepBasic_MeasureValueMember.hxx>
 #include <StepBasic_Product.hxx>
 #include <StepRepr_DescriptiveRepresentationItem.hxx>
 #include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepRepr_HArray1OfRepresentationItem.hxx>
+#include <StepRepr_IntegerRepresentationItem.hxx>
 #include <StepRepr_MeasureRepresentationItem.hxx>
 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
 #include <StepRepr_ProductDefinitionShape.hxx>
 #include <StepRepr_PropertyDefinition.hxx>
+#include <StepRepr_RealRepresentationItem.hxx>
 #include <StepRepr_Representation.hxx>
 #include <StepRepr_RepresentationItem.hxx>
 #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
@@ -247,6 +251,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer()
       myNameMode(Standard_True),
       myLayerMode(Standard_True),
       myPropsMode(Standard_True),
+      myMetadataMode(Standard_True),
       mySHUOMode(Standard_True),
       myGDTMode(Standard_True),
       myMatMode(Standard_True),
@@ -266,6 +271,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer(const Handle(XSControl_WorkSession)
       myNameMode(Standard_True),
       myLayerMode(Standard_True),
       myPropsMode(Standard_True),
+      myMetadataMode(Standard_True),
       mySHUOMode(Standard_True),
       myGDTMode(Standard_True),
       myMatMode(Standard_True),
@@ -786,6 +792,10 @@ Standard_Boolean STEPCAFControl_Writer::transfer(STEPControl_Writer&
   if (GetPropsMode())
     writeValProps(theWriter.WS(), aSubLabels, theIsMulti);
 
+  // write metadata
+  if (GetMetadataMode())
+    writeMetadata(theWriter.WS(), aSubLabels);
+
   // refresh graph
   theWriter.WS()->ComputeGraph(Standard_True);
 
@@ -1606,6 +1616,201 @@ Standard_Boolean STEPCAFControl_Writer::writeNames(const Handle(XSControl_WorkSe
 
 //=================================================================================================
 
+Standard_Boolean STEPCAFControl_Writer::writeMetadata(const Handle(XSControl_WorkSession)& theWS,
+                                                      const TDF_LabelSequence& theLabels) const
+{
+  if (theLabels.IsEmpty())
+  {
+    return Standard_False;
+  }
+
+  // Iterate on requested shapes.
+  for (TDF_LabelSequence::Iterator aLabelIter(theLabels); aLabelIter.More(); aLabelIter.Next())
+  {
+    writeMetadataForLabel(theWS, aLabelIter.Value());
+  }
+
+  return Standard_True;
+}
+
+//=================================================================================================
+
+Standard_Boolean STEPCAFControl_Writer::writeMetadataForLabel(
+  const Handle(XSControl_WorkSession)& theWS,
+  const TDF_Label&                     theLabel) const
+{
+  if (theLabel.IsNull())
+  {
+    return Standard_False;
+  }
+
+  // Get working data:
+  const Handle(XSControl_TransferWriter)& aTW = theWS->TransferWriter();
+  const Handle(Transfer_FinderProcess)&   aFP = aTW->FinderProcess();
+  const Handle(StepData_StepModel)& aModel = Handle(StepData_StepModel)::DownCast(theWS->Model());
+
+  // Check if label has metadata (NamedData):
+  Handle(TDataStd_NamedData) aNamedData;
+  if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), aNamedData))
+    return Standard_False; // No metadata on this label
+
+  // Find target STEP entity for the current shape:
+  if (!myLabels.IsBound(theLabel))
+    return Standard_False; // Not recorded as translated, skip
+
+  const TopoDS_Shape&                             aShape = myLabels.Find(theLabel);
+  Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
+  const Handle(TransferBRep_ShapeMapper)          aMapper = TransferBRep::ShapeMapper(aFP, aShape);
+  if (!aFP->FindTypedTransient(aMapper,
+                               STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation),
+                               aSDR))
+  {
+    return Standard_False; // Cannot find STEP representation
+  }
+
+  // Get the product definition from the shape definition representation:
+  const Handle(StepRepr_PropertyDefinition) aPropDef = aSDR->Definition().PropertyDefinition();
+  if (aPropDef.IsNull())
+    return Standard_False;
+  const Handle(StepBasic_ProductDefinition) aProdDef = aPropDef->Definition().ProductDefinition();
+  if (aProdDef.IsNull())
+    return Standard_False;
+
+  // Export string metadata.
+  const TDataStd_DataMapOfStringString& aStringMap = aNamedData->GetStringsContainer();
+  for (TDataStd_DataMapOfStringString::Iterator anIter(aStringMap); anIter.More(); anIter.Next())
+  {
+    const TCollection_ExtendedString& aKey   = anIter.Key();
+    const TCollection_ExtendedString& aValue = anIter.Value();
+
+    // Create descriptive representation item for the value.
+    const Handle(StepRepr_DescriptiveRepresentationItem) aDescrItem =
+      new StepRepr_DescriptiveRepresentationItem();
+    const Handle(TCollection_HAsciiString) aItemName  = new TCollection_HAsciiString(aKey);
+    const Handle(TCollection_HAsciiString) aItemValue = new TCollection_HAsciiString(aValue);
+    aDescrItem->SetName(aItemName);
+    aDescrItem->SetDescription(aItemValue);
+
+    writeMetadataRepresentationItem(aKey, aModel, aSDR, aProdDef, aDescrItem);
+  }
+
+  // Export integer metadata.
+  const TColStd_DataMapOfStringInteger& aIntMap = aNamedData->GetIntegersContainer();
+  for (TColStd_DataMapOfStringInteger::Iterator anIter(aIntMap); anIter.More(); anIter.Next())
+  {
+    const TCollection_ExtendedString& aKey   = anIter.Key();
+    const Standard_Integer            aValue = anIter.Value();
+    // Create integer representation item for the value.
+    const Handle(StepRepr_IntegerRepresentationItem) aIntItem =
+      new StepRepr_IntegerRepresentationItem();
+    const Handle(TCollection_HAsciiString) aItemName = new TCollection_HAsciiString(aKey);
+    aIntItem->Init(aItemName, aValue);
+
+    writeMetadataRepresentationItem(aKey, aModel, aSDR, aProdDef, aIntItem);
+  }
+
+  // Export real metadata.
+  const TDataStd_DataMapOfStringReal& aRealMap = aNamedData->GetRealsContainer();
+  for (TDataStd_DataMapOfStringReal::Iterator anIter(aRealMap); anIter.More(); anIter.Next())
+  {
+    const TCollection_ExtendedString& aKey   = anIter.Key();
+    const Standard_Real               aValue = anIter.Value();
+    // Create real representation item for the value.
+    const Handle(StepRepr_RealRepresentationItem) aRealItem = new StepRepr_RealRepresentationItem();
+    const Handle(TCollection_HAsciiString)        aItemName = new TCollection_HAsciiString(aKey);
+    aRealItem->Init(aItemName, aValue);
+
+    writeMetadataRepresentationItem(aKey, aModel, aSDR, aProdDef, aRealItem);
+  }
+
+  // Process label children recursively:
+  if (theLabel.HasChild())
+  {
+    for (Standard_Integer aChildInd = 1; aChildInd <= theLabel.NbChildren(); aChildInd++)
+    {
+      const TDF_Label& aChildLabel = theLabel.FindChild(aChildInd);
+      writeMetadataForLabel(theWS, aChildLabel);
+    }
+  }
+
+  return Standard_True;
+}
+
+//=================================================================================================
+
+void STEPCAFControl_Writer::writeMetadataRepresentationItem(
+  const TCollection_AsciiString&                        theKey,
+  const Handle(StepData_StepModel)&                     theModel,
+  const Handle(StepShape_ShapeDefinitionRepresentation) theShapeDefRep,
+  const Handle(StepBasic_ProductDefinition)&            theProdDef,
+  const Handle(StepRepr_RepresentationItem)&            theItem) const
+{
+  // Empty string to use for empty values:
+  const Handle(TCollection_HAsciiString) anEmptyStr = new TCollection_HAsciiString("");
+
+  // Create property_definition:
+  const Handle(StepRepr_PropertyDefinition) aMetaPropDef = new StepRepr_PropertyDefinition();
+  const Handle(TCollection_HAsciiString)    aPropName    = new TCollection_HAsciiString(theKey);
+  const Handle(TCollection_HAsciiString)    aPropDesc =
+    new TCollection_HAsciiString("user defined attribute");
+  aMetaPropDef->SetName(aPropName);
+  aMetaPropDef->SetDescription(aPropDesc);
+
+  // Create a general_property:
+  const Handle(StepBasic_GeneralProperty) aGeneralProp = new StepBasic_GeneralProperty();
+  aGeneralProp->SetId(anEmptyStr);
+  aGeneralProp->SetName(aPropName);
+  aGeneralProp->SetDescription(anEmptyStr);
+
+  // Create a general_property_association:
+  const Handle(StepBasic_GeneralPropertyAssociation) aGeneralPropAssoc =
+    new StepBasic_GeneralPropertyAssociation();
+  aGeneralPropAssoc->SetName(anEmptyStr);
+  aGeneralPropAssoc->SetDescription(anEmptyStr);
+  aGeneralPropAssoc->SetPropertyDefinition(aMetaPropDef);
+  aGeneralPropAssoc->SetGeneralProperty(aGeneralProp);
+
+  // Set the definition to point to the product definition:
+  StepRepr_CharacterizedDefinition aCharDef;
+  aCharDef.SetValue(theProdDef);
+  aMetaPropDef->SetDefinition(aCharDef);
+
+  // Create property_definition_representation:
+  const Handle(StepRepr_PropertyDefinitionRepresentation) aPropDefRepr =
+    new StepRepr_PropertyDefinitionRepresentation();
+  StepRepr_RepresentedDefinition aRepDef;
+  aRepDef.SetValue(aMetaPropDef);
+  aPropDefRepr->SetDefinition(aRepDef);
+
+  // Create representation with descriptive_representation_item:
+  const Handle(StepRepr_Representation)  aRepr     = new StepRepr_Representation();
+  const Handle(TCollection_HAsciiString) aReprName = new TCollection_HAsciiString(theKey);
+  aRepr->SetName(aReprName);
+
+  // Add item to representation:
+  const Handle(StepRepr_HArray1OfRepresentationItem) aItems =
+    new StepRepr_HArray1OfRepresentationItem(1, 1);
+  aItems->SetValue(1, theItem);
+  aRepr->SetItems(aItems);
+
+  // Set representation context (reuse from shape representation):
+  const Handle(StepRepr_RepresentationContext) aRC =
+    theShapeDefRep->UsedRepresentation()->ContextOfItems();
+  aRepr->SetContextOfItems(aRC);
+
+  aPropDefRepr->SetUsedRepresentation(aRepr);
+
+  // Add entities to the model:
+  theModel->AddWithRefs(aMetaPropDef);
+  theModel->AddWithRefs(aGeneralProp);
+  theModel->AddWithRefs(aGeneralPropAssoc);
+  theModel->AddWithRefs(aPropDefRepr);
+  theModel->AddWithRefs(aRepr);
+  theModel->AddWithRefs(theItem);
+}
+
+//=================================================================================================
+
 static Standard_Boolean WritePropsForLabel(const Handle(XSControl_WorkSession)&      theWS,
                                            const STEPCAFControl_DataMapOfLabelShape& theLabels,
                                            const TDF_Label&                          theLabel,
index a32839b8ba2a14c558be59b806a5366dce0de74f..ee39daf9449dbb845a73922c31824a388b522915 100644 (file)
@@ -40,6 +40,7 @@ class XSControl_WorkSession;
 class TDocStd_Document;
 class STEPCAFControl_ExternFile;
 class TopoDS_Shape;
+class StepShape_ShapeDefinitionRepresentation;
 
 //! Provides a tool to write DECAF document to the
 //! STEP file. Besides transfer of shapes (including
@@ -211,6 +212,11 @@ public:
 
   Standard_Boolean GetPropsMode() const { return myPropsMode; }
 
+  //! Set MetadataMode for indicate write metadata or not.
+  void SetMetadataMode(const Standard_Boolean theMetadataMode) { myMetadataMode = theMetadataMode; }
+
+  Standard_Boolean GetMetadataMode() const { return myMetadataMode; }
+
   //! Set SHUO mode for indicate write SHUO or not.
   void SetSHUOMode(const Standard_Boolean theSHUOMode) { mySHUOMode = theSHUOMode; }
 
@@ -316,6 +322,28 @@ protected:
   Standard_Boolean writeNames(const Handle(XSControl_WorkSession)& theWS,
                               const TDF_LabelSequence&             theLabels) const;
 
+  //! Write metadata assigned to specified labels, to STEP model
+  Standard_Boolean writeMetadata(const Handle(XSControl_WorkSession)& theWS,
+                                 const TDF_LabelSequence&             theLabels) const;
+
+  //! Write metadata assigned to specified label, to STEP model.
+  // Also recursively writes metadata for children labels.
+  Standard_Boolean writeMetadataForLabel(const Handle(XSControl_WorkSession)& theWS,
+                                         const TDF_Label&                     theLabel) const;
+
+  //! Write metadata representation item to STEP model.
+  //! @param theKey The key for metadata item.
+  //! @param theModel The STEP model to write to.
+  //! @param theShapeDefRep The shape definition representation.
+  //! @param theProdDef The product definition.
+  //! @param theItem The representation item to write.
+  void writeMetadataRepresentationItem(
+    const TCollection_AsciiString&                        theKey,
+    const Handle(StepData_StepModel)&                     theModel,
+    const Handle(StepShape_ShapeDefinitionRepresentation) theShapeDefRep,
+    const Handle(StepBasic_ProductDefinition)&            theProdDef,
+    const Handle(StepRepr_RepresentationItem)&            theItem) const;
+
   //! Write D&GTs assigned to specified labels, to STEP model
   Standard_Boolean writeDGTs(const Handle(XSControl_WorkSession)& theWS,
                              const TDF_LabelSequence&             theLabels) const;
@@ -398,6 +426,7 @@ private:
   Standard_Boolean                                                                myNameMode;
   Standard_Boolean                                                                myLayerMode;
   Standard_Boolean                                                                myPropsMode;
+  Standard_Boolean                                                                myMetadataMode;
   Standard_Boolean                                                                mySHUOMode;
   MoniTool_DataMapOfShapeTransient                                                myMapCompMDGPR;
   Standard_Boolean                                                                myGDTMode;
index cf0895b77771bab53538da3a78d1fe34c73a220d..27c47402eb89ec6e45206650d33f0d295393214c 100644 (file)
@@ -196,6 +196,7 @@ provider.STEP.OCC.write.name :       1
 provider.STEP.OCC.write.layer :         1
 provider.STEP.OCC.write.material :      1
 provider.STEP.OCC.write.vismaterial :   0
+provider.STEP.OCC.write.metadata :  1
 provider.STEP.OCC.write.props :         1
 provider.STEP.OCC.write.model.type :    0
 provider.STEP.OCC.write.cleanduplicates : 0
index 4999dddb44e9043b8a7a952144ecd6f03c22c00e..ad001886fb243812401ae1ab770f39b622b68e8e 100644 (file)
@@ -141,6 +141,7 @@ provider.STEP.OCC.write.layer :      1
 provider.STEP.OCC.write.props :         1
 provider.STEP.OCC.write.material :      1
 provider.STEP.OCC.write.vismaterial :   0
+provider.STEP.OCC.write.metadata :  1
 provider.STEP.OCC.write.model.type :    0
 provider.STEP.OCC.write.cleanduplicates : 0
 provider.STEP.OCC.write.scaling.trsf : 1
index 8521d66daf0ec2c7e09f08eff8db114634866b8f..1a5abfc032828c7240d9d00b720c550c90e84086 100644 (file)
@@ -1,8 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug28345_30338.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 41611
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 H_CIP : 55.545955351400004
 ProductID : MVE0300X02S030_ASM
 ProductName : MVE0300X02S030_ASM
@@ -35,5 +35,4 @@ MODELED_BY :
 ProductID : NOCUT_MVE0300X02S030
 ProductName : NOCUT_MVE0300X02S030
 Description : NOT SPECIFIED
-
 }
index d4f0cf9c370a044de772a4f122246442f4e1640e..21f49a5bba79503732017cd102c553f8e793a086 100644 (file)
@@ -1,8 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug28389_CONFIDENTIAL_SHEET_METAL_F3D.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 980255
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 yCenterOfGravity : 0.1148447698
 Ixz : 9.3210000000000004e-07
 Izx : 9.3210000000000004e-07
@@ -11,11 +11,11 @@ Surface : 0.34595390710000001
 Volume : 0.0001375456
 Iyz : -1.2030000000000001e-07
 zCenterOfGravity : -0.056064514900000001
-Iyy : 3.6385e-06
 Ixy : 2.044e-07
+Iyy : 3.6385e-06
 xCenterOfGravity : -0.12673526900000001
-Izz : 3.3558999999999999e-06
 Density : 1000
+Izz : 3.3558999999999999e-06
 Ixx : 1.7740000000000001e-06
 Izy : -1.2030000000000001e-07
 Mass : 0.13754561600000001
@@ -24,5 +24,14 @@ OriginX : 0
 OriginZ : 0
 JoggleFormula : 
 ProductID : SHEET METAL F3D
-
+ProductName : SHEET METAL F3D
+Property for [0:1:1:2]:
+ProductID : SOLID
+ProductName : SOLID
+Property for [0:1:1:3]:
+ProductID : COMPOUND
+ProductName : COMPOUND
+Property for [0:1:1:4]:
+ProductID : COMPOUND
+ProductName : COMPOUND
 }
index 18baf5030fb5d9e5aa9374994502715b642c575d..e970d02870e59f15383702b21d7c02273b3c3df7 100644 (file)
@@ -1,8 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug28444_nist_ftc_06_asme1_ct5240_rd.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 914211
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 yCenterOfGravity : 0.0289950044
 Ixz : 0
 Izx : 0
@@ -10,17 +10,23 @@ Surface : 0.28317040780000002
 Volume : 0.0033238733999999999
 Iyz : -1.3068999999999999e-06
 zCenterOfGravity : -0.10963042420000001
-Iyy : 4.46342e-05
 Ixy : 0
+Iyy : 4.46342e-05
 xCenterOfGravity : -0
-Izz : 2.63853e-05
 Density : 1000
+Izz : 2.63853e-05
 Length : 0
 Ixx : 2.16819e-05
 Izy : -1.3068999999999999e-06
 Mass : 3.3238733752999998
 Iyx : 0
 ProductID : NIST PMI FTC 06 ASME1
+ProductName : NIST PMI FTC 06 ASME1
 Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
-
+Property for [0:1:1:2]:
+ProductID : SOLID
+ProductName : SOLID
+Property for [0:1:1:3]:
+ProductID : COMPOUND
+ProductName : COMPOUND
 }
index e5cae202447e253f67bda29b60728a564d5b471b..2d3d1d0e9eca9dc848f9103b35cf021c877a9387 100644 (file)
@@ -1,13 +1,18 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename nist_ftc_08_asme1_ap242-2.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 334466
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 ProductID : NIST PMI FTC 08 ASME1
 ProductDefinition :  
 Revision : C
 PartNumber : NIST PMI FTC 08 ASME1
 DescriptionRef : NIST PMI test model downloaded from http://go.usa.gov/mGVm
 ProductName : NIST PMI FTC 08 ASME1
-
+Property for [0:1:1:2]:
+ProductID : SOLID
+ProductName : SOLID
+Property for [0:1:1:3]:
+ProductID : SHELL
+ProductName : SHELL
 }
index 68c6f2531124d603ec10c816ee71ef936733b9f3..352aaa33342f2f5329e9da49a28a3a4db5bc8a46 100644 (file)
@@ -1,15 +1,15 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug29633_nist_ctc_05_asme1_ap242-1.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 769775
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 FILESIZE : 1495040
 GDT_STANDARD : 5302
 ProductID : nist_ctc_05_asme1
 MaterialMultipleAssigned : FALSE
 ATTR_VERSION : 18.3.001
-Part Number : NIST PMI CTC 05 ASME1
 FILESAVETIME : Tue Dec 09 03:47:24 2014
+Part Number : NIST PMI CTC 05 ASME1
 Revision : D
 CAD_SOURCE : ug
 MTIME : 1418096844
@@ -17,5 +17,4 @@ ProductName : nist_ctc_05_asme1
 MaterialMissingAssignments : TRUE
 FILENAME : nist_ctc_05_asme1.prt
 Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
-
 }
index e23a88960cd71fe9c79f25a008b92533b674acdb..3a9fb07fe3cd038434a48359f23617ef4ac0417c 100644 (file)
@@ -1,30 +1,30 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug29803.stp
-
-set ref_data {
-Property for [0:1:1:1]:
-OUT_MASS : 50.813477444850157
-RELIEF_DIA : 21.005799999999997
+set ref_size 518981
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
+OUT_MASS : 50.813477444850001
+RELIEF_DIA : 21.005800000000001
 HELIX_LENGTH : 0
-OUT_OAL : 78.049999999992593
+OUT_OAL : 78.049999999993005
 HELIX_START : 0
-OUT_SHANK_LEN : 27.2499999999926
+OUT_SHANK_LEN : 27.249999999993001
 RCA_SIZE : 0
 SHANK_UNDER : 0
 OUT_REF_LEN : 50.799999999999997
-BODY_LENGTH : 48.513999999999996
-THEO_BLADE_DIA : 11.074399999999999
-DRILL_DEPTH : 47.625
+BODY_LENGTH : 48.514000000000003
+THEO_BLADE_DIA : 11.074400000000001
 BODY_DIA : 0
+DRILL_DEPTH : 47.625
 SHANK_SIZE : 16
-OUT_SHANK_DIA : 15.999999999999499
-FLUTE_LENGTH : 42.468799999999995
+FLUTE_LENGTH : 42.468800000000002
+OUT_SHANK_DIA : 15.999999999999
 PRIORITY : 0
-OUT_DRILL_DEPTH : 44.754799999999996
+OUT_DRILL_DEPTH : 44.754800000000003
 SCREW_HOLE_SKEW : 1.1000000000000001
-SHANK_DIAMETER : 15.999999999999499
-SS_FLANGE : NO
+SHANK_DIAMETER : 15.999999999999
 DESCRIPTION : T-A HOLDER
+SS_FLANGE : NO
 MODELED_BY : LSD
 STANDARD_BODY_DIA : Y
 DEEP_HOLE_WEBSITE : 
@@ -41,5 +41,4 @@ ProductName : Tool1
 Description : NOT SPECIFIED
 SERIES : Y
 DEEP_HOLE_NOTES : 
-
 }
index aa4292b59367e29ad8599c57e65fff6f9824496d..185f31b88e8843c99c17dd7b55eaa8693643e294 100644 (file)
@@ -1,8 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename sp7_04-do-242.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 2654398
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 PRO_MP_ALT_COGX : - >
 DESCRIPTION ACCESS : Full
 PRO_MP_TRF_21 DESCRIPTION : NULL
@@ -35,8 +35,8 @@ PRO_MP_IZZ DESIGNATED : NO
 PRO_MP_TRF_42 SOURCE : Mass Properties
 PRO_MP_ALT_AREA DESIGNATED : NO
 PRO_MP_TRF_12 DESIGNATED : NO
-PRO_MP_ALT_INERTIA_ORIGIN DESCRIPTION : NULL
 PRO_MP_ALT_AREA SOURCE : Alternate Mass Prop
+PRO_MP_ALT_INERTIA_ORIGIN DESCRIPTION : NULL
 PRO_MP_CSYS DESCRIPTION : NULL
 PRO_MP_TRF_12 SOURCE : Mass Properties
 PRO_MP_TRF_31 DESIGNATED : NO
@@ -77,8 +77,8 @@ PRO_MP_ALT_IZZ DESCRIPTION : NULL
 PRO_MP_ALT_IYY SOURCE : Alternate Mass Prop
 PRO_MP_IYZ ACCESS : Locked
 PRO_MP_ALT_IXZ DESIGNATED : NO
-PRO_MP_TRF_13 ACCESS : Locked
 PRO_MP_IXY ACCESS : Locked
+PRO_MP_TRF_13 ACCESS : Locked
 PRO_MP_DENSITY DESCRIPTION : NULL
 PRO_MP_AREA ACCESS : Locked
 PRO_MP_TRF_31 : - >
@@ -107,8 +107,8 @@ PRO_MP_ALT_IXX DESCRIPTION : NULL
 PRO_MP_IXX SOURCE : Mass Properties
 PRO_MP_ALT_CSYS DESCRIPTION : NULL
 PRO_MP_TRF_13 : - >
-PRO_MP_TRF_21 SOURCE : Mass Properties
 PRO_MP_IYY : - >
+PRO_MP_TRF_21 SOURCE : Mass Properties
 PRO_MP_SOURCE DESCRIPTION : NULL
 PRO_MP_TRF_32 SOURCE : Mass Properties
 PRO_MP_IZZ ACCESS : Locked
@@ -123,14 +123,14 @@ PRO_MP_IXY SOURCE : Mass Properties
 PRO_MP_SOURCE DESIGNATED : NO
 PRO_MP_TRF_22 ACCESS : Locked
 PRO_MP_VOLUME SOURCE : Mass Properties
-PRO_MP_IZZ DESCRIPTION : NULL
 MP_DENSITY DESIGNATED : NO
+PRO_MP_IZZ DESCRIPTION : NULL
 PRO_MP_IXX ACCESS : Locked
 PRO_MP_TRF_31 ACCESS : Locked
 PRO_MP_AREA : - >
 PRO_MP_CSYS : - >
-PRO_MP_ALT_IYZ DESIGNATED : NO
 PRO_MP_ALT_COGX ACCESS : Full
+PRO_MP_ALT_IYZ DESIGNATED : NO
 PRO_MP_TRF_42 DESIGNATED : NO
 PRO_MP_ALT_COGY : - >
 PRO_MP_IXZ DESIGNATED : NO
@@ -155,8 +155,8 @@ PRO_MP_IXZ SOURCE : Mass Properties
 PRO_MP_TRF_23 ACCESS : Locked
 PRO_MP_ALT_IXY : - >
 PRO_MP_ALT_IYZ SOURCE : Alternate Mass Prop
-PRO_MP_ALT_INERTIA_ORIGIN SOURCE : Alternate Mass Prop
 PRO_MP_TRF_42 ACCESS : Locked
+PRO_MP_ALT_INERTIA_ORIGIN SOURCE : Alternate Mass Prop
 REVISION : D
 PRO_MP_ALT_IXY ACCESS : Full
 DESCRIPTION DESIGNATED : YES
@@ -164,25 +164,25 @@ PRO_MP_TRF_22 DESCRIPTION : NULL
 PRO_MP_TRF_12 ACCESS : Locked
 PRO_MP_SOURCE ACCESS : Full
 REVISION DESIGNATED : YES
-PRO_MP_TRF_43 DESCRIPTION : NULL
 PRO_MP_IXZ ACCESS : Locked
+PRO_MP_TRF_43 DESCRIPTION : NULL
 PRO_MP_COGY DESCRIPTION : NULL
 PRO_MP_INERTIA_ORIGIN DESIGNATED : NO
 PRO_MP_TRF_12 : - >
 REVISION DESCRIPTION : NULL
 PRO_MP_ALT_IXY SOURCE : Alternate Mass Prop
 PRO_MP_TRF_11 DESCRIPTION : NULL
-PRO_MP_TRF_11 : - >
 PRO_MP_ALT_MASS DESIGNATED : NO
+PRO_MP_TRF_11 : - >
 PRO_MP_TRF_43 SOURCE : Mass Properties
 PART_NUMBER ACCESS : Full
 PRO_MP_VOLUME DESCRIPTION : NULL
-PRO_MP_COGZ DESCRIPTION : NULL
 PRO_MP_ALT_IXY DESCRIPTION : NULL
+PRO_MP_COGZ DESCRIPTION : NULL
 PRO_MP_COGX : - >
 PRO_MP_SOURCE SOURCE : Alternate Mass Prop
-PRO_MP_TRF_22 DESIGNATED : NO
 PRO_MP_ALT_IXX : - >
+PRO_MP_TRF_22 DESIGNATED : NO
 PRO_MP_TRF_42 : - >
 PRO_MP_INERTIA_ORIGIN SOURCE : Mass Properties
 PRO_MP_COGZ DESIGNATED : NO
@@ -193,6 +193,7 @@ PRO_MP_TRF_23 : - >
 PRO_MP_IXX DESIGNATED : NO
 PRO_MP_ALT_CSYS ACCESS : Full
 PRO_MP_CSYS ACCESS : Locked
+ProductName : NIST_CTC_04_ASME1_RD_CR4050_RA
 PRO_MP_TRF_22 : - >
 PRO_MP_TRF_33 SOURCE : Mass Properties
 PRO_MP_COGZ SOURCE : Mass Properties
@@ -208,8 +209,8 @@ PRO_MP_TRF_21 DESIGNATED : NO
 MP_DENSITY DESCRIPTION : NULL
 PRO_MP_TRF_41 DESIGNATED : NO
 REVISION ACCESS : Full
-PRO_MP_ALT_IZZ DESIGNATED : NO
 PRO_MP_ALT_COGX DESCRIPTION : NULL
+PRO_MP_ALT_IZZ DESIGNATED : NO
 PRO_MP_DENSITY : 0.000000
 PRO_MP_IXY : - >
 PRO_MP_ALT_MASS ACCESS : Full
@@ -218,8 +219,8 @@ PRO_MP_TRF_43 : - >
 PRO_MP_ALT_IXZ SOURCE : Alternate Mass Prop
 PRO_MP_IXZ : - >
 PRO_MP_MASS ACCESS : Locked
-PRO_MP_ALT_COGZ ACCESS : Full
 PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
+PRO_MP_ALT_COGZ ACCESS : Full
 PRO_MP_VOLUME : - >
 PRO_MP_ALT_IXX DESIGNATED : NO
 MP_DENSITY ACCESS : Full
@@ -234,5 +235,13 @@ PRO_MP_ALT_VOLUME DESIGNATED : NO
 PART_NUMBER : NIST PMI CTC 04 ASME1
 PRO_MP_TRF_43 ACCESS : Locked
 PRO_MP_ALT_AREA ACCESS : Full
-
+Property for [0:1:1:2]:
+ProductID : SOLID
+ProductName : SOLID
+Property for [0:1:1:3]:
+ProductID : SHELL
+ProductName : SHELL
+Property for [0:1:1:4]:
+ProductID : COMPOUND
+ProductName : COMPOUND
 }
index cfa9ac30ce9d15865a944f403321c397bb64470f..74b5ccde2e89b061c9df9e887da49e4a5b60f6c0 100644 (file)
@@ -1,8 +1,8 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 set filename bug32087_part.stp
-
-set ref_data {
-Property for [0:1:1:1]:
+set ref_size 105117
+set check_metadata 1
+set ref_metadata {Property for [0:1:1:1]:
 SETUP_PART : 0
 MODEL_3D_REVISION : 1
 MATERIAL_DENSITY : 7850
@@ -12,29 +12,29 @@ WEIGHT_CALCULATED : 0.0070751592515700002
 SUPPLIER_NAME : 
 SEMI_FINISHED_PRODUCT : 
 REFERENCE : 
-MODEL_3D_CAD_SYSTEM : 
-MODEL_3D_APPROVED_BY : 
 REFERENCE_DESIGNATION++ : 
+MODEL_3D_APPROVED_BY : 
+MODEL_3D_CAD_SYSTEM : 
 PART_NAME : 
-ProductID : Block
 MODEL_3D_CHECKED_BY : 
+ProductID : Block
 OWNER : 
 COPYRIGHT : 
 WORK_ORDER_NUMBER : 
 PART_NUMBER : 
 ID_NUMBER_MATERIAL : 
 SPARE_WEARING_PART : 
-TREATMENT : 
 GENERAL_TOLERANCES_DRILL_HOLE : 
+TREATMENT : 
 MODEL_3D_CREATED_BY : 
 UNIT_SYSTEM : 
 MODEL_3D_DATE_OF_ISSUE : 
 ProductDefinition :  
 WELD_TOLERANCES : 
 PROJECT : 
-MODEL_3D_RELEASED_STATUS : 
-MODEL_3D_CREATED_BY_DEPARTMENT : 
 LANGUAGE : 
+MODEL_3D_CREATED_BY_DEPARTMENT : 
+MODEL_3D_RELEASED_STATUS : 
 TECHNICAL_SPECIFICATION : 
 SUPPLIER_NUMBER : 
 SURFACE_PROTECTION : 
@@ -45,22 +45,23 @@ ORDER_NUMBER :
 GENERAL_TOLERANCES_FIT_DRILL_HOLE : 
 REFERENCE_DESIGNATION= : 
 SURFACE_ROUGHNESS : 
-TECHNICAL_DIRECTIVE : 
-TOLERANCING_PRINCIPLE : 
 REFERENCE_DESIGNATION- : 
+TOLERANCING_PRINCIPLE : 
+TECHNICAL_DIRECTIVE : 
 STOCK_NUMBER : 
 MODEL_3D_APPROVED_BY_DEPARTMENT : 
 PART_REVISION_LEVEL : 
-ARTICLE_NUMBER : 
 EDGE_CONDITION_OUTER_EDGE : 
+ARTICLE_NUMBER : 
 MATERIAL : 
-SIMPLIFIED_DRAWING_REVISION : 
 REFERENCE_DESIGNATION== : 
+SIMPLIFIED_DRAWING_REVISION : 
 MODEL_3D_REVISION_LEVEL : 
+ProductName : Block
 MODEL_3D_RELEASED_BY : 
 MODEL_3D_REPLACED_BY : 
-MODEL_3D_ID_NUMBER : 
 REFERENCE_DESIGNATION+ : 
+MODEL_3D_ID_NUMBER : 
 PART_NOTE : 
 WELD_PREPARATION : 
 Description : Block
@@ -68,5 +69,4 @@ MODEL_3D_RELEASED_DATE :
 MODEL_3D_REPLACES : 
 PAINT_SURFACE : 
 PART_SOURCE : 
-
 }
index 4bb4e53c335481f120849e6e74305d946e352232..33f07344ab0ac05c7afcdd86309ae9d5899cf4d9 100644 (file)
 # Set flag dump_file to 1 in order to regenerate script files with actual data
 # used as reference. In this mode all tests intentionally report failure.
 set dump_file 0
-########################################################################
-set mist 0;
-set todo_msg ""
-set todo_mask "puts \"TODO CR00000 ALL: "
-set end_line "\" \n"
-##################################################################
 
-set conf "provider.STEP.OCC.read.productmetadata : 1"
+set aReadMetadataConfig "provider.STEP.OCC.read.productmetadata : 1"
+set aWriteMetadataConfig "provider.STEP.OCC.write.metadata : 1"
 
 # Read original file
-if { [string length $filename] > 1} {
-  set path_file [locate_data_file $filename]
-  if { [catch { ReadFile D $path_file -conf $conf } catch_result] } {
-    set err_msg "Error: file was not read - exception "
-    puts $err_msg
-    append todo_msg $todo_mask $err_msg $end_line
-    set mist 1
-  }
-} else {
-  set mist 1
-}
-
-# Get information about translation
-if { $mist < 1} {
-  puts ""
-  set prop [ XGetProperties D ] 
+set path_file [locate_data_file $filename]
+ReadFile anDocInput_1 $path_file -conf $aReadMetadataConfig
 
-  if { [llength $prop] < 0 } {
-      puts " Metadata was NOT provided"
-    }
-}
-if { $mist < 1} {
-  # Close the document
-  if { [catch { Close D } catch_result] } {
-    set err_msg "Error : cannot close a document D - exception"
-    puts $err_msg
-    append todo_msg $todo_mask $err_msg $end_line
-  }
-}
+#Name for a file to write
+set aWrittenFileName $imagedir/${casename}_written.step
 
-if { $mist != 1 } {
-  puts "" 
-  set result ""
-  append result [format $prop]
-}
+# Write file
+WriteFile anDocInput_1 $aWrittenFileName -conf $aWriteMetadataConfig
+set aSize [file size $aWrittenFileName]
 
-set ref_Compare 0
-# Put reference data to the test script file if option "dump" is set
-if { $dump_file == 1 } {
-  set fd_stream  [open $dirname/$groupname/$gridname/$casename w]
-  fconfigure $fd_stream -encoding utf-8
-  puts $fd_stream "# !!!! This file is generated automatically, do not edit manually! See end script"
-  puts $fd_stream "set filename $filename"
-  if { $mist != 1 } {
-    puts $fd_stream "" 
-    puts $fd_stream "set ref_data \{"
-    puts $fd_stream $result
-    puts $fd_stream "\}"
-  }
-  close $fd_stream 
-} elseif { $mist != 1 } {
-  puts "========================== Comparison with reference data ========"
-  
-  # Comparison of reference data with obtained result
-  set ref_list [split $ref_data \n]
-  set cur_list [split $result \n]
-  set nb_ref [llength $ref_list]
-  for { set i 0 } { $i < $nb_ref } { incr i } {
-    set j [expr $i + 1]
-    set refstr [lindex $ref_list $j]
-    set curstr [lindex $cur_list $i]
-    set isOK 1;
+# Read just written and get its metadata.
+ReadFile anDocInput_2 $aWrittenFileName -conf $aReadMetadataConfig
+set aMetaDataBase [ XGetProperties anDocInput_2 ]
+set aMetaData [format $aMetaDataBase]
 
-    if {[string equal $refstr $curstr] == 0} {
-      incr ref_Compare
-      puts "Reference data - $refstr\n"
-      puts "Current data - $curstr\n"
-      puts "----------------------------------------------\n"
+if { $dump_file == 1 } { 
+    set fd_stream  [open $dirname/$groupname/$gridname/$casename w] 
+    puts $fd_stream "# !!!! This file is generated automatically, do not edit manually! See end script"
+    puts $fd_stream "set filename $filename"
+    puts $fd_stream "set ref_size $aSize"
+    puts $fd_stream "set check_metadata $check_metadata"
+    if {$check_metadata == 1} {
+      puts $fd_stream "set ref_metadata \{$aMetaData\}"
     }
-  }
-}
-
-if { $dump_file != 0 } {
+    close $fd_stream
     puts "Error : Running in regeneration mode, comparison was not performed!"
-    if { $mist != 1 } {
-      puts "Generation of test file $groupname/$gridname/$casename successful"
-    } else {
-      puts "Generation of reference data failed"
-    }
 } else {
-    if { $ref_Compare >= 1} {
-      puts "Error : differences with reference data found : $ref_Compare"
-    } else {
-      puts "Comparison of current result with reference data - OK\n"
+    set tolerance [expr {min(max(0.001 * $ref_size, 1), 100)}]
+    if {abs($aSize - $ref_size) > $tolerance} {
+        puts "Error: Wrong file size $aSize instead of $ref_size"
+    }
+    
+    if {$check_metadata == 1} {
+      # Compare metadata in files.
+      set aMetaDataLines [split ${aMetaData} "\n"]
+      set aRefMetaDataLines [split ${ref_metadata} "\n"]
+      set aMetaDataLinesCount [llength $aMetaDataLines]
+      set aRefMetaDataLinesCount [llength $aRefMetaDataLines]
+      set aMinLineCount [expr min($aMetaDataLinesCount, $aRefMetaDataLinesCount)]
+      for {set aLineIndex 0} {$aLineIndex < $aMinLineCount} {incr aLineIndex} {
+        set aCurrentMetaDataLine [lindex $aMetaDataLines $aLineIndex]
+        set aCurrentRefMetaDataLine [lindex $aRefMetaDataLines $aLineIndex]
+        if {$aCurrentMetaDataLine != $aCurrentRefMetaDataLine} {
+          puts "Error: Incorrect metadata at line $aLineIndex"
+          puts "Expected: \"$aCurrentRefMetaDataLine\""
+          puts "Actual:   \"$aCurrentMetaDataLine\""
+          break
+        }
+      }
+      # It is faster to check this condition first, before string-by-string comparison,
+      # however string-by-string comparison would be more informative in case of error.
+      if {$aMetaDataLinesCount != $aRefMetaDataLinesCount} {
+           puts "Error: Line count is metadata doesn't match the expected value."
+          puts "Expected: $aRefMetaDataLinesCount"
+          puts "Actual:   $aMetaDataLinesCount"
+      }
     }
 }
+
+# finalize scenario
+Close anDocInput_1
+Close anDocInput_2
+file delete $aWrittenFileName
 puts "TEST COMPLETED"