1 // Created on: 2015-06-18
2 // Created by: Ilya Novikov
3 // Copyright (c) 2000-2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <XDEDRAW_GDTs.hxx>
20 #include <DDocStd.hxx>
22 #include <STEPCAFControl_GDTProperty.hxx>
24 #include <TDF_Tool.hxx>
25 #include <TDF_Label.hxx>
26 #include <TDF_LabelSequence.hxx>
27 #include <TDocStd_Document.hxx>
28 #include <XCAFDoc_GraphNode.hxx>
30 #include <XCAFDoc.hxx>
31 #include <XCAFDoc_DocumentTool.hxx>
32 #include <XCAFDoc_ShapeTool.hxx>
33 #include <XCAFDoc_DimTol.hxx>
34 #include <XCAFDoc_Dimension.hxx>
35 #include <XCAFDimTolObjects_DimensionObject.hxx>
36 #include <XCAFDoc_Datum.hxx>
37 #include <XCAFDimTolObjects_DatumObject.hxx>
38 #include <XCAFDoc_GeomTolerance.hxx>
39 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
40 #include <XCAFDoc_DimTolTool.hxx>
41 #include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
42 #include <XCAFDimTolObjects_DatumObjectSequence.hxx>
43 #include <XCAFDimTolObjects_GeomToleranceObjectSequence.hxx>
44 #include <XCAFDimTolObjects_DatumSingleModif.hxx>
45 #include <XCAFDimTolObjects_DimensionModif.hxx>
46 #include <XCAFDimTolObjects_GeomToleranceModif.hxx>
47 #include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
48 #include <XCAFDimTolObjects_DatumObject.hxx>
49 #include <XCAFDimTolObjects_Tool.hxx>
51 #include <TCollection_AsciiString.hxx>
52 #include <TCollection_HAsciiString.hxx>
53 #include <TColStd_HArray1OfReal.hxx>
54 #include <TColgp_HArray1OfPnt.hxx>
57 #include <TopoDS_Shape.hxx>
58 #include <TopoDS_Edge.hxx>
59 #include <TopoDS_Vertex.hxx>
60 #include <BRep_Tool.hxx>
64 static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
67 di<<"Use: XDumpDGTs Doc shape/label/all\n";
70 Handle(TDocStd_Document) Doc;
71 DDocStd::GetDocument(argv[1], Doc);
72 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
73 Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
74 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
76 TCollection_AsciiString name = argv[2];
77 TDF_LabelSequence aLabels;
78 if(name.IsEqual("all"))
80 aShapeTool->GetShapes(aLabels);
81 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
83 aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
89 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
90 if ( !aLabel.IsNull() ) {
91 aLabels.Append(aLabel);
92 aShapeTool->GetSubShapes(aLabel, aLabels);
96 TopoDS_Shape aShape= DBRep::Get(argv[2]);
97 if ( !aShape.IsNull() )
99 aShapeTool->Search(aShape, aLabel);
100 if ( !aLabel.IsNull() ) {
101 aLabels.Append(aLabel);
102 aShapeTool->GetSubShapes(aLabel, aLabels);
106 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
113 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
115 Standard_Boolean flag = Standard_True;
116 TDF_LabelSequence aGDTs;
117 aDimTolTool->GetRefDimensionLabels(aLabels.Value(i), aGDTs);
118 for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ )
120 Handle(XCAFDoc_Dimension) aDimTol;
121 if(aGDTs.Value(j).FindAttribute(XCAFDoc_Dimension::GetID(), aDimTol))
123 Handle(XCAFDimTolObjects_DimensionObject) aDimTolObj = aDimTol->GetObject();
126 TCollection_AsciiString Entry;
127 TDF_Tool::Entry(aLabels.Value(i), Entry);
128 di << "\n " << Entry << " Shape."<< i;
129 flag = Standard_False;
131 TCollection_AsciiString Entry;
132 TDF_Tool::Entry(aGDTs.Value(j), Entry);
133 di << "\n \t " << Entry;
134 flag = Standard_False;
136 di << " Dimension."<< i << "."<< j;
140 di << " T " << aDimTolObj->GetType();
141 if(aDimTolObj->IsDimWithRange())
143 di << ", LB " << aDimTolObj->GetLowerBound();
144 di << ", UB " << aDimTolObj->GetUpperBound();
148 di << ", V " << aDimTolObj->GetValue();
149 if (aDimTolObj->IsDimWithPlusMinusTolerance())
151 di << ", VL " << aDimTolObj->GetLowerTolValue();
152 di << ", VU " << aDimTolObj->GetUpperTolValue();
154 else if (aDimTolObj->IsDimWithClassOfTolerance())
156 Standard_Boolean isH;
157 XCAFDimTolObjects_DimensionFormVariance aFV;
158 XCAFDimTolObjects_DimensionGrade aG;
159 aDimTolObj->GetClassOfTolerance(isH, aFV, aG);
160 di << ", H " << (Standard_Integer)isH<< " F " << aFV << " G " << aG;
163 if (aDimTolObj->HasQualifier())
164 di << ", Q " << aDimTolObj->GetQualifier();
165 if (aDimTolObj->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
168 aDimTolObj->GetDirection(aD);
169 di << ", D (" << aD.X() << ", " << aD.Y() << ", " << aD.Z() << ")";
171 XCAFDimTolObjects_DimensionModifiersSequence aModif =
172 aDimTolObj->GetModifiers();
173 if (!aModif.IsEmpty())
176 for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
178 di << " M " << aModif.Value(k);
181 di << ", P " << (Standard_Integer)!aDimTolObj->GetPath().IsNull();
187 aDimTolTool->GetRefGeomToleranceLabels(aLabels.Value(i), aGDTs);
188 for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ )
190 Handle(XCAFDoc_GeomTolerance) aDimTol;
191 if(aGDTs.Value(j).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aDimTol))
193 Handle(XCAFDimTolObjects_GeomToleranceObject) aDimTolObj = aDimTol->GetObject();
196 TCollection_AsciiString Entry;
197 TDF_Tool::Entry(aLabels.Value(i), Entry);
198 di << "\n " << Entry << " Shape."<< i;
199 flag = Standard_False;
201 TCollection_AsciiString Entry;
202 TDF_Tool::Entry(aGDTs.Value(j), Entry);
203 di << "\n \t " << Entry;
204 flag = Standard_False;
206 di << " GeomTolerance."<< i << "."<< j;
210 di << " T " << aDimTolObj->GetType();
211 di << " TV " << aDimTolObj->GetTypeOfValue();
212 di << ", V " << aDimTolObj->GetValue();
214 if (aDimTolObj->HasAxis())
216 gp_Ax2 anAx = aDimTolObj->GetAxis();
217 di << ", A ( L (" << anAx.Location().X() << anAx.Location().Y() << anAx.Location().Z()
218 << "), XD (" << anAx.XDirection().X() << anAx.XDirection().Y() << anAx.XDirection().Z()
219 << "), RD (" << anAx.YDirection().X() << anAx.YDirection().Y() << anAx.YDirection().Z() << "))";
221 XCAFDimTolObjects_GeomToleranceModifiersSequence aModif =
222 aDimTolObj->GetModifiers();
223 if (!aModif.IsEmpty())
226 for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
228 di << " M " << aModif.Value(k);
231 if (aDimTolObj->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
233 di << ", MR " << aDimTolObj->GetMaterialRequirementModifier();
235 if (aDimTolObj->GetMaxValueModifier() > 0)
237 di << "MaxV " << aDimTolObj->GetMaxValueModifier();
239 if ( aDimTolObj->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
241 di << ", ZM " << aDimTolObj->GetZoneModifier();
242 if (aDimTolObj->GetValueOfZoneModifier() > 0)
244 di << " ZMV " <<aDimTolObj->GetValueOfZoneModifier();
250 Handle(XCAFDoc_GraphNode) aNode;
251 if(aGDTs.Value(j).FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode) && aNode->NbChildren() > 0)
253 for(Standard_Integer k = 1; k<=aNode->NbChildren(); k++)
255 Handle(XCAFDoc_Datum) aDatum;
256 if(aNode->GetChild(k)->Label().FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
258 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
259 TCollection_AsciiString anEntry;
260 TDF_Tool::Entry(aNode->GetChild(k)->Label(), anEntry);
261 di << "\n \t \t " << anEntry;
262 di << " Datum."<< i << "."<< j << "."<< k;
266 XCAFDimTolObjects_DatumModifiersSequence aModif =
267 aDatumObj->GetModifiers();
268 if (!aModif.IsEmpty())
271 for (Standard_Integer iModif = aModif.Lower(); iModif <= aModif.Upper(); iModif++)
273 di << " M " << aModif.Value(iModif);
276 XCAFDimTolObjects_DatumModifWithValue aM;
278 aDatumObj->GetModifierWithValue(aM, aV);
279 if (aM != XCAFDimTolObjects_DatumModifWithValue_None)
281 di << ", MV" << aM << " " << aV;
290 TDF_LabelSequence aDatumL;
291 if (aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatumL))
293 for(Standard_Integer j = aDatumL.Lower(); j <= aDatumL.Upper(); j++)
295 Handle(XCAFDoc_Datum) aDatum;
296 if(aDatumL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDatum) &&
297 aDatum->GetObject()->IsDatumTarget())
299 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
302 TCollection_AsciiString Entry;
303 TDF_Tool::Entry(aLabels.Value(i), Entry);
304 di << "\n " << Entry << " Shape."<< i;
305 flag = Standard_False;
307 TCollection_AsciiString Entry;
308 TDF_Tool::Entry(aDatumL.First(), Entry);
309 di << "\n \t " << Entry;
310 flag = Standard_False;
312 di << " Datum target."<< i << "."<< j;
316 di << " T " << aDatumObj->GetDatumTargetType();
317 if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Area)
319 gp_Ax2 anAx = aDatumObj->GetDatumTargetAxis();
320 di << ", A ( L (" << anAx.Location().X() << anAx.Location().Y() << anAx.Location().Z()
321 << "), XD (" << anAx.XDirection().X() << anAx.XDirection().Y() << anAx.XDirection().Z()
322 << "), RD (" << anAx.YDirection().X() << anAx.YDirection().Y() << anAx.YDirection().Z() << "))";
323 if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
325 di << ", L " << aDatumObj->GetDatumTargetLength() ;
326 if (aDatumObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
328 di << ", W " << aDatumObj->GetDatumTargetWidth() ;
341 static Standard_Integer DumpNbDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
344 di<<"Use: XDumpNbDGTs Doc";
348 Standard_Boolean isFull = Standard_False;
350 char aChar = argv[2][0];
352 isFull = Standard_True;
354 Handle(TDocStd_Document) Doc;
355 DDocStd::GetDocument(argv[1], Doc);
356 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
357 Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
358 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
360 TDF_LabelSequence aLabels;
361 aShapeTool->GetShapes(aLabels);
362 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
364 aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
367 TDF_LabelSequence aGDTs;
368 aDimTolTool->GetDimensionLabels(aGDTs);
369 di << "\n NbOfDimensions : " << aGDTs.Length();
371 Standard_Integer nbSize = 0,
375 for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
376 Handle(XCAFDoc_Dimension) aDimAttr;
377 if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr))
379 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
380 if (anObject.IsNull())
382 XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
383 if (STEPCAFControl_GDTProperty::IsDimensionalLocation(aDimType)) {
386 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) {
390 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) {
394 else if (STEPCAFControl_GDTProperty::IsDimensionalSize(aDimType)) {
397 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) {
401 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) {
406 di << "\n NbOfDimensionalSize : " << nbSize;
407 di << "\n NbOfDimensionalLocation: " << nbLocation;
408 di << "\n NbOfAngular : " << nbAngular;
409 di << "\n NbOfWithPath : " << nbWithPath;
413 aDimTolTool->GetGeomToleranceLabels(aGDTs);
414 di << "\n NbOfTolerances : " << aGDTs.Length();
416 Standard_Integer nbWithModif = 0,
419 for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
420 Handle(XCAFDoc_GeomTolerance) aGTAttr;
421 if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGTAttr))
423 Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
424 if (anObject.IsNull())
426 if (anObject->GetModifiers().Length() > 0 ||
427 anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) {
430 if (anObject->GetMaxValueModifier() != 0) {
433 TDF_LabelSequence aDatumSeq;
434 aDimTolTool->GetDatumWithObjectOfTolerLabels(aGDTs.Value(i), aDatumSeq);
435 if (aDatumSeq.Length() > 0) {
439 di << "\n NbOfGTWithModifiers : " << nbWithModif;
440 di << "\n NbOfGTWithMaxTolerance : " << nbWithMaxTol;
441 di << "\n NbOfGTWithDatums : " << nbWithDatumRef;
444 Standard_Integer aCounter = 0;
445 Standard_Integer aCounter1 = 0;
446 Standard_Integer aCounter2 = 0;
448 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
450 Standard_Boolean isDatum = Standard_False;
451 TDF_LabelSequence aDatL;
452 if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL))
454 for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++)
456 Handle(XCAFDoc_Datum) aDat;
457 if(aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat))
459 if(aDat->GetObject()->IsDatumTarget())
466 isDatum = Standard_True;
474 di << "\n NbOfDatumFeature : " << aCounter;
475 di << "\n NbOfAttachedDatum : " << aCounter2;
476 di << "\n NbOfDatumTarget : " << aCounter1;
481 static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
484 di<<"Use: XAddDimension Doc shape/label [shape/label]\n";
487 Handle(TDocStd_Document) Doc;
488 DDocStd::GetDocument(argv[1], Doc);
489 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
490 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
491 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
494 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
495 if ( aLabel.IsNull() )
497 TopoDS_Shape aShape= DBRep::Get(argv[2]);
498 if ( !aShape.IsNull() )
500 aShapeTool->Search(aShape, aLabel);
501 if ( aLabel.IsNull() )
503 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
511 TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1);
512 if ( aLabel1.IsNull() )
514 TopoDS_Shape aShape= DBRep::Get(argv[3]);
515 if ( !aShape.IsNull() )
517 aShapeTool->Search(aShape, aLabel1);
518 if ( aLabel1.IsNull() )
520 di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
527 TDF_Label aDimL = aDimTolTool->AddDimension();
529 aDimTolTool->SetDimension(aLabel, aDimL);
531 aDimTolTool->SetDimension(aLabel, aLabel1, aDimL);
532 TCollection_AsciiString Entry;
533 TDF_Tool::Entry(aDimL, Entry);
538 static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
541 di<<"Use: XAddGeomTolerance Doc shape/label\n";
544 Handle(TDocStd_Document) Doc;
545 DDocStd::GetDocument(argv[1], Doc);
546 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
547 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
548 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
551 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
552 if ( aLabel.IsNull() )
554 TopoDS_Shape aShape= DBRep::Get(argv[2]);
555 if ( !aShape.IsNull() )
557 aShapeTool->Search(aShape, aLabel);
558 if ( aLabel.IsNull() )
560 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
566 TDF_Label aTolL = aDimTolTool->AddGeomTolerance();
567 aDimTolTool->SetGeomTolerance(aLabel, aTolL);
568 TCollection_AsciiString Entry;
569 TDF_Tool::Entry(aTolL, Entry);
574 static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
577 di<<"Use: XAddDatum Doc shape/label\n";
580 Handle(TDocStd_Document) Doc;
581 DDocStd::GetDocument(argv[1], Doc);
582 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
583 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
584 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
587 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
588 if ( aLabel.IsNull() )
590 TopoDS_Shape aShape= DBRep::Get(argv[2]);
591 if ( !aShape.IsNull() )
593 aShapeTool->Search(aShape, aLabel);
594 if ( aLabel.IsNull() )
596 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
602 TDF_Label aDatumL = aDimTolTool->AddDatum();
603 aDimTolTool->SetDatum(aLabel, aDatumL);
604 TCollection_AsciiString Entry;
605 TDF_Tool::Entry(aDatumL, Entry);
610 static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
613 di<<"Use: XSetDatum Doc Datum_Label GeomTol_Label\n";
616 Handle(TDocStd_Document) Doc;
617 DDocStd::GetDocument(argv[1], Doc);
618 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
619 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
620 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
623 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
624 if ( aLabel.IsNull() )
626 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
631 TDF_Tool::Label(Doc->GetData(), argv[3], aTol);
634 di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
638 aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
642 static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
645 di<<"Use: XGetDatum Doc GeomTol_Label/Shape_Label\n";
648 Handle(TDocStd_Document) Doc;
649 DDocStd::GetDocument(argv[1], Doc);
650 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
651 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
652 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
655 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
656 if ( aLabel.IsNull() )
658 di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
662 TDF_LabelSequence aD;
663 if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
665 aDimTolTool->GetDatumOfTolerLabels(aLabel, aD);
667 for(Standard_Integer i = aD.Lower(); i <= aD.Upper(); i++)
670 TCollection_AsciiString Entry;
671 TDF_Tool::Entry(aD.Value(i), Entry);
677 static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
680 di<<"Use: XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n";
683 Handle(TDocStd_Document) Doc;
684 DDocStd::GetDocument(argv[1], Doc);
685 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
686 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
687 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
690 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
691 if ( aLabel.IsNull() )
693 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
696 Handle(XCAFDoc_Datum) aDatum;
697 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
699 for(Standard_Integer i = 3; i < argc; i++)
701 if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1)
703 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
704 anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i]));
705 aDatum->SetObject(anObj);
712 static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
715 di<<"Use: XGetDatumModifiers Doc Datum_Label\n";
718 Handle(TDocStd_Document) Doc;
719 DDocStd::GetDocument(argv[1], Doc);
720 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
721 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
722 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
725 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
726 if ( aLabel.IsNull() )
728 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
731 Handle(XCAFDoc_Datum) aDatum;
732 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
734 XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers();
735 for(Standard_Integer i = 1; i<=aS.Length();i++)
739 case 0 : di<<"AnyCrossSection"; break;
740 case 1 : di<<"AnyLongitudinalSection"; break;
741 case 2 : di<<"Basic"; break;
742 case 3 : di<<"ContactingFeature\n"; break;
743 case 4 : di<<"DegreeOfFreedomConstraintU"; break;
744 case 5 : di<<"DegreeOfFreedomConstraintV"; break;
745 case 6 : di<<"DegreeOfFreedomConstraintW"; break;
746 case 7 : di<<"DegreeOfFreedomConstraintX"; break;
747 case 8 : di<<"DegreeOfFreedomConstraintY"; break;
748 case 9 : di<<"DegreeOfFreedomConstraintZ"; break;
749 case 10 : di<<"DistanceVariable"; break;
750 case 11 : di<<"FreeState"; break;
751 case 12 : di<<"LeastMaterialRequirement"; break;
752 case 13 : di<<"Line"; break;
753 case 14 : di<<"MajorDiameter"; break;
754 case 15 : di<<"MaximumMaterialRequirement"; break;
755 case 16 : di<<"MinorDiameter"; break;
756 case 17 : di<<"Orientation"; break;
757 case 18 : di<<"PitchDiameter"; break;
758 case 19 : di<<"Plane"; break;
759 case 20 : di<<"Point"; break;
760 case 21 : di<<"Translation"; break;
768 static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
771 di<<"Use: XSetDatumName Doc Datum_Label name\n";
774 Handle(TDocStd_Document) Doc;
775 DDocStd::GetDocument(argv[1], Doc);
776 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
777 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
778 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
781 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
782 if ( aLabel.IsNull() )
784 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
787 Handle(XCAFDoc_Datum) aDatum;
788 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
790 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
791 anObj->SetName(new TCollection_HAsciiString(argv[3]));
792 aDatum->SetObject(anObj);
797 static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
800 di<<"Use: XGetDatumName Doc Datum_Label\n";
803 Handle(TDocStd_Document) Doc;
804 DDocStd::GetDocument(argv[1], Doc);
805 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
806 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
807 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
810 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
811 if ( aLabel.IsNull() )
813 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
816 Handle(XCAFDoc_Datum) aDatum;
817 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
819 di<<aDatum->GetObject()->GetName()->ToCString();
824 static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
827 di<<"Use: XSetTypeOfTolerance Doc GTol_Label type\n";
830 Handle(TDocStd_Document) Doc;
831 DDocStd::GetDocument(argv[1], Doc);
832 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
833 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
834 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
837 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
838 if ( aLabel.IsNull() )
840 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
843 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
844 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
846 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16)
848 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
849 anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3]));
850 aGeomTolerance->SetObject(anObj);
856 static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
859 di<<"Use: XGetTypeOfTolerance Doc GTol_Label\n";
862 Handle(TDocStd_Document) Doc;
863 DDocStd::GetDocument(argv[1], Doc);
864 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
865 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
866 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
869 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
870 if ( aLabel.IsNull() )
872 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
875 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
876 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
878 switch(aGeomTolerance->GetObject()->GetType()){
879 case 0 : di<<"type is absent"; break;
880 case 1 : di<<"Angularity"; break;
881 case 2 : di<<"CircularRunout"; break;
882 case 3 : di<<"CircularityOrRoundness"; break;
883 case 4 : di<<"Coaxiality"; break;
884 case 5 : di<<"Concentricity"; break;
885 case 6 : di<<"Cylindricity"; break;
886 case 7 : di<<"Flatness"; break;
887 case 8 : di<<"Parallelism"; break;
888 case 9 : di<<"Perpendicularity"; break;
889 case 10 : di<<"Position"; break;
890 case 11 : di<<"ProfileOfLine"; break;
891 case 12 : di<<"ProfileOfSurface"; break;
892 case 13 : di<<"Straightness"; break;
893 case 14 : di<<"Symmetry"; break;
894 case 15 : di<<"TotalRunout"; break;
901 static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
904 di<<"Use: XSetTypeOfToleranceValue Doc GTol_Label type\n";
907 Handle(TDocStd_Document) Doc;
908 DDocStd::GetDocument(argv[1], Doc);
909 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
910 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
911 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
914 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
915 if ( aLabel.IsNull() )
917 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
920 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
921 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
923 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
925 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
926 anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3]));
927 aGeomTolerance->SetObject(anObj);
933 static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
936 di<<"Use: XGetTypeOfToleranceValue Doc GTol_Label\n";
939 Handle(TDocStd_Document) Doc;
940 DDocStd::GetDocument(argv[1], Doc);
941 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
942 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
943 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
946 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
947 if ( aLabel.IsNull() )
949 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
952 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
953 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
955 switch(aGeomTolerance->GetObject()->GetTypeOfValue()){
956 case 0 : di<<"type is absent"; break;
957 case 1 : di<<"Diameter"; break;
958 case 2 : di<<"SphericalDiameter"; break;
965 static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
968 di<<"Use: XSetToleranceValue Doc GTol_Label value\n";
971 Handle(TDocStd_Document) Doc;
972 DDocStd::GetDocument(argv[1], Doc);
973 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
974 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
975 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
978 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
979 if ( aLabel.IsNull() )
981 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
984 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
985 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
987 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
988 anObj->SetValue(Draw::Atof(argv[3]));
989 aGeomTolerance->SetObject(anObj);
994 static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
997 di<<"Use: XGetToleranceValue Doc GTol_Label\n";
1000 Handle(TDocStd_Document) Doc;
1001 DDocStd::GetDocument(argv[1], Doc);
1002 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1003 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1004 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1007 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1008 if ( aLabel.IsNull() )
1010 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1013 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1014 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1016 di << aGeomTolerance->GetObject()->GetValue();
1021 static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1024 di<<"Use: XSetTolMaterialReq Doc GTol_Label mod\n";
1027 Handle(TDocStd_Document) Doc;
1028 DDocStd::GetDocument(argv[1], Doc);
1029 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1030 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1031 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1034 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1035 if ( aLabel.IsNull() )
1037 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1040 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1041 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1043 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1045 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1046 anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3]));
1047 aGeomTolerance->SetObject(anObj);
1053 static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1056 di<<"Use: XGetTolMaterialReq Doc GTol_Label\n";
1059 Handle(TDocStd_Document) Doc;
1060 DDocStd::GetDocument(argv[1], Doc);
1061 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1062 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1063 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1066 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1067 if ( aLabel.IsNull() )
1069 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1072 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1073 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1075 switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){
1076 case 0 : di<<"modifier is absent"; break;
1077 case 1 : di<<"M"; break;
1078 case 2 : di<<"L"; break;
1085 static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1088 di<<"Use: XSetTolZoneMod Doc GTol_Label mod\n";
1091 Handle(TDocStd_Document) Doc;
1092 DDocStd::GetDocument(argv[1], Doc);
1093 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1094 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1095 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1098 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1099 if ( aLabel.IsNull() )
1101 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1104 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1105 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1107 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1109 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1110 anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3]));
1111 aGeomTolerance->SetObject(anObj);
1117 static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1120 di<<"Use: XGetTolZoneMod Doc GTol_Label\n";
1123 Handle(TDocStd_Document) Doc;
1124 DDocStd::GetDocument(argv[1], Doc);
1125 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1126 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1127 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1130 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1131 if ( aLabel.IsNull() )
1133 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1136 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1137 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1139 switch(aGeomTolerance->GetObject()->GetZoneModifier()){
1140 case 0 : di<<"modifier is absent"; break;
1141 case 1 : di<<"P"; break;
1142 case 2 : di<<"NonUniform"; break;
1149 static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1152 di<<"Use: XSetTolZoneModValue Doc GTol_Label val\n";
1155 Handle(TDocStd_Document) Doc;
1156 DDocStd::GetDocument(argv[1], Doc);
1157 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1158 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1159 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1162 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1163 if ( aLabel.IsNull() )
1165 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1168 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1169 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1171 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1172 anObj->SetValueOfZoneModifier(Draw::Atof(argv[3]));
1173 aGeomTolerance->SetObject(anObj);
1178 static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1181 di<<"Use: XGetTolZoneModValue Doc GTol_Label\n";
1184 Handle(TDocStd_Document) Doc;
1185 DDocStd::GetDocument(argv[1], Doc);
1186 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1187 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1188 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1191 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1192 if ( aLabel.IsNull() )
1194 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1197 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1198 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1200 di << aGeomTolerance->GetObject()->GetValueOfZoneModifier();
1205 static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1208 di<<"Use: XAddTolModifier Doc Tol_Label mod1 mod2 ...\n";
1211 Handle(TDocStd_Document) Doc;
1212 DDocStd::GetDocument(argv[1], Doc);
1213 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1214 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1215 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1218 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1219 if ( aLabel.IsNull() )
1221 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1224 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1225 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1227 for(Standard_Integer i = 3; i < argc; i++)
1229 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 15)
1231 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1232 anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i]));
1233 aGeomTolerance->SetObject(anObj);
1240 static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1243 di<<"Use: XGetTolModifiers Doc Tol_Label\n";
1246 Handle(TDocStd_Document) Doc;
1247 DDocStd::GetDocument(argv[1], Doc);
1248 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1249 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1250 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1253 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1254 if ( aLabel.IsNull() )
1256 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1259 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1260 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1262 XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers();
1263 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1265 if (i > 1) di<<", ";
1266 switch(aS.Value(i)){
1267 case 0 : di<<"Any_Cross_Section"; break;
1268 case 1 : di<<"Common_Zone"; break;
1269 case 2 : di<<"Each_Radial_Element"; break;
1270 case 3 : di<<"Free_State"; break;
1271 case 4 : di<<"Least_Material_Requirement"; break;
1272 case 5 : di<<"Line_Element"; break;
1273 case 6 : di<<"Major_Diameter"; break;
1274 case 7 : di<<"Maximum_Material_Requirement"; break;
1275 case 8 : di<<"Minor_Diameter"; break;
1276 case 9 : di<<"Not_Convex"; break;
1277 case 10 : di<<"Pitch_Diameter"; break;
1278 case 11 : di<<"Reciprocity_Requirement"; break;
1279 case 12 : di<<"Separate_Requirement"; break;
1280 case 13 : di<<"Statistical_Tolerance"; break;
1281 case 14 : di<<"Tangent_Plane"; break;
1289 static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1292 di<<"Use: XSetTolMaxValue Doc Dim_Label val\n";
1295 Handle(TDocStd_Document) Doc;
1296 DDocStd::GetDocument(argv[1], Doc);
1297 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1298 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1299 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1302 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1303 if ( aLabel.IsNull() )
1305 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1308 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1309 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1311 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1312 anObj->SetMaxValueModifier(Draw::Atof(argv[3]));
1313 aGeomTolerance->SetObject(anObj);
1318 static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1321 di<<"Use: XGetTolMaxValue Doc Dim_Label\n";
1324 Handle(TDocStd_Document) Doc;
1325 DDocStd::GetDocument(argv[1], Doc);
1326 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1327 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1328 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1331 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1332 if ( aLabel.IsNull() )
1334 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1337 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1338 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1340 di << aGeomTolerance->GetObject()->GetMaxValueModifier();
1345 static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1348 di<<"Use: XSetDimensionType Doc Dim_Label type\n";
1351 Handle(TDocStd_Document) Doc;
1352 DDocStd::GetDocument(argv[1], Doc);
1353 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1354 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1355 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1358 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1359 if ( aLabel.IsNull() )
1361 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1364 Handle(XCAFDoc_Dimension) aDimension;
1365 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1367 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30)
1369 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1370 anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3]));
1371 aDimension->SetObject(anObj);
1377 static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1380 di<<"Use: XGetDimensionType Doc Dim_Label\n";
1383 Handle(TDocStd_Document) Doc;
1384 DDocStd::GetDocument(argv[1], Doc);
1385 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1386 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1387 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1390 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1391 if ( aLabel.IsNull() )
1393 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1396 Handle(XCAFDoc_Dimension) aDimension;
1397 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1399 switch(aDimension->GetObject()->GetType()){
1400 case 0 : di<<"type is absent"; break;
1401 case 1 : di<<"Location_CurvedDistance"; break;
1402 case 2 : di<<"Location_LinearDistance"; break;
1403 case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break;
1404 case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break;
1405 case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break;
1406 case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break;
1407 case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break;
1408 case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break;
1409 case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break;
1410 case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break;
1411 case 11 : di<<"Location_Angular"; break;
1412 case 12 : di<<"Location_Oriented"; break;
1413 case 13 : di<<"Location_WithPath"; break;
1414 case 14 : di<<"Size_CurveLength"; break;
1415 case 15 : di<<"Size_Diameter"; break;
1416 case 16 : di<<"Size_SphericalDiameter"; break;
1417 case 17 : di<<"Size_Radius"; break;
1418 case 18 : di<<"Size_SphericalRadius"; break;
1419 case 19 : di<<"Size_ToroidalMinorDiameter"; break;
1420 case 20 : di<<"Size_ToroidalMajorDiameter"; break;
1421 case 21 : di<<"Size_ToroidalMinorRadius"; break;
1422 case 22 : di<<"Size_ToroidalMajorRadius"; break;
1423 case 23 : di<<"Size_ToroidalHighMajorDiameter"; break;
1424 case 24 : di<<"Size_ToroidalLowMajorDiameter"; break;
1425 case 25 : di<<"Size_ToroidalHighMajorRadius"; break;
1426 case 26 : di<<"Size_ToroidalLowMajorRadius"; break;
1427 case 27 : di<<"Size_Thickness"; break;
1428 case 28 : di<<"Size_Angular"; break;
1429 case 29 : di<<"Size_WithPath"; break;
1436 static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1439 di<<"Use: XSetDimensionValue Doc Dim_Label val\n";
1442 Handle(TDocStd_Document) Doc;
1443 DDocStd::GetDocument(argv[1], Doc);
1444 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1445 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1446 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1449 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1450 if ( aLabel.IsNull() )
1452 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1455 Handle(XCAFDoc_Dimension) aDimension;
1456 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1458 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1459 anObj->SetValue(Draw::Atof(argv[3]));
1460 aDimension->SetObject(anObj);
1465 static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1468 di<<"Use: XGetDimensionValue Doc Dim_Label\n";
1471 Handle(TDocStd_Document) Doc;
1472 DDocStd::GetDocument(argv[1], Doc);
1473 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1474 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1475 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1478 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1479 if ( aLabel.IsNull() )
1481 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1484 Handle(XCAFDoc_Dimension) aDimension;
1485 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1487 di << aDimension->GetObject()->GetValue();
1492 static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1495 di<<"Use: XSetDimensionQualifier Doc Dim_Label val\n";
1498 Handle(TDocStd_Document) Doc;
1499 DDocStd::GetDocument(argv[1], Doc);
1500 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1501 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1502 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1505 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1506 if ( aLabel.IsNull() )
1508 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1511 Handle(XCAFDoc_Dimension) aDimension;
1512 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1514 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4)
1516 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1517 anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3]));
1518 aDimension->SetObject(anObj);
1524 static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1527 di<<"Use: XGetDimensionQualifier Doc Dim_Label\n";
1530 Handle(TDocStd_Document) Doc;
1531 DDocStd::GetDocument(argv[1], Doc);
1532 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1533 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1534 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1537 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1538 if ( aLabel.IsNull() )
1540 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1543 Handle(XCAFDoc_Dimension) aDimension;
1544 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1547 switch(aDimension->GetObject()->GetQualifier()){
1548 case 0 : di<<"type is absent"; break;
1549 case 1 : di<<"Min"; break;
1550 case 2 : di<<"Max"; break;
1551 case 3 : di<<"Avg"; break;
1558 static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1561 di<<"Use: XSetDimensionRange Doc Dim_Label low_val up_val\n";
1564 Handle(TDocStd_Document) Doc;
1565 DDocStd::GetDocument(argv[1], Doc);
1566 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1567 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1568 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1571 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1572 if ( aLabel.IsNull() )
1574 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1577 Handle(XCAFDoc_Dimension) aDimension;
1578 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1580 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1582 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1583 anObj->SetLowerBound(Draw::Atof(argv[3]));
1584 anObj->SetUpperBound(Draw::Atof(argv[4]));
1585 aDimension->SetObject(anObj);
1591 static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1594 di<<"Use: XGetDimensionRange Doc Dim_Label\n";
1597 Handle(TDocStd_Document) Doc;
1598 DDocStd::GetDocument(argv[1], Doc);
1599 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1600 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1601 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1604 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1605 if ( aLabel.IsNull() )
1607 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1610 Handle(XCAFDoc_Dimension) aDimension;
1611 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1613 di << "lower " << aDimension->GetObject()->GetLowerBound();
1614 di << " upper " << aDimension->GetObject()->GetUpperBound();
1619 static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1622 di<<"Use: XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n";
1625 Handle(TDocStd_Document) Doc;
1626 DDocStd::GetDocument(argv[1], Doc);
1627 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1628 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1629 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1632 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1633 if ( aLabel.IsNull() )
1635 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1638 Handle(XCAFDoc_Dimension) aDimension;
1639 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1641 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1643 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1644 anObj->SetLowerTolValue(Draw::Atof(argv[3]));
1645 anObj->SetUpperTolValue(Draw::Atof(argv[4]));
1646 aDimension->SetObject(anObj);
1652 static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1655 di<<"Use: XGetDimensionPlusMinusTol Doc Dim_Label\n";
1658 Handle(TDocStd_Document) Doc;
1659 DDocStd::GetDocument(argv[1], Doc);
1660 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1661 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1662 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1665 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1666 if ( aLabel.IsNull() )
1668 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1671 Handle(XCAFDoc_Dimension) aDimension;
1672 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1674 di << "lower " << aDimension->GetObject()->GetLowerTolValue();
1675 di << " upper " << aDimension->GetObject()->GetUpperTolValue();
1680 static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1683 di<<"Use: XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n";
1686 Handle(TDocStd_Document) Doc;
1687 DDocStd::GetDocument(argv[1], Doc);
1688 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1689 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1690 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1693 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1694 if ( aLabel.IsNull() )
1696 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1699 Handle(XCAFDoc_Dimension) aDimension;
1700 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1702 if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20)
1704 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1705 anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5]));
1706 aDimension->SetObject(anObj);
1712 static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1715 di<<"Use: XGetDimensionClassOfTol Doc Dim_Label\n";
1718 Handle(TDocStd_Document) Doc;
1719 DDocStd::GetDocument(argv[1], Doc);
1720 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1721 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1722 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1725 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1726 if ( aLabel.IsNull() )
1728 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1731 Handle(XCAFDoc_Dimension) aDimension;
1732 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1735 XCAFDimTolObjects_DimensionFormVariance f;
1736 XCAFDimTolObjects_DimensionGrade g;
1737 if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g))
1742 case 1 : di<<"a";break;
1743 case 2 : di<<"b";break;
1744 case 3 : di<<"c";break;
1745 case 4 : di<<"cd";break;
1746 case 5 : di<<"d";break;
1747 case 6 : di<<"e";break;
1748 case 7 : di<<"ef";break;
1749 case 8 : di<<"f";break;
1750 case 9 : di<<"fg";break;
1751 case 10 : di<<"g";break;
1752 case 11 : di<<"h";break;
1753 case 12 : di<<"js";break;
1754 case 13 : di<<"j";break;
1755 case 14 : di<<"k";break;
1756 case 15 : di<<"m";break;
1757 case 16 : di<<"n";break;
1758 case 17 : di<<"p";break;
1759 case 18 : di<<"r";break;
1760 case 19 : di<<"s";break;
1761 case 20 : di<<"t";break;
1762 case 21 : di<<"u";break;
1763 case 22 : di<<"v";break;
1764 case 23 : di<<"x";break;
1765 case 24 : di<<"y";break;
1766 case 25 : di<<"z";break;
1767 case 26 : di<<"a";break;
1768 case 27 : di<<"zb";break;
1769 case 28 : di<<"zc";break;
1776 case 1 : di<<"A";break;
1777 case 2 : di<<"B";break;
1778 case 3 : di<<"C";break;
1779 case 4 : di<<"CD";break;
1780 case 5 : di<<"D";break;
1781 case 6 : di<<"E";break;
1782 case 7 : di<<"EF";break;
1783 case 8 : di<<"F";break;
1784 case 9 : di<<"FG";break;
1785 case 10 : di<<"G";break;
1786 case 11 : di<<"H";break;
1787 case 12 : di<<"JS";break;
1788 case 13 : di<<"J";break;
1789 case 14 : di<<"K";break;
1790 case 15 : di<<"M";break;
1791 case 16 : di<<"N";break;
1792 case 17 : di<<"P";break;
1793 case 18 : di<<"R";break;
1794 case 19 : di<<"S";break;
1795 case 20 : di<<"T";break;
1796 case 21 : di<<"U";break;
1797 case 22 : di<<"V";break;
1798 case 23 : di<<"X";break;
1799 case 24 : di<<"Y";break;
1800 case 25 : di<<"Z";break;
1801 case 26 : di<<"ZA";break;
1802 case 27 : di<<"ZB";break;
1803 case 28 : di<<"ZC";break;
1808 case 0 : di<<"01"; break;
1809 case 1 : di<<"0"; break;
1810 case 2 : di<<"1"; break;
1811 case 3 : di<<"2"; break;
1812 case 4 : di<<"3"; break;
1813 case 5 : di<<"4"; break;
1814 case 6 : di<<"5"; break;
1815 case 7 : di<<"6"; break;
1816 case 8 : di<<"7"; break;
1817 case 9 : di<<"8"; break;
1818 case 10 : di<<"9"; break;
1819 case 11 : di<<"10"; break;
1820 case 12 : di<<"11"; break;
1821 case 13 : di<<"12"; break;
1822 case 14 : di<<"13"; break;
1823 case 15 : di<<"14"; break;
1824 case 16 : di<<"15"; break;
1825 case 17 : di<<"16"; break;
1826 case 18 : di<<"17"; break;
1827 case 19 : di<<"18"; break;
1835 static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1838 di<<"Use: XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n";
1841 Handle(TDocStd_Document) Doc;
1842 DDocStd::GetDocument(argv[1], Doc);
1843 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1844 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1845 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1848 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1849 if ( aLabel.IsNull() )
1851 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1854 Handle(XCAFDoc_Dimension) aDimension;
1855 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1857 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1858 anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4]));
1859 aDimension->SetObject(anObj);
1864 static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1867 di<<"Use: XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n";
1870 Handle(TDocStd_Document) Doc;
1871 DDocStd::GetDocument(argv[1], Doc);
1872 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1873 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1874 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1877 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1878 if ( aLabel.IsNull() )
1880 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1883 Handle(XCAFDoc_Dimension) aDimension;
1884 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1886 Standard_Integer l, r;
1887 aDimension->GetObject()->GetNbOfDecimalPlaces(l,r);
1888 di << l << "." << r;
1893 static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1896 di<<"Use: XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n";
1899 Handle(TDocStd_Document) Doc;
1900 DDocStd::GetDocument(argv[1], Doc);
1901 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1902 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1903 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1906 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1907 if ( aLabel.IsNull() )
1909 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1912 Handle(XCAFDoc_Dimension) aDimension;
1913 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1915 for(Standard_Integer i = 3; i < argc; i++)
1917 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24)
1919 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1920 anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i]));
1921 aDimension->SetObject(anObj);
1928 static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1931 di<<"Use: XGetDimensionModifiers Doc Dim_Label\n";
1934 Handle(TDocStd_Document) Doc;
1935 DDocStd::GetDocument(argv[1], Doc);
1936 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1937 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1938 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1941 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1942 if ( aLabel.IsNull() )
1944 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1947 Handle(XCAFDoc_Dimension) aDimension;
1948 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1950 XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers();
1951 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1953 if (i > 1) di<<", ";
1954 switch(aS.Value(i)){
1955 case 0 : di<<"ControlledRadius"; break;
1956 case 1 : di<<"Square"; break;
1957 case 2 : di<<"StatisticalTolerance"; break;
1958 case 3 : di<<"ContinuousFeature"; break;
1959 case 4 : di<<"TwoPointSize"; break;
1960 case 5 : di<<"LocalSizeDefinedBySphere"; break;
1961 case 6 : di<<"LeastSquaresAssociationCriterion"; break;
1962 case 7 : di<<"MaximumInscribedAssociation"; break;
1963 case 8 : di<<"MinimumCircumscribedAssociation"; break;
1964 case 9 : di<<"CircumferenceDiameter"; break;
1965 case 10 : di<<"AreaDiameter"; break;
1966 case 11 : di<<"VolumeDiameter"; break;
1967 case 12 : di<<"MaximumSize"; break;
1968 case 13 : di<<"MinimumSize"; break;
1969 case 14 : di<<"AverageSize"; break;
1970 case 15 : di<<"MedianSize"; break;
1971 case 16 : di<<"MidRangeSize"; break;
1972 case 17 : di<<"RangeOfSizes"; break;
1973 case 18 : di<<"AnyRestrictedPortionOfFeature"; break;
1974 case 19 : di<<"AnyCrossSection"; break;
1975 case 20 : di<<"SpecificFixedCrossSection"; break;
1976 case 21 : di<<"CommonTolerance"; break;
1977 case 22 : di<<"FreeStateCondition"; break;
1978 case 23 : di<<"Between"; break;
1986 static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1989 di<<"Use: XSetDimensionPath Doc Dim_Label path(edge)\n";
1992 Handle(TDocStd_Document) Doc;
1993 DDocStd::GetDocument(argv[1], Doc);
1994 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1995 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1996 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1999 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2000 if ( aLabel.IsNull() )
2002 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2005 Handle(XCAFDoc_Dimension) aDimension;
2006 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2008 TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE));
2011 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2013 aDimension->SetObject(anObj);
2019 static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2022 di<<"Use: XSetDimensionPoints Doc Dim_Label v1 [v2]\n";
2025 Handle(TDocStd_Document) Doc;
2026 DDocStd::GetDocument(argv[1], Doc);
2027 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2028 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2029 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2032 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2033 if ( aLabel.IsNull() )
2035 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2038 Handle(XCAFDoc_Dimension) aDimension;
2039 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2041 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2043 TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX));
2045 anObj->SetPoint(BRep_Tool::Pnt(aV1));
2048 TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX));
2050 anObj->SetPoint2(BRep_Tool::Pnt(aV2));
2053 aDimension->SetObject(anObj);
2058 static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2061 di<<"Use: XGetDimensionPoints Doc Dim_Label\n";
2064 Handle(TDocStd_Document) Doc;
2065 DDocStd::GetDocument(argv[1], Doc);
2066 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2067 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2068 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2071 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2072 if ( aLabel.IsNull() )
2074 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2077 Handle(XCAFDoc_Dimension) aDimension;
2078 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2080 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2081 if(anObj->HasPoint()) {
2082 di << anObj->GetPoint().X() << ";" << anObj->GetPoint().Y() << ";" << anObj->GetPoint().Z() << " ";
2084 if(anObj->HasPoint2()) {
2085 di << anObj->GetPoint2().X() << ";" << anObj->GetPoint2().Y() << ";" << anObj->GetPoint2().Z();
2091 static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2094 di<<"Use: XSetDimensionDir Doc Dim_Label x y z\n";
2097 Handle(TDocStd_Document) Doc;
2098 DDocStd::GetDocument(argv[1], Doc);
2099 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2100 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2101 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2104 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2105 if ( aLabel.IsNull() )
2107 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2110 Handle(XCAFDoc_Dimension) aDimension;
2111 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2113 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2114 anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5])));
2115 aDimension->SetObject(anObj);
2120 static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2123 di<<"Use: XGetDimensionDir Doc Dim_Label\n";
2126 Handle(TDocStd_Document) Doc;
2127 DDocStd::GetDocument(argv[1], Doc);
2128 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2129 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2130 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2133 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2134 if ( aLabel.IsNull() )
2136 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2139 Handle(XCAFDoc_Dimension) aDimension;
2140 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2143 if(aDimension->GetObject()->GetDirection(dir))
2145 di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z();
2151 static Standard_Integer addDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2154 di<<"Use: XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n";
2157 Handle(TDocStd_Document) Doc;
2158 DDocStd::GetDocument(argv[1], Doc);
2159 if ( Doc.IsNull() ) {
2160 di << argv[1] << " is not a document\n";
2165 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2166 if ( aLabel.IsNull() )
2168 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2171 Handle(XCAFDoc_Dimension) aDimension;
2172 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2174 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2175 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(argv[3]);
2176 Handle(TCollection_HAsciiString) aDescrName = (argc == 4) ? new TCollection_HAsciiString()
2177 : new TCollection_HAsciiString(argv[4]);
2178 anObj->AddDescription(aDescription, aDescrName);
2179 aDimension->SetObject(anObj);
2184 static Standard_Integer getDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2187 di << "Use: XGetDimensionDescr Doc Dim_Label\n";
2190 Handle(TDocStd_Document) Doc;
2191 DDocStd::GetDocument(argv[1], Doc);
2192 if ( Doc.IsNull() ) {
2193 di << argv[1] << " is not a document\n";
2198 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2199 if ( aLabel.IsNull() )
2201 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2204 Handle(XCAFDoc_Dimension) aDimension;
2205 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2207 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimension->GetObject();
2208 for (Standard_Integer i = 0; i < anObject->NbDescriptions(); i++) {
2209 Handle(TCollection_HAsciiString) aDescription = anObject->GetDescription(i);
2210 Handle(TCollection_HAsciiString) aDescrName = anObject->GetDescriptionName(i);
2211 di << "name: " << aDescrName->ToCString() << " description: " << aDescription->ToCString() << "\n";
2217 static Standard_Integer addGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2220 di << "Use: XSetGDTPosition Doc GDT_Label loc_x loc_y loc_z normal_x normal_y normal_z xdir_x xdir_y xdir_z\n";
2223 Handle(TDocStd_Document) Doc;
2224 DDocStd::GetDocument(argv[1], Doc);
2225 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2228 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2229 if ( aLabel.IsNull() )
2231 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2235 gp_Pnt aPoint(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]));
2236 gp_Dir aNormal(Draw::Atof(argv[6]), Draw::Atof(argv[7]), Draw::Atof(argv[8]));
2237 gp_Dir aDir(Draw::Atof(argv[9]), Draw::Atof(argv[10]), Draw::Atof(argv[11]));
2238 gp_Ax2 aPlane(aPoint, aNormal, aDir);
2240 Handle(XCAFDoc_Dimension) aDimension;
2241 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2243 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2244 anObj->SetPlane(aPlane);
2245 anObj->SetPointTextAttach(aPoint);
2246 aDimension->SetObject(anObj);
2248 // Geometric Tolerance
2249 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2250 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2252 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2253 anObj->SetPlane(aPlane);
2254 anObj->SetPointTextAttach(aPoint);
2255 aGeomTolerance->SetObject(anObj);
2258 Handle(XCAFDoc_Datum) aDatum;
2259 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2261 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2262 anObj->SetPlane(aPlane);
2263 anObj->SetPointTextAttach(aPoint);
2264 aDatum->SetObject(anObj);
2269 static Standard_Integer getGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2272 di << "Use: XGetGDTPosition Doc GDT_Label\n";
2275 Handle(TDocStd_Document) Doc;
2276 DDocStd::GetDocument(argv[1], Doc);
2277 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2280 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2281 if ( aLabel.IsNull() )
2283 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2287 gp_Dir aNormal, aDir;
2289 Handle(XCAFDoc_Dimension) aDimension;
2290 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2292 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2293 aPoint = anObj->GetPointTextAttach();
2294 aNormal = anObj->GetPlane().Direction();
2295 aDir = anObj->GetPlane().XDirection();
2297 // Geometric Tolerance
2298 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2299 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2301 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2302 aPoint = anObj->GetPointTextAttach();
2303 aNormal = anObj->GetPlane().Direction();
2304 aDir = anObj->GetPlane().XDirection();
2307 Handle(XCAFDoc_Datum) aDatum;
2308 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2310 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2311 aPoint = anObj->GetPointTextAttach();
2312 aNormal = anObj->GetPlane().Direction();
2313 aDir = anObj->GetPlane().XDirection();
2316 di << "position: " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z() << "\n";
2317 di << "normal: " << aNormal.X() << " " << aNormal.Y() << " " << aNormal.Z() << "\n";
2318 di << "x_direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n";
2322 static Standard_Integer addGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2325 di << "Use: XSetGDTPresentation Doc GDT_Label Shape Name\n";
2328 Handle(TDocStd_Document) Doc;
2329 DDocStd::GetDocument(argv[1], Doc);
2330 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2333 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2334 if ( aLabel.IsNull() )
2336 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2340 TopoDS_Shape aPresentation= DBRep::Get(argv[3]);
2341 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[4]);
2343 Handle(XCAFDoc_Dimension) aDimension;
2344 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2346 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2347 anObj->SetPresentation(aPresentation, aName);
2348 aDimension->SetObject(anObj);
2350 // Geometric Tolerance
2351 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2352 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2354 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2355 anObj->SetPresentation(aPresentation, aName);
2356 aGeomTolerance->SetObject(anObj);
2359 Handle(XCAFDoc_Datum) aDatum;
2360 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2362 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2363 anObj->SetPresentation(aPresentation, aName);
2364 aDatum->SetObject(anObj);
2369 static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2372 di << "Use: XGetGDTPresentation Doc GDT_Label Shape\n";
2375 Handle(TDocStd_Document) Doc;
2376 DDocStd::GetDocument(argv[1], Doc);
2377 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2380 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2381 if ( aLabel.IsNull() )
2383 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2386 TopoDS_Shape aPresentation;
2388 Handle(XCAFDoc_Dimension) aDimension;
2389 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2391 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2392 aPresentation = anObj->GetPresentation();
2394 // Geometric Tolerance
2395 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2396 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2398 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2399 aPresentation = anObj->GetPresentation();
2402 Handle(XCAFDoc_Datum) aDatum;
2403 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2405 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2406 aPresentation = anObj->GetPresentation();
2409 DBRep::Set (argv[3], aPresentation);
2413 //=======================================================================
2414 //function : InitCommands
2416 //=======================================================================
2418 void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
2421 static Standard_Boolean initactor = Standard_False;
2422 if (initactor) return; initactor = Standard_True;
2425 Standard_CString g = "XDE G&DTs commands";
2427 di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
2428 __FILE__, DumpDGTs, g);
2430 di.Add ("XDumpNbDGTs","XDumpNbDGTs Doc [f (full dumping)]",
2431 __FILE__, DumpNbDGTs, g);
2433 di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
2434 __FILE__, addDim, g);
2436 di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label",
2437 __FILE__, addGTol, g);
2439 di.Add ("XAddDatum","XAddDatum Doc shape/label",
2440 __FILE__, addDatum, g);
2442 di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label",
2443 __FILE__, setDatum, g);
2445 di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label",
2446 __FILE__, getDatum, g);
2448 di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"
2450 "\n 0 AnyCrossSection"
2451 "\n 1 Any_LongitudinalSection"
2453 "\n 3 ContactingFeature"
2454 "\n 4 DegreeOfFreedomConstraintU"
2455 "\n 5 DegreeOfFreedomConstraintV"
2456 "\n 6 DegreeOfFreedomConstraintW"
2457 "\n 7 DegreeOfFreedomConstraintX"
2458 "\n 8 DegreeOfFreedomConstraintY"
2459 "\n 9 DegreeOfFreedomConstraintZ"
2460 "\n 10 DistanceVariable"
2462 "\n 12 LeastMaterialRequirement"
2464 "\n 14 MajorDiameter"
2465 "\n 15 MaximumMaterialRequirement"
2466 "\n 16 MinorDiameter"
2468 "\n 18 PitchDiameter"
2471 "\n 21 Translation",
2472 __FILE__, addDatumModif, g);
2474 di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label",
2475 __FILE__, getDatumModif, g);
2477 di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name",
2478 __FILE__, setDatumName, g);
2480 di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
2481 __FILE__, getDatumName, g);
2483 di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
2485 "\t 0 type is absent\n"
2487 "\t 2 CircularRunout\n"
2488 "\t 3 CircularityOrRoundness\n"
2490 "\t 5 Concentricity\n"
2491 "\t 6 Cylindricity\n"
2493 "\t 8 Parallelism\n"
2494 "\t 9 Perpendicularity\n"
2496 "\t 11 ProfileOfLine\n"
2497 "\t 12 ProfileOfSurface\n"
2498 "\t 13 Straightness\n"
2500 "\t 15 TotalRunout\n",
2501 __FILE__, setTypeOfTol, g);
2503 di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label",
2504 __FILE__, getTypeOfTol, g);
2506 di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type"
2510 "\n 2 SphericalDiameter",
2511 __FILE__, setTypeOfTolVal, g);
2513 di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label",
2514 __FILE__, getTypeOfTolVal, g);
2516 di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value",
2517 __FILE__, setTolVal, g);
2519 di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label",
2520 __FILE__, getTolVal, g);
2522 di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod"
2527 __FILE__, setMatReq, g);
2529 di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label",
2530 __FILE__, getMatReq, g);
2532 di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod"
2537 __FILE__, setZoneMod, g);
2539 di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label",
2540 __FILE__, getZoneMod, g);
2542 di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val",
2543 __FILE__, setZoneModVal, g);
2545 di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label",
2546 __FILE__, getZoneModVal, g);
2548 di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..."
2550 "\t 0 Any_Cross_Section\n"
2551 "\t 1 Common_Zone\n"
2552 "\t 2 Each_Radial_Element\n"
2554 "\t 4 Least_Material_Requirement\n"
2555 "\t 5 Line_Element\n"
2556 "\t 6 Major_Diameter\n"
2557 "\t 7 Maximum_Material_Requirement\n"
2558 "\t 8 Minor_Diameter\n"
2560 "\t 10 Pitch_Diameter\n"
2561 "\t 11 Reciprocity_Requirement\n"
2562 "\t 12 Separate_Requirement\n"
2563 "\t 13 Statistical_Tolerance\n"
2564 "\t 14 Tangent_Plane\n",
2565 __FILE__, addTolModif, g);
2567 di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label",
2568 __FILE__, getTolModif, g);
2570 di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val",
2571 __FILE__, setTolMaxVal, g);
2573 di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val",
2574 __FILE__, getTolMaxVal, g);
2576 di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type"
2578 "\t 0 type is absent\n"
2579 "\t 1 Location_CurvedDistance\n"
2580 "\t 2 Location_LinearDistance\n"
2581 "\t 3 Location_LinearDistance_FromCenterToOuter\n"
2582 "\t 4 Location_LinearDistance_FromCenterToInner\n"
2583 "\t 5 Location_LinearDistance_FromOuterToCenter\n"
2584 "\t 6 Location_LinearDistance_FromOuterToOuter\n"
2585 "\t 7 Location_LinearDistance_FromOuterToInner\n"
2586 "\t 8 Location_LinearDistance_FromInnerToCenter\n"
2587 "\t 9 Location_LinearDistance_FromInnerToOuter\n"
2588 "\t 10 Location_LinearDistance_FromInnerToInner\n"
2589 "\t 11 Location_Angular\n"
2590 "\t 12 Location_Oriented\n"
2591 "\t 13 Location_WithPath\n"
2592 "\t 14 Size_CurveLength\n"
2593 "\t 15 Size_Diameter\n"
2594 "\t 16 Size_SphericalDiameter\n"
2595 "\t 17 Size_Radius\n"
2596 "\t 18 Size_SphericalRadius\n"
2597 "\t 19 Size_ToroidalMinorDiameter\n"
2598 "\t 20 Size_ToroidalMajorDiameter\n"
2599 "\t 21 Size_ToroidalMinorRadius\n"
2600 "\t 22 Size_ToroidalMajorRadius\n"
2601 "\t 23 Size_ToroidalHighMajorDiameter\n"
2602 "\t 24 Size_ToroidalLowMajorDiameter\n"
2603 "\t 25 Size_ToroidalHighMajorRadius\n"
2604 "\t 26 Size_ToroidalLowMajorRadius\n"
2605 "\t 27 Size_Thickness\n"
2606 "\t 28 Size_Angular\n"
2607 "\t 29 Size_WithPath\n",
2608 __FILE__, setDimType, g);
2610 di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label",
2611 __FILE__, getDimType, g);
2613 di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val",
2614 __FILE__, setDimVal, g);
2616 di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label",
2617 __FILE__, getDimVal, g);
2619 di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val"
2625 __FILE__, setDimQalif, g);
2627 di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label",
2628 __FILE__, getDimQalif, g);
2630 di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val",
2631 __FILE__, setDimRange, g);
2633 di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label",
2634 __FILE__, getDimRange, g);
2636 di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val",
2637 __FILE__, setDimPlusMinusTol, g);
2639 di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label",
2640 __FILE__, getDimPlusMinusTol, g);
2642 di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade"
2643 "Values of formVar:"
2693 __FILE__, setDimClassTol, g);
2695 di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label",
2696 __FILE__, getDimClassTol, g);
2698 di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val",
2699 __FILE__, setDimNbOfDecimalPlaces, g);
2701 di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label",
2702 __FILE__, getDimNbOfDecimalPlaces, g);
2704 di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..."
2706 "\t 0 ControlledRadius\n"
2708 "\t 2 StatisticalTolerance\n"
2709 "\t 3 ContinuousFeature\n"
2710 "\t 4 TwoPointSize\n"
2711 "\t 5 LocalSizeDefinedBySphere\n"
2712 "\t 6 LeastSquaresAssociationCriterion\n"
2713 "\t 7 MaximumInscribedAssociation\n"
2714 "\t 8 MinimumCircumscribedAssociation\n"
2715 "\t 9 CircumferenceDiameter\n"
2716 "\t10 AreaDiameter\n"
2717 "\t11 VolumeDiameter\n"
2718 "\t12 MaximumSize\n"
2719 "\t13 MinimumSize\n"
2720 "\t14 AverageSize\n"
2722 "\t16 MidRangeSize\n"
2723 "\t17 RangeOfSizes\n"
2724 "\t18 AnyRestrictedPortionOfFeature\n"
2725 "\t19 AnyCrossSection\n"
2726 "\t20 SpecificFixedCrossSection\n"
2727 "\t21 CommonTolerance\n"
2728 "\t22 FreeStateCondition\n"
2730 __FILE__, addDimModifier, g);
2732 di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label",
2733 __FILE__, getDimModifier, g);
2735 di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)",
2736 __FILE__, addDimPath, g);
2738 di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 [v2]",
2739 __FILE__, addDimPoints, g);
2741 di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label",
2742 __FILE__, getDimPoints, g);
2744 di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z",
2745 __FILE__, addDimDir, g);
2747 di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label",
2748 __FILE__, getDimDir, g);
2750 di.Add ("XAddDimensionDescr","XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n"
2751 "Add named text description to given Dimension, if DescriptionName is missed"
2752 "name will be an empty string.",
2753 __FILE__, addDimDescr, g);
2755 di.Add ("XGetDimensionDescr","XGetDimensionDescr Doc Dim_Label\n"
2756 "Return all descriptions of given Dimension.",
2757 __FILE__, getDimDescr, g);
2759 di.Add ("XSetGDTPosition","XSetGDTPosition Doc GDT_Label loc_x loc_y loc_z normal_x normal_y normal_z xdir_x xdir_y xdir_z"
2760 "Set plane to display dimension parallel to and point to display text (loc)",
2761 __FILE__, addGDTPosition, g);
2763 di.Add ("XGetGDTPosition","XGetGDTPosition Doc GDT_Label"
2764 "Returns text position and plane, parallel to which dimension is displayed",
2765 __FILE__, getGDTPosition, g);
2767 di.Add ("XSetGDTPresentation","XSetGDTPresentation Doc GDT_Label Shape Name"
2768 "Set presentation with given name for dimension",
2769 __FILE__, addGDTPresentation, g);
2771 di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
2772 "Returns Presentation into Shape",
2773 __FILE__, getGDTPresentation, g);