1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

Data Exchange, Step Import - Adding product attributes to metadata #315

Product attributes metadata for step files is now handled during import.
Attribute ReadProductMetadata is added to DESTEP_Parameters.
Method STEPCAFControl_Reader::ReadMetadata() is partially refactored.
Metadata tests for STEP are updated with new data.
Metadata tests for GLTF are updated with new data (since original
metadata in those tests is acquired from STEP files).
This commit is contained in:
Dmitrii Kulikov 2025-02-01 17:16:21 +00:00 committed by GitHub
parent 60360e3204
commit 4b608f0bf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 512 additions and 224 deletions

View File

@ -142,6 +142,8 @@ bool DESTEP_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
theResource->BooleanVal("read.props", InternalParameters.ReadProps, aScope);
InternalParameters.ReadMetadata =
theResource->BooleanVal("read.metadata", InternalParameters.ReadMetadata, aScope);
InternalParameters.ReadProductMetadata =
theResource->BooleanVal("read.productmetadata", InternalParameters.ReadProductMetadata, aScope);
InternalParameters.WritePrecisionMode =
(DESTEP_Parameters::WriteMode_PrecisionMode)theResource->IntegerVal(
@ -435,6 +437,13 @@ TCollection_AsciiString DESTEP_ConfigurationNode::Save() const
aResult += aScope + "read.metadata :\t " + InternalParameters.ReadMetadata + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the read.productmetadata parameter which is used to indicate whether to "
"read Product Metadata or not\n";
aResult += "!Default value: 0(\"OFF\"). Available values: 0(\"OFF\"), 1(\"ON\")\n";
aResult += aScope + "read.productmetadata :\t " + InternalParameters.ReadProductMetadata + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Write Parameters:\n";
aResult += "!\n";

View File

@ -55,11 +55,6 @@ void DESTEP_Parameters::InitFromStatic()
ReadIdeas = Interface_Static::IVal("read.step.ideas") == 1;
ReadAllShapes = Interface_Static::IVal("read.step.all.shapes") == 1;
ReadRootTransformation = Interface_Static::IVal("read.step.root.transformation") == 1;
ReadColor = Interface_Static::IVal("read.color") == 1;
ReadName = Interface_Static::IVal("read.name") == 1;
ReadLayer = Interface_Static::IVal("read.layer") == 1;
ReadProps = Interface_Static::IVal("read.props") == 1;
ReadMetadata = Interface_Static::IVal("read.metadata") == 1;
WritePrecisionMode =
(DESTEP_Parameters::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");

View File

@ -181,6 +181,7 @@ public:
bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
bool ReadProps = true; //<! PropsMode is used to indicate read Validation properties or not
bool ReadMetadata = true; //! Parameter for metadata reading
bool ReadProductMetadata = false; //! Parameter for product metadata reading
// Write
WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the STEP file

View File

@ -69,6 +69,7 @@ bool DESTEP_Provider::Read(const TCollection_AsciiString& thePath,
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
aReader.SetMetaMode(aNode->InternalParameters.ReadMetadata);
aReader.SetProductMetaMode(aNode->InternalParameters.ReadProductMetadata);
aReader.SetShapeFixParameters(aNode->ShapeFixParameters);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
DESTEP_Parameters aParams = aNode->InternalParameters;

View File

@ -761,7 +761,15 @@ Standard_Boolean STEPCAFControl_Reader::Transfer(STEPControl_Reader&
// read metadata
if (GetMetaMode())
{
ReadMetadata(reader.WS(), doc, aLocalFactors);
}
// read product metadata
if (GetProductMetaMode())
{
ReadProductMetadata(reader.WS(), doc);
}
// Expand resulting CAF structure for sub-shapes (optionally with their
// names) if requested
@ -5731,6 +5739,20 @@ Standard_Boolean STEPCAFControl_Reader::GetMetaMode() const
//=================================================================================================
void STEPCAFControl_Reader::SetProductMetaMode(const Standard_Boolean theProductMetaMode)
{
myProductMetaMode = theProductMetaMode;
}
//=================================================================================================
Standard_Boolean STEPCAFControl_Reader::GetProductMetaMode() const
{
return myProductMetaMode;
}
//=================================================================================================
void STEPCAFControl_Reader::SetSHUOMode(const Standard_Boolean mode)
{
mySHUOMode = mode;
@ -5830,229 +5852,305 @@ const STEPCAFControl_Reader::ProcessingFlags& STEPCAFControl_Reader::GetShapePro
//=================================================================================================
TDF_Label STEPCAFControl_Reader::getShapeLabelFromProductDefinition(
const Handle(Transfer_TransientProcess)& theTransferProcess,
const Handle(StepBasic_ProductDefinition)& theProductDefinition) const
{
TDF_Label aShapeLabel;
Handle(Transfer_Binder) aBinder = theTransferProcess->Find(theProductDefinition);
if (aBinder.IsNull())
{
return aShapeLabel;
}
const TopoDS_Shape aShape = TransferBRep::ShapeResult(theTransferProcess, aBinder);
if (aShape.IsNull())
{
return aShapeLabel;
}
myMap.Find(aShape, aShapeLabel);
return aShapeLabel;
}
//=================================================================================================
Handle(StepBasic_Product) STEPCAFControl_Reader::getProductFromProductDefinition(
const Handle(StepBasic_ProductDefinition)& theProductDefinition) const
{
Handle(StepBasic_ProductDefinitionFormation) aFormation = theProductDefinition->Formation();
if (aFormation.IsNull())
{
return nullptr;
}
return aFormation->OfProduct();
}
//=================================================================================================
std::vector<Handle(StepRepr_PropertyDefinition)> STEPCAFControl_Reader::collectPropertyDefinitions(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Standard_Transient)& theGeneralProperty) const
{
std::vector<Handle(StepRepr_PropertyDefinition)> aResult;
Handle(StepBasic_GeneralProperty) aGeneralProp =
Handle(StepBasic_GeneralProperty)::DownCast(theGeneralProperty);
if (aGeneralProp.IsNull())
{
return aResult;
}
Interface_EntityIterator aSharingListOfGP = theWorkSession->Graph().Sharings(aGeneralProp);
for (aSharingListOfGP.Start(); aSharingListOfGP.More(); aSharingListOfGP.Next())
{
Handle(StepBasic_GeneralPropertyAssociation) aPropAssociation =
Handle(StepBasic_GeneralPropertyAssociation)::DownCast(aSharingListOfGP.Value());
if (aPropAssociation.IsNull())
{
continue;
}
aResult.emplace_back(aPropAssociation->PropertyDefinition());
}
return aResult;
}
//=================================================================================================
std::vector<TDF_Label> STEPCAFControl_Reader::collectShapeLabels(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Transfer_TransientProcess)& theTransferProcess,
const Handle(StepRepr_PropertyDefinition)& theSource) const
{
std::vector<TDF_Label> aResult;
NCollection_List<Handle(Transfer_Binder)> aBinders;
collectBinders(theWorkSession, theTransferProcess, theSource, aBinders);
if (aBinders.IsEmpty())
{
return aResult;
}
NCollection_List<Handle(Transfer_Binder)>::Iterator aBindIt(aBinders);
for (; aBindIt.More(); aBindIt.Next())
{
const TopoDS_Shape aShape = TransferBRep::ShapeResult(theTransferProcess, aBindIt.Value());
if (aShape.IsNull())
{
continue;
}
TDF_Label aShapeResultLabel;
if (myMap.Find(aShape, aShapeResultLabel))
{
aResult.emplace_back(aShapeResultLabel);
}
}
return aResult;
}
//=================================================================================================
std::vector<Handle(StepRepr_PropertyDefinition)> STEPCAFControl_Reader::
collectRelatedPropertyDefinitions(const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(StepRepr_PropertyDefinition)& theProperty) const
{
std::vector<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
aGroupedProperties.emplace_back(theProperty);
Interface_EntityIterator aSharingsListOfPD = theWorkSession->Graph().Sharings(theProperty);
for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next())
{
Handle(StepRepr_PropertyDefinitionRelationship) aRel =
Handle(StepRepr_PropertyDefinitionRelationship)::DownCast(aSharingsListOfPD.Value());
if (aRel.IsNull())
{
continue;
}
Handle(StepRepr_PropertyDefinition) aGroupedProp = aRel->RelatedPropertyDefinition();
if (!aGroupedProp.IsNull())
{
aGroupedProperties.emplace_back(aGroupedProp);
}
}
return aGroupedProperties;
}
//=================================================================================================
Handle(TDataStd_NamedData) STEPCAFControl_Reader::getNamedData(const TDF_Label& theLabel) const
{
Handle(TDataStd_NamedData) anAttribute;
if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), anAttribute))
{
anAttribute = new TDataStd_NamedData;
theLabel.AddAttribute(anAttribute);
}
return anAttribute;
}
//=================================================================================================
void STEPCAFControl_Reader::collectBinders(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Transfer_TransientProcess)& theTransientProcess,
const Handle(StepRepr_PropertyDefinition)& theSource,
NCollection_List<Handle(Transfer_Binder)>& theBinders) const
{
Interface_EntityIterator aSharedListOfPD = theWorkSession->Graph().Shareds(theSource);
for (aSharedListOfPD.Start(); aSharedListOfPD.More(); aSharedListOfPD.Next())
{
// Acquire binder from StepBasic_ProductDefinition.
Handle(StepBasic_ProductDefinition) aProductDefinition =
Handle(StepBasic_ProductDefinition)::DownCast(aSharedListOfPD.Value());
if (!aProductDefinition.IsNull())
{
const Handle(Transfer_Binder) aBinder = theTransientProcess->Find(aProductDefinition);
if (!aBinder.IsNull())
{
theBinders.Append(aBinder);
}
continue;
}
// Acquire binder from StepRepr_ProductDefinitionShape.
Handle(StepRepr_ProductDefinitionShape) aProductDefinitionShape =
Handle(StepRepr_ProductDefinitionShape)::DownCast(aSharedListOfPD.Value());
if (!aProductDefinitionShape.IsNull())
{
Handle(StepBasic_ProductDefinition) aProductDef =
aProductDefinitionShape->Definition().ProductDefinition();
const Handle(Transfer_Binder) aBinder = theTransientProcess->Find(aProductDef);
if (!aBinder.IsNull())
{
theBinders.Append(aBinder);
}
continue;
}
// Acquire binder from StepRepr_NextAssemblyUsageOccurrence.
Handle(StepRepr_NextAssemblyUsageOccurrence) aNextAssembUsOcc =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(aSharedListOfPD.Value());
if (!aNextAssembUsOcc.IsNull())
{
const Handle(Transfer_Binder) aBinder = theTransientProcess->Find(aNextAssembUsOcc);
if (!aBinder.IsNull())
{
theBinders.Append(aBinder);
}
continue;
}
Handle(StepRepr_ShapeAspect) aShapeAspect =
Handle(StepRepr_ShapeAspect)::DownCast(aSharedListOfPD.Value());
if (!aShapeAspect.IsNull())
{
Interface_EntityIterator aSharedListOfSA = theWorkSession->Graph().Sharings(aShapeAspect);
for (aSharedListOfSA.Start(); aSharedListOfSA.More(); aSharedListOfSA.Next())
{
Handle(StepAP242_DraughtingModelItemAssociation) aDMIA =
Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(aSharedListOfSA.Value());
if (!aDMIA.IsNull())
{
break;
}
Handle(StepAP242_ItemIdentifiedRepresentationUsage) anItemIdentUsage =
Handle(StepAP242_ItemIdentifiedRepresentationUsage)::DownCast(aSharedListOfSA.Value());
if (!anItemIdentUsage.IsNull())
{
for (Standard_Integer anIndex = 1; anIndex <= anItemIdentUsage->NbIdentifiedItem();
++anIndex)
{
Handle(StepRepr_RepresentationItem) aReprItem =
anItemIdentUsage->IdentifiedItemValue(anIndex);
if (aReprItem.IsNull())
{
continue;
}
const Handle(Transfer_Binder) aBinder = theTransientProcess->Find(aReprItem);
if (!aBinder.IsNull())
{
theBinders.Append(aBinder);
}
}
continue;
}
Handle(StepRepr_PropertyDefinition) aPropDef =
Handle(StepRepr_PropertyDefinition)::DownCast(aSharedListOfSA.Value());
if (!aPropDef.IsNull() && aPropDef != theSource)
{
Interface_EntityIterator aSharingListOfPD = theWorkSession->Graph().Sharings(aPropDef);
for (aSharingListOfPD.Start(); aSharingListOfPD.More(); aSharingListOfPD.Next())
{
Handle(StepShape_ShapeDefinitionRepresentation) aShDef =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSharingListOfPD.Value());
if (aShDef.IsNull())
{
continue;
}
findReprItems(theWorkSession, aShDef, theBinders);
}
continue;
}
Handle(StepShape_ShapeDefinitionRepresentation) aShapeDefRepr =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSharedListOfSA.Value());
if (!aShapeDefRepr.IsNull())
{
findReprItems(theWorkSession, aShapeDefRepr, theBinders);
}
}
}
}
}
//=================================================================================================
Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_WorkSession)& theWS,
const Handle(TDocStd_Document)& theDoc,
const StepData_Factors& theLocalFactors) const
{
const Handle(Interface_InterfaceModel)& aModel = theWS->Model();
const Handle(XSControl_TransferReader)& aTR = theWS->TransferReader();
const Handle(Transfer_TransientProcess)& aTP = aTR->TransientProcess();
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
if (aSTool.IsNull())
if (XCAFDoc_DocumentTool::ShapeTool(theDoc->Main()).IsNull())
{
return Standard_False;
}
Standard_Integer aNb = aModel->NbEntities();
STEPConstruct_Tool aTool(theWS);
const Handle(Interface_InterfaceModel)& aModel = theWS->Model();
const Handle(Transfer_TransientProcess)& aTransientProcess =
theWS->TransferReader()->TransientProcess();
for (Standard_Integer anEntityInd = 1; anEntityInd <= aNb; ++anEntityInd)
for (Standard_Integer anEntityInd = 1; anEntityInd <= aModel->NbEntities(); ++anEntityInd)
{
Handle(Standard_Transient) anEntity = aModel->Value(anEntityInd);
Handle(StepBasic_GeneralProperty) aGeneralProp =
Handle(StepBasic_GeneralProperty)::DownCast(anEntity);
if (aGeneralProp.IsNull())
continue;
Handle(StepBasic_GeneralPropertyAssociation) aPropAssociation;
NCollection_List<Handle(StepRepr_PropertyDefinition)> aPropDefinitionList;
Interface_EntityIterator aSharingListOfGP = theWS->Graph().Sharings(aGeneralProp);
for (aSharingListOfGP.Start(); aSharingListOfGP.More(); aSharingListOfGP.Next())
for (const auto& aPropertyDefinition :
collectPropertyDefinitions(theWS, aModel->Value(anEntityInd)))
{
aPropAssociation =
Handle(StepBasic_GeneralPropertyAssociation)::DownCast(aSharingListOfGP.Value());
if (aPropAssociation.IsNull())
continue;
// Collect all the related PropertyDefinitions.
const std::vector<Handle(StepRepr_PropertyDefinition)> aGroupedProperties =
collectRelatedPropertyDefinitions(theWS, aPropertyDefinition);
aPropDefinitionList.Append(aPropAssociation->PropertyDefinition());
}
// Collect all the shapes labels.
const std::vector<TDF_Label> aLabels =
collectShapeLabels(theWS, aTransientProcess, aPropertyDefinition);
if (aPropDefinitionList.IsEmpty())
continue;
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropDefIter(
aPropDefinitionList);
for (; aPropDefIter.More(); aPropDefIter.Next())
{
Handle(StepRepr_PropertyDefinition) aPropDefinition = aPropDefIter.Value();
// check group of PropertyDefinition
NCollection_List<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
Interface_EntityIterator aSharingsListOfPD = theWS->Graph().Sharings(aPropDefinition);
for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next())
// Fill all atributes for each shape label.
for (const auto& aLabel : aLabels)
{
Handle(StepRepr_PropertyDefinitionRelationship) aRel =
Handle(StepRepr_PropertyDefinitionRelationship)::DownCast(aSharingsListOfPD.Value());
if (aRel.IsNull())
Handle(TDataStd_NamedData) anAttribute = getNamedData(aLabel);
for (const auto& aPropDefinition : aGroupedProperties)
{
continue;
}
Handle(StepRepr_PropertyDefinition) aGroupedProp = aRel->RelatedPropertyDefinition();
if (!aGroupedProp.IsNull())
{
aGroupedProperties.Append(aGroupedProp);
}
}
NCollection_List<Handle(Transfer_Binder)> aBinders;
Interface_EntityIterator aSharedListOfPD = theWS->Graph().Shareds(aPropDefinition);
for (aSharedListOfPD.Start(); aSharedListOfPD.More(); aSharedListOfPD.Next())
{
Handle(Transfer_Binder) aBinder;
Handle(StepBasic_ProductDefinition) aProductDefinition =
Handle(StepBasic_ProductDefinition)::DownCast(aSharedListOfPD.Value());
if (!aProductDefinition.IsNull())
{
aBinder = aTP->Find(aProductDefinition);
if (!aBinder.IsNull())
{
aBinders.Append(aBinder);
}
continue;
}
Handle(StepRepr_ProductDefinitionShape) aProductDefinitionShape =
Handle(StepRepr_ProductDefinitionShape)::DownCast(aSharedListOfPD.Value());
if (!aProductDefinitionShape.IsNull())
{
Handle(StepBasic_ProductDefinition) aProductDef =
aProductDefinitionShape->Definition().ProductDefinition();
aBinder = aTP->Find(aProductDef);
if (!aBinder.IsNull())
{
aBinders.Append(aBinder);
}
continue;
}
Handle(StepRepr_NextAssemblyUsageOccurrence) aNextAssembUsOcc =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(aSharedListOfPD.Value());
if (!aNextAssembUsOcc.IsNull())
{
aBinder = aTP->Find(aNextAssembUsOcc);
if (!aBinder.IsNull())
{
aBinders.Append(aBinder);
}
continue;
}
Handle(StepRepr_ShapeAspect) aShapeAspect =
Handle(StepRepr_ShapeAspect)::DownCast(aSharedListOfPD.Value());
if (!aShapeAspect.IsNull())
{
TDF_Label aLabel;
if (!aBinder.IsNull())
{
TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, aBinder);
if (aShape.IsNull())
continue;
if (myMap.IsBound(aShape))
{
aLabel = myMap.Find(aShape);
}
}
Interface_EntityIterator aSharedListOfSA = theWS->Graph().Sharings(aShapeAspect);
for (aSharedListOfSA.Start(); aSharedListOfSA.More(); aSharedListOfSA.Next())
{
Handle(StepAP242_DraughtingModelItemAssociation) aDMIA =
Handle(StepAP242_DraughtingModelItemAssociation)::DownCast(aSharedListOfSA.Value());
if (!aDMIA.IsNull())
break;
Handle(StepAP242_ItemIdentifiedRepresentationUsage) anItemIdentUsage =
Handle(StepAP242_ItemIdentifiedRepresentationUsage)::DownCast(
aSharedListOfSA.Value());
if (!anItemIdentUsage.IsNull())
{
for (Standard_Integer anIndex = 1; anIndex <= anItemIdentUsage->NbIdentifiedItem();
++anIndex)
{
Handle(StepRepr_RepresentationItem) aReprItem =
anItemIdentUsage->IdentifiedItemValue(anIndex);
if (aReprItem.IsNull())
continue;
aBinder = aTP->Find(aReprItem);
if (!aBinder.IsNull())
{
aBinders.Append(aBinder);
}
}
continue;
}
Handle(StepRepr_PropertyDefinition) aPropDef =
Handle(StepRepr_PropertyDefinition)::DownCast(aSharedListOfSA.Value());
if (!aPropDef.IsNull() && aPropDef != aPropDefinition)
{
Interface_EntityIterator aSharingListOfPD = theWS->Graph().Sharings(aPropDef);
for (aSharingListOfPD.Start(); aSharingListOfPD.More(); aSharingListOfPD.Next())
{
Handle(StepShape_ShapeDefinitionRepresentation) aShDef =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(
aSharingListOfPD.Value());
if (aShDef.IsNull())
continue;
findReprItems(theWS, aShDef, aBinders);
}
continue;
}
Handle(StepShape_ShapeDefinitionRepresentation) aShapeDefRepr =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSharedListOfSA.Value());
if (!aShapeDefRepr.IsNull())
{
findReprItems(theWS, aShapeDefRepr, aBinders);
}
}
}
}
if (aBinders.IsEmpty())
continue;
TDF_LabelSequence aLabelSeq;
NCollection_List<Handle(Transfer_Binder)>::Iterator aBindIt(aBinders);
for (; aBindIt.More(); aBindIt.Next())
{
TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, aBindIt.Value());
if (aShape.IsNull())
continue;
TDF_Label aShapeLabel;
if (myMap.IsBound(aShape))
{
aShapeLabel = myMap.Find(aShape);
}
if (!aShapeLabel.IsNull())
{
aLabelSeq.Append(aShapeLabel);
}
}
// create metadata
for (TDF_LabelSequence::Iterator aLabelIt(aLabelSeq); aLabelIt.More(); aLabelIt.Next())
{
TDF_Label aLabel = aLabelIt.Value();
Handle(TDataStd_NamedData) anAttr;
if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAttr))
{
anAttr = new TDataStd_NamedData;
aLabel.AddAttribute(anAttr);
}
fillAttributes(theWS, aPropDefinition, theLocalFactors, anAttr);
if (!aGroupedProperties.IsEmpty())
{
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(
aGroupedProperties);
for (; aPropIt.More(); aPropIt.Next())
{
fillAttributes(theWS, aPropIt.Value(), theLocalFactors, anAttr);
}
fillAttributes(theWS, aPropDefinition, theLocalFactors, anAttribute);
}
}
}
@ -6063,6 +6161,68 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
//=================================================================================================
Standard_Boolean STEPCAFControl_Reader::ReadProductMetadata(
const Handle(XSControl_WorkSession)& theWS,
const Handle(TDocStd_Document)& theDoc) const
{
if (XCAFDoc_DocumentTool::ShapeTool(theDoc->Main()).IsNull())
{
return Standard_False;
}
const Handle(Interface_InterfaceModel)& aModel = theWS->Model();
const Handle(Transfer_TransientProcess)& aTransientProcess =
theWS->TransferReader()->TransientProcess();
for (Standard_Integer anEntityInd = 1; anEntityInd <= aModel->NbEntities(); ++anEntityInd)
{
// Processing only StepBasic_ProductDefinition entities.
const Handle(StepBasic_ProductDefinition) aProdDefinition =
Handle(StepBasic_ProductDefinition)::DownCast(aModel->Value(anEntityInd));
if (aProdDefinition.IsNull())
{
continue;
}
// Prepare required data for processing: ShapeLabel and Product entity.
const TDF_Label aShapeLabel =
getShapeLabelFromProductDefinition(aTransientProcess, aProdDefinition);
if (aShapeLabel.IsNull())
{
continue;
}
const Handle(StepBasic_Product) aProduct = getProductFromProductDefinition(aProdDefinition);
if (aProduct.IsNull())
{
continue;
}
// Find or create NamedData attribute for ShapeLabel.
Handle(TDataStd_NamedData) anAttribute = getNamedData(aShapeLabel);
// Fill NamedData attribute with product metadata.
if (aProduct->Id() && !aProduct->Id()->String().IsEmpty())
{
anAttribute->SetString("ProductID", aProduct->Id()->String());
}
if (aProduct->Name() && !aProduct->Name()->String().IsEmpty())
{
anAttribute->SetString("ProductName", aProduct->Name()->String());
}
if (aProduct->Description() && !aProduct->Description()->String().IsEmpty())
{
anAttribute->SetString("Description", aProduct->Description()->String());
}
if (aProdDefinition->Description() && !aProdDefinition->Description()->String().IsEmpty())
{
anAttribute->SetString("ProductDefinition", aProdDefinition->Description()->String());
}
}
return true;
}
//=================================================================================================
Standard_Boolean STEPCAFControl_Reader::findReprItems(
const Handle(XSControl_WorkSession)& theWS,
const Handle(StepShape_ShapeDefinitionRepresentation)& theShDefRepr,

View File

@ -37,6 +37,7 @@ class XCAFDoc_ShapeTool;
class StepRepr_RepresentationItem;
class Transfer_TransientProcess;
class StepBasic_NamedUnit;
class StepBasic_Product;
class StepShape_ConnectedFaceSet;
class StepShape_ShapeDefinitionRepresentation;
class StepRepr_NextAssemblyUsageOccurrence;
@ -199,6 +200,11 @@ public:
Standard_EXPORT Standard_Boolean GetMetaMode() const;
//! MetaMode for indicate whether to read Product Metadata or not.
Standard_EXPORT void SetProductMetaMode(const Standard_Boolean theProductMetaMode);
Standard_EXPORT Standard_Boolean GetProductMetaMode() const;
//! Set SHUO mode for indicate write SHUO or not.
Standard_EXPORT void SetSHUOMode(const Standard_Boolean shuomode);
@ -316,6 +322,10 @@ protected:
const Handle(TDocStd_Document)& theDoc,
const StepData_Factors& theLocalFactors = StepData_Factors()) const;
Standard_EXPORT Standard_Boolean
ReadProductMetadata(const Handle(XSControl_WorkSession)& theWS,
const Handle(TDocStd_Document)& theDoc) const;
//! Reads layers of parts defined in the STEP model and
//! set reference between shape and layers in the DECAF document
Standard_EXPORT Standard_Boolean ReadLayers(const Handle(XSControl_WorkSession)& WS,
@ -435,6 +445,62 @@ private:
const StepData_Factors& theLocalFactors,
Handle(TDataStd_NamedData)& theAttr) const;
//! Returns the label of the shape associated with the given product definition.
//! @param theTransferProcess The transfer process to use for finding the label.
//! @param theProductDefinition The product definition for which to find the label.
//! @return The label of the shape associated with the given product definition.
TDF_Label getShapeLabelFromProductDefinition(
const Handle(Transfer_TransientProcess)& theTransferProcess,
const Handle(StepBasic_ProductDefinition)& theProductDefinition) const;
//! Returns the product associated with the given product definition.
//! @param theProductDefinition The product definition for which to get the product.
//! @return The product associated with the given product definition.
Handle(StepBasic_Product) getProductFromProductDefinition(
const Handle(StepBasic_ProductDefinition)& theProductDefinition) const;
//! Collects property definitions from the given general property and stores them in a vector.
//! @param theWorkSession The work session to use for collecting property definitions.
//! @param theGeneralProperty The general property from which to collect property definitions.
//! @return A vector of collected property definitions.
std::vector<Handle(StepRepr_PropertyDefinition)> collectPropertyDefinitions(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Standard_Transient)& theGeneralProperty) const;
//! Collects shape labels from the given property definition.
//! @param theWorkSession The work session to use for collecting shape labels.
//! @param theTransferProcess The transfer process to use for collecting shape labels.
//! @param theSource The property definition from which to collect shape labels.
//! @return A vector of collected shape labels.
std::vector<TDF_Label> collectShapeLabels(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Transfer_TransientProcess)& theTransferProcess,
const Handle(StepRepr_PropertyDefinition)& theSource) const;
//! Collects a group of related property definitions from the given property definition.
//! @p theProperty itself will be added to the result as well.
//! @param theWorkSession The work session to use for collecting related property definitions.
//! @param theProperty The property definition from which to collect related property definitions.
//! @return A vector of collected related property definitions.
std::vector<Handle(StepRepr_PropertyDefinition)> collectRelatedPropertyDefinitions(
const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(StepRepr_PropertyDefinition)& theProperty) const;
//! Helper method to get NamedData attribute assigned to the given label.
//! @param theLabel The label to get NamedData attribute from.
//! @return Handle to the NamedData attribute. Guarantees that the attribute is never null.
Handle(TDataStd_NamedData) getNamedData(const TDF_Label& theLabel) const;
//! Collects binders from the given property definition and stores them in the binder list.
//! @param theWorkSession The work session to use for collecting binders.
//! @param theTransientProcess The transient process to use for collecting binders.
//! @param theSource The property definition from which to collect binders.
//! @param theBinders The list to store the collected binders.
void collectBinders(const Handle(XSControl_WorkSession)& theWorkSession,
const Handle(Transfer_TransientProcess)& theTransientProcess,
const Handle(StepRepr_PropertyDefinition)& theSource,
NCollection_List<Handle(Transfer_Binder)>& theBinders) const;
private:
STEPControl_Reader myReader;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
@ -444,6 +510,7 @@ private:
Standard_Boolean myLayerMode;
Standard_Boolean myPropsMode;
Standard_Boolean myMetaMode;
Standard_Boolean myProductMetaMode;
Standard_Boolean mySHUOMode;
Standard_Boolean myGDTMode;
Standard_Boolean myMatMode;

View File

@ -178,6 +178,7 @@ provider.STEP.OCC.read.name : 1
provider.STEP.OCC.read.layer : 1
provider.STEP.OCC.read.props : 1
provider.STEP.OCC.read.metadata : 1
provider.STEP.OCC.read.productmetadata : 0
provider.STEP.OCC.write.precision.mode : 0
provider.STEP.OCC.write.precision.val : 0.0001
provider.STEP.OCC.write.assembly : 2

View File

@ -123,6 +123,7 @@ provider.STEP.OCC.read.name : 1
provider.STEP.OCC.read.layer : 1
provider.STEP.OCC.read.props : 1
provider.STEP.OCC.read.metadata : 1
provider.STEP.OCC.read.productmetadata : 0
provider.STEP.OCC.write.precision.mode : 0
provider.STEP.OCC.write.precision.val : 0.0001
provider.STEP.OCC.write.assembly : 2

View File

@ -1,9 +1,12 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug28345_30338.stp
set ref_size 5896
set ref_size 6292
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
H_CIP : 55.545955351400004
ProductID : MVE0300X02S030_ASM
ProductName : MVE0300X02S030_ASM
Description : NOT SPECIFIED
Property for [0:1:1:1:1]:
H : 45
E : 55
@ -15,6 +18,9 @@ C : 140
F : 0.29999999999999999
DESCRIPTION :
MODELED_BY :
ProductID : CUT_MVE0300X02S030
ProductName : CUT_MVE0300X02S030
Description : NOT SPECIFIED
Property for [0:1:1:1:2]:
H : 45
E : 55
@ -26,4 +32,7 @@ C : 140
F : 0.29999999999999999
DESCRIPTION :
MODELED_BY :
ProductID : NOCUT_MVE0300X02S030
ProductName : NOCUT_MVE0300X02S030
Description : NOT SPECIFIED
}

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug28389_CONFIDENTIAL_SHEET_METAL_F3D.stp
set ref_size 86278
set ref_size 86338
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
yCenterOfGravity : 0.1148447698
@ -23,4 +23,5 @@ Iyx : 2.044e-07
OriginX : 0
OriginZ : 0
JoggleFormula :
ProductID : SHEET METAL F3D
}

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug28444_nist_ftc_06_asme1_ct5240_rd.stp
set ref_size 85383
set ref_size 85605
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
yCenterOfGravity : 0.0289950044
@ -20,4 +20,6 @@ Ixx : 2.16819e-05
Izy : -1.3068999999999999e-06
Mass : 3.3238733752999998
Iyx : 0
ProductID : NIST PMI FTC 06 ASME1
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
}

View File

@ -1,4 +1,4 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug29525_rev_part_neu_01.prt_converted_from_datakit.stp
set ref_size 80996
set ref_size 81056
set check_metadata 0

View File

@ -1,10 +1,11 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug29633_nist_ctc_05_asme1_ap242-1.stp
set ref_size 69902
set ref_size 70034
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
FILESAVETIME : Tue Dec 09 03:47:24 2014
@ -12,6 +13,7 @@ Part Number : NIST PMI CTC 05 ASME1
Revision : D
CAD_SOURCE : ug
MTIME : 1418096844
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

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug29803.stp
set ref_size 17032
set ref_size 17176
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
OUT_MASS : 50.813477444850157
@ -28,6 +28,7 @@ SS_FLANGE : NO
MODELED_BY : LSD
STANDARD_BODY_DIA : Y
DEEP_HOLE_WEBSITE :
ProductID : Tool1
ITEM_NUM : HOLDER
LENGTH : STUB
FINISH : BLACK OXIDE
@ -36,6 +37,8 @@ SHANK_IM : M
FLUTE : STRAIGHT
SHANK : ER
MATERIAL : STEEL
ProductName : Tool1
Description : NOT SPECIFIED
SERIES : Y
DEEP_HOLE_NOTES :
}

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename sp7_04-do-242.stp
set ref_size 224779
set ref_size 224869
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
PRO_MP_ALT_COGX : - >
@ -224,6 +224,7 @@ PRO_MP_VOLUME : - >
PRO_MP_ALT_IXX DESIGNATED : NO
MP_DENSITY ACCESS : Full
PRO_MP_TRF_21 ACCESS : Locked
ProductID : NIST_CTC_04_ASME1_RD_CR4050_RA
PRO_MP_ALT_IYY : - >
PRO_MP_TRF_41 DESCRIPTION : NULL
PRO_MP_ALT_MASS DESCRIPTION : NULL

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug32087_part.stp
set ref_size 15789
set ref_size 15921
set check_metadata 1
set ref_metadata {Property for [0:1:1:1]:
SETUP_PART : 0
@ -17,6 +17,7 @@ MODEL_3D_APPROVED_BY :
MODEL_3D_CAD_SYSTEM :
PART_NAME :
MODEL_3D_CHECKED_BY :
ProductID : Block
OWNER :
COPYRIGHT :
WORK_ORDER_NUMBER :
@ -28,6 +29,7 @@ TREATMENT :
MODEL_3D_CREATED_BY :
UNIT_SYSTEM :
MODEL_3D_DATE_OF_ISSUE :
ProductDefinition :
WELD_TOLERANCES :
PROJECT :
LANGUAGE :
@ -61,6 +63,7 @@ REFERENCE_DESIGNATION+ :
MODEL_3D_ID_NUMBER :
PART_NOTE :
WELD_PREPARATION :
Description : Block
MODEL_3D_RELEASED_DATE :
MODEL_3D_REPLACES :
PAINT_SURFACE :

View File

@ -1,9 +1,12 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename nist_ftc_08_asme1_ap242-2.stp
set ref_size 118200
set ref_size 118396
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
}

View File

@ -2,10 +2,12 @@
# used as reference. In this mode all tests intentionally report failure.
set dump_file 0
set conf "provider.STEP.OCC.read.productmetadata : 1"
# Read original file
if { [string length $filename] > 1} {
set path_file [locate_data_file $filename]
if { [catch { ReadFile aDocExport $path_file } catch_result] } {
if { [catch { ReadFile aDocExport $path_file -conf $conf } catch_result] } {
set err_msg "Error: file was not read - exception "
puts $err_msg
}

View File

@ -4,6 +4,9 @@ set filename bug28345_30338.stp
set ref_data {
Property for [0:1:1:1]:
H_CIP : 55.545955351400004
ProductID : MVE0300X02S030_ASM
ProductName : MVE0300X02S030_ASM
Description : NOT SPECIFIED
Property for [0:1:1:2]:
H : 45
E : 55
@ -15,6 +18,9 @@ C : 140
F : 0.29999999999999999
DESCRIPTION :
MODELED_BY :
ProductID : CUT_MVE0300X02S030
ProductName : CUT_MVE0300X02S030
Description : NOT SPECIFIED
Property for [0:1:1:3]:
H : 45
E : 55
@ -26,5 +32,8 @@ C : 140
F : 0.29999999999999999
DESCRIPTION :
MODELED_BY :
ProductID : NOCUT_MVE0300X02S030
ProductName : NOCUT_MVE0300X02S030
Description : NOT SPECIFIED
}

View File

@ -23,5 +23,6 @@ Iyx : 2.044e-07
OriginX : 0
OriginZ : 0
JoggleFormula :
ProductID : SHEET METAL F3D
}

View File

@ -20,5 +20,7 @@ Ixx : 2.16819e-05
Izy : -1.3068999999999999e-06
Mass : 3.3238733752999998
Iyx : 0
ProductID : NIST PMI FTC 06 ASME1
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
}

View File

@ -594,6 +594,7 @@ D_DOCNR DESCRIPTION : NULL
D_MATERIAL : -
PROI_CREATED_BY :
PRO_MP_TRF_21 ACCESS : Locked
ProductID : REV_PART_NEU_01
PRO_MP_ALT_IYY : ->
PRO_MP_TRF_41 DESCRIPTION : NULL
PTC_WM_REVISION DESIGNATED : NO

View File

@ -5,6 +5,7 @@ set ref_data {
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
@ -12,6 +13,7 @@ FILESAVETIME : Tue Dec 09 03:47:24 2014
Revision : D
CAD_SOURCE : ug
MTIME : 1418096844
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

View File

@ -28,6 +28,7 @@ DESCRIPTION : T-A HOLDER
MODELED_BY : LSD
STANDARD_BODY_DIA : Y
DEEP_HOLE_WEBSITE :
ProductID : Tool1
ITEM_NUM : HOLDER
LENGTH : STUB
FINISH : BLACK OXIDE
@ -36,6 +37,8 @@ SHANK_IM : M
FLUTE : STRAIGHT
SHANK : ER
MATERIAL : STEEL
ProductName : Tool1
Description : NOT SPECIFIED
SERIES : Y
DEEP_HOLE_NOTES :

View File

@ -224,6 +224,7 @@ PRO_MP_VOLUME : - >
PRO_MP_ALT_IXX DESIGNATED : NO
MP_DENSITY ACCESS : Full
PRO_MP_TRF_21 ACCESS : Locked
ProductID : NIST_CTC_04_ASME1_RD_CR4050_RA
PRO_MP_ALT_IYY : - >
PRO_MP_TRF_41 DESCRIPTION : NULL
PRO_MP_ALT_MASS DESCRIPTION : NULL

View File

@ -16,6 +16,7 @@ MODEL_3D_CAD_SYSTEM :
MODEL_3D_APPROVED_BY :
REFERENCE_DESIGNATION++ :
PART_NAME :
ProductID : Block
MODEL_3D_CHECKED_BY :
OWNER :
COPYRIGHT :
@ -28,6 +29,7 @@ GENERAL_TOLERANCES_DRILL_HOLE :
MODEL_3D_CREATED_BY :
UNIT_SYSTEM :
MODEL_3D_DATE_OF_ISSUE :
ProductDefinition :
WELD_TOLERANCES :
PROJECT :
MODEL_3D_RELEASED_STATUS :
@ -61,6 +63,7 @@ MODEL_3D_ID_NUMBER :
REFERENCE_DESIGNATION+ :
PART_NOTE :
WELD_PREPARATION :
Description : Block
MODEL_3D_RELEASED_DATE :
MODEL_3D_REPLACES :
PAINT_SURFACE :

View File

@ -3,8 +3,11 @@ set filename nist_ftc_08_asme1_ap242-2.stp
set ref_data {
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
}

View File

@ -8,10 +8,12 @@ set todo_mask "puts \"TODO CR00000 ALL: "
set end_line "\" \n"
##################################################################
set conf "provider.STEP.OCC.read.productmetadata : 1"
# Read original file
if { [string length $filename] > 1} {
set path_file [locate_data_file $filename]
if { [catch { ReadFile D $path_file } catch_result] } {
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