- 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
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 =
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";
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
#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>
myNameMode(Standard_True),
myLayerMode(Standard_True),
myPropsMode(Standard_True),
+ myMetadataMode(Standard_True),
mySHUOMode(Standard_True),
myGDTMode(Standard_True),
myMatMode(Standard_True),
myNameMode(Standard_True),
myLayerMode(Standard_True),
myPropsMode(Standard_True),
+ myMetadataMode(Standard_True),
mySHUOMode(Standard_True),
myGDTMode(Standard_True),
myMatMode(Standard_True),
if (GetPropsMode())
writeValProps(theWriter.WS(), aSubLabels, theIsMulti);
+ // write metadata
+ if (GetMetadataMode())
+ writeMetadata(theWriter.WS(), aSubLabels);
+
// refresh graph
theWriter.WS()->ComputeGraph(Standard_True);
//=================================================================================================
+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,
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
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; }
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>s assigned to specified labels, to STEP model
Standard_Boolean writeDGTs(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
Standard_Boolean myNameMode;
Standard_Boolean myLayerMode;
Standard_Boolean myPropsMode;
+ Standard_Boolean myMetadataMode;
Standard_Boolean mySHUOMode;
MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
Standard_Boolean myGDTMode;
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
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
# !!!! 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
ProductID : NOCUT_MVE0300X02S030
ProductName : NOCUT_MVE0300X02S030
Description : NOT SPECIFIED
-
}
# !!!! 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
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
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
}
# !!!! 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
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
}
# !!!! 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
}
# !!!! 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
MaterialMissingAssignments : TRUE
FILENAME : nist_ctc_05_asme1.prt
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
-
}
# !!!! 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 :
Description : NOT SPECIFIED
SERIES : Y
DEEP_HOLE_NOTES :
-
}
# !!!! 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
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
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 : - >
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
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
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
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
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
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
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
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
}
# !!!! 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
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 :
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
MODEL_3D_REPLACES :
PAINT_SURFACE :
PART_SOURCE :
-
}
# 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"