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.
#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>
{
// 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 );
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 );
}
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
__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);
+
}
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 )
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 )
--- /dev/null
+# !!!! 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 )
+
+}