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->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) {
434 else if (anObject->GetModifiers().Length() > 0) {
435 Standard_Boolean isHasModif = Standard_False;
436 for (Standard_Integer j = 1; j <= anObject->GetModifiers().Length(); j++)
437 if (anObject->GetModifiers().Value(j) != XCAFDimTolObjects_GeomToleranceModif_All_Around &&
438 anObject->GetModifiers().Value(j) != XCAFDimTolObjects_GeomToleranceModif_All_Over) {
439 isHasModif = Standard_True;
445 if (anObject->GetMaxValueModifier() != 0) {
448 TDF_LabelSequence aDatumSeq;
449 aDimTolTool->GetDatumWithObjectOfTolerLabels(aGDTs.Value(i), aDatumSeq);
450 if (aDatumSeq.Length() > 0) {
454 di << "\n NbOfGTWithModifiers : " << nbWithModif;
455 di << "\n NbOfGTWithMaxTolerance : " << nbWithMaxTol;
456 di << "\n NbOfGTWithDatums : " << nbWithDatumRef;
459 Standard_Integer aCounter = 0;
460 Standard_Integer aCounter1 = 0;
461 Standard_Integer aCounter2 = 0;
463 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
465 Standard_Boolean isDatum = Standard_False;
466 TDF_LabelSequence aDatL;
467 if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL))
469 for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++)
471 Handle(XCAFDoc_Datum) aDat;
472 if(aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat))
474 if(aDat->GetObject()->IsDatumTarget())
481 isDatum = Standard_True;
489 di << "\n NbOfDatumFeature : " << aCounter;
490 di << "\n NbOfAttachedDatum : " << aCounter2;
491 di << "\n NbOfDatumTarget : " << aCounter1;
496 static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
499 di<<"Use: XAddDimension Doc shape/label [shape/label]\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 TopoDS_Shape aShape= DBRep::Get(argv[2]);
513 if ( !aShape.IsNull() )
515 aShapeTool->Search(aShape, aLabel);
516 if ( aLabel.IsNull() )
518 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
526 TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1);
527 if ( aLabel1.IsNull() )
529 TopoDS_Shape aShape= DBRep::Get(argv[3]);
530 if ( !aShape.IsNull() )
532 aShapeTool->Search(aShape, aLabel1);
533 if ( aLabel1.IsNull() )
535 di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
542 TDF_Label aDimL = aDimTolTool->AddDimension();
544 aDimTolTool->SetDimension(aLabel, aDimL);
546 aDimTolTool->SetDimension(aLabel, aLabel1, aDimL);
547 TCollection_AsciiString Entry;
548 TDF_Tool::Entry(aDimL, Entry);
553 static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
556 di<<"Use: XAddGeomTolerance Doc shape/label\n";
559 Handle(TDocStd_Document) Doc;
560 DDocStd::GetDocument(argv[1], Doc);
561 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
562 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
563 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
566 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
567 if ( aLabel.IsNull() )
569 TopoDS_Shape aShape= DBRep::Get(argv[2]);
570 if ( !aShape.IsNull() )
572 aShapeTool->Search(aShape, aLabel);
573 if ( aLabel.IsNull() )
575 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
581 TDF_Label aTolL = aDimTolTool->AddGeomTolerance();
582 aDimTolTool->SetGeomTolerance(aLabel, aTolL);
583 TCollection_AsciiString Entry;
584 TDF_Tool::Entry(aTolL, Entry);
589 static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
592 di<<"Use: XAddDatum Doc shape1/label1 ... shapeN/labelN\n";
595 Handle(TDocStd_Document) Doc;
596 DDocStd::GetDocument(argv[1], Doc);
597 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
598 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
599 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
601 TDF_LabelSequence aLabelSeq;
602 for (Standard_Integer i = 2; i < argc; i++) {
604 TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
605 if (aLabel.IsNull()) {
606 TopoDS_Shape aShape = DBRep::Get(argv[i]);
607 if (!aShape.IsNull())
608 aShapeTool->Search(aShape, aLabel);
612 aLabelSeq.Append(aLabel);
615 TDF_Label aDatumL = aDimTolTool->AddDatum();
616 aDimTolTool->SetDatum(aLabelSeq, aDatumL);
617 TCollection_AsciiString Entry;
618 TDF_Tool::Entry(aDatumL, Entry);
623 static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
626 di<<"Use: XSetDatum Doc Datum_Label GeomTol_Label\n";
629 Handle(TDocStd_Document) Doc;
630 DDocStd::GetDocument(argv[1], Doc);
631 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
632 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
633 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
636 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
637 if ( aLabel.IsNull() )
639 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
644 TDF_Tool::Label(Doc->GetData(), argv[3], aTol);
647 di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
651 // check datum position number
652 Handle(XCAFDoc_Datum) aDatumAttr;
653 if (!aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr))
655 di<<"Invalid datum object\n";
658 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
659 if (aDatumObj.IsNull())
661 di<<"Invalid datum object\n";
665 if (aDatumObj->GetPosition() < 1 || aDatumObj->GetPosition() > 3)
667 di<<"Invalid datum position number: use XSetDatumPosition\n";
671 aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
675 static Standard_Integer setDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
678 di<<"Use: XSetDatumPosition Doc Datum_Label position[1-3]\n";
682 if (Draw::Atoi(argv[3]) < 1 || Draw::Atoi(argv[3]) > 3) {
683 di<<"Datum position should be 1, 2 or 3\n";
687 Handle(TDocStd_Document) Doc;
688 DDocStd::GetDocument(argv[1], Doc);
689 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
690 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
691 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
694 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
695 if ( aLabel.IsNull() )
697 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
700 Handle(XCAFDoc_Datum) aDatum;
701 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
703 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
704 anObj->SetPosition(Draw::Atoi(argv[3]));
705 aDatum->SetObject(anObj);
710 static Standard_Integer getDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
713 di<<"Use: XGetDatumPosition Doc Datum_Label\n";
716 Handle(TDocStd_Document) Doc;
717 DDocStd::GetDocument(argv[1], Doc);
718 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
719 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
720 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
723 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
724 if ( aLabel.IsNull() )
726 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
729 Handle(XCAFDoc_Datum) aDatum;
730 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
732 di << aDatum->GetObject()->GetPosition();
738 static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
741 di<<"Use: XGetDatum Doc GeomTol_Label/Shape_Label\n";
744 Handle(TDocStd_Document) Doc;
745 DDocStd::GetDocument(argv[1], Doc);
746 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
747 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
748 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
751 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
752 if ( aLabel.IsNull() )
754 di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
758 TDF_LabelSequence aD;
759 if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
761 aDimTolTool->GetDatumOfTolerLabels(aLabel, aD);
763 for(Standard_Integer i = aD.Lower(); i <= aD.Upper(); i++)
766 TCollection_AsciiString Entry;
767 TDF_Tool::Entry(aD.Value(i), Entry);
773 static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
776 di<<"Use: XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n";
779 Handle(TDocStd_Document) Doc;
780 DDocStd::GetDocument(argv[1], Doc);
781 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
782 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
783 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
786 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
787 if ( aLabel.IsNull() )
789 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
792 Handle(XCAFDoc_Datum) aDatum;
793 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
795 for(Standard_Integer i = 3; i < argc; i++)
797 if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1)
799 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
800 anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i]));
801 aDatum->SetObject(anObj);
808 static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
811 di<<"Use: XGetDatumModifiers Doc Datum_Label\n";
814 Handle(TDocStd_Document) Doc;
815 DDocStd::GetDocument(argv[1], Doc);
816 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
817 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
818 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
821 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
822 if ( aLabel.IsNull() )
824 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
827 Handle(XCAFDoc_Datum) aDatum;
828 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
830 XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers();
831 for(Standard_Integer i = 1; i<=aS.Length();i++)
835 case 0 : di<<"AnyCrossSection"; break;
836 case 1 : di<<"AnyLongitudinalSection"; break;
837 case 2 : di<<"Basic"; break;
838 case 3 : di<<"ContactingFeature\n"; break;
839 case 4 : di<<"DegreeOfFreedomConstraintU"; break;
840 case 5 : di<<"DegreeOfFreedomConstraintV"; break;
841 case 6 : di<<"DegreeOfFreedomConstraintW"; break;
842 case 7 : di<<"DegreeOfFreedomConstraintX"; break;
843 case 8 : di<<"DegreeOfFreedomConstraintY"; break;
844 case 9 : di<<"DegreeOfFreedomConstraintZ"; break;
845 case 10 : di<<"DistanceVariable"; break;
846 case 11 : di<<"FreeState"; break;
847 case 12 : di<<"LeastMaterialRequirement"; break;
848 case 13 : di<<"Line"; break;
849 case 14 : di<<"MajorDiameter"; break;
850 case 15 : di<<"MaximumMaterialRequirement"; break;
851 case 16 : di<<"MinorDiameter"; break;
852 case 17 : di<<"Orientation"; break;
853 case 18 : di<<"PitchDiameter"; break;
854 case 19 : di<<"Plane"; break;
855 case 20 : di<<"Point"; break;
856 case 21 : di<<"Translation"; break;
864 static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
867 di<<"Use: XSetDatumName Doc Datum_Label name\n";
870 Handle(TDocStd_Document) Doc;
871 DDocStd::GetDocument(argv[1], Doc);
872 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
873 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
874 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
877 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
878 if ( aLabel.IsNull() )
880 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
883 Handle(XCAFDoc_Datum) aDatum;
884 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
886 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
887 anObj->SetName(new TCollection_HAsciiString(argv[3]));
888 aDatum->SetObject(anObj);
893 static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
896 di<<"Use: XGetDatumName Doc Datum_Label\n";
899 Handle(TDocStd_Document) Doc;
900 DDocStd::GetDocument(argv[1], Doc);
901 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
902 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
903 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
906 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
907 if ( aLabel.IsNull() )
909 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
912 Handle(XCAFDoc_Datum) aDatum;
913 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
915 di<<aDatum->GetObject()->GetName()->ToCString();
920 static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
923 di<<"Use: XSetTypeOfTolerance Doc GTol_Label type\n";
926 Handle(TDocStd_Document) Doc;
927 DDocStd::GetDocument(argv[1], Doc);
928 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
929 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
930 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
933 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
934 if ( aLabel.IsNull() )
936 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
939 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
940 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
942 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16)
944 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
945 anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3]));
946 aGeomTolerance->SetObject(anObj);
952 static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
955 di<<"Use: XGetTypeOfTolerance Doc GTol_Label\n";
958 Handle(TDocStd_Document) Doc;
959 DDocStd::GetDocument(argv[1], Doc);
960 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
961 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
962 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
965 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
966 if ( aLabel.IsNull() )
968 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
971 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
972 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
974 switch(aGeomTolerance->GetObject()->GetType()){
975 case 0 : di<<"type is absent"; break;
976 case 1 : di<<"Angularity"; break;
977 case 2 : di<<"CircularRunout"; break;
978 case 3 : di<<"CircularityOrRoundness"; break;
979 case 4 : di<<"Coaxiality"; break;
980 case 5 : di<<"Concentricity"; break;
981 case 6 : di<<"Cylindricity"; break;
982 case 7 : di<<"Flatness"; break;
983 case 8 : di<<"Parallelism"; break;
984 case 9 : di<<"Perpendicularity"; break;
985 case 10 : di<<"Position"; break;
986 case 11 : di<<"ProfileOfLine"; break;
987 case 12 : di<<"ProfileOfSurface"; break;
988 case 13 : di<<"Straightness"; break;
989 case 14 : di<<"Symmetry"; break;
990 case 15 : di<<"TotalRunout"; break;
997 static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1000 di<<"Use: XSetTypeOfToleranceValue Doc GTol_Label type\n";
1003 Handle(TDocStd_Document) Doc;
1004 DDocStd::GetDocument(argv[1], Doc);
1005 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1006 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1007 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1010 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1011 if ( aLabel.IsNull() )
1013 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1016 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1017 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1019 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1021 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1022 anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3]));
1023 aGeomTolerance->SetObject(anObj);
1029 static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1032 di<<"Use: XGetTypeOfToleranceValue Doc GTol_Label\n";
1035 Handle(TDocStd_Document) Doc;
1036 DDocStd::GetDocument(argv[1], Doc);
1037 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1038 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1039 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1042 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1043 if ( aLabel.IsNull() )
1045 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1048 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1049 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1051 switch(aGeomTolerance->GetObject()->GetTypeOfValue()){
1052 case 0 : di<<"type is absent"; break;
1053 case 1 : di<<"Diameter"; break;
1054 case 2 : di<<"SphericalDiameter"; break;
1061 static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1064 di<<"Use: XSetToleranceValue Doc GTol_Label value\n";
1067 Handle(TDocStd_Document) Doc;
1068 DDocStd::GetDocument(argv[1], Doc);
1069 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1070 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1071 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1074 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1075 if ( aLabel.IsNull() )
1077 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1080 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1081 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1083 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1084 anObj->SetValue(Draw::Atof(argv[3]));
1085 aGeomTolerance->SetObject(anObj);
1090 static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1093 di<<"Use: XGetToleranceValue Doc GTol_Label\n";
1096 Handle(TDocStd_Document) Doc;
1097 DDocStd::GetDocument(argv[1], Doc);
1098 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1099 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1100 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1103 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1104 if ( aLabel.IsNull() )
1106 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1109 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1110 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1112 di << aGeomTolerance->GetObject()->GetValue();
1117 static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1120 di<<"Use: XSetTolMaterialReq Doc GTol_Label mod\n";
1123 Handle(TDocStd_Document) Doc;
1124 DDocStd::GetDocument(argv[1], Doc);
1125 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1126 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1127 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1130 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1131 if ( aLabel.IsNull() )
1133 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1136 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1137 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1139 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1141 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1142 anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3]));
1143 aGeomTolerance->SetObject(anObj);
1149 static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1152 di<<"Use: XGetTolMaterialReq Doc GTol_Label\n";
1155 Handle(TDocStd_Document) Doc;
1156 DDocStd::GetDocument(argv[1], Doc);
1157 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1158 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1159 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1162 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1163 if ( aLabel.IsNull() )
1165 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1168 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1169 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1171 switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){
1172 case 0 : di<<"modifier is absent"; break;
1173 case 1 : di<<"M"; break;
1174 case 2 : di<<"L"; break;
1181 static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1184 di<<"Use: XSetTolZoneMod Doc GTol_Label mod\n";
1187 Handle(TDocStd_Document) Doc;
1188 DDocStd::GetDocument(argv[1], Doc);
1189 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1190 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1191 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1194 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1195 if ( aLabel.IsNull() )
1197 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1200 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1201 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1203 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1205 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1206 anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3]));
1207 aGeomTolerance->SetObject(anObj);
1213 static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1216 di<<"Use: XGetTolZoneMod Doc GTol_Label\n";
1219 Handle(TDocStd_Document) Doc;
1220 DDocStd::GetDocument(argv[1], Doc);
1221 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1222 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1223 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1226 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1227 if ( aLabel.IsNull() )
1229 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1232 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1233 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1235 switch(aGeomTolerance->GetObject()->GetZoneModifier()){
1236 case 0 : di<<"modifier is absent"; break;
1237 case 1 : di<<"P"; break;
1238 case 2 : di<<"NonUniform"; break;
1245 static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1248 di<<"Use: XSetTolZoneModValue Doc GTol_Label val\n";
1251 Handle(TDocStd_Document) Doc;
1252 DDocStd::GetDocument(argv[1], Doc);
1253 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1254 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1255 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1258 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1259 if ( aLabel.IsNull() )
1261 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1264 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1265 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1267 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1268 anObj->SetValueOfZoneModifier(Draw::Atof(argv[3]));
1269 aGeomTolerance->SetObject(anObj);
1274 static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1277 di<<"Use: XGetTolZoneModValue Doc GTol_Label\n";
1280 Handle(TDocStd_Document) Doc;
1281 DDocStd::GetDocument(argv[1], Doc);
1282 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1283 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1284 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1287 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1288 if ( aLabel.IsNull() )
1290 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1293 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1294 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1296 di << aGeomTolerance->GetObject()->GetValueOfZoneModifier();
1301 static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1304 di<<"Use: XAddTolModifier Doc Tol_Label mod1 mod2 ...\n";
1307 Handle(TDocStd_Document) Doc;
1308 DDocStd::GetDocument(argv[1], Doc);
1309 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1310 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1311 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1314 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1315 if ( aLabel.IsNull() )
1317 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1320 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1321 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1323 for(Standard_Integer i = 3; i < argc; i++)
1325 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 17)
1327 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1328 anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i]));
1329 aGeomTolerance->SetObject(anObj);
1336 static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1339 di<<"Use: XGetTolModifiers Doc Tol_Label\n";
1342 Handle(TDocStd_Document) Doc;
1343 DDocStd::GetDocument(argv[1], Doc);
1344 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1345 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1346 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1349 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1350 if ( aLabel.IsNull() )
1352 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1355 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1356 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1358 XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers();
1359 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1361 if (i > 1) di<<", ";
1362 switch(aS.Value(i)){
1363 case 0 : di<<"Any_Cross_Section"; break;
1364 case 1 : di<<"Common_Zone"; break;
1365 case 2 : di<<"Each_Radial_Element"; break;
1366 case 3 : di<<"Free_State"; break;
1367 case 4 : di<<"Least_Material_Requirement"; break;
1368 case 5 : di<<"Line_Element"; break;
1369 case 6 : di<<"Major_Diameter"; break;
1370 case 7 : di<<"Maximum_Material_Requirement"; break;
1371 case 8 : di<<"Minor_Diameter"; break;
1372 case 9 : di<<"Not_Convex"; break;
1373 case 10 : di<<"Pitch_Diameter"; break;
1374 case 11 : di<<"Reciprocity_Requirement"; break;
1375 case 12 : di<<"Separate_Requirement"; break;
1376 case 13 : di<<"Statistical_Tolerance"; break;
1377 case 14 : di<<"Tangent_Plane"; break;
1385 static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1388 di<<"Use: XSetTolMaxValue Doc Dim_Label val\n";
1391 Handle(TDocStd_Document) Doc;
1392 DDocStd::GetDocument(argv[1], Doc);
1393 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1394 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1395 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1398 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1399 if ( aLabel.IsNull() )
1401 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1404 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1405 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1407 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1408 anObj->SetMaxValueModifier(Draw::Atof(argv[3]));
1409 aGeomTolerance->SetObject(anObj);
1414 static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1417 di<<"Use: XGetTolMaxValue Doc Dim_Label\n";
1420 Handle(TDocStd_Document) Doc;
1421 DDocStd::GetDocument(argv[1], Doc);
1422 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1423 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1424 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1427 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1428 if ( aLabel.IsNull() )
1430 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1433 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1434 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1436 di << aGeomTolerance->GetObject()->GetMaxValueModifier();
1441 static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1444 di<<"Use: XSetDimensionType Doc Dim_Label type\n";
1447 Handle(TDocStd_Document) Doc;
1448 DDocStd::GetDocument(argv[1], Doc);
1449 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1450 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1451 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1454 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1455 if ( aLabel.IsNull() )
1457 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1460 Handle(XCAFDoc_Dimension) aDimension;
1461 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1463 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30)
1465 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1466 anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3]));
1467 aDimension->SetObject(anObj);
1473 static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1476 di<<"Use: XGetDimensionType Doc Dim_Label\n";
1479 Handle(TDocStd_Document) Doc;
1480 DDocStd::GetDocument(argv[1], Doc);
1481 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1482 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1483 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1486 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1487 if ( aLabel.IsNull() )
1489 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1492 Handle(XCAFDoc_Dimension) aDimension;
1493 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1495 switch(aDimension->GetObject()->GetType()){
1496 case 0 : di<<"type is absent"; break;
1497 case 1 : di<<"Location_CurvedDistance"; break;
1498 case 2 : di<<"Location_LinearDistance"; break;
1499 case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break;
1500 case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break;
1501 case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break;
1502 case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break;
1503 case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break;
1504 case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break;
1505 case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break;
1506 case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break;
1507 case 11 : di<<"Location_Angular"; break;
1508 case 12 : di<<"Location_Oriented"; break;
1509 case 13 : di<<"Location_WithPath"; break;
1510 case 14 : di<<"Size_CurveLength"; break;
1511 case 15 : di<<"Size_Diameter"; break;
1512 case 16 : di<<"Size_SphericalDiameter"; break;
1513 case 17 : di<<"Size_Radius"; break;
1514 case 18 : di<<"Size_SphericalRadius"; break;
1515 case 19 : di<<"Size_ToroidalMinorDiameter"; break;
1516 case 20 : di<<"Size_ToroidalMajorDiameter"; break;
1517 case 21 : di<<"Size_ToroidalMinorRadius"; break;
1518 case 22 : di<<"Size_ToroidalMajorRadius"; break;
1519 case 23 : di<<"Size_ToroidalHighMajorDiameter"; break;
1520 case 24 : di<<"Size_ToroidalLowMajorDiameter"; break;
1521 case 25 : di<<"Size_ToroidalHighMajorRadius"; break;
1522 case 26 : di<<"Size_ToroidalLowMajorRadius"; break;
1523 case 27 : di<<"Size_Thickness"; break;
1524 case 28 : di<<"Size_Angular"; break;
1525 case 29 : di<<"Size_WithPath"; break;
1532 static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1535 di<<"Use: XSetDimensionValue Doc Dim_Label val\n";
1538 Handle(TDocStd_Document) Doc;
1539 DDocStd::GetDocument(argv[1], Doc);
1540 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1541 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1542 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1545 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1546 if ( aLabel.IsNull() )
1548 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1551 Handle(XCAFDoc_Dimension) aDimension;
1552 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1554 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1555 anObj->SetValue(Draw::Atof(argv[3]));
1556 aDimension->SetObject(anObj);
1561 static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1564 di<<"Use: XGetDimensionValue Doc Dim_Label\n";
1567 Handle(TDocStd_Document) Doc;
1568 DDocStd::GetDocument(argv[1], Doc);
1569 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1570 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1571 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1574 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1575 if ( aLabel.IsNull() )
1577 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1580 Handle(XCAFDoc_Dimension) aDimension;
1581 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1583 di << aDimension->GetObject()->GetValue();
1588 static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1591 di<<"Use: XSetDimensionQualifier Doc Dim_Label val\n";
1594 Handle(TDocStd_Document) Doc;
1595 DDocStd::GetDocument(argv[1], Doc);
1596 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1597 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1598 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1601 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1602 if ( aLabel.IsNull() )
1604 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1607 Handle(XCAFDoc_Dimension) aDimension;
1608 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1610 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4)
1612 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1613 anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3]));
1614 aDimension->SetObject(anObj);
1620 static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1623 di<<"Use: XGetDimensionQualifier Doc Dim_Label\n";
1626 Handle(TDocStd_Document) Doc;
1627 DDocStd::GetDocument(argv[1], Doc);
1628 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1629 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1630 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1633 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1634 if ( aLabel.IsNull() )
1636 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1639 Handle(XCAFDoc_Dimension) aDimension;
1640 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1643 switch(aDimension->GetObject()->GetQualifier()){
1644 case 0 : di<<"type is absent"; break;
1645 case 1 : di<<"Min"; break;
1646 case 2 : di<<"Max"; break;
1647 case 3 : di<<"Avg"; break;
1654 static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1657 di<<"Use: XSetDimensionRange Doc Dim_Label low_val up_val\n";
1660 Handle(TDocStd_Document) Doc;
1661 DDocStd::GetDocument(argv[1], Doc);
1662 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1663 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1664 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1667 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1668 if ( aLabel.IsNull() )
1670 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1673 Handle(XCAFDoc_Dimension) aDimension;
1674 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1676 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1678 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1679 anObj->SetLowerBound(Draw::Atof(argv[3]));
1680 anObj->SetUpperBound(Draw::Atof(argv[4]));
1681 aDimension->SetObject(anObj);
1687 static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1690 di<<"Use: XGetDimensionRange Doc Dim_Label\n";
1693 Handle(TDocStd_Document) Doc;
1694 DDocStd::GetDocument(argv[1], Doc);
1695 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1696 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1697 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1700 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1701 if ( aLabel.IsNull() )
1703 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1706 Handle(XCAFDoc_Dimension) aDimension;
1707 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1709 di << "lower " << aDimension->GetObject()->GetLowerBound();
1710 di << " upper " << aDimension->GetObject()->GetUpperBound();
1715 static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1718 di<<"Use: XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n";
1721 Handle(TDocStd_Document) Doc;
1722 DDocStd::GetDocument(argv[1], Doc);
1723 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1724 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1725 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1728 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1729 if ( aLabel.IsNull() )
1731 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1734 Handle(XCAFDoc_Dimension) aDimension;
1735 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1737 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1739 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1740 anObj->SetLowerTolValue(Draw::Atof(argv[3]));
1741 anObj->SetUpperTolValue(Draw::Atof(argv[4]));
1742 aDimension->SetObject(anObj);
1748 static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1751 di<<"Use: XGetDimensionPlusMinusTol Doc Dim_Label\n";
1754 Handle(TDocStd_Document) Doc;
1755 DDocStd::GetDocument(argv[1], Doc);
1756 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1757 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1758 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1761 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1762 if ( aLabel.IsNull() )
1764 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1767 Handle(XCAFDoc_Dimension) aDimension;
1768 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1770 di << "lower " << aDimension->GetObject()->GetLowerTolValue();
1771 di << " upper " << aDimension->GetObject()->GetUpperTolValue();
1776 static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1779 di<<"Use: XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n";
1782 Handle(TDocStd_Document) Doc;
1783 DDocStd::GetDocument(argv[1], Doc);
1784 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1785 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1786 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1789 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1790 if ( aLabel.IsNull() )
1792 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1795 Handle(XCAFDoc_Dimension) aDimension;
1796 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1798 if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20)
1800 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1801 anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5]));
1802 aDimension->SetObject(anObj);
1808 static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1811 di<<"Use: XGetDimensionClassOfTol Doc Dim_Label\n";
1814 Handle(TDocStd_Document) Doc;
1815 DDocStd::GetDocument(argv[1], Doc);
1816 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1817 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1818 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1821 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1822 if ( aLabel.IsNull() )
1824 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1827 Handle(XCAFDoc_Dimension) aDimension;
1828 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1831 XCAFDimTolObjects_DimensionFormVariance f;
1832 XCAFDimTolObjects_DimensionGrade g;
1833 if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g))
1838 case 1 : di<<"a";break;
1839 case 2 : di<<"b";break;
1840 case 3 : di<<"c";break;
1841 case 4 : di<<"cd";break;
1842 case 5 : di<<"d";break;
1843 case 6 : di<<"e";break;
1844 case 7 : di<<"ef";break;
1845 case 8 : di<<"f";break;
1846 case 9 : di<<"fg";break;
1847 case 10 : di<<"g";break;
1848 case 11 : di<<"h";break;
1849 case 12 : di<<"js";break;
1850 case 13 : di<<"j";break;
1851 case 14 : di<<"k";break;
1852 case 15 : di<<"m";break;
1853 case 16 : di<<"n";break;
1854 case 17 : di<<"p";break;
1855 case 18 : di<<"r";break;
1856 case 19 : di<<"s";break;
1857 case 20 : di<<"t";break;
1858 case 21 : di<<"u";break;
1859 case 22 : di<<"v";break;
1860 case 23 : di<<"x";break;
1861 case 24 : di<<"y";break;
1862 case 25 : di<<"z";break;
1863 case 26 : di<<"a";break;
1864 case 27 : di<<"zb";break;
1865 case 28 : di<<"zc";break;
1872 case 1 : di<<"A";break;
1873 case 2 : di<<"B";break;
1874 case 3 : di<<"C";break;
1875 case 4 : di<<"CD";break;
1876 case 5 : di<<"D";break;
1877 case 6 : di<<"E";break;
1878 case 7 : di<<"EF";break;
1879 case 8 : di<<"F";break;
1880 case 9 : di<<"FG";break;
1881 case 10 : di<<"G";break;
1882 case 11 : di<<"H";break;
1883 case 12 : di<<"JS";break;
1884 case 13 : di<<"J";break;
1885 case 14 : di<<"K";break;
1886 case 15 : di<<"M";break;
1887 case 16 : di<<"N";break;
1888 case 17 : di<<"P";break;
1889 case 18 : di<<"R";break;
1890 case 19 : di<<"S";break;
1891 case 20 : di<<"T";break;
1892 case 21 : di<<"U";break;
1893 case 22 : di<<"V";break;
1894 case 23 : di<<"X";break;
1895 case 24 : di<<"Y";break;
1896 case 25 : di<<"Z";break;
1897 case 26 : di<<"ZA";break;
1898 case 27 : di<<"ZB";break;
1899 case 28 : di<<"ZC";break;
1904 case 0 : di<<"01"; break;
1905 case 1 : di<<"0"; break;
1906 case 2 : di<<"1"; break;
1907 case 3 : di<<"2"; break;
1908 case 4 : di<<"3"; break;
1909 case 5 : di<<"4"; break;
1910 case 6 : di<<"5"; break;
1911 case 7 : di<<"6"; break;
1912 case 8 : di<<"7"; break;
1913 case 9 : di<<"8"; break;
1914 case 10 : di<<"9"; break;
1915 case 11 : di<<"10"; break;
1916 case 12 : di<<"11"; break;
1917 case 13 : di<<"12"; break;
1918 case 14 : di<<"13"; break;
1919 case 15 : di<<"14"; break;
1920 case 16 : di<<"15"; break;
1921 case 17 : di<<"16"; break;
1922 case 18 : di<<"17"; break;
1923 case 19 : di<<"18"; break;
1931 static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1934 di<<"Use: XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n";
1937 Handle(TDocStd_Document) Doc;
1938 DDocStd::GetDocument(argv[1], Doc);
1939 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1940 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1941 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1944 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1945 if ( aLabel.IsNull() )
1947 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1950 Handle(XCAFDoc_Dimension) aDimension;
1951 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1953 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1954 anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4]));
1955 aDimension->SetObject(anObj);
1960 static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1963 di<<"Use: XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n";
1966 Handle(TDocStd_Document) Doc;
1967 DDocStd::GetDocument(argv[1], Doc);
1968 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1969 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1970 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1973 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1974 if ( aLabel.IsNull() )
1976 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1979 Handle(XCAFDoc_Dimension) aDimension;
1980 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1982 Standard_Integer l, r;
1983 aDimension->GetObject()->GetNbOfDecimalPlaces(l,r);
1984 di << l << "." << r;
1989 static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1992 di<<"Use: XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n";
1995 Handle(TDocStd_Document) Doc;
1996 DDocStd::GetDocument(argv[1], Doc);
1997 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1998 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1999 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2002 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2003 if ( aLabel.IsNull() )
2005 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2008 Handle(XCAFDoc_Dimension) aDimension;
2009 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2011 for(Standard_Integer i = 3; i < argc; i++)
2013 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24)
2015 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2016 anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i]));
2017 aDimension->SetObject(anObj);
2024 static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2027 di<<"Use: XGetDimensionModifiers Doc Dim_Label\n";
2030 Handle(TDocStd_Document) Doc;
2031 DDocStd::GetDocument(argv[1], Doc);
2032 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2033 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2034 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2037 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2038 if ( aLabel.IsNull() )
2040 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2043 Handle(XCAFDoc_Dimension) aDimension;
2044 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2046 XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers();
2047 for(Standard_Integer i = 1; i <= aS.Length(); i++)
2049 if (i > 1) di<<", ";
2050 switch(aS.Value(i)){
2051 case 0 : di<<"ControlledRadius"; break;
2052 case 1 : di<<"Square"; break;
2053 case 2 : di<<"StatisticalTolerance"; break;
2054 case 3 : di<<"ContinuousFeature"; break;
2055 case 4 : di<<"TwoPointSize"; break;
2056 case 5 : di<<"LocalSizeDefinedBySphere"; break;
2057 case 6 : di<<"LeastSquaresAssociationCriterion"; break;
2058 case 7 : di<<"MaximumInscribedAssociation"; break;
2059 case 8 : di<<"MinimumCircumscribedAssociation"; break;
2060 case 9 : di<<"CircumferenceDiameter"; break;
2061 case 10 : di<<"AreaDiameter"; break;
2062 case 11 : di<<"VolumeDiameter"; break;
2063 case 12 : di<<"MaximumSize"; break;
2064 case 13 : di<<"MinimumSize"; break;
2065 case 14 : di<<"AverageSize"; break;
2066 case 15 : di<<"MedianSize"; break;
2067 case 16 : di<<"MidRangeSize"; break;
2068 case 17 : di<<"RangeOfSizes"; break;
2069 case 18 : di<<"AnyRestrictedPortionOfFeature"; break;
2070 case 19 : di<<"AnyCrossSection"; break;
2071 case 20 : di<<"SpecificFixedCrossSection"; break;
2072 case 21 : di<<"CommonTolerance"; break;
2073 case 22 : di<<"FreeStateCondition"; break;
2074 case 23 : di<<"Between"; break;
2082 static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2085 di<<"Use: XSetDimensionPath Doc Dim_Label path(edge)\n";
2088 Handle(TDocStd_Document) Doc;
2089 DDocStd::GetDocument(argv[1], Doc);
2090 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2091 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2092 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2095 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2096 if ( aLabel.IsNull() )
2098 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2101 Handle(XCAFDoc_Dimension) aDimension;
2102 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2104 TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE));
2107 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2109 aDimension->SetObject(anObj);
2115 static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2118 di<<"Use: XSetDimensionPoints Doc Dim_Label v1 [v2]\n";
2121 Handle(TDocStd_Document) Doc;
2122 DDocStd::GetDocument(argv[1], Doc);
2123 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2124 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2125 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2128 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2129 if ( aLabel.IsNull() )
2131 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2134 Handle(XCAFDoc_Dimension) aDimension;
2135 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2137 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2139 TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX));
2141 anObj->SetPoint(BRep_Tool::Pnt(aV1));
2144 TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX));
2146 anObj->SetPoint2(BRep_Tool::Pnt(aV2));
2149 aDimension->SetObject(anObj);
2154 static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2157 di<<"Use: XGetDimensionPoints Doc Dim_Label\n";
2160 Handle(TDocStd_Document) Doc;
2161 DDocStd::GetDocument(argv[1], Doc);
2162 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2163 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2164 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2167 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2168 if ( aLabel.IsNull() )
2170 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2173 Handle(XCAFDoc_Dimension) aDimension;
2174 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2176 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2177 if(anObj->HasPoint()) {
2178 di << anObj->GetPoint().X() << ";" << anObj->GetPoint().Y() << ";" << anObj->GetPoint().Z() << " ";
2180 if(anObj->HasPoint2()) {
2181 di << anObj->GetPoint2().X() << ";" << anObj->GetPoint2().Y() << ";" << anObj->GetPoint2().Z();
2187 static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2190 di<<"Use: XSetDimensionDir Doc Dim_Label x y z\n";
2193 Handle(TDocStd_Document) Doc;
2194 DDocStd::GetDocument(argv[1], Doc);
2195 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2196 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2197 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2200 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2201 if ( aLabel.IsNull() )
2203 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2206 Handle(XCAFDoc_Dimension) aDimension;
2207 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2209 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2210 anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5])));
2211 aDimension->SetObject(anObj);
2216 static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2219 di<<"Use: XGetDimensionDir Doc Dim_Label\n";
2222 Handle(TDocStd_Document) Doc;
2223 DDocStd::GetDocument(argv[1], Doc);
2224 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2225 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2226 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2229 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2230 if ( aLabel.IsNull() )
2232 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2235 Handle(XCAFDoc_Dimension) aDimension;
2236 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2239 if(aDimension->GetObject()->GetDirection(dir))
2241 di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z();
2247 static Standard_Integer addDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2250 di<<"Use: XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n";
2253 Handle(TDocStd_Document) Doc;
2254 DDocStd::GetDocument(argv[1], Doc);
2255 if ( Doc.IsNull() ) {
2256 di << argv[1] << " is not a document\n";
2261 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2262 if ( aLabel.IsNull() )
2264 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2267 Handle(XCAFDoc_Dimension) aDimension;
2268 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2270 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2271 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(argv[3]);
2272 Handle(TCollection_HAsciiString) aDescrName = (argc == 4) ? new TCollection_HAsciiString()
2273 : new TCollection_HAsciiString(argv[4]);
2274 anObj->AddDescription(aDescription, aDescrName);
2275 aDimension->SetObject(anObj);
2280 static Standard_Integer getDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2283 di << "Use: XGetDimensionDescr Doc Dim_Label\n";
2286 Handle(TDocStd_Document) Doc;
2287 DDocStd::GetDocument(argv[1], Doc);
2288 if ( Doc.IsNull() ) {
2289 di << argv[1] << " is not a document\n";
2294 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2295 if ( aLabel.IsNull() )
2297 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2300 Handle(XCAFDoc_Dimension) aDimension;
2301 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2303 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimension->GetObject();
2304 for (Standard_Integer i = 0; i < anObject->NbDescriptions(); i++) {
2305 Handle(TCollection_HAsciiString) aDescription = anObject->GetDescription(i);
2306 Handle(TCollection_HAsciiString) aDescrName = anObject->GetDescriptionName(i);
2307 di << "name: " << aDescrName->ToCString() << " description: " << aDescription->ToCString() << "\n";
2313 static Standard_Integer addGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2316 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";
2319 Handle(TDocStd_Document) Doc;
2320 DDocStd::GetDocument(argv[1], Doc);
2321 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2324 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2325 if ( aLabel.IsNull() )
2327 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2331 gp_Pnt aPoint(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]));
2332 gp_Dir aNormal(Draw::Atof(argv[6]), Draw::Atof(argv[7]), Draw::Atof(argv[8]));
2333 gp_Dir aDir(Draw::Atof(argv[9]), Draw::Atof(argv[10]), Draw::Atof(argv[11]));
2334 gp_Ax2 aPlane(aPoint, aNormal, aDir);
2336 Handle(XCAFDoc_Dimension) aDimension;
2337 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2339 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2340 anObj->SetPlane(aPlane);
2341 anObj->SetPointTextAttach(aPoint);
2342 aDimension->SetObject(anObj);
2344 // Geometric Tolerance
2345 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2346 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2348 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2349 anObj->SetPlane(aPlane);
2350 anObj->SetPointTextAttach(aPoint);
2351 aGeomTolerance->SetObject(anObj);
2354 Handle(XCAFDoc_Datum) aDatum;
2355 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2357 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2358 anObj->SetPlane(aPlane);
2359 anObj->SetPointTextAttach(aPoint);
2360 aDatum->SetObject(anObj);
2365 static Standard_Integer getGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2368 di << "Use: XGetGDTPosition Doc GDT_Label\n";
2371 Handle(TDocStd_Document) Doc;
2372 DDocStd::GetDocument(argv[1], Doc);
2373 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2376 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2377 if ( aLabel.IsNull() )
2379 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2383 gp_Dir aNormal, aDir;
2385 Handle(XCAFDoc_Dimension) aDimension;
2386 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2388 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2389 aPoint = anObj->GetPointTextAttach();
2390 aNormal = anObj->GetPlane().Direction();
2391 aDir = anObj->GetPlane().XDirection();
2393 // Geometric Tolerance
2394 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2395 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2397 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2398 aPoint = anObj->GetPointTextAttach();
2399 aNormal = anObj->GetPlane().Direction();
2400 aDir = anObj->GetPlane().XDirection();
2403 Handle(XCAFDoc_Datum) aDatum;
2404 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2406 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2407 aPoint = anObj->GetPointTextAttach();
2408 aNormal = anObj->GetPlane().Direction();
2409 aDir = anObj->GetPlane().XDirection();
2412 di << "position: " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z() << "\n";
2413 di << "normal: " << aNormal.X() << " " << aNormal.Y() << " " << aNormal.Z() << "\n";
2414 di << "x_direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n";
2418 static Standard_Integer addGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2421 di << "Use: XSetGDTPresentation Doc GDT_Label Shape Name\n";
2424 Handle(TDocStd_Document) Doc;
2425 DDocStd::GetDocument(argv[1], Doc);
2426 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2429 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2430 if ( aLabel.IsNull() )
2432 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2436 TopoDS_Shape aPresentation= DBRep::Get(argv[3]);
2437 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[4]);
2439 Handle(XCAFDoc_Dimension) aDimension;
2440 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2442 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2443 anObj->SetPresentation(aPresentation, aName);
2444 aDimension->SetObject(anObj);
2446 // Geometric Tolerance
2447 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2448 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2450 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2451 anObj->SetPresentation(aPresentation, aName);
2452 aGeomTolerance->SetObject(anObj);
2455 Handle(XCAFDoc_Datum) aDatum;
2456 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2458 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2459 anObj->SetPresentation(aPresentation, aName);
2460 aDatum->SetObject(anObj);
2465 static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2468 di << "Use: XGetGDTPresentation Doc GDT_Label Shape\n";
2471 Handle(TDocStd_Document) Doc;
2472 DDocStd::GetDocument(argv[1], Doc);
2473 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2476 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2477 if ( aLabel.IsNull() )
2479 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2482 TopoDS_Shape aPresentation;
2484 Handle(XCAFDoc_Dimension) aDimension;
2485 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2487 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2488 aPresentation = anObj->GetPresentation();
2490 // Geometric Tolerance
2491 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2492 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2494 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2495 aPresentation = anObj->GetPresentation();
2498 Handle(XCAFDoc_Datum) aDatum;
2499 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2501 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2502 aPresentation = anObj->GetPresentation();
2505 DBRep::Set (argv[3], aPresentation);
2509 //=======================================================================
2510 //function : InitCommands
2512 //=======================================================================
2514 void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
2516 static Standard_Boolean initactor = Standard_False;
2521 initactor = Standard_True;
2523 Standard_CString g = "XDE G&DTs commands";
2525 di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
2526 __FILE__, DumpDGTs, g);
2528 di.Add ("XDumpNbDGTs","XDumpNbDGTs Doc [f (full dumping)]",
2529 __FILE__, DumpNbDGTs, g);
2531 di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
2532 __FILE__, addDim, g);
2534 di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label",
2535 __FILE__, addGTol, g);
2537 di.Add ("XAddDatum","XAddDatum Doc shape1/label1 ... shapeN/labelN",
2538 __FILE__, addDatum, g);
2540 di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label",
2541 __FILE__, setDatum, g);
2543 di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label",
2544 __FILE__, getDatum, g);
2546 di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"
2548 "\n 0 AnyCrossSection"
2549 "\n 1 Any_LongitudinalSection"
2551 "\n 3 ContactingFeature"
2552 "\n 4 DegreeOfFreedomConstraintU"
2553 "\n 5 DegreeOfFreedomConstraintV"
2554 "\n 6 DegreeOfFreedomConstraintW"
2555 "\n 7 DegreeOfFreedomConstraintX"
2556 "\n 8 DegreeOfFreedomConstraintY"
2557 "\n 9 DegreeOfFreedomConstraintZ"
2558 "\n 10 DistanceVariable"
2560 "\n 12 LeastMaterialRequirement"
2562 "\n 14 MajorDiameter"
2563 "\n 15 MaximumMaterialRequirement"
2564 "\n 16 MinorDiameter"
2566 "\n 18 PitchDiameter"
2569 "\n 21 Translation",
2570 __FILE__, addDatumModif, g);
2572 di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label",
2573 __FILE__, getDatumModif, g);
2575 di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name",
2576 __FILE__, setDatumName, g);
2578 di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
2579 __FILE__, getDatumName, g);
2581 di.Add ("XSetDatumPosition","XSetDatumPosition Doc Datum_Label position[1-3]"
2582 "Set datum position number in geometric tolerance datum system",
2583 __FILE__, setDatumPosition, g);
2585 di.Add ("XGetDatumPosition","XGetDatumPosition Doc Datum_Label",
2586 __FILE__, getDatumPosition, g);
2588 di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
2590 "\t 0 type is absent\n"
2592 "\t 2 CircularRunout\n"
2593 "\t 3 CircularityOrRoundness\n"
2595 "\t 5 Concentricity\n"
2596 "\t 6 Cylindricity\n"
2598 "\t 8 Parallelism\n"
2599 "\t 9 Perpendicularity\n"
2601 "\t 11 ProfileOfLine\n"
2602 "\t 12 ProfileOfSurface\n"
2603 "\t 13 Straightness\n"
2605 "\t 15 TotalRunout\n",
2606 __FILE__, setTypeOfTol, g);
2608 di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label",
2609 __FILE__, getTypeOfTol, g);
2611 di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type"
2615 "\n 2 SphericalDiameter",
2616 __FILE__, setTypeOfTolVal, g);
2618 di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label",
2619 __FILE__, getTypeOfTolVal, g);
2621 di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value",
2622 __FILE__, setTolVal, g);
2624 di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label",
2625 __FILE__, getTolVal, g);
2627 di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod"
2632 __FILE__, setMatReq, g);
2634 di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label",
2635 __FILE__, getMatReq, g);
2637 di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod"
2642 __FILE__, setZoneMod, g);
2644 di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label",
2645 __FILE__, getZoneMod, g);
2647 di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val",
2648 __FILE__, setZoneModVal, g);
2650 di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label",
2651 __FILE__, getZoneModVal, g);
2653 di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..."
2655 "\t 0 Any_Cross_Section\n"
2656 "\t 1 Common_Zone\n"
2657 "\t 2 Each_Radial_Element\n"
2659 "\t 4 Least_Material_Requirement\n"
2660 "\t 5 Line_Element\n"
2661 "\t 6 Major_Diameter\n"
2662 "\t 7 Maximum_Material_Requirement\n"
2663 "\t 8 Minor_Diameter\n"
2665 "\t 10 Pitch_Diameter\n"
2666 "\t 11 Reciprocity_Requirement\n"
2667 "\t 12 Separate_Requirement\n"
2668 "\t 13 Statistical_Tolerance\n"
2669 "\t 14 Tangent_Plane\n",
2670 __FILE__, addTolModif, g);
2672 di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label",
2673 __FILE__, getTolModif, g);
2675 di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val",
2676 __FILE__, setTolMaxVal, g);
2678 di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val",
2679 __FILE__, getTolMaxVal, g);
2681 di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type"
2683 "\t 0 type is absent\n"
2684 "\t 1 Location_CurvedDistance\n"
2685 "\t 2 Location_LinearDistance\n"
2686 "\t 3 Location_LinearDistance_FromCenterToOuter\n"
2687 "\t 4 Location_LinearDistance_FromCenterToInner\n"
2688 "\t 5 Location_LinearDistance_FromOuterToCenter\n"
2689 "\t 6 Location_LinearDistance_FromOuterToOuter\n"
2690 "\t 7 Location_LinearDistance_FromOuterToInner\n"
2691 "\t 8 Location_LinearDistance_FromInnerToCenter\n"
2692 "\t 9 Location_LinearDistance_FromInnerToOuter\n"
2693 "\t 10 Location_LinearDistance_FromInnerToInner\n"
2694 "\t 11 Location_Angular\n"
2695 "\t 12 Location_Oriented\n"
2696 "\t 13 Location_WithPath\n"
2697 "\t 14 Size_CurveLength\n"
2698 "\t 15 Size_Diameter\n"
2699 "\t 16 Size_SphericalDiameter\n"
2700 "\t 17 Size_Radius\n"
2701 "\t 18 Size_SphericalRadius\n"
2702 "\t 19 Size_ToroidalMinorDiameter\n"
2703 "\t 20 Size_ToroidalMajorDiameter\n"
2704 "\t 21 Size_ToroidalMinorRadius\n"
2705 "\t 22 Size_ToroidalMajorRadius\n"
2706 "\t 23 Size_ToroidalHighMajorDiameter\n"
2707 "\t 24 Size_ToroidalLowMajorDiameter\n"
2708 "\t 25 Size_ToroidalHighMajorRadius\n"
2709 "\t 26 Size_ToroidalLowMajorRadius\n"
2710 "\t 27 Size_Thickness\n"
2711 "\t 28 Size_Angular\n"
2712 "\t 29 Size_WithPath\n",
2713 __FILE__, setDimType, g);
2715 di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label",
2716 __FILE__, getDimType, g);
2718 di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val",
2719 __FILE__, setDimVal, g);
2721 di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label",
2722 __FILE__, getDimVal, g);
2724 di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val"
2730 __FILE__, setDimQalif, g);
2732 di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label",
2733 __FILE__, getDimQalif, g);
2735 di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val",
2736 __FILE__, setDimRange, g);
2738 di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label",
2739 __FILE__, getDimRange, g);
2741 di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val",
2742 __FILE__, setDimPlusMinusTol, g);
2744 di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label",
2745 __FILE__, getDimPlusMinusTol, g);
2747 di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade"
2748 "Values of formVar:"
2798 __FILE__, setDimClassTol, g);
2800 di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label",
2801 __FILE__, getDimClassTol, g);
2803 di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val",
2804 __FILE__, setDimNbOfDecimalPlaces, g);
2806 di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label",
2807 __FILE__, getDimNbOfDecimalPlaces, g);
2809 di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..."
2811 "\t 0 ControlledRadius\n"
2813 "\t 2 StatisticalTolerance\n"
2814 "\t 3 ContinuousFeature\n"
2815 "\t 4 TwoPointSize\n"
2816 "\t 5 LocalSizeDefinedBySphere\n"
2817 "\t 6 LeastSquaresAssociationCriterion\n"
2818 "\t 7 MaximumInscribedAssociation\n"
2819 "\t 8 MinimumCircumscribedAssociation\n"
2820 "\t 9 CircumferenceDiameter\n"
2821 "\t10 AreaDiameter\n"
2822 "\t11 VolumeDiameter\n"
2823 "\t12 MaximumSize\n"
2824 "\t13 MinimumSize\n"
2825 "\t14 AverageSize\n"
2827 "\t16 MidRangeSize\n"
2828 "\t17 RangeOfSizes\n"
2829 "\t18 AnyRestrictedPortionOfFeature\n"
2830 "\t19 AnyCrossSection\n"
2831 "\t20 SpecificFixedCrossSection\n"
2832 "\t21 CommonTolerance\n"
2833 "\t22 FreeStateCondition\n"
2835 __FILE__, addDimModifier, g);
2837 di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label",
2838 __FILE__, getDimModifier, g);
2840 di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)",
2841 __FILE__, addDimPath, g);
2843 di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 [v2]",
2844 __FILE__, addDimPoints, g);
2846 di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label",
2847 __FILE__, getDimPoints, g);
2849 di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z",
2850 __FILE__, addDimDir, g);
2852 di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label",
2853 __FILE__, getDimDir, g);
2855 di.Add ("XAddDimensionDescr","XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n"
2856 "Add named text description to given Dimension, if DescriptionName is missed"
2857 "name will be an empty string.",
2858 __FILE__, addDimDescr, g);
2860 di.Add ("XGetDimensionDescr","XGetDimensionDescr Doc Dim_Label\n"
2861 "Return all descriptions of given Dimension.",
2862 __FILE__, getDimDescr, g);
2864 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"
2865 "Set plane to display dimension parallel to and point to display text (loc)",
2866 __FILE__, addGDTPosition, g);
2868 di.Add ("XGetGDTPosition","XGetGDTPosition Doc GDT_Label"
2869 "Returns text position and plane, parallel to which dimension is displayed",
2870 __FILE__, getGDTPosition, g);
2872 di.Add ("XSetGDTPresentation","XSetGDTPresentation Doc GDT_Label Shape Name"
2873 "Set presentation with given name for dimension",
2874 __FILE__, addGDTPresentation, g);
2876 di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
2877 "Returns Presentation into Shape",
2878 __FILE__, getGDTPresentation, g);