mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0033660: Data Exchange, Step Import - Adding product attributes to metadata
Attributes of product was added to metadata.
This commit is contained in:
parent
96a4eafb75
commit
b936aa6ed1
@ -4957,9 +4957,47 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
|
|||||||
Standard_Integer aNb = aModel->NbEntities();
|
Standard_Integer aNb = aModel->NbEntities();
|
||||||
STEPConstruct_Tool aTool(theWS);
|
STEPConstruct_Tool aTool(theWS);
|
||||||
|
|
||||||
|
TDF_LabelMap aGeneralLabelMap;
|
||||||
|
NCollection_DataMap<TDF_Label, NCollection_Sequence<Handle(StepRepr_PropertyDefinition)>, TDF_LabelMapHasher> anAttrMap;
|
||||||
|
NCollection_DataMap<TDF_Label, NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>, TDF_LabelMapHasher> anExtraAttrMap;
|
||||||
for (Standard_Integer anEntityInd = 1; anEntityInd <= aNb; ++anEntityInd)
|
for (Standard_Integer anEntityInd = 1; anEntityInd <= aNb; ++anEntityInd)
|
||||||
{
|
{
|
||||||
Handle(Standard_Transient) anEntity = aModel->Value(anEntityInd);
|
Handle(Standard_Transient) anEntity = aModel->Value(anEntityInd);
|
||||||
|
|
||||||
|
// checking for Product attributes
|
||||||
|
Handle(StepBasic_ProductDefinition) aProdDefinition = Handle(StepBasic_ProductDefinition)::DownCast(anEntity);
|
||||||
|
if (!aProdDefinition.IsNull())
|
||||||
|
{
|
||||||
|
Handle(Transfer_Binder) aBinder = aTP->Find(aProdDefinition);
|
||||||
|
if (!aBinder.IsNull())
|
||||||
|
{
|
||||||
|
TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, aBinder);
|
||||||
|
if (aShape.IsNull())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TDF_Label aShapeLabel;
|
||||||
|
if (myMap.IsBound(aShape))
|
||||||
|
{
|
||||||
|
aShapeLabel = myMap.Find(aShape);
|
||||||
|
}
|
||||||
|
if (!aShapeLabel.IsNull())
|
||||||
|
{
|
||||||
|
if (!aGeneralLabelMap.Contains(aShapeLabel))
|
||||||
|
{
|
||||||
|
aGeneralLabelMap.Add(aShapeLabel);
|
||||||
|
}
|
||||||
|
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> anAttrSeq;
|
||||||
|
Handle(StepBasic_Product) aProduct = aProdDefinition->Formation()->OfProduct();
|
||||||
|
anAttrSeq.Append({ "ProductID", aProduct->Id() });
|
||||||
|
anAttrSeq.Append({ "ProductName", aProduct->Name() });
|
||||||
|
anAttrSeq.Append({ "Description", aProduct->Description() });
|
||||||
|
anAttrSeq.Append({ "ProductDefinition", aProdDefinition->Description() });
|
||||||
|
anExtraAttrMap.Bind(aShapeLabel, anAttrSeq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checking for User Defined Attributes
|
||||||
Handle(StepBasic_GeneralProperty) aGeneralProp = Handle(StepBasic_GeneralProperty)::DownCast(anEntity);
|
Handle(StepBasic_GeneralProperty) aGeneralProp = Handle(StepBasic_GeneralProperty)::DownCast(anEntity);
|
||||||
if (aGeneralProp.IsNull())
|
if (aGeneralProp.IsNull())
|
||||||
continue;
|
continue;
|
||||||
@ -4979,13 +5017,13 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
|
|||||||
if (aPropDefinitionList.IsEmpty())
|
if (aPropDefinitionList.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
NCollection_List<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
|
||||||
NCollection_List< Handle(StepRepr_PropertyDefinition)>::Iterator aPropDefIter(aPropDefinitionList);
|
NCollection_List< Handle(StepRepr_PropertyDefinition)>::Iterator aPropDefIter(aPropDefinitionList);
|
||||||
for ( ; aPropDefIter.More(); aPropDefIter.Next())
|
for ( ; aPropDefIter.More(); aPropDefIter.Next())
|
||||||
{
|
{
|
||||||
Handle(StepRepr_PropertyDefinition) aPropDefinition = aPropDefIter.Value();
|
Handle(StepRepr_PropertyDefinition) aPropDefinition = aPropDefIter.Value();
|
||||||
|
|
||||||
// check group of PropertyDefinition
|
// check group of PropertyDefinition
|
||||||
NCollection_List<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
|
|
||||||
Interface_EntityIterator aSharingsListOfPD = theWS->Graph().Sharings(aPropDefinition);
|
Interface_EntityIterator aSharingsListOfPD = theWS->Graph().Sharings(aPropDefinition);
|
||||||
for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next())
|
for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next())
|
||||||
{
|
{
|
||||||
@ -5134,29 +5172,79 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
|
|||||||
if (!aShapeLabel.IsNull())
|
if (!aShapeLabel.IsNull())
|
||||||
{
|
{
|
||||||
aLabelSeq.Append(aShapeLabel);
|
aLabelSeq.Append(aShapeLabel);
|
||||||
|
if (!aGeneralLabelMap.Contains(aShapeLabel))
|
||||||
|
{
|
||||||
|
aGeneralLabelMap.Add(aShapeLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//create metadata
|
// fill user defined attribute map
|
||||||
for (TDF_LabelSequence::Iterator aLabelIt(aLabelSeq); aLabelIt.More(); aLabelIt.Next())
|
for (TDF_LabelSequence::Iterator aLabelIt(aLabelSeq); aLabelIt.More(); aLabelIt.Next())
|
||||||
{
|
{
|
||||||
TDF_Label aLabel = aLabelIt.Value();
|
if (anAttrMap.IsBound(aLabelIt.Value()))
|
||||||
Handle(TDataStd_NamedData) anAttr;
|
|
||||||
if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAttr))
|
|
||||||
{
|
{
|
||||||
anAttr = new TDataStd_NamedData;
|
anAttrMap.ChangeFind(aLabelIt.Value()).Append(aPropDefinition);
|
||||||
aLabel.AddAttribute(anAttr);
|
if (!aGroupedProperties.IsEmpty())
|
||||||
}
|
|
||||||
|
|
||||||
fillAttributes(theWS, aPropDefinition, anAttr);
|
|
||||||
if (!aGroupedProperties.IsEmpty())
|
|
||||||
{
|
|
||||||
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
|
|
||||||
for ( ; aPropIt.More(); aPropIt.Next())
|
|
||||||
{
|
{
|
||||||
fillAttributes(theWS, aPropIt.Value(), anAttr);
|
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
|
||||||
|
for (; aPropIt.More(); aPropIt.Next())
|
||||||
|
{
|
||||||
|
anAttrMap.ChangeFind(aLabelIt.Value()).Append(aPropIt.Value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> aPropSeq;
|
||||||
|
aPropSeq.Append(aPropDefinition);
|
||||||
|
if (!aGroupedProperties.IsEmpty())
|
||||||
|
{
|
||||||
|
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
|
||||||
|
for (; aPropIt.More(); aPropIt.Next())
|
||||||
|
{
|
||||||
|
aPropSeq.Append(aPropIt.Value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
anAttrMap.Bind(aLabelIt.Value(), aPropSeq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create metadata
|
||||||
|
for (TDF_LabelMap::Iterator aLabelIt(aGeneralLabelMap); aLabelIt.More(); aLabelIt.Next())
|
||||||
|
{
|
||||||
|
Handle(TDataStd_NamedData) anAttr;
|
||||||
|
if (!aLabelIt.Value().FindAttribute(TDataStd_NamedData::GetID(), anAttr))
|
||||||
|
{
|
||||||
|
anAttr = new TDataStd_NamedData;
|
||||||
|
aLabelIt.Value().AddAttribute(anAttr);
|
||||||
|
}
|
||||||
|
if (anAttrMap.IsBound(aLabelIt.Value()))
|
||||||
|
{
|
||||||
|
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> anAttrib = anAttrMap.Find(aLabelIt.Value());
|
||||||
|
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(anAttrib);
|
||||||
|
for (; aPropIt.More(); aPropIt.Next())
|
||||||
|
{
|
||||||
|
fillAttributes(theWS, aPropIt.Value(), anAttr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (anExtraAttrMap.IsBound(aLabelIt.Value()))
|
||||||
|
{
|
||||||
|
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> aStrSeq = anExtraAttrMap.Find(aLabelIt.Value());
|
||||||
|
if (!aStrSeq.IsEmpty())
|
||||||
|
{
|
||||||
|
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>::Iterator anIt(aStrSeq);
|
||||||
|
for (; anIt.More(); anIt.Next())
|
||||||
|
{
|
||||||
|
auto aPair = anIt.Value();
|
||||||
|
if (aPair.second.IsNull())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
anAttr->SetString(aPair.first, aPair.second->String());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ set end_line "\" \n"
|
|||||||
# Read original file
|
# Read original file
|
||||||
if { [string length $filename] > 1} {
|
if { [string length $filename] > 1} {
|
||||||
set path_file [locate_data_file $filename]
|
set path_file [locate_data_file $filename]
|
||||||
if { [catch { ReadFile D $path_file -conf $conf} catch_result] } {
|
if { [catch { ReadFile D $path_file} catch_result] } {
|
||||||
set err_msg "Error: file was not read - exception "
|
set err_msg "Error: file was not read - exception "
|
||||||
puts $err_msg
|
puts $err_msg
|
||||||
append todo_msg $todo_mask $err_msg $end_line
|
append todo_msg $todo_mask $err_msg $end_line
|
||||||
|
@ -4,6 +4,9 @@ set filename bug28345_30338.stp
|
|||||||
set ref_data {
|
set ref_data {
|
||||||
Property for [0:1:1:1]:
|
Property for [0:1:1:1]:
|
||||||
H_CIP : 55.545955351400004
|
H_CIP : 55.545955351400004
|
||||||
|
ProductID : MVE0300X02S030_ASM
|
||||||
|
Description : NOT SPECIFIED
|
||||||
|
ProductName : MVE0300X02S030_ASM
|
||||||
Property for [0:1:1:2]:
|
Property for [0:1:1:2]:
|
||||||
A : 3
|
A : 3
|
||||||
B : 16
|
B : 16
|
||||||
@ -13,8 +16,11 @@ E : 55
|
|||||||
F : 0.29999999999999999
|
F : 0.29999999999999999
|
||||||
H : 45
|
H : 45
|
||||||
I : 15
|
I : 15
|
||||||
|
ProductID : CUT_MVE0300X02S030
|
||||||
MODELED_BY :
|
MODELED_BY :
|
||||||
DESCRIPTION :
|
DESCRIPTION :
|
||||||
|
Description : NOT SPECIFIED
|
||||||
|
ProductName : CUT_MVE0300X02S030
|
||||||
Property for [0:1:1:3]:
|
Property for [0:1:1:3]:
|
||||||
A : 3
|
A : 3
|
||||||
B : 16
|
B : 16
|
||||||
@ -24,7 +30,10 @@ E : 55
|
|||||||
F : 0.29999999999999999
|
F : 0.29999999999999999
|
||||||
H : 45
|
H : 45
|
||||||
I : 15
|
I : 15
|
||||||
|
ProductID : NOCUT_MVE0300X02S030
|
||||||
MODELED_BY :
|
MODELED_BY :
|
||||||
DESCRIPTION :
|
DESCRIPTION :
|
||||||
|
Description : NOT SPECIFIED
|
||||||
|
ProductName : NOCUT_MVE0300X02S030
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ Iyx : 2.044e-07
|
|||||||
Iyy : 3.6385e-06
|
Iyy : 3.6385e-06
|
||||||
Iyz : -1.2030000000000001e-07
|
Iyz : -1.2030000000000001e-07
|
||||||
zCenterOfGravity : -0.056064514900000001
|
zCenterOfGravity : -0.056064514900000001
|
||||||
|
ProductID : SHEET METAL F3D
|
||||||
JoggleFormula :
|
JoggleFormula :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,7 @@ Iyy : 4.46342e-05
|
|||||||
Iyz : -1.3068999999999999e-06
|
Iyz : -1.3068999999999999e-06
|
||||||
zCenterOfGravity : -0.10963042420000001
|
zCenterOfGravity : -0.10963042420000001
|
||||||
Length : 0
|
Length : 0
|
||||||
|
ProductID : NIST PMI FTC 06 ASME1
|
||||||
|
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -603,6 +603,7 @@ BOHR_TIEFE DESCRIPTION : NULL
|
|||||||
STEIGUNG SOURCE : Mass Properties
|
STEIGUNG SOURCE : Mass Properties
|
||||||
D_LAST_MODIFIED SOURCE : User-Defined
|
D_LAST_MODIFIED SOURCE : User-Defined
|
||||||
PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
|
PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
|
||||||
|
ProductID : REV_PART_NEU_01
|
||||||
PRO_MP_TRF_21 SOURCE : Mass Properties
|
PRO_MP_TRF_21 SOURCE : Mass Properties
|
||||||
PRO_MP_TRF_41 : ->
|
PRO_MP_TRF_41 : ->
|
||||||
PROI_RELEASE ACCESS : Limited
|
PROI_RELEASE ACCESS : Limited
|
||||||
|
@ -8,6 +8,7 @@ FILESIZE : 1495040
|
|||||||
MaterialMultipleAssigned : FALSE
|
MaterialMultipleAssigned : FALSE
|
||||||
FILESAVETIME : Tue Dec 09 03:47:24 2014
|
FILESAVETIME : Tue Dec 09 03:47:24 2014
|
||||||
Revision : D
|
Revision : D
|
||||||
|
ProductID : nist_ctc_05_asme1
|
||||||
CAD_SOURCE : ug
|
CAD_SOURCE : ug
|
||||||
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
|
Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
|
||||||
ATTR_VERSION : 18.3.001
|
ATTR_VERSION : 18.3.001
|
||||||
@ -15,5 +16,6 @@ FILENAME : nist_ctc_05_asme1.prt
|
|||||||
MTIME : 1418096844
|
MTIME : 1418096844
|
||||||
MaterialMissingAssignments : TRUE
|
MaterialMissingAssignments : TRUE
|
||||||
Part Number : NIST PMI CTC 05 ASME1
|
Part Number : NIST PMI CTC 05 ASME1
|
||||||
|
ProductName : nist_ctc_05_asme1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,11 @@ FINISH : BLACK OXIDE
|
|||||||
NOTES :
|
NOTES :
|
||||||
LENGTH : STUB
|
LENGTH : STUB
|
||||||
SHANK_IM : M
|
SHANK_IM : M
|
||||||
|
ProductID : Tool1
|
||||||
MODELED_BY : LSD
|
MODELED_BY : LSD
|
||||||
STANDARD_BODY_DIA : Y
|
STANDARD_BODY_DIA : Y
|
||||||
DESCRIPTION : T-A HOLDER
|
DESCRIPTION : T-A HOLDER
|
||||||
|
Description : NOT SPECIFIED
|
||||||
SS_FLANGE : NO
|
SS_FLANGE : NO
|
||||||
MATERIAL : STEEL
|
MATERIAL : STEEL
|
||||||
DEEP_HOLE_NOTES :
|
DEEP_HOLE_NOTES :
|
||||||
@ -38,5 +40,6 @@ SHANK : ER
|
|||||||
FLUTE : STRAIGHT
|
FLUTE : STRAIGHT
|
||||||
SERIES : Y
|
SERIES : Y
|
||||||
DEEP_HOLE_WEBSITE :
|
DEEP_HOLE_WEBSITE :
|
||||||
|
ProductName : Tool1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -226,6 +226,7 @@ PRO_MP_TRF_32 : - >
|
|||||||
PRO_MP_TRF_33 : - >
|
PRO_MP_TRF_33 : - >
|
||||||
PRO_MP_VOLUME DESIGNATED : NO
|
PRO_MP_VOLUME DESIGNATED : NO
|
||||||
PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
|
PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
|
||||||
|
ProductID : NIST_CTC_04_ASME1_RD_CR4050_RA
|
||||||
PRO_MP_TRF_21 SOURCE : Mass Properties
|
PRO_MP_TRF_21 SOURCE : Mass Properties
|
||||||
PRO_MP_TRF_41 : - >
|
PRO_MP_TRF_41 : - >
|
||||||
PRO_MP_TRF_42 : - >
|
PRO_MP_TRF_42 : - >
|
||||||
|
@ -24,6 +24,7 @@ REFERENCE :
|
|||||||
PART_NUMBER :
|
PART_NUMBER :
|
||||||
REFERENCE_DESIGNATION== :
|
REFERENCE_DESIGNATION== :
|
||||||
LANGUAGE :
|
LANGUAGE :
|
||||||
|
ProductID : Block
|
||||||
TECHNICAL_SPECIFICATION :
|
TECHNICAL_SPECIFICATION :
|
||||||
MODEL_3D_APPROVED_BY_DEPARTMENT :
|
MODEL_3D_APPROVED_BY_DEPARTMENT :
|
||||||
PROJECT :
|
PROJECT :
|
||||||
@ -43,12 +44,14 @@ PART_SOURCE :
|
|||||||
GENERAL_TOLERANCES :
|
GENERAL_TOLERANCES :
|
||||||
MODEL_3D_CHECKED_BY :
|
MODEL_3D_CHECKED_BY :
|
||||||
SPARE_WEARING_PART :
|
SPARE_WEARING_PART :
|
||||||
|
Description : Block
|
||||||
ARTICLE_NUMBER :
|
ARTICLE_NUMBER :
|
||||||
TOLERANCING_PRINCIPLE :
|
TOLERANCING_PRINCIPLE :
|
||||||
REFERENCE_DESIGNATION= :
|
REFERENCE_DESIGNATION= :
|
||||||
MATERIAL :
|
MATERIAL :
|
||||||
EDGE_CONDITION_INNER_EDGE :
|
EDGE_CONDITION_INNER_EDGE :
|
||||||
SURFACE_PROTECTION :
|
SURFACE_PROTECTION :
|
||||||
|
ProductDefinition :
|
||||||
SUPPLIER_NUMBER :
|
SUPPLIER_NUMBER :
|
||||||
SEMI_FINISHED_PRODUCT :
|
SEMI_FINISHED_PRODUCT :
|
||||||
SIMPLIFIED_DRAWING_REVISION :
|
SIMPLIFIED_DRAWING_REVISION :
|
||||||
|
@ -4,7 +4,10 @@ set filename nist_ftc_08_asme1_ap242-2.stp
|
|||||||
set ref_data {
|
set ref_data {
|
||||||
Property for [0:1:1:1]:
|
Property for [0:1:1:1]:
|
||||||
Revision : C
|
Revision : C
|
||||||
|
ProductID : NIST PMI FTC 08 ASME1
|
||||||
DescriptionRef : NIST PMI test model downloaded from http://go.usa.gov/mGVm
|
DescriptionRef : NIST PMI test model downloaded from http://go.usa.gov/mGVm
|
||||||
PartNumber : NIST PMI FTC 08 ASME1
|
PartNumber : NIST PMI FTC 08 ASME1
|
||||||
|
ProductDefinition :
|
||||||
|
ProductName : NIST PMI FTC 08 ASME1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
set conf "provider.STEP.OCC.read.metadata : 1"
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user