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 <TDF_Tool.hxx>
23 #include <TDF_Label.hxx>
24 #include <TDF_LabelSequence.hxx>
25 #include <TDocStd_Document.hxx>
26 #include <XCAFDoc_GraphNode.hxx>
28 #include <XCAFDoc.hxx>
29 #include <XCAFDoc_DocumentTool.hxx>
30 #include <XCAFDoc_ShapeTool.hxx>
31 #include <XCAFDoc_DimTol.hxx>
32 #include <XCAFDoc_Dimension.hxx>
33 #include <XCAFDimTolObjects_DimensionObject.hxx>
34 #include <XCAFDoc_Datum.hxx>
35 #include <XCAFDimTolObjects_DatumObject.hxx>
36 #include <XCAFDoc_GeomTolerance.hxx>
37 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
38 #include <XCAFDoc_DimTolTool.hxx>
39 #include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
40 #include <XCAFDimTolObjects_DatumObjectSequence.hxx>
41 #include <XCAFDimTolObjects_GeomToleranceObjectSequence.hxx>
42 #include <XCAFDimTolObjects_DatumSingleModif.hxx>
43 #include <XCAFDimTolObjects_DimensionModif.hxx>
44 #include <XCAFDimTolObjects_GeomToleranceModif.hxx>
45 #include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
46 #include <XCAFDimTolObjects_DatumObject.hxx>
47 #include <XCAFDimTolObjects_Tool.hxx>
49 #include <TCollection_AsciiString.hxx>
50 #include <TCollection_HAsciiString.hxx>
51 #include <TColStd_HArray1OfReal.hxx>
52 #include <TColgp_HArray1OfPnt.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <TopoDS_Edge.hxx>
57 #include <TopoDS_Vertex.hxx>
58 #include <BRep_Tool.hxx>
62 static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
65 di<<"Use: "<<"XDumpDGTs Doc shape/label/all\n";
68 Handle(TDocStd_Document) Doc;
69 DDocStd::GetDocument(argv[1], Doc);
70 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
71 Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
72 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
74 TCollection_AsciiString name = argv[2];
75 TDF_LabelSequence aLabels;
76 if(name.IsEqual("all"))
78 aShapeTool->GetShapes(aLabels);
79 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
81 aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
87 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
88 if ( !aLabel.IsNull() ) {
89 aLabels.Append(aLabel);
90 aShapeTool->GetSubShapes(aLabel, aLabels);
94 TopoDS_Shape aShape= DBRep::Get(argv[2]);
95 if ( !aShape.IsNull() )
97 aShapeTool->Search(aShape, aLabel);
98 if ( !aLabel.IsNull() ) {
99 aLabels.Append(aLabel);
100 aShapeTool->GetSubShapes(aLabel, aLabels);
104 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
111 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
113 Standard_Boolean flag = Standard_True;
114 TDF_LabelSequence aGDTs;
115 aDimTolTool->GetRefDimensionLabels(aLabels.Value(i), aGDTs);
116 for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ )
118 Handle(XCAFDoc_Dimension) aDimTol;
119 if(aGDTs.Value(j).FindAttribute(XCAFDoc_Dimension::GetID(), aDimTol))
121 Handle(XCAFDimTolObjects_DimensionObject) aDimTolObj = aDimTol->GetObject();
124 TCollection_AsciiString Entry;
125 TDF_Tool::Entry(aLabels.Value(i), Entry);
126 di << "\n " << Entry;
127 flag = Standard_False;
129 TCollection_AsciiString Entry;
130 TDF_Tool::Entry(aGDTs.Value(j), Entry);
131 di << "\n \t " << Entry;
132 flag = Standard_False;
138 aDimTolTool->GetRefGeomToleranceLabels(aLabels.Value(i), aGDTs);
139 for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ )
141 Handle(XCAFDoc_GeomTolerance) aDimTol;
142 if(aGDTs.Value(j).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aDimTol))
144 Handle(XCAFDimTolObjects_GeomToleranceObject) aDimTolObj = aDimTol->GetObject();
147 TCollection_AsciiString Entry;
148 TDF_Tool::Entry(aLabels.Value(i), Entry);
149 di << "\n " << Entry;
150 flag = Standard_False;
152 TCollection_AsciiString Entry;
153 TDF_Tool::Entry(aGDTs.Value(j), Entry);
154 di << "\n \t " << Entry;
155 flag = Standard_False;
157 di << " GeomTolerance";
158 Handle(XCAFDoc_GraphNode) aNode;
159 if(aGDTs.Value(j).FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode) && aNode->NbChildren() > 0)
161 for(Standard_Integer k = 1; k<=aNode->NbChildren(); k++)
163 Handle(XCAFDoc_Datum) aDatum;
164 if(aNode->GetChild(k)->Label().FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
166 TCollection_AsciiString anEntry;
167 TDF_Tool::Entry(aNode->GetChild(k)->Label(), anEntry);
168 di << "\n \t \t " << anEntry;
176 if (aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatumL))
178 Handle(XCAFDoc_Datum) aDatum;
179 if(aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
183 TCollection_AsciiString Entry;
184 TDF_Tool::Entry(aLabels.Value(i), Entry);
185 di << "\n " << Entry;
186 flag = Standard_False;
188 TCollection_AsciiString Entry;
189 TDF_Tool::Entry(aDatumL, Entry);
190 di << "\n \t " << Entry;
191 flag = Standard_False;
200 static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
203 di<<"Use: "<<"XAddDimension Doc shape/label [shape/label]\n";
206 Handle(TDocStd_Document) Doc;
207 DDocStd::GetDocument(argv[1], Doc);
208 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
209 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
210 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
213 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
214 if ( aLabel.IsNull() )
216 TopoDS_Shape aShape= DBRep::Get(argv[2]);
217 if ( !aShape.IsNull() )
219 aShapeTool->Search(aShape, aLabel);
220 if ( aLabel.IsNull() )
222 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
230 TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1);
231 if ( aLabel1.IsNull() )
233 TopoDS_Shape aShape= DBRep::Get(argv[3]);
234 if ( !aShape.IsNull() )
236 aShapeTool->Search(aShape, aLabel1);
237 if ( aLabel1.IsNull() )
239 di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
246 TDF_Label aDimL = aDimTolTool->AddDimension();
248 aDimTolTool->SetDimension(aLabel, aDimL);
250 aDimTolTool->SetDimension(aLabel, aLabel1, aDimL);
251 TCollection_AsciiString Entry;
252 TDF_Tool::Entry(aDimL, Entry);
257 static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
260 di<<"Use: "<<"XAddGeomTolerance Doc shape/label\n";
263 Handle(TDocStd_Document) Doc;
264 DDocStd::GetDocument(argv[1], Doc);
265 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
266 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
267 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
270 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
271 if ( aLabel.IsNull() )
273 TopoDS_Shape aShape= DBRep::Get(argv[2]);
274 if ( !aShape.IsNull() )
276 aShapeTool->Search(aShape, aLabel);
277 if ( aLabel.IsNull() )
279 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
285 TDF_Label aTolL = aDimTolTool->AddGeomTolerance();
286 aDimTolTool->SetGeomTolerance(aLabel, aTolL);
287 TCollection_AsciiString Entry;
288 TDF_Tool::Entry(aTolL, Entry);
293 static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
296 di<<"Use: "<<"XAddDatum Doc shape/label\n";
299 Handle(TDocStd_Document) Doc;
300 DDocStd::GetDocument(argv[1], Doc);
301 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
302 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
303 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
306 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
307 if ( aLabel.IsNull() )
309 TopoDS_Shape aShape= DBRep::Get(argv[2]);
310 if ( !aShape.IsNull() )
312 aShapeTool->Search(aShape, aLabel);
313 if ( aLabel.IsNull() )
315 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
321 TDF_Label aDatumL = aDimTolTool->AddDatum();
322 aDimTolTool->SetDatum(aLabel, aDatumL);
323 TCollection_AsciiString Entry;
324 TDF_Tool::Entry(aDatumL, Entry);
329 static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
332 di<<"Use: "<<"XSetDatum Doc Datum_Label GeomTol_Label\n";
335 Handle(TDocStd_Document) Doc;
336 DDocStd::GetDocument(argv[1], Doc);
337 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
338 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
339 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
342 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
343 if ( aLabel.IsNull() )
345 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
350 TDF_Tool::Label(Doc->GetData(), argv[3], aTol);
353 di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
357 aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
361 static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
364 di<<"Use: "<<"XGetDatum Doc GeomTol_Label/Shape_Label\n";
367 Handle(TDocStd_Document) Doc;
368 DDocStd::GetDocument(argv[1], Doc);
369 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
370 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
371 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
374 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
375 if ( aLabel.IsNull() )
377 di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
382 if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
384 TDF_LabelSequence aDS;
385 if(aDimTolTool->GetDatumOfTolerLabels(aLabel, aDS))
387 for(Standard_Integer i = 1; i<=aDS.Length();i++)
390 TCollection_AsciiString Entry;
391 TDF_Tool::Entry(aDS.Value(i), Entry);
398 TCollection_AsciiString Entry;
399 TDF_Tool::Entry(aD, Entry);
405 static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
408 di<<"Use: "<<"XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n";
411 Handle(TDocStd_Document) Doc;
412 DDocStd::GetDocument(argv[1], Doc);
413 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
414 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
415 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
418 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
419 if ( aLabel.IsNull() )
421 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
424 Handle(XCAFDoc_Datum) aDatum;
425 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
427 for(Standard_Integer i = 3; i < argc; i++)
429 if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1)
431 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
432 anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i]));
433 aDatum->SetObject(anObj);
440 static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
443 di<<"Use: "<<"XGetDatumModifiers Doc Datum_Label\n";
446 Handle(TDocStd_Document) Doc;
447 DDocStd::GetDocument(argv[1], Doc);
448 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
449 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
450 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
453 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
454 if ( aLabel.IsNull() )
456 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
459 Handle(XCAFDoc_Datum) aDatum;
460 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
462 XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers();
463 for(Standard_Integer i = 1; i<=aS.Length();i++)
467 case 0 : di<<"AnyCrossSection"; break;
468 case 1 : di<<"AnyLongitudinalSection"; break;
469 case 2 : di<<"Basic"; break;
470 case 3 : di<<"ContactingFeature\n"; break;
471 case 4 : di<<"DegreeOfFreedomConstraintU"; break;
472 case 5 : di<<"DegreeOfFreedomConstraintV"; break;
473 case 6 : di<<"DegreeOfFreedomConstraintW"; break;
474 case 7 : di<<"DegreeOfFreedomConstraintX"; break;
475 case 8 : di<<"DegreeOfFreedomConstraintY"; break;
476 case 9 : di<<"DegreeOfFreedomConstraintZ"; break;
477 case 10 : di<<"DistanceVariable"; break;
478 case 11 : di<<"FreeState"; break;
479 case 12 : di<<"LeastMaterialRequirement"; break;
480 case 13 : di<<"Line"; break;
481 case 14 : di<<"MajorDiameter"; break;
482 case 15 : di<<"MaximumMaterialRequirement"; break;
483 case 16 : di<<"MinorDiameter"; break;
484 case 17 : di<<"Orientation"; break;
485 case 18 : di<<"PitchDiameter"; break;
486 case 19 : di<<"Plane"; break;
487 case 20 : di<<"Point"; break;
488 case 21 : di<<"Translation"; break;
496 static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
499 di<<"Use: "<<"XSetDatumName Doc Datum_Label name\n";
502 Handle(TDocStd_Document) Doc;
503 DDocStd::GetDocument(argv[1], Doc);
504 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
505 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
506 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
509 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
510 if ( aLabel.IsNull() )
512 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
515 Handle(XCAFDoc_Datum) aDatum;
516 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
518 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
519 anObj->SetName(new TCollection_HAsciiString(argv[3]));
520 aDatum->SetObject(anObj);
525 static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
528 di<<"Use: "<<"XGetDatumName Doc Datum_Label\n";
531 Handle(TDocStd_Document) Doc;
532 DDocStd::GetDocument(argv[1], Doc);
533 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
534 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
535 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
538 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
539 if ( aLabel.IsNull() )
541 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
544 Handle(XCAFDoc_Datum) aDatum;
545 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
547 di<<aDatum->GetObject()->GetName()->ToCString();
552 static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
555 di<<"Use: "<<"XSetTypeOfTolerance Doc GTol_Label type\n";
558 Handle(TDocStd_Document) Doc;
559 DDocStd::GetDocument(argv[1], Doc);
560 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
561 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
562 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
565 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
566 if ( aLabel.IsNull() )
568 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
571 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
572 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
574 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16)
576 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
577 anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3]));
578 aGeomTolerance->SetObject(anObj);
584 static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
587 di<<"Use: "<<"XGetTypeOfTolerance Doc GTol_Label\n";
590 Handle(TDocStd_Document) Doc;
591 DDocStd::GetDocument(argv[1], Doc);
592 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
593 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
594 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
597 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
598 if ( aLabel.IsNull() )
600 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
603 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
604 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
606 switch(aGeomTolerance->GetObject()->GetType()){
607 case 0 : di<<"type is absent"; break;
608 case 1 : di<<"Angularity"; break;
609 case 2 : di<<"CircularRunout"; break;
610 case 3 : di<<"CircularityOrRoundness"; break;
611 case 4 : di<<"Coaxiality"; break;
612 case 5 : di<<"Concentricity"; break;
613 case 6 : di<<"Cylindricity"; break;
614 case 7 : di<<"Flatness"; break;
615 case 8 : di<<"Parallelism"; break;
616 case 9 : di<<"Perpendicularity"; break;
617 case 10 : di<<"Position"; break;
618 case 11 : di<<"ProfileOfLine"; break;
619 case 12 : di<<"ProfileOfSurface"; break;
620 case 13 : di<<"Straightness"; break;
621 case 14 : di<<"Symmetry"; break;
622 case 15 : di<<"TotalRunout"; break;
629 static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
632 di<<"Use: "<<"XSetTypeOfToleranceValue Doc GTol_Label type\n";
635 Handle(TDocStd_Document) Doc;
636 DDocStd::GetDocument(argv[1], Doc);
637 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
638 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
639 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
642 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
643 if ( aLabel.IsNull() )
645 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
648 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
649 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
651 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
653 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
654 anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3]));
655 aGeomTolerance->SetObject(anObj);
661 static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
664 di<<"Use: "<<"XGetTypeOfToleranceValue Doc GTol_Label\n";
667 Handle(TDocStd_Document) Doc;
668 DDocStd::GetDocument(argv[1], Doc);
669 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
670 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
671 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
674 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
675 if ( aLabel.IsNull() )
677 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
680 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
681 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
683 switch(aGeomTolerance->GetObject()->GetTypeOfValue()){
684 case 0 : di<<"type is absent"; break;
685 case 1 : di<<"Diameter"; break;
686 case 2 : di<<"SphericalDiameter"; break;
693 static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
696 di<<"Use: "<<"XSetToleranceValue Doc GTol_Label value\n";
699 Handle(TDocStd_Document) Doc;
700 DDocStd::GetDocument(argv[1], Doc);
701 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
702 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
703 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
706 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
707 if ( aLabel.IsNull() )
709 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
712 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
713 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
715 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
716 anObj->SetValue(Draw::Atof(argv[3]));
717 aGeomTolerance->SetObject(anObj);
722 static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
725 di<<"Use: "<<"XGetToleranceValue Doc GTol_Label\n";
728 Handle(TDocStd_Document) Doc;
729 DDocStd::GetDocument(argv[1], Doc);
730 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
731 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
732 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
735 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
736 if ( aLabel.IsNull() )
738 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
741 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
742 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
744 di << aGeomTolerance->GetObject()->GetValue();
749 static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
752 di<<"Use: "<<"XSetTolMaterialReq Doc GTol_Label mod\n";
755 Handle(TDocStd_Document) Doc;
756 DDocStd::GetDocument(argv[1], Doc);
757 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
758 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
759 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
762 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
763 if ( aLabel.IsNull() )
765 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
768 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
769 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
771 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
773 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
774 anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3]));
775 aGeomTolerance->SetObject(anObj);
781 static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
784 di<<"Use: "<<"XGetTolMaterialReq Doc GTol_Label\n";
787 Handle(TDocStd_Document) Doc;
788 DDocStd::GetDocument(argv[1], Doc);
789 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
790 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
791 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
794 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
795 if ( aLabel.IsNull() )
797 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
800 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
801 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
803 switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){
804 case 0 : di<<"modifier is absent"; break;
805 case 1 : di<<"M"; break;
806 case 2 : di<<"L"; break;
813 static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
816 di<<"Use: "<<"XSetTolZoneMod Doc GTol_Label mod\n";
819 Handle(TDocStd_Document) Doc;
820 DDocStd::GetDocument(argv[1], Doc);
821 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
822 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
823 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
826 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
827 if ( aLabel.IsNull() )
829 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
832 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
833 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
835 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
837 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
838 anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3]));
839 aGeomTolerance->SetObject(anObj);
845 static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
848 di<<"Use: "<<"XGetTolZoneMod Doc GTol_Label\n";
851 Handle(TDocStd_Document) Doc;
852 DDocStd::GetDocument(argv[1], Doc);
853 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
854 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
855 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
858 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
859 if ( aLabel.IsNull() )
861 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
864 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
865 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
867 switch(aGeomTolerance->GetObject()->GetZoneModifier()){
868 case 0 : di<<"modifier is absent"; break;
869 case 1 : di<<"P"; break;
870 case 2 : di<<"NonUniform"; break;
877 static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
880 di<<"Use: "<<"XSetTolZoneModValue Doc GTol_Label val\n";
883 Handle(TDocStd_Document) Doc;
884 DDocStd::GetDocument(argv[1], Doc);
885 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
886 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
887 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
890 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
891 if ( aLabel.IsNull() )
893 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
896 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
897 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
899 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
900 anObj->SetValueOfZoneModifier(Draw::Atof(argv[3]));
901 aGeomTolerance->SetObject(anObj);
906 static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
909 di<<"Use: "<<"XGetTolZoneModValue Doc GTol_Label\n";
912 Handle(TDocStd_Document) Doc;
913 DDocStd::GetDocument(argv[1], Doc);
914 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
915 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
916 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
919 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
920 if ( aLabel.IsNull() )
922 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
925 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
926 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
928 di << aGeomTolerance->GetObject()->GetValueOfZoneModifier();
933 static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
936 di<<"Use: "<<"XAddTolModifier Doc Tol_Label mod1 mod2 ...\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 for(Standard_Integer i = 3; i < argc; i++)
957 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 15)
959 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
960 anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i]));
961 aGeomTolerance->SetObject(anObj);
968 static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
971 di<<"Use: "<<"XGetTolModifiers Doc Tol_Label\n";
974 Handle(TDocStd_Document) Doc;
975 DDocStd::GetDocument(argv[1], Doc);
976 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
977 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
978 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
981 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
982 if ( aLabel.IsNull() )
984 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
987 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
988 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
990 XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers();
991 for(Standard_Integer i = 1; i <= aS.Length(); i++)
995 case 0 : di<<"Any_Cross_Section"; break;
996 case 1 : di<<"Common_Zone"; break;
997 case 2 : di<<"Each_Radial_Element"; break;
998 case 3 : di<<"Free_State"; break;
999 case 4 : di<<"Least_Material_Requirement"; break;
1000 case 5 : di<<"Line_Element"; break;
1001 case 6 : di<<"Major_Diameter"; break;
1002 case 7 : di<<"Maximum_Material_Requirement"; break;
1003 case 8 : di<<"Minor_Diameter"; break;
1004 case 9 : di<<"Not_Convex"; break;
1005 case 10 : di<<"Pitch_Diameter"; break;
1006 case 11 : di<<"Reciprocity_Requirement"; break;
1007 case 12 : di<<"Separate_Requirement"; break;
1008 case 13 : di<<"Statistical_Tolerance"; break;
1009 case 14 : di<<"Tangent_Plane"; break;
1017 static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1020 di<<"Use: "<<"XSetTolMaxValue Doc Dim_Label val\n";
1023 Handle(TDocStd_Document) Doc;
1024 DDocStd::GetDocument(argv[1], Doc);
1025 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1026 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1027 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1030 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1031 if ( aLabel.IsNull() )
1033 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1036 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1037 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1039 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1040 anObj->SetMaxValueModifier(Draw::Atof(argv[3]));
1041 aGeomTolerance->SetObject(anObj);
1046 static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1049 di<<"Use: "<<"XGetTolMaxValue Doc Dim_Label\n";
1052 Handle(TDocStd_Document) Doc;
1053 DDocStd::GetDocument(argv[1], Doc);
1054 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1055 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1056 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1059 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1060 if ( aLabel.IsNull() )
1062 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1065 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1066 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1068 di << aGeomTolerance->GetObject()->GetMaxValueModifier();
1073 static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1076 di<<"Use: "<<"XSetDimensionType Doc Dim_Label type\n";
1079 Handle(TDocStd_Document) Doc;
1080 DDocStd::GetDocument(argv[1], Doc);
1081 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1082 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1083 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1086 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1087 if ( aLabel.IsNull() )
1089 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1092 Handle(XCAFDoc_Dimension) aDimension;
1093 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1095 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30)
1097 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1098 anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3]));
1099 aDimension->SetObject(anObj);
1105 static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1108 di<<"Use: "<<"XGetDimensionType Doc Dim_Label\n";
1111 Handle(TDocStd_Document) Doc;
1112 DDocStd::GetDocument(argv[1], Doc);
1113 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1114 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1115 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1118 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1119 if ( aLabel.IsNull() )
1121 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1124 Handle(XCAFDoc_Dimension) aDimension;
1125 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1127 switch(aDimension->GetObject()->GetType()){
1128 case 0 : di<<"type is absent"; break;
1129 case 1 : di<<"Location_CurvedDistance"; break;
1130 case 2 : di<<"Location_LinearDistance"; break;
1131 case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break;
1132 case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break;
1133 case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break;
1134 case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break;
1135 case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break;
1136 case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break;
1137 case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break;
1138 case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break;
1139 case 11 : di<<"Location_Angular"; break;
1140 case 12 : di<<"Location_Oriented"; break;
1141 case 13 : di<<"Location_WithPath"; break;
1142 case 14 : di<<"Size_CurveLength"; break;
1143 case 15 : di<<"Size_Diameter"; break;
1144 case 16 : di<<"Size_SphericalDiameter"; break;
1145 case 17 : di<<"Size_Radius"; break;
1146 case 18 : di<<"Size_SphericalRadius"; break;
1147 case 19 : di<<"Size_ToroidalMinorDiameter"; break;
1148 case 20 : di<<"Size_ToroidalMajorDiameter"; break;
1149 case 21 : di<<"Size_ToroidalMinorRadius"; break;
1150 case 22 : di<<"Size_ToroidalMajorRadius"; break;
1151 case 23 : di<<"Size_ToroidalHighMajorDiameter"; break;
1152 case 24 : di<<"Size_ToroidalLowMajorDiameter"; break;
1153 case 25 : di<<"Size_ToroidalHighMajorRadius"; break;
1154 case 26 : di<<"Size_ToroidalLowMajorRadius"; break;
1155 case 27 : di<<"Size_Thickness"; break;
1156 case 28 : di<<"Size_Angular"; break;
1157 case 29 : di<<"Size_WithPath"; break;
1164 static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1167 di<<"Use: "<<"XSetDimensionValue Doc Dim_Label val\n";
1170 Handle(TDocStd_Document) Doc;
1171 DDocStd::GetDocument(argv[1], Doc);
1172 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1173 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1174 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1177 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1178 if ( aLabel.IsNull() )
1180 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1183 Handle(XCAFDoc_Dimension) aDimension;
1184 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1186 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1187 anObj->SetValue(Draw::Atof(argv[3]));
1188 aDimension->SetObject(anObj);
1193 static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1196 di<<"Use: "<<"XGetDimensionValue Doc Dim_Label\n";
1199 Handle(TDocStd_Document) Doc;
1200 DDocStd::GetDocument(argv[1], Doc);
1201 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1202 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1203 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1206 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1207 if ( aLabel.IsNull() )
1209 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1212 Handle(XCAFDoc_Dimension) aDimension;
1213 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1215 di << aDimension->GetObject()->GetValue();
1220 static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1223 di<<"Use: "<<"XSetDimensionQualifier Doc Dim_Label val\n";
1226 Handle(TDocStd_Document) Doc;
1227 DDocStd::GetDocument(argv[1], Doc);
1228 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1229 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1230 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1233 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1234 if ( aLabel.IsNull() )
1236 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1239 Handle(XCAFDoc_Dimension) aDimension;
1240 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1242 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4)
1244 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1245 anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3]));
1246 aDimension->SetObject(anObj);
1252 static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1255 di<<"Use: "<<"XGetDimensionQualifier Doc Dim_Label\n";
1258 Handle(TDocStd_Document) Doc;
1259 DDocStd::GetDocument(argv[1], Doc);
1260 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1261 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1262 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1265 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1266 if ( aLabel.IsNull() )
1268 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1271 Handle(XCAFDoc_Dimension) aDimension;
1272 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1275 switch(aDimension->GetObject()->GetQualifier()){
1276 case 0 : di<<"type is absent"; break;
1277 case 1 : di<<"Min"; break;
1278 case 2 : di<<"Max"; break;
1279 case 3 : di<<"Avg"; break;
1286 static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1289 di<<"Use: "<<"XSetDimensionRange Doc Dim_Label low_val up_val\n";
1292 Handle(TDocStd_Document) Doc;
1293 DDocStd::GetDocument(argv[1], Doc);
1294 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1295 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1296 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1299 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1300 if ( aLabel.IsNull() )
1302 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1305 Handle(XCAFDoc_Dimension) aDimension;
1306 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1308 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1310 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1311 anObj->SetLowerBound(Draw::Atof(argv[3]));
1312 anObj->SetUpperBound(Draw::Atof(argv[4]));
1313 aDimension->SetObject(anObj);
1319 static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1322 di<<"Use: "<<"XGetDimensionRange Doc Dim_Label\n";
1325 Handle(TDocStd_Document) Doc;
1326 DDocStd::GetDocument(argv[1], Doc);
1327 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1328 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1329 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1332 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1333 if ( aLabel.IsNull() )
1335 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1338 Handle(XCAFDoc_Dimension) aDimension;
1339 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1341 di << "lower " << aDimension->GetObject()->GetLowerBound();
1342 di << " upper " << aDimension->GetObject()->GetUpperBound();
1347 static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1350 di<<"Use: "<<"XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n";
1353 Handle(TDocStd_Document) Doc;
1354 DDocStd::GetDocument(argv[1], Doc);
1355 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1356 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1357 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1360 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1361 if ( aLabel.IsNull() )
1363 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1366 Handle(XCAFDoc_Dimension) aDimension;
1367 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1369 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1371 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1372 anObj->SetLowerTolValue(Draw::Atof(argv[3]));
1373 anObj->SetUpperTolValue(Draw::Atof(argv[4]));
1374 aDimension->SetObject(anObj);
1380 static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1383 di<<"Use: "<<"XGetDimensionPlusMinusTol Doc Dim_Label\n";
1386 Handle(TDocStd_Document) Doc;
1387 DDocStd::GetDocument(argv[1], Doc);
1388 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1389 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1390 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1393 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1394 if ( aLabel.IsNull() )
1396 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1399 Handle(XCAFDoc_Dimension) aDimension;
1400 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1402 di << "lower " << aDimension->GetObject()->GetLowerTolValue();
1403 di << " upper " << aDimension->GetObject()->GetUpperTolValue();
1408 static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1411 di<<"Use: "<<"XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n";
1414 Handle(TDocStd_Document) Doc;
1415 DDocStd::GetDocument(argv[1], Doc);
1416 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1417 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1418 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1421 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1422 if ( aLabel.IsNull() )
1424 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1427 Handle(XCAFDoc_Dimension) aDimension;
1428 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1430 if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20)
1432 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1433 anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5]));
1434 aDimension->SetObject(anObj);
1440 static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1443 di<<"Use: "<<"XGetDimensionClassOfTol Doc Dim_Label\n";
1446 Handle(TDocStd_Document) Doc;
1447 DDocStd::GetDocument(argv[1], Doc);
1448 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1449 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1450 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1453 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1454 if ( aLabel.IsNull() )
1456 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1459 Handle(XCAFDoc_Dimension) aDimension;
1460 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1463 XCAFDimTolObjects_DimensionFormVariance f;
1464 XCAFDimTolObjects_DimensionGrade g;
1465 if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g))
1470 case 1 : di<<"a";break;
1471 case 2 : di<<"b";break;
1472 case 3 : di<<"c";break;
1473 case 4 : di<<"cd";break;
1474 case 5 : di<<"d";break;
1475 case 6 : di<<"e";break;
1476 case 7 : di<<"ef";break;
1477 case 8 : di<<"f";break;
1478 case 9 : di<<"fg";break;
1479 case 10 : di<<"g";break;
1480 case 11 : di<<"h";break;
1481 case 12 : di<<"js";break;
1482 case 13 : di<<"j";break;
1483 case 14 : di<<"k";break;
1484 case 15 : di<<"m";break;
1485 case 16 : di<<"n";break;
1486 case 17 : di<<"p";break;
1487 case 18 : di<<"r";break;
1488 case 19 : di<<"s";break;
1489 case 20 : di<<"t";break;
1490 case 21 : di<<"u";break;
1491 case 22 : di<<"v";break;
1492 case 23 : di<<"x";break;
1493 case 24 : di<<"y";break;
1494 case 25 : di<<"z";break;
1495 case 26 : di<<"a";break;
1496 case 27 : di<<"zb";break;
1497 case 28 : di<<"zc";break;
1504 case 1 : di<<"A";break;
1505 case 2 : di<<"B";break;
1506 case 3 : di<<"C";break;
1507 case 4 : di<<"CD";break;
1508 case 5 : di<<"D";break;
1509 case 6 : di<<"E";break;
1510 case 7 : di<<"EF";break;
1511 case 8 : di<<"F";break;
1512 case 9 : di<<"FG";break;
1513 case 10 : di<<"G";break;
1514 case 11 : di<<"H";break;
1515 case 12 : di<<"JS";break;
1516 case 13 : di<<"J";break;
1517 case 14 : di<<"K";break;
1518 case 15 : di<<"M";break;
1519 case 16 : di<<"N";break;
1520 case 17 : di<<"P";break;
1521 case 18 : di<<"R";break;
1522 case 19 : di<<"S";break;
1523 case 20 : di<<"T";break;
1524 case 21 : di<<"U";break;
1525 case 22 : di<<"V";break;
1526 case 23 : di<<"X";break;
1527 case 24 : di<<"Y";break;
1528 case 25 : di<<"Z";break;
1529 case 26 : di<<"ZA";break;
1530 case 27 : di<<"ZB";break;
1531 case 28 : di<<"ZC";break;
1536 case 0 : di<<"01"; break;
1537 case 1 : di<<"0"; break;
1538 case 2 : di<<"1"; break;
1539 case 3 : di<<"2"; break;
1540 case 4 : di<<"3"; break;
1541 case 5 : di<<"4"; break;
1542 case 6 : di<<"5"; break;
1543 case 7 : di<<"6"; break;
1544 case 8 : di<<"7"; break;
1545 case 9 : di<<"8"; break;
1546 case 10 : di<<"9"; break;
1547 case 11 : di<<"10"; break;
1548 case 12 : di<<"11"; break;
1549 case 13 : di<<"12"; break;
1550 case 14 : di<<"13"; break;
1551 case 15 : di<<"14"; break;
1552 case 16 : di<<"15"; break;
1553 case 17 : di<<"16"; break;
1554 case 18 : di<<"17"; break;
1555 case 19 : di<<"18"; break;
1563 static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1566 di<<"Use: "<<"XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n";
1569 Handle(TDocStd_Document) Doc;
1570 DDocStd::GetDocument(argv[1], Doc);
1571 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1572 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1573 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1576 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1577 if ( aLabel.IsNull() )
1579 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1582 Handle(XCAFDoc_Dimension) aDimension;
1583 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1585 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1586 anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4]));
1587 aDimension->SetObject(anObj);
1592 static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1595 di<<"Use: "<<"XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n";
1598 Handle(TDocStd_Document) Doc;
1599 DDocStd::GetDocument(argv[1], Doc);
1600 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1601 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1602 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1605 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1606 if ( aLabel.IsNull() )
1608 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1611 Handle(XCAFDoc_Dimension) aDimension;
1612 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1614 Standard_Integer l, r;
1615 aDimension->GetObject()->GetNbOfDecimalPlaces(l,r);
1616 di << l << "." << r;
1621 static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1624 di<<"Use: "<<"XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n";
1627 Handle(TDocStd_Document) Doc;
1628 DDocStd::GetDocument(argv[1], Doc);
1629 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1630 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1631 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1634 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1635 if ( aLabel.IsNull() )
1637 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1640 Handle(XCAFDoc_Dimension) aDimension;
1641 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1643 for(Standard_Integer i = 3; i < argc; i++)
1645 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24)
1647 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1648 anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i]));
1649 aDimension->SetObject(anObj);
1656 static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1659 di<<"Use: "<<"XGetDimensionModifiers Doc Dim_Label\n";
1662 Handle(TDocStd_Document) Doc;
1663 DDocStd::GetDocument(argv[1], Doc);
1664 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1665 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1666 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1669 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1670 if ( aLabel.IsNull() )
1672 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1675 Handle(XCAFDoc_Dimension) aDimension;
1676 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1678 XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers();
1679 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1681 if (i > 1) di<<", ";
1682 switch(aS.Value(i)){
1683 case 0 : di<<"ControlledRadius"; break;
1684 case 1 : di<<"Square"; break;
1685 case 2 : di<<"StatisticalTolerance"; break;
1686 case 3 : di<<"ContinuousFeature"; break;
1687 case 4 : di<<"TwoPointSize"; break;
1688 case 5 : di<<"LocalSizeDefinedBySphere"; break;
1689 case 6 : di<<"LeastSquaresAssociationCriterion"; break;
1690 case 7 : di<<"MaximumInscribedAssociation"; break;
1691 case 8 : di<<"MinimumCircumscribedAssociation"; break;
1692 case 9 : di<<"CircumferenceDiameter"; break;
1693 case 10 : di<<"AreaDiameter"; break;
1694 case 11 : di<<"VolumeDiameter"; break;
1695 case 12 : di<<"MaximumSize"; break;
1696 case 13 : di<<"MinimumSize"; break;
1697 case 14 : di<<"AverageSize"; break;
1698 case 15 : di<<"MedianSize"; break;
1699 case 16 : di<<"MidRangeSize"; break;
1700 case 17 : di<<"RangeOfSizes"; break;
1701 case 18 : di<<"AnyRestrictedPortionOfFeature"; break;
1702 case 19 : di<<"AnyCrossSection"; break;
1703 case 20 : di<<"SpecificFixedCrossSection"; break;
1704 case 21 : di<<"CommonTolerance"; break;
1705 case 22 : di<<"FreeStateCondition"; break;
1706 case 23 : di<<"Between"; break;
1714 static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1717 di<<"Use: "<<"XSetDimensionPath Doc Dim_Label path(edge)\n";
1720 Handle(TDocStd_Document) Doc;
1721 DDocStd::GetDocument(argv[1], Doc);
1722 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1723 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1724 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1727 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1728 if ( aLabel.IsNull() )
1730 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1733 Handle(XCAFDoc_Dimension) aDimension;
1734 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1736 TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE));
1739 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1741 aDimension->SetObject(anObj);
1747 static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1750 di<<"Use: "<<"XSetDimensionPoints Doc Dim_Label v1 v2\n";
1753 Handle(TDocStd_Document) Doc;
1754 DDocStd::GetDocument(argv[1], Doc);
1755 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1756 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1757 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1760 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1761 if ( aLabel.IsNull() )
1763 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1766 Handle(XCAFDoc_Dimension) aDimension;
1767 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1769 TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX));
1770 TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX));
1771 if(!aV1.IsNull() && !aV1.IsNull())
1773 Handle(TColgp_HArray1OfPnt) arr = new TColgp_HArray1OfPnt(1,2);
1774 arr->SetValue(1, BRep_Tool::Pnt(aV1));
1775 arr->SetValue(2, BRep_Tool::Pnt(aV2));
1776 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1777 anObj->SetPoints(arr);
1778 aDimension->SetObject(anObj);
1784 static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1787 di<<"Use: "<<"XGetDimensionPoints Doc Dim_Label\n";
1790 Handle(TDocStd_Document) Doc;
1791 DDocStd::GetDocument(argv[1], Doc);
1792 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1793 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1794 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1797 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1798 if ( aLabel.IsNull() )
1800 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1803 Handle(XCAFDoc_Dimension) aDimension;
1804 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1806 Handle(TColgp_HArray1OfPnt) pnts = aDimension->GetObject()->GetPoints();
1807 if(!pnts.IsNull() && pnts->Length() == 2)
1809 di << pnts->Value(1).X() << ";" << pnts->Value(1).Y() << ";" << pnts->Value(1).Z() << " ";
1810 di << pnts->Value(2).X() << ";" << pnts->Value(2).Y() << ";" << pnts->Value(2).Z();
1816 static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1819 di<<"Use: "<<"XSetDimensionDir Doc Dim_Label x y z\n";
1822 Handle(TDocStd_Document) Doc;
1823 DDocStd::GetDocument(argv[1], Doc);
1824 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1825 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1826 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1829 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1830 if ( aLabel.IsNull() )
1832 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1835 Handle(XCAFDoc_Dimension) aDimension;
1836 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1838 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1839 anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5])));
1840 aDimension->SetObject(anObj);
1845 static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1848 di<<"Use: "<<"XSetDimensionDir Doc Dim_Label\n";
1851 Handle(TDocStd_Document) Doc;
1852 DDocStd::GetDocument(argv[1], Doc);
1853 if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
1854 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1855 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1858 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1859 if ( aLabel.IsNull() )
1861 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1864 Handle(XCAFDoc_Dimension) aDimension;
1865 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1868 if(aDimension->GetObject()->GetDirection(dir))
1870 di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z();
1876 //=======================================================================
1877 //function : InitCommands
1879 //=======================================================================
1881 void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
1884 static Standard_Boolean initactor = Standard_False;
1885 if (initactor) return; initactor = Standard_True;
1888 Standard_CString g = "XDE G&DTs commands";
1890 di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
1891 __FILE__, DumpDGTs, g);
1893 di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
1894 __FILE__, addDim, g);
1896 di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label",
1897 __FILE__, addGTol, g);
1899 di.Add ("XAddDatum","XAddDatum Doc shape/label",
1900 __FILE__, addDatum, g);
1902 di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label",
1903 __FILE__, setDatum, g);
1905 di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label",
1906 __FILE__, getDatum, g);
1908 di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"
1910 "\n 0 AnyCrossSection"
1911 "\n 1 Any_LongitudinalSection"
1913 "\n 3 ContactingFeature"
1914 "\n 4 DegreeOfFreedomConstraintU"
1915 "\n 5 DegreeOfFreedomConstraintV"
1916 "\n 6 DegreeOfFreedomConstraintW"
1917 "\n 7 DegreeOfFreedomConstraintX"
1918 "\n 8 DegreeOfFreedomConstraintY"
1919 "\n 9 DegreeOfFreedomConstraintZ"
1920 "\n 10 DistanceVariable"
1922 "\n 12 LeastMaterialRequirement"
1924 "\n 14 MajorDiameter"
1925 "\n 15 MaximumMaterialRequirement"
1926 "\n 16 MinorDiameter"
1928 "\n 18 PitchDiameter"
1931 "\n 21 Translation",
1932 __FILE__, addDatumModif, g);
1934 di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label",
1935 __FILE__, getDatumModif, g);
1937 di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name",
1938 __FILE__, setDatumName, g);
1940 di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
1941 __FILE__, getDatumName, g);
1943 di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
1945 "\t 0 type is absent\n"
1947 "\t 2 CircularRunout\n"
1948 "\t 3 CircularityOrRoundness\n"
1950 "\t 5 Concentricity\n"
1951 "\t 6 Cylindricity\n"
1953 "\t 8 Parallelism\n"
1954 "\t 9 Perpendicularity\n"
1956 "\t 11 ProfileOfLine\n"
1957 "\t 12 ProfileOfSurface\n"
1958 "\t 13 Straightness\n"
1960 "\t 15 TotalRunout\n",
1961 __FILE__, setTypeOfTol, g);
1963 di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label",
1964 __FILE__, getTypeOfTol, g);
1966 di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type"
1970 "\n 2 SphericalDiameter",
1971 __FILE__, setTypeOfTolVal, g);
1973 di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label",
1974 __FILE__, getTypeOfTolVal, g);
1976 di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value",
1977 __FILE__, setTolVal, g);
1979 di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label",
1980 __FILE__, getTolVal, g);
1982 di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod"
1987 __FILE__, setMatReq, g);
1989 di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label",
1990 __FILE__, getMatReq, g);
1992 di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod"
1997 __FILE__, setZoneMod, g);
1999 di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label",
2000 __FILE__, getZoneMod, g);
2002 di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val",
2003 __FILE__, setZoneModVal, g);
2005 di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label",
2006 __FILE__, getZoneModVal, g);
2008 di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..."
2010 "\t 0 Any_Cross_Section\n"
2011 "\t 1 Common_Zone\n"
2012 "\t 2 Each_Radial_Element\n"
2014 "\t 4 Least_Material_Requirement\n"
2015 "\t 5 Line_Element\n"
2016 "\t 6 Major_Diameter\n"
2017 "\t 7 Maximum_Material_Requirement\n"
2018 "\t 8 Minor_Diameter\n"
2020 "\t 10 Pitch_Diameter\n"
2021 "\t 11 Reciprocity_Requirement\n"
2022 "\t 12 Separate_Requirement\n"
2023 "\t 13 Statistical_Tolerance\n"
2024 "\t 14 Tangent_Plane\n",
2025 __FILE__, addTolModif, g);
2027 di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label",
2028 __FILE__, getTolModif, g);
2030 di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val",
2031 __FILE__, setTolMaxVal, g);
2033 di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val",
2034 __FILE__, getTolMaxVal, g);
2036 di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type"
2038 "\t 0 type is absent\n"
2039 "\t 1 Location_CurvedDistance\n"
2040 "\t 2 Location_LinearDistance\n"
2041 "\t 3 Location_LinearDistance_FromCenterToOuter\n"
2042 "\t 4 Location_LinearDistance_FromCenterToInner\n"
2043 "\t 5 Location_LinearDistance_FromOuterToCenter\n"
2044 "\t 6 Location_LinearDistance_FromOuterToOuter\n"
2045 "\t 7 Location_LinearDistance_FromOuterToInner\n"
2046 "\t 8 Location_LinearDistance_FromInnerToCenter\n"
2047 "\t 9 Location_LinearDistance_FromInnerToOuter\n"
2048 "\t 10 Location_LinearDistance_FromInnerToInner\n"
2049 "\t 11 Location_Angular\n"
2050 "\t 12 Location_Oriented\n"
2051 "\t 13 Location_WithPath\n"
2052 "\t 14 Size_CurveLength\n"
2053 "\t 15 Size_Diameter\n"
2054 "\t 16 Size_SphericalDiameter\n"
2055 "\t 17 Size_Radius\n"
2056 "\t 18 Size_SphericalRadius\n"
2057 "\t 19 Size_ToroidalMinorDiameter\n"
2058 "\t 20 Size_ToroidalMajorDiameter\n"
2059 "\t 21 Size_ToroidalMinorRadius\n"
2060 "\t 22 Size_ToroidalMajorRadius\n"
2061 "\t 23 Size_ToroidalHighMajorDiameter\n"
2062 "\t 24 Size_ToroidalLowMajorDiameter\n"
2063 "\t 25 Size_ToroidalHighMajorRadius\n"
2064 "\t 26 Size_ToroidalLowMajorRadius\n"
2065 "\t 27 Size_Thickness\n"
2066 "\t 28 Size_Angular\n"
2067 "\t 29 Size_WithPath\n",
2068 __FILE__, setDimType, g);
2070 di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label",
2071 __FILE__, getDimType, g);
2073 di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val",
2074 __FILE__, setDimVal, g);
2076 di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label",
2077 __FILE__, getDimVal, g);
2079 di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val"
2085 __FILE__, setDimQalif, g);
2087 di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label",
2088 __FILE__, getDimQalif, g);
2090 di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val",
2091 __FILE__, setDimRange, g);
2093 di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label",
2094 __FILE__, getDimRange, g);
2096 di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val",
2097 __FILE__, setDimPlusMinusTol, g);
2099 di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label",
2100 __FILE__, getDimPlusMinusTol, g);
2102 di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade"
2103 "Values of formVar:"
2153 __FILE__, setDimClassTol, g);
2155 di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label",
2156 __FILE__, getDimClassTol, g);
2158 di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val",
2159 __FILE__, setDimNbOfDecimalPlaces, g);
2161 di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label",
2162 __FILE__, getDimNbOfDecimalPlaces, g);
2164 di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..."
2166 "\t 0 ControlledRadius\n"
2168 "\t 2 StatisticalTolerance\n"
2169 "\t 3 ContinuousFeature\n"
2170 "\t 4 TwoPointSize\n"
2171 "\t 5 LocalSizeDefinedBySphere\n"
2172 "\t 6 LeastSquaresAssociationCriterion\n"
2173 "\t 7 MaximumInscribedAssociation\n"
2174 "\t 8 MinimumCircumscribedAssociation\n"
2175 "\t 9 CircumferenceDiameter\n"
2176 "\t10 AreaDiameter\n"
2177 "\t11 VolumeDiameter\n"
2178 "\t12 MaximumSize\n"
2179 "\t13 MinimumSize\n"
2180 "\t14 AverageSize\n"
2182 "\t16 MidRangeSize\n"
2183 "\t17 RangeOfSizes\n"
2184 "\t18 AnyRestrictedPortionOfFeature\n"
2185 "\t19 AnyCrossSection\n"
2186 "\t20 SpecificFixedCrossSection\n"
2187 "\t21 CommonTolerance\n"
2188 "\t22 FreeStateCondition\n"
2190 __FILE__, addDimModifier, g);
2192 di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label",
2193 __FILE__, getDimModifier, g);
2195 di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)",
2196 __FILE__, addDimPath, g);
2198 di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 v2",
2199 __FILE__, addDimPoints, g);
2201 di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label",
2202 __FILE__, getDimPoints, g);
2204 di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z",
2205 __FILE__, addDimDir, g);
2207 di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label",
2208 __FILE__, getDimDir, g);