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,
376 for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
377 Handle(XCAFDoc_Dimension) aDimAttr;
378 if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr))
380 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
381 if (anObject.IsNull())
383 XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
384 if (aDimType == XCAFDimTolObjects_DimensionType_CommonLabel) {
387 else if (STEPCAFControl_GDTProperty::IsDimensionalLocation(aDimType)) {
390 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) {
394 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) {
398 else if (STEPCAFControl_GDTProperty::IsDimensionalSize(aDimType)) {
401 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) {
405 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) {
410 di << "\n NbOfDimensionalSize : " << nbSize;
411 di << "\n NbOfDimensionalLocation: " << nbLocation;
412 di << "\n NbOfAngular : " << nbAngular;
413 di << "\n NbOfWithPath : " << nbWithPath;
414 di << "\n NbOfCommonLabels : " << nbCommon;
418 aDimTolTool->GetGeomToleranceLabels(aGDTs);
419 di << "\n NbOfTolerances : " << aGDTs.Length();
421 Standard_Integer nbWithModif = 0,
424 for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
425 Handle(XCAFDoc_GeomTolerance) aGTAttr;
426 if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGTAttr))
428 Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
429 if (anObject.IsNull())
431 if (anObject->GetModifiers().Length() > 0 ||
432 anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) {
435 if (anObject->GetMaxValueModifier() != 0) {
438 TDF_LabelSequence aDatumSeq;
439 aDimTolTool->GetDatumWithObjectOfTolerLabels(aGDTs.Value(i), aDatumSeq);
440 if (aDatumSeq.Length() > 0) {
444 di << "\n NbOfGTWithModifiers : " << nbWithModif;
445 di << "\n NbOfGTWithMaxTolerance : " << nbWithMaxTol;
446 di << "\n NbOfGTWithDatums : " << nbWithDatumRef;
449 Standard_Integer aCounter = 0;
450 Standard_Integer aCounter1 = 0;
451 Standard_Integer aCounter2 = 0;
453 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
455 Standard_Boolean isDatum = Standard_False;
456 TDF_LabelSequence aDatL;
457 if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL))
459 for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++)
461 Handle(XCAFDoc_Datum) aDat;
462 if(aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat))
464 if(aDat->GetObject()->IsDatumTarget())
471 isDatum = Standard_True;
479 di << "\n NbOfDatumFeature : " << aCounter;
480 di << "\n NbOfAttachedDatum : " << aCounter2;
481 di << "\n NbOfDatumTarget : " << aCounter1;
486 static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
489 di<<"Use: XAddDimension Doc shape/label [shape/label]\n";
492 Handle(TDocStd_Document) Doc;
493 DDocStd::GetDocument(argv[1], Doc);
494 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
495 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
496 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
499 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
500 if ( aLabel.IsNull() )
502 TopoDS_Shape aShape= DBRep::Get(argv[2]);
503 if ( !aShape.IsNull() )
505 aShapeTool->Search(aShape, aLabel);
506 if ( aLabel.IsNull() )
508 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
516 TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1);
517 if ( aLabel1.IsNull() )
519 TopoDS_Shape aShape= DBRep::Get(argv[3]);
520 if ( !aShape.IsNull() )
522 aShapeTool->Search(aShape, aLabel1);
523 if ( aLabel1.IsNull() )
525 di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
532 TDF_Label aDimL = aDimTolTool->AddDimension();
534 aDimTolTool->SetDimension(aLabel, aDimL);
536 aDimTolTool->SetDimension(aLabel, aLabel1, aDimL);
537 TCollection_AsciiString Entry;
538 TDF_Tool::Entry(aDimL, Entry);
543 static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
546 di<<"Use: XAddGeomTolerance Doc shape/label\n";
549 Handle(TDocStd_Document) Doc;
550 DDocStd::GetDocument(argv[1], Doc);
551 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
552 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
553 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
556 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
557 if ( aLabel.IsNull() )
559 TopoDS_Shape aShape= DBRep::Get(argv[2]);
560 if ( !aShape.IsNull() )
562 aShapeTool->Search(aShape, aLabel);
563 if ( aLabel.IsNull() )
565 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
571 TDF_Label aTolL = aDimTolTool->AddGeomTolerance();
572 aDimTolTool->SetGeomTolerance(aLabel, aTolL);
573 TCollection_AsciiString Entry;
574 TDF_Tool::Entry(aTolL, Entry);
579 static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
582 di<<"Use: XAddDatum Doc shape/label\n";
585 Handle(TDocStd_Document) Doc;
586 DDocStd::GetDocument(argv[1], Doc);
587 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
588 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
589 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
592 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
593 if ( aLabel.IsNull() )
595 TopoDS_Shape aShape= DBRep::Get(argv[2]);
596 if ( !aShape.IsNull() )
598 aShapeTool->Search(aShape, aLabel);
599 if ( aLabel.IsNull() )
601 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
607 TDF_Label aDatumL = aDimTolTool->AddDatum();
608 aDimTolTool->SetDatum(aLabel, aDatumL);
609 TCollection_AsciiString Entry;
610 TDF_Tool::Entry(aDatumL, Entry);
615 static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
618 di<<"Use: XSetDatum Doc Datum_Label GeomTol_Label\n";
621 Handle(TDocStd_Document) Doc;
622 DDocStd::GetDocument(argv[1], Doc);
623 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
624 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
625 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
628 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
629 if ( aLabel.IsNull() )
631 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
636 TDF_Tool::Label(Doc->GetData(), argv[3], aTol);
639 di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
643 // check datum position number
644 Handle(XCAFDoc_Datum) aDatumAttr;
645 if (!aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr))
647 di<<"Invalid datum object\n";
650 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
651 if (aDatumObj.IsNull())
653 di<<"Invalid datum object\n";
657 if (aDatumObj->GetPosition() < 1 || aDatumObj->GetPosition() > 3)
659 di<<"Invalid datum position number: use XSetDatumPosition\n";
663 aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
667 static Standard_Integer setDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
670 di<<"Use: XSetDatumPosition Doc Datum_Label position[1-3]\n";
674 if (Draw::Atoi(argv[3]) < 1 || Draw::Atoi(argv[3]) > 3) {
675 di<<"Datum position should be 1, 2 or 3\n";
679 Handle(TDocStd_Document) Doc;
680 DDocStd::GetDocument(argv[1], Doc);
681 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
682 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
683 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
686 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
687 if ( aLabel.IsNull() )
689 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
692 Handle(XCAFDoc_Datum) aDatum;
693 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
695 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
696 anObj->SetPosition(Draw::Atoi(argv[3]));
697 aDatum->SetObject(anObj);
702 static Standard_Integer getDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
705 di<<"Use: XGetDatumPosition Doc Datum_Label\n";
708 Handle(TDocStd_Document) Doc;
709 DDocStd::GetDocument(argv[1], Doc);
710 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
711 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
712 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
715 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
716 if ( aLabel.IsNull() )
718 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
721 Handle(XCAFDoc_Datum) aDatum;
722 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
724 di << aDatum->GetObject()->GetPosition();
730 static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
733 di<<"Use: XGetDatum Doc GeomTol_Label/Shape_Label\n";
736 Handle(TDocStd_Document) Doc;
737 DDocStd::GetDocument(argv[1], Doc);
738 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
739 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
740 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
743 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
744 if ( aLabel.IsNull() )
746 di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
750 TDF_LabelSequence aD;
751 if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
753 aDimTolTool->GetDatumOfTolerLabels(aLabel, aD);
755 for(Standard_Integer i = aD.Lower(); i <= aD.Upper(); i++)
758 TCollection_AsciiString Entry;
759 TDF_Tool::Entry(aD.Value(i), Entry);
765 static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
768 di<<"Use: XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n";
771 Handle(TDocStd_Document) Doc;
772 DDocStd::GetDocument(argv[1], Doc);
773 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
774 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
775 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
778 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
779 if ( aLabel.IsNull() )
781 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
784 Handle(XCAFDoc_Datum) aDatum;
785 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
787 for(Standard_Integer i = 3; i < argc; i++)
789 if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1)
791 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
792 anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i]));
793 aDatum->SetObject(anObj);
800 static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
803 di<<"Use: XGetDatumModifiers Doc Datum_Label\n";
806 Handle(TDocStd_Document) Doc;
807 DDocStd::GetDocument(argv[1], Doc);
808 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
809 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
810 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
813 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
814 if ( aLabel.IsNull() )
816 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
819 Handle(XCAFDoc_Datum) aDatum;
820 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
822 XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers();
823 for(Standard_Integer i = 1; i<=aS.Length();i++)
827 case 0 : di<<"AnyCrossSection"; break;
828 case 1 : di<<"AnyLongitudinalSection"; break;
829 case 2 : di<<"Basic"; break;
830 case 3 : di<<"ContactingFeature\n"; break;
831 case 4 : di<<"DegreeOfFreedomConstraintU"; break;
832 case 5 : di<<"DegreeOfFreedomConstraintV"; break;
833 case 6 : di<<"DegreeOfFreedomConstraintW"; break;
834 case 7 : di<<"DegreeOfFreedomConstraintX"; break;
835 case 8 : di<<"DegreeOfFreedomConstraintY"; break;
836 case 9 : di<<"DegreeOfFreedomConstraintZ"; break;
837 case 10 : di<<"DistanceVariable"; break;
838 case 11 : di<<"FreeState"; break;
839 case 12 : di<<"LeastMaterialRequirement"; break;
840 case 13 : di<<"Line"; break;
841 case 14 : di<<"MajorDiameter"; break;
842 case 15 : di<<"MaximumMaterialRequirement"; break;
843 case 16 : di<<"MinorDiameter"; break;
844 case 17 : di<<"Orientation"; break;
845 case 18 : di<<"PitchDiameter"; break;
846 case 19 : di<<"Plane"; break;
847 case 20 : di<<"Point"; break;
848 case 21 : di<<"Translation"; break;
856 static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
859 di<<"Use: XSetDatumName Doc Datum_Label name\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<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
875 Handle(XCAFDoc_Datum) aDatum;
876 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
878 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
879 anObj->SetName(new TCollection_HAsciiString(argv[3]));
880 aDatum->SetObject(anObj);
885 static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
888 di<<"Use: XGetDatumName Doc Datum_Label\n";
891 Handle(TDocStd_Document) Doc;
892 DDocStd::GetDocument(argv[1], Doc);
893 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
894 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
895 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
898 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
899 if ( aLabel.IsNull() )
901 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
904 Handle(XCAFDoc_Datum) aDatum;
905 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
907 di<<aDatum->GetObject()->GetName()->ToCString();
912 static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
915 di<<"Use: XSetTypeOfTolerance Doc GTol_Label type\n";
918 Handle(TDocStd_Document) Doc;
919 DDocStd::GetDocument(argv[1], Doc);
920 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
921 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
922 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
925 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
926 if ( aLabel.IsNull() )
928 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
931 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
932 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
934 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16)
936 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
937 anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3]));
938 aGeomTolerance->SetObject(anObj);
944 static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
947 di<<"Use: XGetTypeOfTolerance Doc GTol_Label\n";
950 Handle(TDocStd_Document) Doc;
951 DDocStd::GetDocument(argv[1], Doc);
952 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
953 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
954 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
957 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
958 if ( aLabel.IsNull() )
960 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
963 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
964 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
966 switch(aGeomTolerance->GetObject()->GetType()){
967 case 0 : di<<"type is absent"; break;
968 case 1 : di<<"Angularity"; break;
969 case 2 : di<<"CircularRunout"; break;
970 case 3 : di<<"CircularityOrRoundness"; break;
971 case 4 : di<<"Coaxiality"; break;
972 case 5 : di<<"Concentricity"; break;
973 case 6 : di<<"Cylindricity"; break;
974 case 7 : di<<"Flatness"; break;
975 case 8 : di<<"Parallelism"; break;
976 case 9 : di<<"Perpendicularity"; break;
977 case 10 : di<<"Position"; break;
978 case 11 : di<<"ProfileOfLine"; break;
979 case 12 : di<<"ProfileOfSurface"; break;
980 case 13 : di<<"Straightness"; break;
981 case 14 : di<<"Symmetry"; break;
982 case 15 : di<<"TotalRunout"; break;
989 static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
992 di<<"Use: XSetTypeOfToleranceValue Doc GTol_Label type\n";
995 Handle(TDocStd_Document) Doc;
996 DDocStd::GetDocument(argv[1], Doc);
997 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
998 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
999 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1002 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1003 if ( aLabel.IsNull() )
1005 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1008 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1009 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1011 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1013 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1014 anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3]));
1015 aGeomTolerance->SetObject(anObj);
1021 static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1024 di<<"Use: XGetTypeOfToleranceValue Doc GTol_Label\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 switch(aGeomTolerance->GetObject()->GetTypeOfValue()){
1044 case 0 : di<<"type is absent"; break;
1045 case 1 : di<<"Diameter"; break;
1046 case 2 : di<<"SphericalDiameter"; break;
1053 static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1056 di<<"Use: XSetToleranceValue Doc GTol_Label value\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 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1076 anObj->SetValue(Draw::Atof(argv[3]));
1077 aGeomTolerance->SetObject(anObj);
1082 static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1085 di<<"Use: XGetToleranceValue Doc GTol_Label\n";
1088 Handle(TDocStd_Document) Doc;
1089 DDocStd::GetDocument(argv[1], Doc);
1090 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1091 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1092 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1095 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1096 if ( aLabel.IsNull() )
1098 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1101 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1102 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1104 di << aGeomTolerance->GetObject()->GetValue();
1109 static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1112 di<<"Use: XSetTolMaterialReq Doc GTol_Label mod\n";
1115 Handle(TDocStd_Document) Doc;
1116 DDocStd::GetDocument(argv[1], Doc);
1117 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1118 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1119 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1122 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1123 if ( aLabel.IsNull() )
1125 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1128 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1129 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1131 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1133 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1134 anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3]));
1135 aGeomTolerance->SetObject(anObj);
1141 static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1144 di<<"Use: XGetTolMaterialReq Doc GTol_Label\n";
1147 Handle(TDocStd_Document) Doc;
1148 DDocStd::GetDocument(argv[1], Doc);
1149 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1150 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1151 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1154 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1155 if ( aLabel.IsNull() )
1157 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1160 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1161 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1163 switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){
1164 case 0 : di<<"modifier is absent"; break;
1165 case 1 : di<<"M"; break;
1166 case 2 : di<<"L"; break;
1173 static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1176 di<<"Use: XSetTolZoneMod Doc GTol_Label mod\n";
1179 Handle(TDocStd_Document) Doc;
1180 DDocStd::GetDocument(argv[1], Doc);
1181 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1182 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1183 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1186 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1187 if ( aLabel.IsNull() )
1189 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1192 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1193 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1195 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1197 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1198 anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3]));
1199 aGeomTolerance->SetObject(anObj);
1205 static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1208 di<<"Use: XGetTolZoneMod Doc GTol_Label\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 switch(aGeomTolerance->GetObject()->GetZoneModifier()){
1228 case 0 : di<<"modifier is absent"; break;
1229 case 1 : di<<"P"; break;
1230 case 2 : di<<"NonUniform"; break;
1237 static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1240 di<<"Use: XSetTolZoneModValue Doc GTol_Label val\n";
1243 Handle(TDocStd_Document) Doc;
1244 DDocStd::GetDocument(argv[1], Doc);
1245 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1246 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1247 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1250 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1251 if ( aLabel.IsNull() )
1253 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1256 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1257 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1259 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1260 anObj->SetValueOfZoneModifier(Draw::Atof(argv[3]));
1261 aGeomTolerance->SetObject(anObj);
1266 static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1269 di<<"Use: XGetTolZoneModValue Doc GTol_Label\n";
1272 Handle(TDocStd_Document) Doc;
1273 DDocStd::GetDocument(argv[1], Doc);
1274 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1275 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1276 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1279 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1280 if ( aLabel.IsNull() )
1282 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1285 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1286 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1288 di << aGeomTolerance->GetObject()->GetValueOfZoneModifier();
1293 static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1296 di<<"Use: XAddTolModifier Doc Tol_Label mod1 mod2 ...\n";
1299 Handle(TDocStd_Document) Doc;
1300 DDocStd::GetDocument(argv[1], Doc);
1301 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1302 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1303 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1306 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1307 if ( aLabel.IsNull() )
1309 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1312 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1313 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1315 for(Standard_Integer i = 3; i < argc; i++)
1317 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 15)
1319 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1320 anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i]));
1321 aGeomTolerance->SetObject(anObj);
1328 static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1331 di<<"Use: XGetTolModifiers Doc Tol_Label\n";
1334 Handle(TDocStd_Document) Doc;
1335 DDocStd::GetDocument(argv[1], Doc);
1336 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1337 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1338 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1341 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1342 if ( aLabel.IsNull() )
1344 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1347 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1348 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1350 XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers();
1351 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1353 if (i > 1) di<<", ";
1354 switch(aS.Value(i)){
1355 case 0 : di<<"Any_Cross_Section"; break;
1356 case 1 : di<<"Common_Zone"; break;
1357 case 2 : di<<"Each_Radial_Element"; break;
1358 case 3 : di<<"Free_State"; break;
1359 case 4 : di<<"Least_Material_Requirement"; break;
1360 case 5 : di<<"Line_Element"; break;
1361 case 6 : di<<"Major_Diameter"; break;
1362 case 7 : di<<"Maximum_Material_Requirement"; break;
1363 case 8 : di<<"Minor_Diameter"; break;
1364 case 9 : di<<"Not_Convex"; break;
1365 case 10 : di<<"Pitch_Diameter"; break;
1366 case 11 : di<<"Reciprocity_Requirement"; break;
1367 case 12 : di<<"Separate_Requirement"; break;
1368 case 13 : di<<"Statistical_Tolerance"; break;
1369 case 14 : di<<"Tangent_Plane"; break;
1377 static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1380 di<<"Use: XSetTolMaxValue Doc Dim_Label val\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<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1396 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1397 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1399 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1400 anObj->SetMaxValueModifier(Draw::Atof(argv[3]));
1401 aGeomTolerance->SetObject(anObj);
1406 static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1409 di<<"Use: XGetTolMaxValue Doc Dim_Label\n";
1412 Handle(TDocStd_Document) Doc;
1413 DDocStd::GetDocument(argv[1], Doc);
1414 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1415 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1416 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1419 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1420 if ( aLabel.IsNull() )
1422 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1425 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1426 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1428 di << aGeomTolerance->GetObject()->GetMaxValueModifier();
1433 static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1436 di<<"Use: XSetDimensionType Doc Dim_Label type\n";
1439 Handle(TDocStd_Document) Doc;
1440 DDocStd::GetDocument(argv[1], Doc);
1441 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1442 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1443 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1446 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1447 if ( aLabel.IsNull() )
1449 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1452 Handle(XCAFDoc_Dimension) aDimension;
1453 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1455 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30)
1457 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1458 anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3]));
1459 aDimension->SetObject(anObj);
1465 static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1468 di<<"Use: XGetDimensionType 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 switch(aDimension->GetObject()->GetType()){
1488 case 0 : di<<"type is absent"; break;
1489 case 1 : di<<"Location_CurvedDistance"; break;
1490 case 2 : di<<"Location_LinearDistance"; break;
1491 case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break;
1492 case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break;
1493 case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break;
1494 case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break;
1495 case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break;
1496 case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break;
1497 case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break;
1498 case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break;
1499 case 11 : di<<"Location_Angular"; break;
1500 case 12 : di<<"Location_Oriented"; break;
1501 case 13 : di<<"Location_WithPath"; break;
1502 case 14 : di<<"Size_CurveLength"; break;
1503 case 15 : di<<"Size_Diameter"; break;
1504 case 16 : di<<"Size_SphericalDiameter"; break;
1505 case 17 : di<<"Size_Radius"; break;
1506 case 18 : di<<"Size_SphericalRadius"; break;
1507 case 19 : di<<"Size_ToroidalMinorDiameter"; break;
1508 case 20 : di<<"Size_ToroidalMajorDiameter"; break;
1509 case 21 : di<<"Size_ToroidalMinorRadius"; break;
1510 case 22 : di<<"Size_ToroidalMajorRadius"; break;
1511 case 23 : di<<"Size_ToroidalHighMajorDiameter"; break;
1512 case 24 : di<<"Size_ToroidalLowMajorDiameter"; break;
1513 case 25 : di<<"Size_ToroidalHighMajorRadius"; break;
1514 case 26 : di<<"Size_ToroidalLowMajorRadius"; break;
1515 case 27 : di<<"Size_Thickness"; break;
1516 case 28 : di<<"Size_Angular"; break;
1517 case 29 : di<<"Size_WithPath"; break;
1524 static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1527 di<<"Use: XSetDimensionValue Doc Dim_Label val\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))
1546 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1547 anObj->SetValue(Draw::Atof(argv[3]));
1548 aDimension->SetObject(anObj);
1553 static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1556 di<<"Use: XGetDimensionValue Doc Dim_Label\n";
1559 Handle(TDocStd_Document) Doc;
1560 DDocStd::GetDocument(argv[1], Doc);
1561 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1562 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1563 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1566 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1567 if ( aLabel.IsNull() )
1569 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1572 Handle(XCAFDoc_Dimension) aDimension;
1573 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1575 di << aDimension->GetObject()->GetValue();
1580 static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1583 di<<"Use: XSetDimensionQualifier Doc Dim_Label val\n";
1586 Handle(TDocStd_Document) Doc;
1587 DDocStd::GetDocument(argv[1], Doc);
1588 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1589 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1590 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1593 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1594 if ( aLabel.IsNull() )
1596 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1599 Handle(XCAFDoc_Dimension) aDimension;
1600 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1602 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4)
1604 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1605 anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3]));
1606 aDimension->SetObject(anObj);
1612 static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1615 di<<"Use: XGetDimensionQualifier Doc Dim_Label\n";
1618 Handle(TDocStd_Document) Doc;
1619 DDocStd::GetDocument(argv[1], Doc);
1620 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1621 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1622 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1625 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1626 if ( aLabel.IsNull() )
1628 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1631 Handle(XCAFDoc_Dimension) aDimension;
1632 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1635 switch(aDimension->GetObject()->GetQualifier()){
1636 case 0 : di<<"type is absent"; break;
1637 case 1 : di<<"Min"; break;
1638 case 2 : di<<"Max"; break;
1639 case 3 : di<<"Avg"; break;
1646 static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1649 di<<"Use: XSetDimensionRange Doc Dim_Label low_val up_val\n";
1652 Handle(TDocStd_Document) Doc;
1653 DDocStd::GetDocument(argv[1], Doc);
1654 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1655 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1656 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1659 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1660 if ( aLabel.IsNull() )
1662 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1665 Handle(XCAFDoc_Dimension) aDimension;
1666 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1668 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1670 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1671 anObj->SetLowerBound(Draw::Atof(argv[3]));
1672 anObj->SetUpperBound(Draw::Atof(argv[4]));
1673 aDimension->SetObject(anObj);
1679 static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1682 di<<"Use: XGetDimensionRange Doc Dim_Label\n";
1685 Handle(TDocStd_Document) Doc;
1686 DDocStd::GetDocument(argv[1], Doc);
1687 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1688 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1689 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1692 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1693 if ( aLabel.IsNull() )
1695 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1698 Handle(XCAFDoc_Dimension) aDimension;
1699 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1701 di << "lower " << aDimension->GetObject()->GetLowerBound();
1702 di << " upper " << aDimension->GetObject()->GetUpperBound();
1707 static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1710 di<<"Use: XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n";
1713 Handle(TDocStd_Document) Doc;
1714 DDocStd::GetDocument(argv[1], Doc);
1715 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1716 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1717 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1720 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1721 if ( aLabel.IsNull() )
1723 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1726 Handle(XCAFDoc_Dimension) aDimension;
1727 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1729 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1731 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1732 anObj->SetLowerTolValue(Draw::Atof(argv[3]));
1733 anObj->SetUpperTolValue(Draw::Atof(argv[4]));
1734 aDimension->SetObject(anObj);
1740 static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1743 di<<"Use: XGetDimensionPlusMinusTol Doc Dim_Label\n";
1746 Handle(TDocStd_Document) Doc;
1747 DDocStd::GetDocument(argv[1], Doc);
1748 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1749 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1750 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1753 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1754 if ( aLabel.IsNull() )
1756 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1759 Handle(XCAFDoc_Dimension) aDimension;
1760 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1762 di << "lower " << aDimension->GetObject()->GetLowerTolValue();
1763 di << " upper " << aDimension->GetObject()->GetUpperTolValue();
1768 static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1771 di<<"Use: XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n";
1774 Handle(TDocStd_Document) Doc;
1775 DDocStd::GetDocument(argv[1], Doc);
1776 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1777 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1778 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1781 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1782 if ( aLabel.IsNull() )
1784 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1787 Handle(XCAFDoc_Dimension) aDimension;
1788 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1790 if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20)
1792 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1793 anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5]));
1794 aDimension->SetObject(anObj);
1800 static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1803 di<<"Use: XGetDimensionClassOfTol Doc Dim_Label\n";
1806 Handle(TDocStd_Document) Doc;
1807 DDocStd::GetDocument(argv[1], Doc);
1808 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1809 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1810 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1813 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1814 if ( aLabel.IsNull() )
1816 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1819 Handle(XCAFDoc_Dimension) aDimension;
1820 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1823 XCAFDimTolObjects_DimensionFormVariance f;
1824 XCAFDimTolObjects_DimensionGrade g;
1825 if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g))
1830 case 1 : di<<"a";break;
1831 case 2 : di<<"b";break;
1832 case 3 : di<<"c";break;
1833 case 4 : di<<"cd";break;
1834 case 5 : di<<"d";break;
1835 case 6 : di<<"e";break;
1836 case 7 : di<<"ef";break;
1837 case 8 : di<<"f";break;
1838 case 9 : di<<"fg";break;
1839 case 10 : di<<"g";break;
1840 case 11 : di<<"h";break;
1841 case 12 : di<<"js";break;
1842 case 13 : di<<"j";break;
1843 case 14 : di<<"k";break;
1844 case 15 : di<<"m";break;
1845 case 16 : di<<"n";break;
1846 case 17 : di<<"p";break;
1847 case 18 : di<<"r";break;
1848 case 19 : di<<"s";break;
1849 case 20 : di<<"t";break;
1850 case 21 : di<<"u";break;
1851 case 22 : di<<"v";break;
1852 case 23 : di<<"x";break;
1853 case 24 : di<<"y";break;
1854 case 25 : di<<"z";break;
1855 case 26 : di<<"a";break;
1856 case 27 : di<<"zb";break;
1857 case 28 : di<<"zc";break;
1864 case 1 : di<<"A";break;
1865 case 2 : di<<"B";break;
1866 case 3 : di<<"C";break;
1867 case 4 : di<<"CD";break;
1868 case 5 : di<<"D";break;
1869 case 6 : di<<"E";break;
1870 case 7 : di<<"EF";break;
1871 case 8 : di<<"F";break;
1872 case 9 : di<<"FG";break;
1873 case 10 : di<<"G";break;
1874 case 11 : di<<"H";break;
1875 case 12 : di<<"JS";break;
1876 case 13 : di<<"J";break;
1877 case 14 : di<<"K";break;
1878 case 15 : di<<"M";break;
1879 case 16 : di<<"N";break;
1880 case 17 : di<<"P";break;
1881 case 18 : di<<"R";break;
1882 case 19 : di<<"S";break;
1883 case 20 : di<<"T";break;
1884 case 21 : di<<"U";break;
1885 case 22 : di<<"V";break;
1886 case 23 : di<<"X";break;
1887 case 24 : di<<"Y";break;
1888 case 25 : di<<"Z";break;
1889 case 26 : di<<"ZA";break;
1890 case 27 : di<<"ZB";break;
1891 case 28 : di<<"ZC";break;
1896 case 0 : di<<"01"; break;
1897 case 1 : di<<"0"; break;
1898 case 2 : di<<"1"; break;
1899 case 3 : di<<"2"; break;
1900 case 4 : di<<"3"; break;
1901 case 5 : di<<"4"; break;
1902 case 6 : di<<"5"; break;
1903 case 7 : di<<"6"; break;
1904 case 8 : di<<"7"; break;
1905 case 9 : di<<"8"; break;
1906 case 10 : di<<"9"; break;
1907 case 11 : di<<"10"; break;
1908 case 12 : di<<"11"; break;
1909 case 13 : di<<"12"; break;
1910 case 14 : di<<"13"; break;
1911 case 15 : di<<"14"; break;
1912 case 16 : di<<"15"; break;
1913 case 17 : di<<"16"; break;
1914 case 18 : di<<"17"; break;
1915 case 19 : di<<"18"; break;
1923 static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1926 di<<"Use: XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n";
1929 Handle(TDocStd_Document) Doc;
1930 DDocStd::GetDocument(argv[1], Doc);
1931 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1932 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1933 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1936 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1937 if ( aLabel.IsNull() )
1939 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1942 Handle(XCAFDoc_Dimension) aDimension;
1943 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1945 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1946 anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4]));
1947 aDimension->SetObject(anObj);
1952 static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1955 di<<"Use: XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n";
1958 Handle(TDocStd_Document) Doc;
1959 DDocStd::GetDocument(argv[1], Doc);
1960 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1961 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1962 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1965 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1966 if ( aLabel.IsNull() )
1968 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1971 Handle(XCAFDoc_Dimension) aDimension;
1972 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1974 Standard_Integer l, r;
1975 aDimension->GetObject()->GetNbOfDecimalPlaces(l,r);
1976 di << l << "." << r;
1981 static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1984 di<<"Use: XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n";
1987 Handle(TDocStd_Document) Doc;
1988 DDocStd::GetDocument(argv[1], Doc);
1989 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1990 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1991 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1994 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1995 if ( aLabel.IsNull() )
1997 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2000 Handle(XCAFDoc_Dimension) aDimension;
2001 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2003 for(Standard_Integer i = 3; i < argc; i++)
2005 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24)
2007 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2008 anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i]));
2009 aDimension->SetObject(anObj);
2016 static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2019 di<<"Use: XGetDimensionModifiers Doc Dim_Label\n";
2022 Handle(TDocStd_Document) Doc;
2023 DDocStd::GetDocument(argv[1], Doc);
2024 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2025 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2026 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2029 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2030 if ( aLabel.IsNull() )
2032 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2035 Handle(XCAFDoc_Dimension) aDimension;
2036 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2038 XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers();
2039 for(Standard_Integer i = 1; i <= aS.Length(); i++)
2041 if (i > 1) di<<", ";
2042 switch(aS.Value(i)){
2043 case 0 : di<<"ControlledRadius"; break;
2044 case 1 : di<<"Square"; break;
2045 case 2 : di<<"StatisticalTolerance"; break;
2046 case 3 : di<<"ContinuousFeature"; break;
2047 case 4 : di<<"TwoPointSize"; break;
2048 case 5 : di<<"LocalSizeDefinedBySphere"; break;
2049 case 6 : di<<"LeastSquaresAssociationCriterion"; break;
2050 case 7 : di<<"MaximumInscribedAssociation"; break;
2051 case 8 : di<<"MinimumCircumscribedAssociation"; break;
2052 case 9 : di<<"CircumferenceDiameter"; break;
2053 case 10 : di<<"AreaDiameter"; break;
2054 case 11 : di<<"VolumeDiameter"; break;
2055 case 12 : di<<"MaximumSize"; break;
2056 case 13 : di<<"MinimumSize"; break;
2057 case 14 : di<<"AverageSize"; break;
2058 case 15 : di<<"MedianSize"; break;
2059 case 16 : di<<"MidRangeSize"; break;
2060 case 17 : di<<"RangeOfSizes"; break;
2061 case 18 : di<<"AnyRestrictedPortionOfFeature"; break;
2062 case 19 : di<<"AnyCrossSection"; break;
2063 case 20 : di<<"SpecificFixedCrossSection"; break;
2064 case 21 : di<<"CommonTolerance"; break;
2065 case 22 : di<<"FreeStateCondition"; break;
2066 case 23 : di<<"Between"; break;
2074 static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2077 di<<"Use: XSetDimensionPath Doc Dim_Label path(edge)\n";
2080 Handle(TDocStd_Document) Doc;
2081 DDocStd::GetDocument(argv[1], Doc);
2082 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2083 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2084 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2087 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2088 if ( aLabel.IsNull() )
2090 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2093 Handle(XCAFDoc_Dimension) aDimension;
2094 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2096 TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE));
2099 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2101 aDimension->SetObject(anObj);
2107 static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2110 di<<"Use: XSetDimensionPoints Doc Dim_Label v1 [v2]\n";
2113 Handle(TDocStd_Document) Doc;
2114 DDocStd::GetDocument(argv[1], Doc);
2115 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2116 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2117 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2120 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2121 if ( aLabel.IsNull() )
2123 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2126 Handle(XCAFDoc_Dimension) aDimension;
2127 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2129 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2131 TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX));
2133 anObj->SetPoint(BRep_Tool::Pnt(aV1));
2136 TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX));
2138 anObj->SetPoint2(BRep_Tool::Pnt(aV2));
2141 aDimension->SetObject(anObj);
2146 static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2149 di<<"Use: XGetDimensionPoints Doc Dim_Label\n";
2152 Handle(TDocStd_Document) Doc;
2153 DDocStd::GetDocument(argv[1], Doc);
2154 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2155 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2156 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2159 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2160 if ( aLabel.IsNull() )
2162 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2165 Handle(XCAFDoc_Dimension) aDimension;
2166 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2168 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2169 if(anObj->HasPoint()) {
2170 di << anObj->GetPoint().X() << ";" << anObj->GetPoint().Y() << ";" << anObj->GetPoint().Z() << " ";
2172 if(anObj->HasPoint2()) {
2173 di << anObj->GetPoint2().X() << ";" << anObj->GetPoint2().Y() << ";" << anObj->GetPoint2().Z();
2179 static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2182 di<<"Use: XSetDimensionDir Doc Dim_Label x y z\n";
2185 Handle(TDocStd_Document) Doc;
2186 DDocStd::GetDocument(argv[1], Doc);
2187 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2188 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2189 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2192 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2193 if ( aLabel.IsNull() )
2195 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2198 Handle(XCAFDoc_Dimension) aDimension;
2199 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2201 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2202 anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5])));
2203 aDimension->SetObject(anObj);
2208 static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2211 di<<"Use: XGetDimensionDir Doc Dim_Label\n";
2214 Handle(TDocStd_Document) Doc;
2215 DDocStd::GetDocument(argv[1], Doc);
2216 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2217 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2218 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2221 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2222 if ( aLabel.IsNull() )
2224 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2227 Handle(XCAFDoc_Dimension) aDimension;
2228 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2231 if(aDimension->GetObject()->GetDirection(dir))
2233 di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z();
2239 static Standard_Integer addDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2242 di<<"Use: XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n";
2245 Handle(TDocStd_Document) Doc;
2246 DDocStd::GetDocument(argv[1], Doc);
2247 if ( Doc.IsNull() ) {
2248 di << argv[1] << " is not a document\n";
2253 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2254 if ( aLabel.IsNull() )
2256 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2259 Handle(XCAFDoc_Dimension) aDimension;
2260 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2262 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2263 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(argv[3]);
2264 Handle(TCollection_HAsciiString) aDescrName = (argc == 4) ? new TCollection_HAsciiString()
2265 : new TCollection_HAsciiString(argv[4]);
2266 anObj->AddDescription(aDescription, aDescrName);
2267 aDimension->SetObject(anObj);
2272 static Standard_Integer getDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2275 di << "Use: XGetDimensionDescr Doc Dim_Label\n";
2278 Handle(TDocStd_Document) Doc;
2279 DDocStd::GetDocument(argv[1], Doc);
2280 if ( Doc.IsNull() ) {
2281 di << argv[1] << " is not a document\n";
2286 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2287 if ( aLabel.IsNull() )
2289 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2292 Handle(XCAFDoc_Dimension) aDimension;
2293 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2295 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimension->GetObject();
2296 for (Standard_Integer i = 0; i < anObject->NbDescriptions(); i++) {
2297 Handle(TCollection_HAsciiString) aDescription = anObject->GetDescription(i);
2298 Handle(TCollection_HAsciiString) aDescrName = anObject->GetDescriptionName(i);
2299 di << "name: " << aDescrName->ToCString() << " description: " << aDescription->ToCString() << "\n";
2305 static Standard_Integer addGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2308 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";
2311 Handle(TDocStd_Document) Doc;
2312 DDocStd::GetDocument(argv[1], Doc);
2313 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2316 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2317 if ( aLabel.IsNull() )
2319 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2323 gp_Pnt aPoint(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]));
2324 gp_Dir aNormal(Draw::Atof(argv[6]), Draw::Atof(argv[7]), Draw::Atof(argv[8]));
2325 gp_Dir aDir(Draw::Atof(argv[9]), Draw::Atof(argv[10]), Draw::Atof(argv[11]));
2326 gp_Ax2 aPlane(aPoint, aNormal, aDir);
2328 Handle(XCAFDoc_Dimension) aDimension;
2329 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2331 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2332 anObj->SetPlane(aPlane);
2333 anObj->SetPointTextAttach(aPoint);
2334 aDimension->SetObject(anObj);
2336 // Geometric Tolerance
2337 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2338 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2340 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2341 anObj->SetPlane(aPlane);
2342 anObj->SetPointTextAttach(aPoint);
2343 aGeomTolerance->SetObject(anObj);
2346 Handle(XCAFDoc_Datum) aDatum;
2347 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2349 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2350 anObj->SetPlane(aPlane);
2351 anObj->SetPointTextAttach(aPoint);
2352 aDatum->SetObject(anObj);
2357 static Standard_Integer getGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2360 di << "Use: XGetGDTPosition Doc GDT_Label\n";
2363 Handle(TDocStd_Document) Doc;
2364 DDocStd::GetDocument(argv[1], Doc);
2365 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2368 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2369 if ( aLabel.IsNull() )
2371 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2375 gp_Dir aNormal, aDir;
2377 Handle(XCAFDoc_Dimension) aDimension;
2378 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2380 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2381 aPoint = anObj->GetPointTextAttach();
2382 aNormal = anObj->GetPlane().Direction();
2383 aDir = anObj->GetPlane().XDirection();
2385 // Geometric Tolerance
2386 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2387 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2389 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2390 aPoint = anObj->GetPointTextAttach();
2391 aNormal = anObj->GetPlane().Direction();
2392 aDir = anObj->GetPlane().XDirection();
2395 Handle(XCAFDoc_Datum) aDatum;
2396 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2398 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2399 aPoint = anObj->GetPointTextAttach();
2400 aNormal = anObj->GetPlane().Direction();
2401 aDir = anObj->GetPlane().XDirection();
2404 di << "position: " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z() << "\n";
2405 di << "normal: " << aNormal.X() << " " << aNormal.Y() << " " << aNormal.Z() << "\n";
2406 di << "x_direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n";
2410 static Standard_Integer addGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2413 di << "Use: XSetGDTPresentation Doc GDT_Label Shape Name\n";
2416 Handle(TDocStd_Document) Doc;
2417 DDocStd::GetDocument(argv[1], Doc);
2418 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2421 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2422 if ( aLabel.IsNull() )
2424 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2428 TopoDS_Shape aPresentation= DBRep::Get(argv[3]);
2429 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[4]);
2431 Handle(XCAFDoc_Dimension) aDimension;
2432 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2434 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2435 anObj->SetPresentation(aPresentation, aName);
2436 aDimension->SetObject(anObj);
2438 // Geometric Tolerance
2439 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2440 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2442 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2443 anObj->SetPresentation(aPresentation, aName);
2444 aGeomTolerance->SetObject(anObj);
2447 Handle(XCAFDoc_Datum) aDatum;
2448 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2450 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2451 anObj->SetPresentation(aPresentation, aName);
2452 aDatum->SetObject(anObj);
2457 static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2460 di << "Use: XGetGDTPresentation Doc GDT_Label Shape\n";
2463 Handle(TDocStd_Document) Doc;
2464 DDocStd::GetDocument(argv[1], Doc);
2465 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2468 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2469 if ( aLabel.IsNull() )
2471 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2474 TopoDS_Shape aPresentation;
2476 Handle(XCAFDoc_Dimension) aDimension;
2477 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2479 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2480 aPresentation = anObj->GetPresentation();
2482 // Geometric Tolerance
2483 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2484 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2486 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2487 aPresentation = anObj->GetPresentation();
2490 Handle(XCAFDoc_Datum) aDatum;
2491 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2493 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2494 aPresentation = anObj->GetPresentation();
2497 DBRep::Set (argv[3], aPresentation);
2501 //=======================================================================
2502 //function : InitCommands
2504 //=======================================================================
2506 void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
2509 static Standard_Boolean initactor = Standard_False;
2510 if (initactor) return; initactor = Standard_True;
2513 Standard_CString g = "XDE G&DTs commands";
2515 di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
2516 __FILE__, DumpDGTs, g);
2518 di.Add ("XDumpNbDGTs","XDumpNbDGTs Doc [f (full dumping)]",
2519 __FILE__, DumpNbDGTs, g);
2521 di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
2522 __FILE__, addDim, g);
2524 di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label",
2525 __FILE__, addGTol, g);
2527 di.Add ("XAddDatum","XAddDatum Doc shape/label",
2528 __FILE__, addDatum, g);
2530 di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label",
2531 __FILE__, setDatum, g);
2533 di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label",
2534 __FILE__, getDatum, g);
2536 di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"
2538 "\n 0 AnyCrossSection"
2539 "\n 1 Any_LongitudinalSection"
2541 "\n 3 ContactingFeature"
2542 "\n 4 DegreeOfFreedomConstraintU"
2543 "\n 5 DegreeOfFreedomConstraintV"
2544 "\n 6 DegreeOfFreedomConstraintW"
2545 "\n 7 DegreeOfFreedomConstraintX"
2546 "\n 8 DegreeOfFreedomConstraintY"
2547 "\n 9 DegreeOfFreedomConstraintZ"
2548 "\n 10 DistanceVariable"
2550 "\n 12 LeastMaterialRequirement"
2552 "\n 14 MajorDiameter"
2553 "\n 15 MaximumMaterialRequirement"
2554 "\n 16 MinorDiameter"
2556 "\n 18 PitchDiameter"
2559 "\n 21 Translation",
2560 __FILE__, addDatumModif, g);
2562 di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label",
2563 __FILE__, getDatumModif, g);
2565 di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name",
2566 __FILE__, setDatumName, g);
2568 di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
2569 __FILE__, getDatumName, g);
2571 di.Add ("XSetDatumPosition","XSetDatumPosition Doc Datum_Label position[1-3]"
2572 "Set datum position number in geometric tolerance datum system",
2573 __FILE__, setDatumPosition, g);
2575 di.Add ("XGetDatumPosition","XGetDatumPosition Doc Datum_Label",
2576 __FILE__, getDatumPosition, g);
2578 di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
2580 "\t 0 type is absent\n"
2582 "\t 2 CircularRunout\n"
2583 "\t 3 CircularityOrRoundness\n"
2585 "\t 5 Concentricity\n"
2586 "\t 6 Cylindricity\n"
2588 "\t 8 Parallelism\n"
2589 "\t 9 Perpendicularity\n"
2591 "\t 11 ProfileOfLine\n"
2592 "\t 12 ProfileOfSurface\n"
2593 "\t 13 Straightness\n"
2595 "\t 15 TotalRunout\n",
2596 __FILE__, setTypeOfTol, g);
2598 di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label",
2599 __FILE__, getTypeOfTol, g);
2601 di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type"
2605 "\n 2 SphericalDiameter",
2606 __FILE__, setTypeOfTolVal, g);
2608 di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label",
2609 __FILE__, getTypeOfTolVal, g);
2611 di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value",
2612 __FILE__, setTolVal, g);
2614 di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label",
2615 __FILE__, getTolVal, g);
2617 di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod"
2622 __FILE__, setMatReq, g);
2624 di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label",
2625 __FILE__, getMatReq, g);
2627 di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod"
2632 __FILE__, setZoneMod, g);
2634 di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label",
2635 __FILE__, getZoneMod, g);
2637 di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val",
2638 __FILE__, setZoneModVal, g);
2640 di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label",
2641 __FILE__, getZoneModVal, g);
2643 di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..."
2645 "\t 0 Any_Cross_Section\n"
2646 "\t 1 Common_Zone\n"
2647 "\t 2 Each_Radial_Element\n"
2649 "\t 4 Least_Material_Requirement\n"
2650 "\t 5 Line_Element\n"
2651 "\t 6 Major_Diameter\n"
2652 "\t 7 Maximum_Material_Requirement\n"
2653 "\t 8 Minor_Diameter\n"
2655 "\t 10 Pitch_Diameter\n"
2656 "\t 11 Reciprocity_Requirement\n"
2657 "\t 12 Separate_Requirement\n"
2658 "\t 13 Statistical_Tolerance\n"
2659 "\t 14 Tangent_Plane\n",
2660 __FILE__, addTolModif, g);
2662 di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label",
2663 __FILE__, getTolModif, g);
2665 di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val",
2666 __FILE__, setTolMaxVal, g);
2668 di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val",
2669 __FILE__, getTolMaxVal, g);
2671 di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type"
2673 "\t 0 type is absent\n"
2674 "\t 1 Location_CurvedDistance\n"
2675 "\t 2 Location_LinearDistance\n"
2676 "\t 3 Location_LinearDistance_FromCenterToOuter\n"
2677 "\t 4 Location_LinearDistance_FromCenterToInner\n"
2678 "\t 5 Location_LinearDistance_FromOuterToCenter\n"
2679 "\t 6 Location_LinearDistance_FromOuterToOuter\n"
2680 "\t 7 Location_LinearDistance_FromOuterToInner\n"
2681 "\t 8 Location_LinearDistance_FromInnerToCenter\n"
2682 "\t 9 Location_LinearDistance_FromInnerToOuter\n"
2683 "\t 10 Location_LinearDistance_FromInnerToInner\n"
2684 "\t 11 Location_Angular\n"
2685 "\t 12 Location_Oriented\n"
2686 "\t 13 Location_WithPath\n"
2687 "\t 14 Size_CurveLength\n"
2688 "\t 15 Size_Diameter\n"
2689 "\t 16 Size_SphericalDiameter\n"
2690 "\t 17 Size_Radius\n"
2691 "\t 18 Size_SphericalRadius\n"
2692 "\t 19 Size_ToroidalMinorDiameter\n"
2693 "\t 20 Size_ToroidalMajorDiameter\n"
2694 "\t 21 Size_ToroidalMinorRadius\n"
2695 "\t 22 Size_ToroidalMajorRadius\n"
2696 "\t 23 Size_ToroidalHighMajorDiameter\n"
2697 "\t 24 Size_ToroidalLowMajorDiameter\n"
2698 "\t 25 Size_ToroidalHighMajorRadius\n"
2699 "\t 26 Size_ToroidalLowMajorRadius\n"
2700 "\t 27 Size_Thickness\n"
2701 "\t 28 Size_Angular\n"
2702 "\t 29 Size_WithPath\n",
2703 __FILE__, setDimType, g);
2705 di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label",
2706 __FILE__, getDimType, g);
2708 di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val",
2709 __FILE__, setDimVal, g);
2711 di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label",
2712 __FILE__, getDimVal, g);
2714 di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val"
2720 __FILE__, setDimQalif, g);
2722 di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label",
2723 __FILE__, getDimQalif, g);
2725 di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val",
2726 __FILE__, setDimRange, g);
2728 di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label",
2729 __FILE__, getDimRange, g);
2731 di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val",
2732 __FILE__, setDimPlusMinusTol, g);
2734 di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label",
2735 __FILE__, getDimPlusMinusTol, g);
2737 di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade"
2738 "Values of formVar:"
2788 __FILE__, setDimClassTol, g);
2790 di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label",
2791 __FILE__, getDimClassTol, g);
2793 di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val",
2794 __FILE__, setDimNbOfDecimalPlaces, g);
2796 di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label",
2797 __FILE__, getDimNbOfDecimalPlaces, g);
2799 di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..."
2801 "\t 0 ControlledRadius\n"
2803 "\t 2 StatisticalTolerance\n"
2804 "\t 3 ContinuousFeature\n"
2805 "\t 4 TwoPointSize\n"
2806 "\t 5 LocalSizeDefinedBySphere\n"
2807 "\t 6 LeastSquaresAssociationCriterion\n"
2808 "\t 7 MaximumInscribedAssociation\n"
2809 "\t 8 MinimumCircumscribedAssociation\n"
2810 "\t 9 CircumferenceDiameter\n"
2811 "\t10 AreaDiameter\n"
2812 "\t11 VolumeDiameter\n"
2813 "\t12 MaximumSize\n"
2814 "\t13 MinimumSize\n"
2815 "\t14 AverageSize\n"
2817 "\t16 MidRangeSize\n"
2818 "\t17 RangeOfSizes\n"
2819 "\t18 AnyRestrictedPortionOfFeature\n"
2820 "\t19 AnyCrossSection\n"
2821 "\t20 SpecificFixedCrossSection\n"
2822 "\t21 CommonTolerance\n"
2823 "\t22 FreeStateCondition\n"
2825 __FILE__, addDimModifier, g);
2827 di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label",
2828 __FILE__, getDimModifier, g);
2830 di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)",
2831 __FILE__, addDimPath, g);
2833 di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 [v2]",
2834 __FILE__, addDimPoints, g);
2836 di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label",
2837 __FILE__, getDimPoints, g);
2839 di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z",
2840 __FILE__, addDimDir, g);
2842 di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label",
2843 __FILE__, getDimDir, g);
2845 di.Add ("XAddDimensionDescr","XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n"
2846 "Add named text description to given Dimension, if DescriptionName is missed"
2847 "name will be an empty string.",
2848 __FILE__, addDimDescr, g);
2850 di.Add ("XGetDimensionDescr","XGetDimensionDescr Doc Dim_Label\n"
2851 "Return all descriptions of given Dimension.",
2852 __FILE__, getDimDescr, g);
2854 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"
2855 "Set plane to display dimension parallel to and point to display text (loc)",
2856 __FILE__, addGDTPosition, g);
2858 di.Add ("XGetGDTPosition","XGetGDTPosition Doc GDT_Label"
2859 "Returns text position and plane, parallel to which dimension is displayed",
2860 __FILE__, getGDTPosition, g);
2862 di.Add ("XSetGDTPresentation","XSetGDTPresentation Doc GDT_Label Shape Name"
2863 "Set presentation with given name for dimension",
2864 __FILE__, addGDTPresentation, g);
2866 di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
2867 "Returns Presentation into Shape",
2868 __FILE__, getGDTPresentation, g);