0028250: Data Exchange - Wrong number of geometric tolerance modifiers.
[occt.git] / src / XDEDRAW / XDEDRAW_GDTs.cxx
CommitLineData
9ebaae37 1// Created on: 2015-06-18
2// Created by: Ilya Novikov
3// Copyright (c) 2000-2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <XDEDRAW_GDTs.hxx>
17
18#include <Draw.hxx>
19#include <DBRep.hxx>
20#include <DDocStd.hxx>
21
727b5ad9 22#include <STEPCAFControl_GDTProperty.hxx>
6595eee7 23
9ebaae37 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>
29
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>
50
51#include <TCollection_AsciiString.hxx>
52#include <TCollection_HAsciiString.hxx>
53#include <TColStd_HArray1OfReal.hxx>
54#include <TColgp_HArray1OfPnt.hxx>
55
56#include <TopoDS.hxx>
57#include <TopoDS_Shape.hxx>
58#include <TopoDS_Edge.hxx>
59#include <TopoDS_Vertex.hxx>
60#include <BRep_Tool.hxx>
61
62
63
64static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
65{
66 if (argc < 3) {
586db386 67 di<<"Use: XDumpDGTs Doc shape/label/all\n";
9ebaae37 68 return 1;
69 }
70 Handle(TDocStd_Document) Doc;
71 DDocStd::GetDocument(argv[1], Doc);
586db386 72 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 73 Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
74 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
75
76 TCollection_AsciiString name = argv[2];
77 TDF_LabelSequence aLabels;
78 if(name.IsEqual("all"))
79 {
80 aShapeTool->GetShapes(aLabels);
81 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
82 {
83 aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
84 }
85 }
86 else
87 {
88 TDF_Label aLabel;
89 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
90 if ( !aLabel.IsNull() ) {
91 aLabels.Append(aLabel);
92 aShapeTool->GetSubShapes(aLabel, aLabels);
93 }
94 else
95 {
96 TopoDS_Shape aShape= DBRep::Get(argv[2]);
97 if ( !aShape.IsNull() )
98 {
99 aShapeTool->Search(aShape, aLabel);
100 if ( !aLabel.IsNull() ) {
101 aLabels.Append(aLabel);
102 aShapeTool->GetSubShapes(aLabel, aLabels);
103 }
104 else
105 {
106 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
107 return 1;
108 }
109 }
110 }
111 }
112
113 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
114 {
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++ )
119 {
120 Handle(XCAFDoc_Dimension) aDimTol;
121 if(aGDTs.Value(j).FindAttribute(XCAFDoc_Dimension::GetID(), aDimTol))
122 {
123 Handle(XCAFDimTolObjects_DimensionObject) aDimTolObj = aDimTol->GetObject();
124 if(flag)
125 {
126 TCollection_AsciiString Entry;
127 TDF_Tool::Entry(aLabels.Value(i), Entry);
586db386 128 di << "\n " << Entry << " Shape."<< i;
9ebaae37 129 flag = Standard_False;
130 }
131 TCollection_AsciiString Entry;
132 TDF_Tool::Entry(aGDTs.Value(j), Entry);
133 di << "\n \t " << Entry;
134 flag = Standard_False;
135
586db386 136 di << " Dimension."<< i << "."<< j;
1c9d3225 137 if (argc > 3)
138 {
139 di <<" (";
140 di << " T " << aDimTolObj->GetType();
141 if(aDimTolObj->IsDimWithRange())
142 {
143 di << ", LB " << aDimTolObj->GetLowerBound();
144 di << ", UB " << aDimTolObj->GetUpperBound();
145 }
146 else
147 {
148 di << ", V " << aDimTolObj->GetValue();
149 if (aDimTolObj->IsDimWithPlusMinusTolerance())
150 {
151 di << ", VL " << aDimTolObj->GetLowerTolValue();
152 di << ", VU " << aDimTolObj->GetUpperTolValue();
153 }
154 else if (aDimTolObj->IsDimWithClassOfTolerance())
155 {
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;
161 }
162 }
163 if (aDimTolObj->HasQualifier())
164 di << ", Q " << aDimTolObj->GetQualifier();
165 if (aDimTolObj->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
166 {
167 gp_Dir aD;
168 aDimTolObj->GetDirection(aD);
169 di << ", D (" << aD.X() << ", " << aD.Y() << ", " << aD.Z() << ")";
170 }
171 XCAFDimTolObjects_DimensionModifiersSequence aModif =
172 aDimTolObj->GetModifiers();
173 if (!aModif.IsEmpty())
174 {
175 di << ",";
176 for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
177 {
178 di << " M " << aModif.Value(k);
179 }
180 }
181 di << ", P " << (Standard_Integer)!aDimTolObj->GetPath().IsNull();
182 di << " )";
183 }
9ebaae37 184 }
185 }
186 aGDTs.Clear();
187 aDimTolTool->GetRefGeomToleranceLabels(aLabels.Value(i), aGDTs);
188 for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ )
189 {
190 Handle(XCAFDoc_GeomTolerance) aDimTol;
191 if(aGDTs.Value(j).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aDimTol))
192 {
193 Handle(XCAFDimTolObjects_GeomToleranceObject) aDimTolObj = aDimTol->GetObject();
194 if(flag)
195 {
196 TCollection_AsciiString Entry;
197 TDF_Tool::Entry(aLabels.Value(i), Entry);
586db386 198 di << "\n " << Entry << " Shape."<< i;
9ebaae37 199 flag = Standard_False;
200 }
201 TCollection_AsciiString Entry;
202 TDF_Tool::Entry(aGDTs.Value(j), Entry);
203 di << "\n \t " << Entry;
204 flag = Standard_False;
205
586db386 206 di << " GeomTolerance."<< i << "."<< j;
1c9d3225 207 if (argc > 3)
208 {
209 di <<" (";
210 di << " T " << aDimTolObj->GetType();
211 di << " TV " << aDimTolObj->GetTypeOfValue();
212 di << ", V " << aDimTolObj->GetValue();
213
214 if (aDimTolObj->HasAxis())
215 {
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() << "))";
220 }
221 XCAFDimTolObjects_GeomToleranceModifiersSequence aModif =
222 aDimTolObj->GetModifiers();
223 if (!aModif.IsEmpty())
224 {
225 di << ",";
226 for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
227 {
228 di << " M " << aModif.Value(k);
229 }
230 }
231 if (aDimTolObj->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
232 {
233 di << ", MR " << aDimTolObj->GetMaterialRequirementModifier();
234 }
235 if (aDimTolObj->GetMaxValueModifier() > 0)
236 {
237 di << "MaxV " << aDimTolObj->GetMaxValueModifier();
238 }
239 if ( aDimTolObj->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
240 {
241 di << ", ZM " << aDimTolObj->GetZoneModifier();
242 if (aDimTolObj->GetValueOfZoneModifier() > 0)
243 {
244 di << " ZMV " <<aDimTolObj->GetValueOfZoneModifier();
245 }
246 }
247
248 di << " )";
249 }
9ebaae37 250 Handle(XCAFDoc_GraphNode) aNode;
251 if(aGDTs.Value(j).FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode) && aNode->NbChildren() > 0)
252 {
51740958 253 for(Standard_Integer k = 1; k<=aNode->NbChildren(); k++)
9ebaae37 254 {
255 Handle(XCAFDoc_Datum) aDatum;
51740958 256 if(aNode->GetChild(k)->Label().FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
9ebaae37 257 {
1c9d3225 258 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
51740958 259 TCollection_AsciiString anEntry;
260 TDF_Tool::Entry(aNode->GetChild(k)->Label(), anEntry);
261 di << "\n \t \t " << anEntry;
586db386 262 di << " Datum."<< i << "."<< j << "."<< k;
1c9d3225 263 if (argc > 3)
264 {
265 di <<" (";
266 XCAFDimTolObjects_DatumModifiersSequence aModif =
267 aDatumObj->GetModifiers();
268 if (!aModif.IsEmpty())
269 {
270 di << ",";
f2139a7f 271 for (Standard_Integer iModif = aModif.Lower(); iModif <= aModif.Upper(); iModif++)
1c9d3225 272 {
f2139a7f 273 di << " M " << aModif.Value(iModif);
1c9d3225 274 }
275 }
276 XCAFDimTolObjects_DatumModifWithValue aM;
277 Standard_Real aV;
278 aDatumObj->GetModifierWithValue(aM, aV);
279 if (aM != XCAFDimTolObjects_DatumModifWithValue_None)
280 {
281 di << ", MV" << aM << " " << aV;
282 }
283 di << " )";
284 }
9ebaae37 285 }
286 }
287 }
288 }
289 }
1c9d3225 290 TDF_LabelSequence aDatumL;
9ebaae37 291 if (aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatumL))
292 {
1c9d3225 293 for(Standard_Integer j = aDatumL.Lower(); j <= aDatumL.Upper(); j++)
9ebaae37 294 {
1c9d3225 295 Handle(XCAFDoc_Datum) aDatum;
296 if(aDatumL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDatum) &&
297 aDatum->GetObject()->IsDatumTarget())
9ebaae37 298 {
1c9d3225 299 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
300 if(flag)
301 {
302 TCollection_AsciiString Entry;
303 TDF_Tool::Entry(aLabels.Value(i), Entry);
586db386 304 di << "\n " << Entry << " Shape."<< i;
1c9d3225 305 flag = Standard_False;
306 }
9ebaae37 307 TCollection_AsciiString Entry;
1c9d3225 308 TDF_Tool::Entry(aDatumL.First(), Entry);
309 di << "\n \t " << Entry;
9ebaae37 310 flag = Standard_False;
1c9d3225 311
586db386 312 di << " Datum target."<< i << "."<< j;
1c9d3225 313 if (argc > 3)
314 {
315 di <<" (";
316 di << " T " << aDatumObj->GetDatumTargetType();
317 if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Area)
318 {
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)
324 {
325 di << ", L " << aDatumObj->GetDatumTargetLength() ;
326 if (aDatumObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
327 {
328 di << ", W " << aDatumObj->GetDatumTargetWidth() ;
329 }
330 }
331 }
332 di << " )";
333 }
9ebaae37 334 }
1c9d3225 335 }
336 }
337 }
338 return 0;
339}
340
341static Standard_Integer DumpNbDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
342{
343 if (argc < 2) {
586db386 344 di<<"Use: XDumpNbDGTs Doc";
1c9d3225 345 return 1;
346 }
6595eee7 347
348 Standard_Boolean isFull = Standard_False;
349 if (argc == 3) {
350 char aChar = argv[2][0];
351 if (aChar == 'f')
352 isFull = Standard_True;
353 }
1c9d3225 354 Handle(TDocStd_Document) Doc;
355 DDocStd::GetDocument(argv[1], Doc);
586db386 356 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
1c9d3225 357 Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
358 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
359
360 TDF_LabelSequence aLabels;
361 aShapeTool->GetShapes(aLabels);
362 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
363 {
364 aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
365 }
9ebaae37 366
1c9d3225 367 TDF_LabelSequence aGDTs;
368 aDimTolTool->GetDimensionLabels(aGDTs);
369 di << "\n NbOfDimensions : " << aGDTs.Length();
6595eee7 370 if (isFull) {
371 Standard_Integer nbSize = 0,
372 nbLocation = 0,
373 nbAngular = 0,
0b622d67 374 nbWithPath = 0,
375 nbCommon = 0;
6595eee7 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))
379 continue;
380 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
381 if (anObject.IsNull())
382 continue;
383 XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
0b622d67 384 if (aDimType == XCAFDimTolObjects_DimensionType_CommonLabel) {
385 nbCommon++;
386 }
387 else if (STEPCAFControl_GDTProperty::IsDimensionalLocation(aDimType)) {
6595eee7 388 nbLocation++;
389 }
390 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) {
391 nbAngular++;
392 nbLocation++;
393 }
394 else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) {
395 nbLocation++;
396 nbWithPath++;
397 }
727b5ad9 398 else if (STEPCAFControl_GDTProperty::IsDimensionalSize(aDimType)) {
6595eee7 399 nbSize++;
400 }
401 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) {
402 nbSize++;
403 nbAngular++;
404 }
405 else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) {
406 nbSize++;
407 nbWithPath++;
408 }
409 }
410 di << "\n NbOfDimensionalSize : " << nbSize;
411 di << "\n NbOfDimensionalLocation: " << nbLocation;
412 di << "\n NbOfAngular : " << nbAngular;
413 di << "\n NbOfWithPath : " << nbWithPath;
0b622d67 414 di << "\n NbOfCommonLabels : " << nbCommon;
6595eee7 415 }
1c9d3225 416
417 aGDTs.Clear();
418 aDimTolTool->GetGeomToleranceLabels(aGDTs);
419 di << "\n NbOfTolerances : " << aGDTs.Length();
6595eee7 420 if (isFull) {
421 Standard_Integer nbWithModif = 0,
422 nbWithMaxTol = 0,
423 nbWithDatumRef = 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))
427 continue;
428 Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
429 if (anObject.IsNull())
430 continue;
51663cb4 431 if (anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) {
6595eee7 432 nbWithModif++;
433 }
51663cb4 434 else if (anObject->GetModifiers().Length() > 0) {
435 Standard_Boolean isHasModif = Standard_False;
436 for (Standard_Integer i = 1; i <= anObject->GetModifiers().Length(); i++)
437 if (anObject->GetModifiers().Value(i) != XCAFDimTolObjects_GeomToleranceModif_All_Around &&
438 anObject->GetModifiers().Value(i) != XCAFDimTolObjects_GeomToleranceModif_All_Over) {
439 isHasModif = Standard_True;
440 break;
441 }
442 if (isHasModif)
443 nbWithModif++;
444 }
6595eee7 445 if (anObject->GetMaxValueModifier() != 0) {
446 nbWithMaxTol++;
447 }
448 TDF_LabelSequence aDatumSeq;
449 aDimTolTool->GetDatumWithObjectOfTolerLabels(aGDTs.Value(i), aDatumSeq);
450 if (aDatumSeq.Length() > 0) {
451 nbWithDatumRef++;
452 }
453 }
454 di << "\n NbOfGTWithModifiers : " << nbWithModif;
455 di << "\n NbOfGTWithMaxTolerance : " << nbWithMaxTol;
456 di << "\n NbOfGTWithDatums : " << nbWithDatumRef;
457 }
1c9d3225 458
459 Standard_Integer aCounter = 0;
460 Standard_Integer aCounter1 = 0;
461 Standard_Integer aCounter2 = 0;
462
463 for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
464 {
465 Standard_Boolean isDatum = Standard_False;
466 TDF_LabelSequence aDatL;
467 if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL))
468 {
469 for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++)
470 {
471 Handle(XCAFDoc_Datum) aDat;
472 if(aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat))
473 {
474 if(aDat->GetObject()->IsDatumTarget())
475 {
476 aCounter1++;
477 }
478 else
479 {
480 aCounter2++;
481 isDatum = Standard_True;
482 }
483 }
9ebaae37 484 }
1c9d3225 485 if(isDatum)
486 aCounter++;
9ebaae37 487 }
488 }
1c9d3225 489 di << "\n NbOfDatumFeature : " << aCounter;
490 di << "\n NbOfAttachedDatum : " << aCounter2;
491 di << "\n NbOfDatumTarget : " << aCounter1;
492
9ebaae37 493 return 0;
494}
495
496static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
497{
498 if (argc < 3) {
586db386 499 di<<"Use: XAddDimension Doc shape/label [shape/label]\n";
9ebaae37 500 return 1;
501 }
502 Handle(TDocStd_Document) Doc;
503 DDocStd::GetDocument(argv[1], Doc);
586db386 504 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 505 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
506 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
507
508 TDF_Label aLabel;
509 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
510 if ( aLabel.IsNull() )
511 {
512 TopoDS_Shape aShape= DBRep::Get(argv[2]);
513 if ( !aShape.IsNull() )
514 {
515 aShapeTool->Search(aShape, aLabel);
516 if ( aLabel.IsNull() )
517 {
518 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
519 return 1;
520 }
521 }
522 }
523 TDF_Label aLabel1;
524 if(argc == 4)
525 {
526 TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1);
527 if ( aLabel1.IsNull() )
528 {
529 TopoDS_Shape aShape= DBRep::Get(argv[3]);
530 if ( !aShape.IsNull() )
531 {
532 aShapeTool->Search(aShape, aLabel1);
533 if ( aLabel1.IsNull() )
534 {
535 di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
536 return 1;
537 }
538 }
539 }
540 }
541
542 TDF_Label aDimL = aDimTolTool->AddDimension();
543 if(aLabel1.IsNull())
544 aDimTolTool->SetDimension(aLabel, aDimL);
545 else
546 aDimTolTool->SetDimension(aLabel, aLabel1, aDimL);
547 TCollection_AsciiString Entry;
548 TDF_Tool::Entry(aDimL, Entry);
549 di << Entry;
550 return 0;
551}
552
553static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
554{
555 if (argc < 3) {
586db386 556 di<<"Use: XAddGeomTolerance Doc shape/label\n";
9ebaae37 557 return 1;
558 }
559 Handle(TDocStd_Document) Doc;
560 DDocStd::GetDocument(argv[1], Doc);
586db386 561 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 562 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
563 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
564
565 TDF_Label aLabel;
566 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
567 if ( aLabel.IsNull() )
568 {
569 TopoDS_Shape aShape= DBRep::Get(argv[2]);
570 if ( !aShape.IsNull() )
571 {
572 aShapeTool->Search(aShape, aLabel);
573 if ( aLabel.IsNull() )
574 {
575 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
576 return 1;
577 }
578 }
579 }
580
581 TDF_Label aTolL = aDimTolTool->AddGeomTolerance();
582 aDimTolTool->SetGeomTolerance(aLabel, aTolL);
583 TCollection_AsciiString Entry;
584 TDF_Tool::Entry(aTolL, Entry);
585 di << Entry;
586 return 0;
587}
588
589static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
590{
591 if (argc < 3) {
586db386 592 di<<"Use: XAddDatum Doc shape/label\n";
9ebaae37 593 return 1;
594 }
595 Handle(TDocStd_Document) Doc;
596 DDocStd::GetDocument(argv[1], Doc);
586db386 597 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 598 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
599 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
600
601 TDF_Label aLabel;
602 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
603 if ( aLabel.IsNull() )
604 {
605 TopoDS_Shape aShape= DBRep::Get(argv[2]);
606 if ( !aShape.IsNull() )
607 {
608 aShapeTool->Search(aShape, aLabel);
609 if ( aLabel.IsNull() )
610 {
611 di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
612 return 1;
613 }
614 }
615 }
616
617 TDF_Label aDatumL = aDimTolTool->AddDatum();
618 aDimTolTool->SetDatum(aLabel, aDatumL);
619 TCollection_AsciiString Entry;
620 TDF_Tool::Entry(aDatumL, Entry);
621 di << Entry;
622 return 0;
623}
624
625static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
626{
627 if (argc < 4) {
586db386 628 di<<"Use: XSetDatum Doc Datum_Label GeomTol_Label\n";
9ebaae37 629 return 1;
630 }
631 Handle(TDocStd_Document) Doc;
632 DDocStd::GetDocument(argv[1], Doc);
586db386 633 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 634 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
635 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
636
637 TDF_Label aLabel;
638 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
639 if ( aLabel.IsNull() )
640 {
641 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
642 return 1;
643 }
644
645 TDF_Label aTol;
646 TDF_Tool::Label(Doc->GetData(), argv[3], aTol);
647 if ( aTol.IsNull() )
648 {
649 di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n";
650 return 1;
651 }
652
c1070321 653 // check datum position number
654 Handle(XCAFDoc_Datum) aDatumAttr;
655 if (!aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr))
656 {
657 di<<"Invalid datum object\n";
658 return 1;
659 }
660 Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
661 if (aDatumObj.IsNull())
662 {
663 di<<"Invalid datum object\n";
664 return 1;
665 }
666
667 if (aDatumObj->GetPosition() < 1 || aDatumObj->GetPosition() > 3)
668 {
669 di<<"Invalid datum position number: use XSetDatumPosition\n";
670 return 1;
671 }
672
9ebaae37 673 aDimTolTool->SetDatumToGeomTol(aLabel, aTol);
674 return 0;
675}
676
c1070321 677static Standard_Integer setDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
678{
679 if (argc < 4) {
680 di<<"Use: XSetDatumPosition Doc Datum_Label position[1-3]\n";
681 return 1;
682 }
683
684 if (Draw::Atoi(argv[3]) < 1 || Draw::Atoi(argv[3]) > 3) {
685 di<<"Datum position should be 1, 2 or 3\n";
686 return 1;
687 }
688
689 Handle(TDocStd_Document) Doc;
690 DDocStd::GetDocument(argv[1], Doc);
691 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
692 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
693 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
694
695 TDF_Label aLabel;
696 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
697 if ( aLabel.IsNull() )
698 {
699 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
700 return 1;
701 }
702 Handle(XCAFDoc_Datum) aDatum;
703 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
704 {
705 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
706 anObj->SetPosition(Draw::Atoi(argv[3]));
707 aDatum->SetObject(anObj);
708 }
709 return 0;
710}
711
712static Standard_Integer getDatumPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
713{
714 if (argc < 3) {
715 di<<"Use: XGetDatumPosition Doc Datum_Label\n";
716 return 1;
717 }
718 Handle(TDocStd_Document) Doc;
719 DDocStd::GetDocument(argv[1], Doc);
720 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
721 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
722 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
723
724 TDF_Label aLabel;
725 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
726 if ( aLabel.IsNull() )
727 {
728 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
729 return 1;
730 }
731 Handle(XCAFDoc_Datum) aDatum;
732 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
733 {
734 di << aDatum->GetObject()->GetPosition();
735 }
736 return 0;
737}
738
739
9ebaae37 740static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
741{
742 if (argc < 3) {
586db386 743 di<<"Use: XGetDatum Doc GeomTol_Label/Shape_Label\n";
9ebaae37 744 return 1;
745 }
746 Handle(TDocStd_Document) Doc;
747 DDocStd::GetDocument(argv[1], Doc);
586db386 748 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 749 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
750 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
751
752 TDF_Label aLabel;
753 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
754 if ( aLabel.IsNull() )
755 {
756 di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
757 return 1;
758 }
759
1c9d3225 760 TDF_LabelSequence aD;
9ebaae37 761 if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
762 {
1c9d3225 763 aDimTolTool->GetDatumOfTolerLabels(aLabel, aD);
9ebaae37 764 }
1c9d3225 765 for(Standard_Integer i = aD.Lower(); i <= aD.Upper(); i++)
9ebaae37 766 {
1c9d3225 767 if(i>1) di<<", ";
9ebaae37 768 TCollection_AsciiString Entry;
1c9d3225 769 TDF_Tool::Entry(aD.Value(i), Entry);
9ebaae37 770 di<<Entry;
771 }
772 return 0;
773}
774
775static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
776{
777 if (argc < 4) {
586db386 778 di<<"Use: XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n";
9ebaae37 779 return 1;
780 }
781 Handle(TDocStd_Document) Doc;
782 DDocStd::GetDocument(argv[1], Doc);
586db386 783 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 784 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
785 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
786
787 TDF_Label aLabel;
788 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
789 if ( aLabel.IsNull() )
790 {
791 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
792 return 1;
793 }
794 Handle(XCAFDoc_Datum) aDatum;
795 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
796 {
797 for(Standard_Integer i = 3; i < argc; i++)
798 {
799 if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1)
800 {
801 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
802 anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i]));
803 aDatum->SetObject(anObj);
804 }
805 }
806 }
807 return 0;
808}
809
810static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
811{
812 if (argc < 3) {
586db386 813 di<<"Use: XGetDatumModifiers Doc Datum_Label\n";
9ebaae37 814 return 1;
815 }
816 Handle(TDocStd_Document) Doc;
817 DDocStd::GetDocument(argv[1], Doc);
586db386 818 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 819 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
820 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
821
822 TDF_Label aLabel;
823 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
824 if ( aLabel.IsNull() )
825 {
826 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
827 return 1;
828 }
829 Handle(XCAFDoc_Datum) aDatum;
830 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
831 {
832 XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers();
833 for(Standard_Integer i = 1; i<=aS.Length();i++)
834 {
835 if (i > 1) di<<", ";
836 switch(aS.Value(i)){
837 case 0 : di<<"AnyCrossSection"; break;
838 case 1 : di<<"AnyLongitudinalSection"; break;
839 case 2 : di<<"Basic"; break;
840 case 3 : di<<"ContactingFeature\n"; break;
841 case 4 : di<<"DegreeOfFreedomConstraintU"; break;
842 case 5 : di<<"DegreeOfFreedomConstraintV"; break;
843 case 6 : di<<"DegreeOfFreedomConstraintW"; break;
844 case 7 : di<<"DegreeOfFreedomConstraintX"; break;
845 case 8 : di<<"DegreeOfFreedomConstraintY"; break;
846 case 9 : di<<"DegreeOfFreedomConstraintZ"; break;
847 case 10 : di<<"DistanceVariable"; break;
848 case 11 : di<<"FreeState"; break;
849 case 12 : di<<"LeastMaterialRequirement"; break;
850 case 13 : di<<"Line"; break;
851 case 14 : di<<"MajorDiameter"; break;
852 case 15 : di<<"MaximumMaterialRequirement"; break;
853 case 16 : di<<"MinorDiameter"; break;
854 case 17 : di<<"Orientation"; break;
855 case 18 : di<<"PitchDiameter"; break;
856 case 19 : di<<"Plane"; break;
857 case 20 : di<<"Point"; break;
858 case 21 : di<<"Translation"; break;
859 default : break;
860 }
861 }
862 }
863 return 0;
864}
865
866static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
867{
868 if (argc < 4) {
586db386 869 di<<"Use: XSetDatumName Doc Datum_Label name\n";
9ebaae37 870 return 1;
871 }
872 Handle(TDocStd_Document) Doc;
873 DDocStd::GetDocument(argv[1], Doc);
586db386 874 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 875 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
876 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
877
878 TDF_Label aLabel;
879 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
880 if ( aLabel.IsNull() )
881 {
882 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
883 return 1;
884 }
885 Handle(XCAFDoc_Datum) aDatum;
886 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
887 {
888 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
889 anObj->SetName(new TCollection_HAsciiString(argv[3]));
890 aDatum->SetObject(anObj);
891 }
892 return 0;
893}
894
895static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
896{
897 if (argc < 3) {
586db386 898 di<<"Use: XGetDatumName Doc Datum_Label\n";
9ebaae37 899 return 1;
900 }
901 Handle(TDocStd_Document) Doc;
902 DDocStd::GetDocument(argv[1], Doc);
586db386 903 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 904 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
905 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
906
907 TDF_Label aLabel;
908 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
909 if ( aLabel.IsNull() )
910 {
911 di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
912 return 1;
913 }
914 Handle(XCAFDoc_Datum) aDatum;
915 if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
916 {
917 di<<aDatum->GetObject()->GetName()->ToCString();
918 }
919 return 0;
920}
921
922static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
923{
924 if (argc < 4) {
586db386 925 di<<"Use: XSetTypeOfTolerance Doc GTol_Label type\n";
9ebaae37 926 return 1;
927 }
928 Handle(TDocStd_Document) Doc;
929 DDocStd::GetDocument(argv[1], Doc);
586db386 930 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 931 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
932 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
933
934 TDF_Label aLabel;
935 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
936 if ( aLabel.IsNull() )
937 {
938 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
939 return 1;
940 }
941 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
942 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
943 {
944 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16)
945 {
946 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
947 anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3]));
948 aGeomTolerance->SetObject(anObj);
949 }
950 }
951 return 0;
952}
953
954static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
955{
956 if (argc < 3) {
586db386 957 di<<"Use: XGetTypeOfTolerance Doc GTol_Label\n";
9ebaae37 958 return 1;
959 }
960 Handle(TDocStd_Document) Doc;
961 DDocStd::GetDocument(argv[1], Doc);
586db386 962 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 963 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
964 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
965
966 TDF_Label aLabel;
967 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
968 if ( aLabel.IsNull() )
969 {
970 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
971 return 1;
972 }
973 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
974 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
975 {
976 switch(aGeomTolerance->GetObject()->GetType()){
977 case 0 : di<<"type is absent"; break;
978 case 1 : di<<"Angularity"; break;
979 case 2 : di<<"CircularRunout"; break;
980 case 3 : di<<"CircularityOrRoundness"; break;
981 case 4 : di<<"Coaxiality"; break;
982 case 5 : di<<"Concentricity"; break;
983 case 6 : di<<"Cylindricity"; break;
984 case 7 : di<<"Flatness"; break;
985 case 8 : di<<"Parallelism"; break;
986 case 9 : di<<"Perpendicularity"; break;
987 case 10 : di<<"Position"; break;
988 case 11 : di<<"ProfileOfLine"; break;
989 case 12 : di<<"ProfileOfSurface"; break;
990 case 13 : di<<"Straightness"; break;
991 case 14 : di<<"Symmetry"; break;
992 case 15 : di<<"TotalRunout"; break;
993 default : break;
994 }
995 }
996 return 0;
997}
998
999static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1000{
1001 if (argc < 4) {
586db386 1002 di<<"Use: XSetTypeOfToleranceValue Doc GTol_Label type\n";
9ebaae37 1003 return 1;
1004 }
1005 Handle(TDocStd_Document) Doc;
1006 DDocStd::GetDocument(argv[1], Doc);
586db386 1007 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1008 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1009 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1010
1011 TDF_Label aLabel;
1012 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1013 if ( aLabel.IsNull() )
1014 {
1015 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1016 return 1;
1017 }
1018 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1019 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1020 {
1021 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1022 {
1023 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1024 anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3]));
1025 aGeomTolerance->SetObject(anObj);
1026 }
1027 }
1028 return 0;
1029}
1030
1031static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1032{
1033 if (argc < 3) {
586db386 1034 di<<"Use: XGetTypeOfToleranceValue Doc GTol_Label\n";
9ebaae37 1035 return 1;
1036 }
1037 Handle(TDocStd_Document) Doc;
1038 DDocStd::GetDocument(argv[1], Doc);
586db386 1039 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1040 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1041 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1042
1043 TDF_Label aLabel;
1044 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1045 if ( aLabel.IsNull() )
1046 {
1047 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1048 return 1;
1049 }
1050 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1051 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1052 {
1053 switch(aGeomTolerance->GetObject()->GetTypeOfValue()){
1054 case 0 : di<<"type is absent"; break;
1055 case 1 : di<<"Diameter"; break;
1056 case 2 : di<<"SphericalDiameter"; break;
1057 default : break;
1058 }
1059 }
1060 return 0;
1061}
1062
1063static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1064{
1065 if (argc < 4) {
586db386 1066 di<<"Use: XSetToleranceValue Doc GTol_Label value\n";
9ebaae37 1067 return 1;
1068 }
1069 Handle(TDocStd_Document) Doc;
1070 DDocStd::GetDocument(argv[1], Doc);
586db386 1071 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1072 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1073 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1074
1075 TDF_Label aLabel;
1076 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1077 if ( aLabel.IsNull() )
1078 {
1079 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1080 return 1;
1081 }
1082 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1083 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1084 {
1085 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1086 anObj->SetValue(Draw::Atof(argv[3]));
1087 aGeomTolerance->SetObject(anObj);
1088 }
1089 return 0;
1090}
1091
1092static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1093{
1094 if (argc < 3) {
586db386 1095 di<<"Use: XGetToleranceValue Doc GTol_Label\n";
9ebaae37 1096 return 1;
1097 }
1098 Handle(TDocStd_Document) Doc;
1099 DDocStd::GetDocument(argv[1], Doc);
586db386 1100 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1101 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1102 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1103
1104 TDF_Label aLabel;
1105 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1106 if ( aLabel.IsNull() )
1107 {
1108 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1109 return 1;
1110 }
1111 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1112 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1113 {
1114 di << aGeomTolerance->GetObject()->GetValue();
1115 }
1116 return 0;
1117}
1118
1119static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1120{
1121 if (argc < 4) {
586db386 1122 di<<"Use: XSetTolMaterialReq Doc GTol_Label mod\n";
9ebaae37 1123 return 1;
1124 }
1125 Handle(TDocStd_Document) Doc;
1126 DDocStd::GetDocument(argv[1], Doc);
586db386 1127 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1128 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1129 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1130
1131 TDF_Label aLabel;
1132 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1133 if ( aLabel.IsNull() )
1134 {
1135 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1136 return 1;
1137 }
1138 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1139 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1140 {
1141 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1142 {
1143 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1144 anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3]));
1145 aGeomTolerance->SetObject(anObj);
1146 }
1147 }
1148 return 0;
1149}
1150
1151static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1152{
1153 if (argc < 3) {
586db386 1154 di<<"Use: XGetTolMaterialReq Doc GTol_Label\n";
9ebaae37 1155 return 1;
1156 }
1157 Handle(TDocStd_Document) Doc;
1158 DDocStd::GetDocument(argv[1], Doc);
586db386 1159 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1160 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1161 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1162
1163 TDF_Label aLabel;
1164 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1165 if ( aLabel.IsNull() )
1166 {
1167 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1168 return 1;
1169 }
1170 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1171 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1172 {
1173 switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){
1174 case 0 : di<<"modifier is absent"; break;
1175 case 1 : di<<"M"; break;
1176 case 2 : di<<"L"; break;
1177 default : break;
1178 }
1179 }
1180 return 0;
1181}
1182
1183static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1184{
1185 if (argc < 4) {
586db386 1186 di<<"Use: XSetTolZoneMod Doc GTol_Label mod\n";
9ebaae37 1187 return 1;
1188 }
1189 Handle(TDocStd_Document) Doc;
1190 DDocStd::GetDocument(argv[1], Doc);
586db386 1191 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1192 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1193 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1194
1195 TDF_Label aLabel;
1196 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1197 if ( aLabel.IsNull() )
1198 {
1199 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1200 return 1;
1201 }
1202 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1203 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1204 {
1205 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3)
1206 {
1207 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1208 anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3]));
1209 aGeomTolerance->SetObject(anObj);
1210 }
1211 }
1212 return 0;
1213}
1214
1215static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1216{
1217 if (argc < 3) {
586db386 1218 di<<"Use: XGetTolZoneMod Doc GTol_Label\n";
9ebaae37 1219 return 1;
1220 }
1221 Handle(TDocStd_Document) Doc;
1222 DDocStd::GetDocument(argv[1], Doc);
586db386 1223 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1224 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1225 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1226
1227 TDF_Label aLabel;
1228 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1229 if ( aLabel.IsNull() )
1230 {
1231 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1232 return 1;
1233 }
1234 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1235 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1236 {
1237 switch(aGeomTolerance->GetObject()->GetZoneModifier()){
1238 case 0 : di<<"modifier is absent"; break;
1239 case 1 : di<<"P"; break;
1240 case 2 : di<<"NonUniform"; break;
1241 default : break;
1242 }
1243 }
1244 return 0;
1245}
1246
1247static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1248{
1249 if (argc < 4) {
586db386 1250 di<<"Use: XSetTolZoneModValue Doc GTol_Label val\n";
9ebaae37 1251 return 1;
1252 }
1253 Handle(TDocStd_Document) Doc;
1254 DDocStd::GetDocument(argv[1], Doc);
586db386 1255 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1256 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1257 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1258
1259 TDF_Label aLabel;
1260 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1261 if ( aLabel.IsNull() )
1262 {
1263 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1264 return 1;
1265 }
1266 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1267 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1268 {
1269 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1270 anObj->SetValueOfZoneModifier(Draw::Atof(argv[3]));
1271 aGeomTolerance->SetObject(anObj);
1272 }
1273 return 0;
1274}
1275
1276static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1277{
1278 if (argc < 3) {
586db386 1279 di<<"Use: XGetTolZoneModValue Doc GTol_Label\n";
9ebaae37 1280 return 1;
1281 }
1282 Handle(TDocStd_Document) Doc;
1283 DDocStd::GetDocument(argv[1], Doc);
586db386 1284 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1285 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1286 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1287
1288 TDF_Label aLabel;
1289 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1290 if ( aLabel.IsNull() )
1291 {
1292 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1293 return 1;
1294 }
1295 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1296 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1297 {
1298 di << aGeomTolerance->GetObject()->GetValueOfZoneModifier();
1299 }
1300 return 0;
1301}
1302
1303static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1304{
1305 if (argc < 4) {
586db386 1306 di<<"Use: XAddTolModifier Doc Tol_Label mod1 mod2 ...\n";
9ebaae37 1307 return 1;
1308 }
1309 Handle(TDocStd_Document) Doc;
1310 DDocStd::GetDocument(argv[1], Doc);
586db386 1311 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1312 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1313 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1314
1315 TDF_Label aLabel;
1316 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1317 if ( aLabel.IsNull() )
1318 {
1319 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1320 return 1;
1321 }
1322 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1323 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1324 {
1325 for(Standard_Integer i = 3; i < argc; i++)
1326 {
1327 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 15)
1328 {
1329 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1330 anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i]));
1331 aGeomTolerance->SetObject(anObj);
1332 }
1333 }
1334 }
1335 return 0;
1336}
1337
1338static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1339{
1340 if (argc < 3) {
586db386 1341 di<<"Use: XGetTolModifiers Doc Tol_Label\n";
9ebaae37 1342 return 1;
1343 }
1344 Handle(TDocStd_Document) Doc;
1345 DDocStd::GetDocument(argv[1], Doc);
586db386 1346 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1347 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1348 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1349
1350 TDF_Label aLabel;
1351 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1352 if ( aLabel.IsNull() )
1353 {
1354 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1355 return 1;
1356 }
1357 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1358 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1359 {
1360 XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers();
1361 for(Standard_Integer i = 1; i <= aS.Length(); i++)
1362 {
1363 if (i > 1) di<<", ";
1364 switch(aS.Value(i)){
1365 case 0 : di<<"Any_Cross_Section"; break;
1366 case 1 : di<<"Common_Zone"; break;
1367 case 2 : di<<"Each_Radial_Element"; break;
1368 case 3 : di<<"Free_State"; break;
1369 case 4 : di<<"Least_Material_Requirement"; break;
1370 case 5 : di<<"Line_Element"; break;
1371 case 6 : di<<"Major_Diameter"; break;
1372 case 7 : di<<"Maximum_Material_Requirement"; break;
1373 case 8 : di<<"Minor_Diameter"; break;
1374 case 9 : di<<"Not_Convex"; break;
1375 case 10 : di<<"Pitch_Diameter"; break;
1376 case 11 : di<<"Reciprocity_Requirement"; break;
1377 case 12 : di<<"Separate_Requirement"; break;
1378 case 13 : di<<"Statistical_Tolerance"; break;
1379 case 14 : di<<"Tangent_Plane"; break;
1380 default : break;
1381 }
1382 }
1383 }
1384 return 0;
1385}
1386
1387static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1388{
1389 if (argc < 4) {
586db386 1390 di<<"Use: XSetTolMaxValue Doc Dim_Label val\n";
9ebaae37 1391 return 1;
1392 }
1393 Handle(TDocStd_Document) Doc;
1394 DDocStd::GetDocument(argv[1], Doc);
586db386 1395 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1396 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1397 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1398
1399 TDF_Label aLabel;
1400 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1401 if ( aLabel.IsNull() )
1402 {
1403 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1404 return 1;
1405 }
1406 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1407 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1408 {
1409 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
1410 anObj->SetMaxValueModifier(Draw::Atof(argv[3]));
1411 aGeomTolerance->SetObject(anObj);
1412 }
1413 return 0;
1414}
1415
1416static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1417{
1418 if (argc < 3) {
586db386 1419 di<<"Use: XGetTolMaxValue Doc Dim_Label\n";
9ebaae37 1420 return 1;
1421 }
1422 Handle(TDocStd_Document) Doc;
1423 DDocStd::GetDocument(argv[1], Doc);
586db386 1424 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1425 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1426 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1427
1428 TDF_Label aLabel;
1429 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1430 if ( aLabel.IsNull() )
1431 {
1432 di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1433 return 1;
1434 }
1435 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
1436 if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
1437 {
1438 di << aGeomTolerance->GetObject()->GetMaxValueModifier();
1439 }
1440 return 0;
1441}
1442
1443static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1444{
1445 if (argc < 4) {
586db386 1446 di<<"Use: XSetDimensionType Doc Dim_Label type\n";
9ebaae37 1447 return 1;
1448 }
1449 Handle(TDocStd_Document) Doc;
1450 DDocStd::GetDocument(argv[1], Doc);
586db386 1451 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1452 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1453 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1454
1455 TDF_Label aLabel;
1456 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1457 if ( aLabel.IsNull() )
1458 {
1459 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1460 return 1;
1461 }
1462 Handle(XCAFDoc_Dimension) aDimension;
1463 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1464 {
1465 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30)
1466 {
1467 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1468 anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3]));
1469 aDimension->SetObject(anObj);
1470 }
1471 }
1472 return 0;
1473}
1474
1475static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1476{
1477 if (argc < 3) {
586db386 1478 di<<"Use: XGetDimensionType Doc Dim_Label\n";
9ebaae37 1479 return 1;
1480 }
1481 Handle(TDocStd_Document) Doc;
1482 DDocStd::GetDocument(argv[1], Doc);
586db386 1483 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1484 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1485 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1486
1487 TDF_Label aLabel;
1488 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1489 if ( aLabel.IsNull() )
1490 {
1491 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1492 return 1;
1493 }
1494 Handle(XCAFDoc_Dimension) aDimension;
1495 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1496 {
1497 switch(aDimension->GetObject()->GetType()){
1498 case 0 : di<<"type is absent"; break;
1499 case 1 : di<<"Location_CurvedDistance"; break;
1500 case 2 : di<<"Location_LinearDistance"; break;
1501 case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break;
1502 case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break;
1503 case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break;
1504 case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break;
1505 case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break;
1506 case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break;
1507 case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break;
1508 case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break;
1509 case 11 : di<<"Location_Angular"; break;
1510 case 12 : di<<"Location_Oriented"; break;
1511 case 13 : di<<"Location_WithPath"; break;
1512 case 14 : di<<"Size_CurveLength"; break;
1513 case 15 : di<<"Size_Diameter"; break;
1514 case 16 : di<<"Size_SphericalDiameter"; break;
1515 case 17 : di<<"Size_Radius"; break;
1516 case 18 : di<<"Size_SphericalRadius"; break;
1517 case 19 : di<<"Size_ToroidalMinorDiameter"; break;
1518 case 20 : di<<"Size_ToroidalMajorDiameter"; break;
1519 case 21 : di<<"Size_ToroidalMinorRadius"; break;
1520 case 22 : di<<"Size_ToroidalMajorRadius"; break;
1521 case 23 : di<<"Size_ToroidalHighMajorDiameter"; break;
1522 case 24 : di<<"Size_ToroidalLowMajorDiameter"; break;
1523 case 25 : di<<"Size_ToroidalHighMajorRadius"; break;
1524 case 26 : di<<"Size_ToroidalLowMajorRadius"; break;
1525 case 27 : di<<"Size_Thickness"; break;
1526 case 28 : di<<"Size_Angular"; break;
1527 case 29 : di<<"Size_WithPath"; break;
1528 default : break;
1529 }
1530 }
1531 return 0;
1532}
1533
1534static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1535{
1536 if (argc < 4) {
586db386 1537 di<<"Use: XSetDimensionValue Doc Dim_Label val\n";
9ebaae37 1538 return 1;
1539 }
1540 Handle(TDocStd_Document) Doc;
1541 DDocStd::GetDocument(argv[1], Doc);
586db386 1542 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1543 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1544 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1545
1546 TDF_Label aLabel;
1547 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1548 if ( aLabel.IsNull() )
1549 {
1550 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1551 return 1;
1552 }
1553 Handle(XCAFDoc_Dimension) aDimension;
1554 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1555 {
1556 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1557 anObj->SetValue(Draw::Atof(argv[3]));
1558 aDimension->SetObject(anObj);
1559 }
1560 return 0;
1561}
1562
1563static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1564{
1565 if (argc < 3) {
586db386 1566 di<<"Use: XGetDimensionValue Doc Dim_Label\n";
9ebaae37 1567 return 1;
1568 }
1569 Handle(TDocStd_Document) Doc;
1570 DDocStd::GetDocument(argv[1], Doc);
586db386 1571 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1572 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1573 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1574
1575 TDF_Label aLabel;
1576 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1577 if ( aLabel.IsNull() )
1578 {
1579 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1580 return 1;
1581 }
1582 Handle(XCAFDoc_Dimension) aDimension;
1583 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1584 {
1585 di << aDimension->GetObject()->GetValue();
1586 }
1587 return 0;
1588}
1589
1590static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1591{
1592 if (argc < 4) {
586db386 1593 di<<"Use: XSetDimensionQualifier Doc Dim_Label val\n";
9ebaae37 1594 return 1;
1595 }
1596 Handle(TDocStd_Document) Doc;
1597 DDocStd::GetDocument(argv[1], Doc);
586db386 1598 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1599 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1600 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1601
1602 TDF_Label aLabel;
1603 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1604 if ( aLabel.IsNull() )
1605 {
1606 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1607 return 1;
1608 }
1609 Handle(XCAFDoc_Dimension) aDimension;
1610 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1611 {
1612 if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4)
1613 {
1614 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1615 anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3]));
1616 aDimension->SetObject(anObj);
1617 }
1618 }
1619 return 0;
1620}
1621
1622static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1623{
1624 if (argc < 3) {
586db386 1625 di<<"Use: XGetDimensionQualifier Doc Dim_Label\n";
9ebaae37 1626 return 1;
1627 }
1628 Handle(TDocStd_Document) Doc;
1629 DDocStd::GetDocument(argv[1], Doc);
586db386 1630 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1631 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1632 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1633
1634 TDF_Label aLabel;
1635 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1636 if ( aLabel.IsNull() )
1637 {
1638 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1639 return 1;
1640 }
1641 Handle(XCAFDoc_Dimension) aDimension;
1642 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1643 {
1644
1645 switch(aDimension->GetObject()->GetQualifier()){
1646 case 0 : di<<"type is absent"; break;
1647 case 1 : di<<"Min"; break;
1648 case 2 : di<<"Max"; break;
1649 case 3 : di<<"Avg"; break;
1650 default : break;
1651 }
1652 }
1653 return 0;
1654}
1655
1656static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1657{
1658 if (argc < 5) {
586db386 1659 di<<"Use: XSetDimensionRange Doc Dim_Label low_val up_val\n";
9ebaae37 1660 return 1;
1661 }
1662 Handle(TDocStd_Document) Doc;
1663 DDocStd::GetDocument(argv[1], Doc);
586db386 1664 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1665 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1666 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1667
1668 TDF_Label aLabel;
1669 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1670 if ( aLabel.IsNull() )
1671 {
1672 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1673 return 1;
1674 }
1675 Handle(XCAFDoc_Dimension) aDimension;
1676 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1677 {
1678 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1679 {
1680 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1681 anObj->SetLowerBound(Draw::Atof(argv[3]));
1682 anObj->SetUpperBound(Draw::Atof(argv[4]));
1683 aDimension->SetObject(anObj);
1684 }
1685 }
1686 return 0;
1687}
1688
1689static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1690{
1691 if (argc < 3) {
586db386 1692 di<<"Use: XGetDimensionRange Doc Dim_Label\n";
9ebaae37 1693 return 1;
1694 }
1695 Handle(TDocStd_Document) Doc;
1696 DDocStd::GetDocument(argv[1], Doc);
586db386 1697 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1698 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1699 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1700
1701 TDF_Label aLabel;
1702 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1703 if ( aLabel.IsNull() )
1704 {
1705 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1706 return 1;
1707 }
1708 Handle(XCAFDoc_Dimension) aDimension;
1709 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1710 {
1711 di << "lower " << aDimension->GetObject()->GetLowerBound();
1712 di << " upper " << aDimension->GetObject()->GetUpperBound();
1713 }
1714 return 0;
1715}
1716
1717static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1718{
1719 if (argc < 5) {
586db386 1720 di<<"Use: XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n";
9ebaae37 1721 return 1;
1722 }
1723 Handle(TDocStd_Document) Doc;
1724 DDocStd::GetDocument(argv[1], Doc);
586db386 1725 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1726 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1727 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1728
1729 TDF_Label aLabel;
1730 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1731 if ( aLabel.IsNull() )
1732 {
1733 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1734 return 1;
1735 }
1736 Handle(XCAFDoc_Dimension) aDimension;
1737 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1738 {
1739 if(Draw::Atof(argv[3]) < Draw::Atof(argv[4]))
1740 {
1741 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1742 anObj->SetLowerTolValue(Draw::Atof(argv[3]));
1743 anObj->SetUpperTolValue(Draw::Atof(argv[4]));
1744 aDimension->SetObject(anObj);
1745 }
1746 }
1747 return 0;
1748}
1749
1750static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1751{
1752 if (argc < 3) {
586db386 1753 di<<"Use: XGetDimensionPlusMinusTol Doc Dim_Label\n";
9ebaae37 1754 return 1;
1755 }
1756 Handle(TDocStd_Document) Doc;
1757 DDocStd::GetDocument(argv[1], Doc);
586db386 1758 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1759 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1760 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1761
1762 TDF_Label aLabel;
1763 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1764 if ( aLabel.IsNull() )
1765 {
1766 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1767 return 1;
1768 }
1769 Handle(XCAFDoc_Dimension) aDimension;
1770 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1771 {
1772 di << "lower " << aDimension->GetObject()->GetLowerTolValue();
1773 di << " upper " << aDimension->GetObject()->GetUpperTolValue();
1774 }
1775 return 0;
1776}
1777
1778static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1779{
1780 if (argc < 6) {
586db386 1781 di<<"Use: XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n";
9ebaae37 1782 return 1;
1783 }
1784 Handle(TDocStd_Document) Doc;
1785 DDocStd::GetDocument(argv[1], Doc);
586db386 1786 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1787 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1788 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1789
1790 TDF_Label aLabel;
1791 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1792 if ( aLabel.IsNull() )
1793 {
1794 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1795 return 1;
1796 }
1797 Handle(XCAFDoc_Dimension) aDimension;
1798 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1799 {
1800 if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20)
1801 {
1802 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1803 anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5]));
1804 aDimension->SetObject(anObj);
1805 }
1806 }
1807 return 0;
1808}
1809
1810static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1811{
1812 if (argc < 3) {
586db386 1813 di<<"Use: XGetDimensionClassOfTol Doc Dim_Label\n";
9ebaae37 1814 return 1;
1815 }
1816 Handle(TDocStd_Document) Doc;
1817 DDocStd::GetDocument(argv[1], Doc);
586db386 1818 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1819 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1820 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1821
1822 TDF_Label aLabel;
1823 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1824 if ( aLabel.IsNull() )
1825 {
1826 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1827 return 1;
1828 }
1829 Handle(XCAFDoc_Dimension) aDimension;
1830 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1831 {
1832 Standard_Boolean h;
1833 XCAFDimTolObjects_DimensionFormVariance f;
1834 XCAFDimTolObjects_DimensionGrade g;
1835 if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g))
1836 {
1837 if(h)
1838 {
1839 switch(f){
1840 case 1 : di<<"a";break;
1841 case 2 : di<<"b";break;
1842 case 3 : di<<"c";break;
1843 case 4 : di<<"cd";break;
1844 case 5 : di<<"d";break;
1845 case 6 : di<<"e";break;
1846 case 7 : di<<"ef";break;
1847 case 8 : di<<"f";break;
1848 case 9 : di<<"fg";break;
1849 case 10 : di<<"g";break;
1850 case 11 : di<<"h";break;
1851 case 12 : di<<"js";break;
1852 case 13 : di<<"j";break;
1853 case 14 : di<<"k";break;
1854 case 15 : di<<"m";break;
1855 case 16 : di<<"n";break;
1856 case 17 : di<<"p";break;
1857 case 18 : di<<"r";break;
1858 case 19 : di<<"s";break;
1859 case 20 : di<<"t";break;
1860 case 21 : di<<"u";break;
1861 case 22 : di<<"v";break;
1862 case 23 : di<<"x";break;
1863 case 24 : di<<"y";break;
1864 case 25 : di<<"z";break;
1865 case 26 : di<<"a";break;
1866 case 27 : di<<"zb";break;
1867 case 28 : di<<"zc";break;
1868 default : break;
1869 }
1870 }
1871 else
1872 {
1873 switch(f){
1874 case 1 : di<<"A";break;
1875 case 2 : di<<"B";break;
1876 case 3 : di<<"C";break;
1877 case 4 : di<<"CD";break;
1878 case 5 : di<<"D";break;
1879 case 6 : di<<"E";break;
1880 case 7 : di<<"EF";break;
1881 case 8 : di<<"F";break;
1882 case 9 : di<<"FG";break;
1883 case 10 : di<<"G";break;
1884 case 11 : di<<"H";break;
1885 case 12 : di<<"JS";break;
1886 case 13 : di<<"J";break;
1887 case 14 : di<<"K";break;
1888 case 15 : di<<"M";break;
1889 case 16 : di<<"N";break;
1890 case 17 : di<<"P";break;
1891 case 18 : di<<"R";break;
1892 case 19 : di<<"S";break;
1893 case 20 : di<<"T";break;
1894 case 21 : di<<"U";break;
1895 case 22 : di<<"V";break;
1896 case 23 : di<<"X";break;
1897 case 24 : di<<"Y";break;
1898 case 25 : di<<"Z";break;
1899 case 26 : di<<"ZA";break;
1900 case 27 : di<<"ZB";break;
1901 case 28 : di<<"ZC";break;
1902 default : break;
1903 }
1904 }
1905 switch(g){
1906 case 0 : di<<"01"; break;
1907 case 1 : di<<"0"; break;
1908 case 2 : di<<"1"; break;
1909 case 3 : di<<"2"; break;
1910 case 4 : di<<"3"; break;
1911 case 5 : di<<"4"; break;
1912 case 6 : di<<"5"; break;
1913 case 7 : di<<"6"; break;
1914 case 8 : di<<"7"; break;
1915 case 9 : di<<"8"; break;
1916 case 10 : di<<"9"; break;
1917 case 11 : di<<"10"; break;
1918 case 12 : di<<"11"; break;
1919 case 13 : di<<"12"; break;
1920 case 14 : di<<"13"; break;
1921 case 15 : di<<"14"; break;
1922 case 16 : di<<"15"; break;
1923 case 17 : di<<"16"; break;
1924 case 18 : di<<"17"; break;
1925 case 19 : di<<"18"; break;
1926 default : break;
1927 }
1928 }
1929 }
1930 return 0;
1931}
1932
1933static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1934{
1935 if (argc < 5) {
586db386 1936 di<<"Use: XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n";
9ebaae37 1937 return 1;
1938 }
1939 Handle(TDocStd_Document) Doc;
1940 DDocStd::GetDocument(argv[1], Doc);
586db386 1941 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1942 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1943 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1944
1945 TDF_Label aLabel;
1946 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1947 if ( aLabel.IsNull() )
1948 {
1949 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1950 return 1;
1951 }
1952 Handle(XCAFDoc_Dimension) aDimension;
1953 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1954 {
1955 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
1956 anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4]));
1957 aDimension->SetObject(anObj);
1958 }
1959 return 0;
1960}
1961
1962static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1963{
1964 if (argc < 3) {
586db386 1965 di<<"Use: XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n";
9ebaae37 1966 return 1;
1967 }
1968 Handle(TDocStd_Document) Doc;
1969 DDocStd::GetDocument(argv[1], Doc);
586db386 1970 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 1971 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
1972 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1973
1974 TDF_Label aLabel;
1975 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
1976 if ( aLabel.IsNull() )
1977 {
1978 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
1979 return 1;
1980 }
1981 Handle(XCAFDoc_Dimension) aDimension;
1982 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
1983 {
1984 Standard_Integer l, r;
1985 aDimension->GetObject()->GetNbOfDecimalPlaces(l,r);
1986 di << l << "." << r;
1987 }
1988 return 0;
1989}
1990
1991static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1992{
1993 if (argc < 4) {
586db386 1994 di<<"Use: XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n";
9ebaae37 1995 return 1;
1996 }
1997 Handle(TDocStd_Document) Doc;
1998 DDocStd::GetDocument(argv[1], Doc);
586db386 1999 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2000 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2001 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2002
2003 TDF_Label aLabel;
2004 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2005 if ( aLabel.IsNull() )
2006 {
2007 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2008 return 1;
2009 }
2010 Handle(XCAFDoc_Dimension) aDimension;
2011 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2012 {
2013 for(Standard_Integer i = 3; i < argc; i++)
2014 {
2015 if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24)
2016 {
2017 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2018 anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i]));
2019 aDimension->SetObject(anObj);
2020 }
2021 }
2022 }
2023 return 0;
2024}
2025
2026static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2027{
2028 if (argc < 3) {
586db386 2029 di<<"Use: XGetDimensionModifiers Doc Dim_Label\n";
9ebaae37 2030 return 1;
2031 }
2032 Handle(TDocStd_Document) Doc;
2033 DDocStd::GetDocument(argv[1], Doc);
586db386 2034 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2035 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2036 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2037
2038 TDF_Label aLabel;
2039 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2040 if ( aLabel.IsNull() )
2041 {
2042 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2043 return 1;
2044 }
2045 Handle(XCAFDoc_Dimension) aDimension;
2046 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2047 {
2048 XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers();
2049 for(Standard_Integer i = 1; i <= aS.Length(); i++)
2050 {
2051 if (i > 1) di<<", ";
2052 switch(aS.Value(i)){
2053 case 0 : di<<"ControlledRadius"; break;
2054 case 1 : di<<"Square"; break;
2055 case 2 : di<<"StatisticalTolerance"; break;
2056 case 3 : di<<"ContinuousFeature"; break;
2057 case 4 : di<<"TwoPointSize"; break;
2058 case 5 : di<<"LocalSizeDefinedBySphere"; break;
2059 case 6 : di<<"LeastSquaresAssociationCriterion"; break;
2060 case 7 : di<<"MaximumInscribedAssociation"; break;
2061 case 8 : di<<"MinimumCircumscribedAssociation"; break;
2062 case 9 : di<<"CircumferenceDiameter"; break;
2063 case 10 : di<<"AreaDiameter"; break;
2064 case 11 : di<<"VolumeDiameter"; break;
2065 case 12 : di<<"MaximumSize"; break;
2066 case 13 : di<<"MinimumSize"; break;
2067 case 14 : di<<"AverageSize"; break;
2068 case 15 : di<<"MedianSize"; break;
2069 case 16 : di<<"MidRangeSize"; break;
2070 case 17 : di<<"RangeOfSizes"; break;
2071 case 18 : di<<"AnyRestrictedPortionOfFeature"; break;
2072 case 19 : di<<"AnyCrossSection"; break;
2073 case 20 : di<<"SpecificFixedCrossSection"; break;
2074 case 21 : di<<"CommonTolerance"; break;
2075 case 22 : di<<"FreeStateCondition"; break;
2076 case 23 : di<<"Between"; break;
2077 default : break;
2078 }
2079 }
2080 }
2081 return 0;
2082}
2083
2084static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2085{
2086 if (argc < 4) {
586db386 2087 di<<"Use: XSetDimensionPath Doc Dim_Label path(edge)\n";
9ebaae37 2088 return 1;
2089 }
2090 Handle(TDocStd_Document) Doc;
2091 DDocStd::GetDocument(argv[1], Doc);
586db386 2092 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2093 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2094 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2095
2096 TDF_Label aLabel;
2097 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2098 if ( aLabel.IsNull() )
2099 {
2100 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2101 return 1;
2102 }
2103 Handle(XCAFDoc_Dimension) aDimension;
2104 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2105 {
2106 TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE));
2107 if(!aE.IsNull())
2108 {
2109 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2110 anObj->SetPath(aE);
2111 aDimension->SetObject(anObj);
2112 }
2113 }
2114 return 0;
2115}
2116
2117static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2118{
b7b2f85a 2119 if (argc < 4) {
2120 di<<"Use: XSetDimensionPoints Doc Dim_Label v1 [v2]\n";
9ebaae37 2121 return 1;
2122 }
2123 Handle(TDocStd_Document) Doc;
2124 DDocStd::GetDocument(argv[1], Doc);
586db386 2125 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2126 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2127 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2128
2129 TDF_Label aLabel;
2130 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2131 if ( aLabel.IsNull() )
2132 {
2133 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2134 return 1;
2135 }
2136 Handle(XCAFDoc_Dimension) aDimension;
2137 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2138 {
b7b2f85a 2139 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2140
9ebaae37 2141 TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX));
b7b2f85a 2142 if(!aV1.IsNull()) {
2143 anObj->SetPoint(BRep_Tool::Pnt(aV1));
9ebaae37 2144 }
b7b2f85a 2145 if (argc == 5) {
2146 TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX));
2147 if(!aV2.IsNull()) {
2148 anObj->SetPoint2(BRep_Tool::Pnt(aV2));
2149 }
2150 }
2151 aDimension->SetObject(anObj);
9ebaae37 2152 }
2153 return 0;
2154}
2155
2156static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2157{
2158 if (argc < 3) {
586db386 2159 di<<"Use: XGetDimensionPoints Doc Dim_Label\n";
9ebaae37 2160 return 1;
2161 }
2162 Handle(TDocStd_Document) Doc;
2163 DDocStd::GetDocument(argv[1], Doc);
586db386 2164 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2165 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2166 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2167
2168 TDF_Label aLabel;
2169 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2170 if ( aLabel.IsNull() )
2171 {
2172 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2173 return 1;
2174 }
2175 Handle(XCAFDoc_Dimension) aDimension;
2176 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2177 {
b7b2f85a 2178 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2179 if(anObj->HasPoint()) {
2180 di << anObj->GetPoint().X() << ";" << anObj->GetPoint().Y() << ";" << anObj->GetPoint().Z() << " ";
2181 }
2182 if(anObj->HasPoint2()) {
2183 di << anObj->GetPoint2().X() << ";" << anObj->GetPoint2().Y() << ";" << anObj->GetPoint2().Z();
9ebaae37 2184 }
2185 }
2186 return 0;
2187}
2188
2189static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2190{
2191 if (argc < 6) {
586db386 2192 di<<"Use: XSetDimensionDir Doc Dim_Label x y z\n";
9ebaae37 2193 return 1;
2194 }
2195 Handle(TDocStd_Document) Doc;
2196 DDocStd::GetDocument(argv[1], Doc);
586db386 2197 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2198 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2199 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2200
2201 TDF_Label aLabel;
2202 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2203 if ( aLabel.IsNull() )
2204 {
2205 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2206 return 1;
2207 }
2208 Handle(XCAFDoc_Dimension) aDimension;
2209 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2210 {
2211 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2212 anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5])));
2213 aDimension->SetObject(anObj);
2214 }
2215 return 0;
2216}
2217
2218static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2219{
2220 if (argc < 3) {
7644c7f4 2221 di<<"Use: XGetDimensionDir Doc Dim_Label\n";
9ebaae37 2222 return 1;
2223 }
2224 Handle(TDocStd_Document) Doc;
2225 DDocStd::GetDocument(argv[1], Doc);
586db386 2226 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
9ebaae37 2227 Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
2228 Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
2229
2230 TDF_Label aLabel;
2231 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2232 if ( aLabel.IsNull() )
2233 {
2234 di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n";
2235 return 1;
2236 }
2237 Handle(XCAFDoc_Dimension) aDimension;
2238 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2239 {
2240 gp_Dir dir;
2241 if(aDimension->GetObject()->GetDirection(dir))
2242 {
2243 di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z();
2244 }
2245 }
2246 return 0;
2247}
2248
7644c7f4 2249static Standard_Integer addDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2250{
2251 if (argc < 4) {
2252 di<<"Use: XAddDimensionDescr Doc Dim_Label Description [DescriptionName]\n";
2253 return 1;
2254 }
2255 Handle(TDocStd_Document) Doc;
2256 DDocStd::GetDocument(argv[1], Doc);
2257 if ( Doc.IsNull() ) {
2258 di << argv[1] << " is not a document\n";
2259 return 1;
2260 }
2261
2262 TDF_Label aLabel;
2263 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2264 if ( aLabel.IsNull() )
2265 {
2266 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2267 return 1;
2268 }
2269 Handle(XCAFDoc_Dimension) aDimension;
2270 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2271 {
2272 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2273 Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString(argv[3]);
2274 Handle(TCollection_HAsciiString) aDescrName = (argc == 4) ? new TCollection_HAsciiString()
2275 : new TCollection_HAsciiString(argv[4]);
2276 anObj->AddDescription(aDescription, aDescrName);
2277 aDimension->SetObject(anObj);
2278 }
2279 return 0;
2280}
2281
2282static Standard_Integer getDimDescr (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2283{
2284 if (argc < 3) {
2285 di << "Use: XGetDimensionDescr Doc Dim_Label\n";
2286 return 1;
2287 }
2288 Handle(TDocStd_Document) Doc;
2289 DDocStd::GetDocument(argv[1], Doc);
2290 if ( Doc.IsNull() ) {
2291 di << argv[1] << " is not a document\n";
2292 return 1;
2293 }
2294
2295 TDF_Label aLabel;
2296 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2297 if ( aLabel.IsNull() )
2298 {
2299 di << "Dimension "<< argv[2] << " is absent in " << argv[1] << "\n";
2300 return 1;
2301 }
2302 Handle(XCAFDoc_Dimension) aDimension;
2303 if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2304 {
2305 Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimension->GetObject();
2306 for (Standard_Integer i = 0; i < anObject->NbDescriptions(); i++) {
2307 Handle(TCollection_HAsciiString) aDescription = anObject->GetDescription(i);
2308 Handle(TCollection_HAsciiString) aDescrName = anObject->GetDescriptionName(i);
2309 di << "name: " << aDescrName->ToCString() << " description: " << aDescription->ToCString() << "\n";
2310 }
2311 }
2312 return 0;
2313}
2314
f0bf70e8 2315static Standard_Integer addGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2316{
2317 if (argc < 12) {
2318 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 return 1;
2320 }
2321 Handle(TDocStd_Document) Doc;
2322 DDocStd::GetDocument(argv[1], Doc);
2323 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2324
2325 TDF_Label aLabel;
2326 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2327 if ( aLabel.IsNull() )
2328 {
2329 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2330 return 1;
2331 }
2332
2333 gp_Pnt aPoint(Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]));
2334 gp_Dir aNormal(Draw::Atof(argv[6]), Draw::Atof(argv[7]), Draw::Atof(argv[8]));
2335 gp_Dir aDir(Draw::Atof(argv[9]), Draw::Atof(argv[10]), Draw::Atof(argv[11]));
2336 gp_Ax2 aPlane(aPoint, aNormal, aDir);
2337 // Dimension
2338 Handle(XCAFDoc_Dimension) aDimension;
2339 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2340 {
2341 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2342 anObj->SetPlane(aPlane);
2343 anObj->SetPointTextAttach(aPoint);
2344 aDimension->SetObject(anObj);
2345 }
2346 // Geometric Tolerance
2347 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2348 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2349 {
2350 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2351 anObj->SetPlane(aPlane);
2352 anObj->SetPointTextAttach(aPoint);
2353 aGeomTolerance->SetObject(anObj);
2354 }
2355 // Datum
2356 Handle(XCAFDoc_Datum) aDatum;
2357 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2358 {
2359 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2360 anObj->SetPlane(aPlane);
2361 anObj->SetPointTextAttach(aPoint);
2362 aDatum->SetObject(anObj);
2363 }
2364 return 0;
2365}
2366
2367static Standard_Integer getGDTPosition (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2368{
2369 if (argc < 3) {
2370 di << "Use: XGetGDTPosition Doc GDT_Label\n";
2371 return 1;
2372 }
2373 Handle(TDocStd_Document) Doc;
2374 DDocStd::GetDocument(argv[1], Doc);
2375 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2376
2377 TDF_Label aLabel;
2378 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2379 if ( aLabel.IsNull() )
2380 {
2381 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2382 return 1;
2383 }
2384 gp_Pnt aPoint;
2385 gp_Dir aNormal, aDir;
2386 // Dimension
2387 Handle(XCAFDoc_Dimension) aDimension;
2388 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2389 {
2390 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2391 aPoint = anObj->GetPointTextAttach();
2392 aNormal = anObj->GetPlane().Direction();
2393 aDir = anObj->GetPlane().XDirection();
2394 }
2395 // Geometric Tolerance
2396 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2397 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2398 {
2399 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2400 aPoint = anObj->GetPointTextAttach();
2401 aNormal = anObj->GetPlane().Direction();
2402 aDir = anObj->GetPlane().XDirection();
2403 }
2404 // Datum
2405 Handle(XCAFDoc_Datum) aDatum;
2406 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2407 {
2408 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2409 aPoint = anObj->GetPointTextAttach();
2410 aNormal = anObj->GetPlane().Direction();
2411 aDir = anObj->GetPlane().XDirection();
2412 }
2413
2414 di << "position: " << aPoint.X() << " " << aPoint.Y() << " " << aPoint.Z() << "\n";
2415 di << "normal: " << aNormal.X() << " " << aNormal.Y() << " " << aNormal.Z() << "\n";
2416 di << "x_direction: " << aDir.X() << " " << aDir.Y() << " " << aDir.Z() << "\n";
2417 return 0;
2418}
2419
2420static Standard_Integer addGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2421{
2422 if (argc < 5) {
2423 di << "Use: XSetGDTPresentation Doc GDT_Label Shape Name\n";
2424 return 1;
2425 }
2426 Handle(TDocStd_Document) Doc;
2427 DDocStd::GetDocument(argv[1], Doc);
2428 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2429
2430 TDF_Label aLabel;
2431 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2432 if ( aLabel.IsNull() )
2433 {
2434 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2435 return 1;
2436 }
2437
2438 TopoDS_Shape aPresentation= DBRep::Get(argv[3]);
2439 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[4]);
2440 // Dimension
2441 Handle(XCAFDoc_Dimension) aDimension;
2442 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2443 {
2444 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2445 anObj->SetPresentation(aPresentation, aName);
2446 aDimension->SetObject(anObj);
2447 }
2448 // Geometric Tolerance
2449 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2450 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2451 {
2452 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2453 anObj->SetPresentation(aPresentation, aName);
2454 aGeomTolerance->SetObject(anObj);
2455 }
2456 // Datum
2457 Handle(XCAFDoc_Datum) aDatum;
2458 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2459 {
2460 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2461 anObj->SetPresentation(aPresentation, aName);
2462 aDatum->SetObject(anObj);
2463 }
2464 return 0;
2465}
2466
2467static Standard_Integer getGDTPresentation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2468{
2469 if (argc < 3) {
2470 di << "Use: XGetGDTPresentation Doc GDT_Label Shape\n";
2471 return 1;
2472 }
2473 Handle(TDocStd_Document) Doc;
2474 DDocStd::GetDocument(argv[1], Doc);
2475 if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
2476
2477 TDF_Label aLabel;
2478 TDF_Tool::Label(Doc->GetData(), argv[2], aLabel);
2479 if ( aLabel.IsNull() )
2480 {
2481 di << "GDT " << argv[2] << " is absent in " << argv[1] << "\n";
2482 return 1;
2483 }
2484 TopoDS_Shape aPresentation;
2485 // Dimension
2486 Handle(XCAFDoc_Dimension) aDimension;
2487 if (aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension))
2488 {
2489 Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject();
2490 aPresentation = anObj->GetPresentation();
2491 }
2492 // Geometric Tolerance
2493 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
2494 if (aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance))
2495 {
2496 Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject();
2497 aPresentation = anObj->GetPresentation();
2498 }
2499 // Datum
2500 Handle(XCAFDoc_Datum) aDatum;
2501 if (aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
2502 {
2503 Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject();
2504 aPresentation = anObj->GetPresentation();
2505 }
2506
2507 DBRep::Set (argv[3], aPresentation);
2508 return 0;
2509}
2510
9ebaae37 2511//=======================================================================
2512//function : InitCommands
2513//purpose :
2514//=======================================================================
2515
2516void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
2517{
2518
2519 static Standard_Boolean initactor = Standard_False;
2520 if (initactor) return; initactor = Standard_True;
2521
2522
2523 Standard_CString g = "XDE G&DTs commands";
2524
2525 di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
2526 __FILE__, DumpDGTs, g);
2527
6595eee7 2528 di.Add ("XDumpNbDGTs","XDumpNbDGTs Doc [f (full dumping)]",
1c9d3225 2529 __FILE__, DumpNbDGTs, g);
2530
9ebaae37 2531 di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
2532 __FILE__, addDim, g);
2533
2534 di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label",
2535 __FILE__, addGTol, g);
2536
2537 di.Add ("XAddDatum","XAddDatum Doc shape/label",
2538 __FILE__, addDatum, g);
2539
2540 di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label",
2541 __FILE__, setDatum, g);
2542
2543 di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label",
2544 __FILE__, getDatum, g);
2545
2546 di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"
2547 "Values:"
2548 "\n 0 AnyCrossSection"
2549 "\n 1 Any_LongitudinalSection"
2550 "\n 2 Basic"
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"
2559 "\n 11 FreeState"
2560 "\n 12 LeastMaterialRequirement"
2561 "\n 13 Line"
2562 "\n 14 MajorDiameter"
2563 "\n 15 MaximumMaterialRequirement"
2564 "\n 16 MinorDiameter"
2565 "\n 17 Orientation"
2566 "\n 18 PitchDiameter"
2567 "\n 19 Plane"
2568 "\n 20 Point"
2569 "\n 21 Translation",
2570 __FILE__, addDatumModif, g);
2571
2572 di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label",
2573 __FILE__, getDatumModif, g);
2574
2575 di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name",
2576 __FILE__, setDatumName, g);
2577
2578 di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label",
2579 __FILE__, getDatumName, g);
2580
c1070321 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);
2584
2585 di.Add ("XGetDatumPosition","XGetDatumPosition Doc Datum_Label",
2586 __FILE__, getDatumPosition, g);
2587
9ebaae37 2588 di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type"
2589 "Values:\n"
2590 "\t 0 type is absent\n"
2591 "\t 1 Angularity\n"
2592 "\t 2 CircularRunout\n"
2593 "\t 3 CircularityOrRoundness\n"
2594 "\t 4 Coaxiality\n"
2595 "\t 5 Concentricity\n"
2596 "\t 6 Cylindricity\n"
2597 "\t 7 Flatness\n"
2598 "\t 8 Parallelism\n"
2599 "\t 9 Perpendicularity\n"
2600 "\t 10 Position\n"
2601 "\t 11 ProfileOfLine\n"
2602 "\t 12 ProfileOfSurface\n"
2603 "\t 13 Straightness\n"
2604 "\t 14 Symmetry\n"
2605 "\t 15 TotalRunout\n",
2606 __FILE__, setTypeOfTol, g);
2607
2608 di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label",
2609 __FILE__, getTypeOfTol, g);
2610
2611 di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type"
2612 "Values:"
2613 "\n 0 none"
2614 "\n 1 Diameter"
2615 "\n 2 SphericalDiameter",
2616 __FILE__, setTypeOfTolVal, g);
2617
2618 di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label",
2619 __FILE__, getTypeOfTolVal, g);
2620
2621 di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value",
2622 __FILE__, setTolVal, g);
2623
2624 di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label",
2625 __FILE__, getTolVal, g);
2626
2627 di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod"
2628 "Values:"
2629 "\n 0 none"
2630 "\n 1 M"
2631 "\n 2 L",
2632 __FILE__, setMatReq, g);
2633
2634 di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label",
2635 __FILE__, getMatReq, g);
2636
2637 di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod"
2638 "Values:"
2639 "\n 0 none"
2640 "\n 1 P"
2641 "\n 2 NonUniform",
2642 __FILE__, setZoneMod, g);
2643
2644 di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label",
2645 __FILE__, getZoneMod, g);
2646
2647 di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val",
2648 __FILE__, setZoneModVal, g);
2649
2650 di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label",
2651 __FILE__, getZoneModVal, g);
2652
2653 di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..."
2654 "Values:\n"
2655 "\t 0 Any_Cross_Section\n"
2656 "\t 1 Common_Zone\n"
2657 "\t 2 Each_Radial_Element\n"
2658 "\t 3 Free_State\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"
2664 "\t 9 Not_Convex\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);
2671
2672 di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label",
2673 __FILE__, getTolModif, g);
2674
2675 di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val",
2676 __FILE__, setTolMaxVal, g);
2677
2678 di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val",
2679 __FILE__, getTolMaxVal, g);
2680
2681 di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type"
2682 "Values:"
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);
2714
2715 di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label",
2716 __FILE__, getDimType, g);
2717
2718 di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val",
2719 __FILE__, setDimVal, g);
2720
2721 di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label",
2722 __FILE__, getDimVal, g);
2723
2724 di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val"
2725 "Values:"
2726 "\n 0 none"
2727 "\n 1 Min"
2728 "\n 2 Max"
2729 "\n 3 Avg",
2730 __FILE__, setDimQalif, g);
2731
2732 di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label",
2733 __FILE__, getDimQalif, g);
2734
2735 di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val",
2736 __FILE__, setDimRange, g);
2737
2738 di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label",
2739 __FILE__, getDimRange, g);
2740
2741 di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val",
2742 __FILE__, setDimPlusMinusTol, g);
2743
2744 di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label",
2745 __FILE__, getDimPlusMinusTol, g);
2746
2747 di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade"
2748 "Values of formVar:"
2749 "\t 1 a\n"
2750 "\t 2 b\n"
2751 "\t 3 c\n"
2752 "\t 4 cd\n"
2753 "\t 5 d\n"
2754 "\t 6 e\n"
2755 "\t 7 ef\n"
2756 "\t 8 f\n"
2757 "\t 9 fg\n"
2758 "\t10 g\n"
2759 "\t11 h\n"
2760 "\t12 js\n"
2761 "\t13 j\n"
2762 "\t14 k\n"
2763 "\t15 m\n"
2764 "\t16 n\n"
2765 "\t17 p\n"
2766 "\t18 r\n"
2767 "\t19 s\n"
2768 "\t20 t\n"
2769 "\t21 u\n"
2770 "\t22 v\n"
2771 "\t23 x\n"
2772 "\t24 y\n"
2773 "\t25 z\n"
2774 "\t26 za\n"
2775 "\t27 zb\n"
2776 "\t28 zc\n\n"
2777 "Values of grade:"
2778 "\t 0 01\n"
2779 "\t 1 0\n"
2780 "\t 2 1\n"
2781 "\t 3 2d\n"
2782 "\t 4 3\n"
2783 "\t 5 4\n"
2784 "\t 6 5f\n"
2785 "\t 7 76\n"
2786 "\t 8 7g\n"
2787 "\t 9 8\n"
2788 "\t10 9\n"
2789 "\t11 10js\n"
2790 "\t12 11j\n"
2791 "\t13 12k\n"
2792 "\t14 13m\n"
2793 "\t15 14n\n"
2794 "\t16 15p\n"
2795 "\t17 16r\n"
2796 "\t18 17s\n"
2797 "\t19 18t\n",
2798 __FILE__, setDimClassTol, g);
2799
2800 di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label",
2801 __FILE__, getDimClassTol, g);
2802
2803 di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val",
2804 __FILE__, setDimNbOfDecimalPlaces, g);
2805
2806 di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label",
2807 __FILE__, getDimNbOfDecimalPlaces, g);
2808
2809 di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..."
2810 "Values:"
2811 "\t 0 ControlledRadius\n"
2812 "\t 1 Square\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"
2826 "\t15 MedianSize\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"
2834 "\t23 Between\n",
2835 __FILE__, addDimModifier, g);
2836
2837 di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label",
2838 __FILE__, getDimModifier, g);
2839
2840 di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)",
2841 __FILE__, addDimPath, g);
2842
b7b2f85a 2843 di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 [v2]",
9ebaae37 2844 __FILE__, addDimPoints, g);
2845
2846 di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label",
2847 __FILE__, getDimPoints, g);
2848
2849 di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z",
2850 __FILE__, addDimDir, g);
2851
2852 di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label",
2853 __FILE__, getDimDir, g);
7644c7f4 2854
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);
2859
2860 di.Add ("XGetDimensionDescr","XGetDimensionDescr Doc Dim_Label\n"
2861 "Return all descriptions of given Dimension.",
2862 __FILE__, getDimDescr, g);
f0bf70e8 2863
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);
2867
2868 di.Add ("XGetGDTPosition","XGetGDTPosition Doc GDT_Label"
2869 "Returns text position and plane, parallel to which dimension is displayed",
2870 __FILE__, getGDTPosition, g);
2871
2872 di.Add ("XSetGDTPresentation","XSetGDTPresentation Doc GDT_Label Shape Name"
2873 "Set presentation with given name for dimension",
2874 __FILE__, addGDTPresentation, g);
2875
2876 di.Add ("XGetGDTPresentation","XGetGDTPresentation Doc GDT_Label Shape"
2877 "Returns Presentation into Shape",
2878 __FILE__, getGDTPresentation, g);
9ebaae37 2879}