return 1;
}
+ // check datum position number
+ Handle(XCAFDoc_Datum) aDatumAttr;
+ if (!aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr))
+ {
+ di<<"Invalid datum object\n";
+ return 1;
+ }
+ Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
+ if (aDatumObj.IsNull())
+ {
+ di<<"Invalid datum object\n";
+ return 1;
+ }
+
+ if (aDatumObj->GetPosition() < 1 || aDatumObj->GetPosition() > 3)
+ {
+ di<<"Invalid datum position number: use XSetDatumPosition\n";
+ return 1;
+ }
+
aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
return 0;
}
+static Standard_Integer setDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di<<"Use: XSetDatumPosition Doc Datum_Label position[1-3]\n";
+ return 1;
+ }
+
+ if (Draw::Atoi(argv[3]) < 1 || Draw::Atoi(argv[3]) > 3) {
+ di<<"Datum position should be 1, 2 or 3\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_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
+ Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
+
+ TDF_Label aLabel;
+ TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
+ if ( aLabel.IsNull() )
+ {
+ di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
+ return 1;
+ }
+ Handle(XCAFDoc_Datum) aDatum;
+ if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
+ {
+ Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
+ anObj->SetPosition(Draw::Atoi(argv[3]));
+ aDatum->SetObject(anObj);
+ }
+ return 0;
+}
+
+static Standard_Integer getDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di<<"Use: XGetDatumPosition Doc Datum_Label\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_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
+ Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
+
+ TDF_Label aLabel;
+ TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
+ if ( aLabel.IsNull() )
+ {
+ di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
+ return 1;
+ }
+ Handle(XCAFDoc_Datum) aDatum;
+ if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
+ {
+ di << aDatum->GetObject()->GetPosition();
+ }
+ return 0;
+}
+
+
static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
__FILE__, getDatumName, g);
+ di.Add ("XSetDatumPosition","XSetDatumPosition Doc Datum_Label position[1-3]"
+ "Set datum position number in geometric tolerance datum system",
+ __FILE__, setDatumPosition, g);
+
+ di.Add ("XGetDatumPosition","XGetDatumPosition Doc Datum_Label",
+ __FILE__, getDatumPosition, g);
+
di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
"Values:\n"
"\t 0 type is absent\n"
--- /dev/null
+puts "========"
+puts "OCC27313"
+puts "========"
+puts ""
+##########################################################################
+# Exception during WriteStep with PMI
+##########################################################################
+
+pload DCAF
+
+box b 10 10 10
+explode b
+explode b_1
+NewDocument D
+XAddShape D b
+XAddGeomTolerance D b_1_1
+XAddDatum D b_1_2
+#0:1:4:1
+#0:1:4:2
+XSetDatumName D 0:1:4:2 A
+XAddDatumModifier D 0:1:4:2 10
+XSetDatumPosition D 0:1:4:2 1
+XSetDatum D 0:1:4:2 0:1:4:1
+XSetToleranceValue D 0:1:4:1 0.5
+XSetTypeOfTolerance D 0:1:4:1 1
+XSetTypeOfToleranceValue D 0:1:4:1 1
+param write.step.schema 5
+newmodel
+WriteStep D $imagedir/${casename}_D.stp
+param write.step.schema 4
+newmodel