From ffe1b14331b448bcb50d8ca137af7f2d9e9aad1b Mon Sep 17 00:00:00 2001 From: gka Date: Thu, 5 Jul 2018 19:10:31 +0300 Subject: [PATCH] 0029846: Data Exchange - STEP validation properties support is obsolete Name of the PROPERTY_DEFINITION entity for validation properties is changed to "geometric validation property" according to the current version of the recommended practices. For compatibility with older definitions (with underscores) the check is made using string with underscores replaced by spaces. --- .../STEPConstruct_ValidationProps.cxx | 20 +++- src/XDEDRAW/XDEDRAW_Props.cxx | 94 ++++++++++++++++++- tests/de/step_2/B2 | 2 +- tests/de/step_4/H3 | 2 +- tests/de/step_5/B7 | 18 ++++ 5 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 tests/de/step_5/B7 diff --git a/src/STEPConstruct/STEPConstruct_ValidationProps.cxx b/src/STEPConstruct/STEPConstruct_ValidationProps.cxx index d8e9193b5d..8172591486 100644 --- a/src/STEPConstruct/STEPConstruct_ValidationProps.cxx +++ b/src/STEPConstruct/STEPConstruct_ValidationProps.cxx @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -338,7 +339,7 @@ Standard_Boolean STEPConstruct_ValidationProps::AddProp (const StepRepr_Characte { // FINALLY, create a structure of 5 entities describing a link between a shape and its property Handle(TCollection_HAsciiString) PropDefName = - new TCollection_HAsciiString ( "geometric_validation_property" ); + new TCollection_HAsciiString ( "geometric validation property" ); Handle(TCollection_HAsciiString) PropDefDescr = new TCollection_HAsciiString ( Descr ); Handle(StepRepr_PropertyDefinition) propdef = new StepRepr_PropertyDefinition; propdef->Init ( PropDefName, Standard_True, PropDefDescr, target ); @@ -493,11 +494,20 @@ Standard_Boolean STEPConstruct_ValidationProps::LoadProps (TColStd_SequenceOfTra Handle(StepRepr_PropertyDefinitionRepresentation) PDR = Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( enti ); - // check that PDR is for validation props + // Check that PDR is for validation props. Handle(StepRepr_PropertyDefinition) PD = PDR->Definition().PropertyDefinition(); - if ( PD.IsNull() || PD->Name().IsNull() - || PD->Name()->String() != "geometric_validation_property" ) - continue; + if (!PD.IsNull() && !PD->Name().IsNull()) + { + // Note: according to "Recommended Practices for Geometric and Assembly Validation Properties" Release 4.4 + // as of Augist 17, 2016, item 4.6, the name of PropertyDefinition should be "geometric validation property" + // with words separated by spaces; however older versions of the same RP document used underscores. + // To be able to read files written using older convention, we convert all underscores to spaces for this check. + TCollection_AsciiString aName = PD->Name()->String(); + aName.ChangeAll('_', ' ', Standard_False); + aName.LowerCase(); + if (aName != "geometric validation property") + continue; + } seq.Append ( PDR ); } diff --git a/src/XDEDRAW/XDEDRAW_Props.cxx b/src/XDEDRAW/XDEDRAW_Props.cxx index f304352bb7..b0e305d17e 100644 --- a/src/XDEDRAW/XDEDRAW_Props.cxx +++ b/src/XDEDRAW/XDEDRAW_Props.cxx @@ -898,6 +898,97 @@ static Standard_Integer SetMaterial (Draw_Interpretor& di, Standard_Integer argc return 0; } +static Standard_Integer GetValidationProps(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc< 2) { + di<<"Use: "<Main()); + TDF_LabelSequence aLabels; + if( argc == 2) + STool->GetShapes (aLabels); + else + { + TDF_Label aLabel; + TopoDS_Shape aShape = DBRep::Get(argv[2]); + if( aShape.IsNull()) + { + TDF_Label aLabel; + TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); + } + else + { + aLabel = STool->FindShape(aShape); + } + if( !aLabel.IsNull()) + aLabels.Append(aLabel); + } + + + enum + { + Vol =0, + Area = 1, + Centroid = 2 + }; + Standard_Integer nbProps[3]; + Standard_Integer j =0; + for( ; j <= Centroid; j++) + nbProps[j] = 0; + Standard_Integer i = 1; + for( ; i <= aLabels.Length() ; i++) + { + TDF_Label aLabel = aLabels(i); + + Standard_Real aProp[2]; + + aProp[0] = 0.; + aProp[1] = 0.; + + + gp_Pnt aP(Precision::Infinite(), Precision::Infinite(), Precision::Infinite()); + XCAFDoc_Volume::Get(aLabel, aProp[Vol]); + XCAFDoc_Area::Get(aLabel, aProp[Area]); + + Handle(XCAFDoc_Centroid) aCentroid = new (XCAFDoc_Centroid); + if (aLabel.FindAttribute (XCAFDoc_Centroid::GetID(), aCentroid)) + XCAFDoc_Centroid::Get(aLabel, aP); + + if(aProp[Vol] > 0 || aProp[Area] > 0 || !Precision::IsInfinite(aP.X()) ) + { + TCollection_AsciiString str; + TDF_Tool::Entry ( aLabel, str ); + di<<"Label : "< 0) + { + di<<(j == Vol ? "; Volume - " : "; Area - ")<