]> OCCT Git - occt.git/commitdiff
0029846: Data Exchange - STEP validation properties support is obsolete
authorgka <gka@opencascade.com>
Thu, 5 Jul 2018 16:10:31 +0000 (19:10 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 13 Jul 2018 13:38:08 +0000 (16:38 +0300)
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.

src/STEPConstruct/STEPConstruct_ValidationProps.cxx
src/XDEDRAW/XDEDRAW_Props.cxx
tests/de/step_2/B2
tests/de/step_4/H3
tests/de/step_5/B7 [new file with mode: 0644]

index d8e9193b5d689058417664f06a294182c4e01256..817259148675cf446a18af3000d180850adae46f 100644 (file)
@@ -57,6 +57,7 @@
 #include <StepShape_ShapeRepresentation.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <TopLoc_Location.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
 #include <Transfer_Binder.hxx>
 #include <Transfer_SimpleBinderOfTransient.hxx>
@@ -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 );
   }
index f304352bb7096cad6b3907e4a3237836de065fc8..b0e305d17e650dafe1af2dfb3a265d13e230e05d 100644 (file)
@@ -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: "<<argv[0]<<" Doc {Label|Shape}\n";
+    return 1;
+  }
+  Handle(TDocStd_Document) Doc;   
+  DDocStd::GetDocument(argv[1], Doc);
+  if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
+  Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool(Doc->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 : "<<str;
+      
+      for(j = 0 ; j <= Area; j++)
+      {
+        if( aProp[j] > 0)
+        {
+          di<<(j == Vol ? "; Volume - " : "; Area - ")<<aProp[j];
+          nbProps[j]++;
+        }
+      }
+
+      if( !Precision::IsInfinite(aP.X()) )
+      {      
+        di<< "; Centroid -  "<< aP.X()<<" "<<aP.Y()<<" "<<aP.Z();
+        nbProps[Centroid]++;
+      }
+       di<<"\n";
+    }
+  }
+  di<<"========================================================="<<"\n";
+  di<< "Number of the validation properties : ";
+  for( i = Vol; i <= Centroid; i++)
+    di<< ( i == Vol ? "Volume" : (i == Area ? "Area" : "Centroid"))<<" : "<<nbProps[i]<<" ; "; 
+    
+  di<<"\n";
+  return 0;
+}
 
 //=======================================================================
 //function : InitCommands
@@ -944,5 +1035,6 @@ void XDEDRAW_Props::InitCommands(Draw_Interpretor& di)
                   __FILE__,ShapeMassProps , g);
   di.Add ("XSetMaterial","Doc {Label|Shape} name density(g/cu sm) \t: Set material to shape given by Label",
                   __FILE__, SetMaterial, g);
-
+  di.Add ("XGetValProps","Doc {Label|Shape}",__FILE__, GetValidationProps, g);
 }
index 7a6ac204e3cd8fd615cd69c29559e8a06ce07148..a8a700b8ea480bf1b9ed6edcf5edef34c3d28779 100644 (file)
@@ -13,7 +13,7 @@ NBSHAPES    : Solid    = 1  ( 1 )  Shell    = 1  ( 1 )  Face     = 308  ( 308 )
 STATSHAPE   : Solid    = 1  ( 1 )  Shell    = 1  ( 1 )  Face     = 308  ( 308 )   FreeWire = 0  ( 0 ) 
 TOLERANCE   : MaxTol   =  0.00708774003  ( 0.005806659935 )  AvgTol   =  0.0003095391197  (  0.0005353175043 )
 LABELS      : N0Labels = 1  ( 1 )  N1Labels = 0  ( 0 )  N2Labels = 0  ( 0 )   TotalLabels = 1  ( 1 )   NameLabels = 1  ( 1 )   ColorLabels = 1  ( 1 )   LayerLabels = 1  ( 1 )
-PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
+PROPS       : Centroid = 1  ( 1 )  Volume   = 1  ( 1 )  Area     = 1  ( 1 )
 NCOLORS     : NColors  = 1  ( 1 )
 COLORS      : Colors   = WHITE  ( WHITE )
 NLAYERS     : NLayers  = 1  ( 1 )
index 3be035de62f4904ef654b480ea5acb0f7dc0359f..7638bcd09e3c8b591dca3f27aab138813e802b7e 100644 (file)
@@ -9,7 +9,7 @@ NBSHAPES    : Solid    = 1  ( 1 )  Shell    = 1  ( 1 )  Face     = 528  ( 528 )
 STATSHAPE   : Solid    = 1  ( 1 )  Shell    = 1  ( 1 )  Face     = 528  ( 528 )   FreeWire = 0  ( 0 ) 
 TOLERANCE   : MaxTol   =   0.1201139499  (   0.1201139499 )  AvgTol   =  0.001747131975  (  0.001911592557 )
 LABELS      : N0Labels = 1  ( 1 )  N1Labels = 0  ( 0 )  N2Labels = 0  ( 0 )   TotalLabels = 1  ( 1 )   NameLabels = 1  ( 1 )   ColorLabels = 1  ( 1 )   LayerLabels = 1  ( 1 )
-PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
+PROPS       : Centroid = 1  ( 1 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
 NCOLORS     : NColors  = 1  ( 1 )
 COLORS      : Colors   = CYAN1  ( CYAN1 )
 NLAYERS     : NLayers  = 1  ( 1 )
diff --git a/tests/de/step_5/B7 b/tests/de/step_5/B7
new file mode 100644 (file)
index 0000000..f134296
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug21802_as1-oc-214.stp
+
+set ref_data {
+DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
+TPSTAT      : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
+CHECKSHAPE  : Wires    = 0  ( 0 )  Faces    = 0  ( 0 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
+NBSHAPES    : Solid    = 5  ( 5 )  Shell    = 5  ( 5 )  Face     = 53  ( 53 ) 
+STATSHAPE   : Solid    = 18  ( 18 )  Shell    = 18  ( 18 )  Face     = 160  ( 160 )   FreeWire = 0  ( 0 ) 
+TOLERANCE   : MaxTol   = 2.825576197e-005  ( 2.825576197e-005 )  AvgTol   =  6.514039857e-006  (  6.514039857e-006 )
+LABELS      : N0Labels = 9  ( 9 )  N1Labels = 13  ( 13 )  N2Labels = 0  ( 0 )   TotalLabels = 22  ( 22 )   NameLabels = 22  ( 22 )   ColorLabels = 5  ( 5 )   LayerLabels = 5  ( 5 )
+PROPS       : Centroid = 9  ( 9 )  Volume   = 9  ( 9 )  Area     = 9  ( 9 )
+NCOLORS     : NColors  = 5  ( 5 )
+COLORS      : Colors   = BLUE1 DARKORANGE1 GREEN RED YELLOW2  ( BLUE1 DARKORANGE1 GREEN RED YELLOW2 )
+NLAYERS     : NLayers  = 1  ( 1 )
+LAYERS      : Layers   = 256  ( 256 )
+
+}