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 | |
22 | #include <TDF_Tool.hxx> |
23 | #include <TDF_Label.hxx> |
24 | #include <TDF_LabelSequence.hxx> |
25 | #include <TDocStd_Document.hxx> |
26 | #include <XCAFDoc_GraphNode.hxx> |
27 | |
28 | #include <XCAFDoc.hxx> |
29 | #include <XCAFDoc_DocumentTool.hxx> |
30 | #include <XCAFDoc_ShapeTool.hxx> |
31 | #include <XCAFDoc_DimTol.hxx> |
32 | #include <XCAFDoc_Dimension.hxx> |
33 | #include <XCAFDimTolObjects_DimensionObject.hxx> |
34 | #include <XCAFDoc_Datum.hxx> |
35 | #include <XCAFDimTolObjects_DatumObject.hxx> |
36 | #include <XCAFDoc_GeomTolerance.hxx> |
37 | #include <XCAFDimTolObjects_GeomToleranceObject.hxx> |
38 | #include <XCAFDoc_DimTolTool.hxx> |
39 | #include <XCAFDimTolObjects_DimensionObjectSequence.hxx> |
40 | #include <XCAFDimTolObjects_DatumObjectSequence.hxx> |
41 | #include <XCAFDimTolObjects_GeomToleranceObjectSequence.hxx> |
42 | #include <XCAFDimTolObjects_DatumSingleModif.hxx> |
43 | #include <XCAFDimTolObjects_DimensionModif.hxx> |
44 | #include <XCAFDimTolObjects_GeomToleranceModif.hxx> |
45 | #include <XCAFDimTolObjects_DatumModifiersSequence.hxx> |
46 | #include <XCAFDimTolObjects_DatumObject.hxx> |
47 | #include <XCAFDimTolObjects_Tool.hxx> |
48 | |
49 | #include <TCollection_AsciiString.hxx> |
50 | #include <TCollection_HAsciiString.hxx> |
51 | #include <TColStd_HArray1OfReal.hxx> |
52 | #include <TColgp_HArray1OfPnt.hxx> |
53 | |
54 | #include <TopoDS.hxx> |
55 | #include <TopoDS_Shape.hxx> |
56 | #include <TopoDS_Edge.hxx> |
57 | #include <TopoDS_Vertex.hxx> |
58 | #include <BRep_Tool.hxx> |
59 | |
60 | |
61 | |
62 | static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
63 | { |
64 | if (argc < 3) { |
65 | di<<"Use: "<<"XDumpDGTs Doc shape/label/all\n"; |
66 | return 1; |
67 | } |
68 | Handle(TDocStd_Document) Doc; |
69 | DDocStd::GetDocument(argv[1], Doc); |
70 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
71 | Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
72 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
73 | |
74 | TCollection_AsciiString name = argv[2]; |
75 | TDF_LabelSequence aLabels; |
76 | if(name.IsEqual("all")) |
77 | { |
78 | aShapeTool->GetShapes(aLabels); |
79 | for ( Standard_Integer i=1; i <= aLabels.Length(); i++ ) |
80 | { |
81 | aShapeTool->GetSubShapes(aLabels.Value(i), aLabels); |
82 | } |
83 | } |
84 | else |
85 | { |
86 | TDF_Label aLabel; |
87 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
88 | if ( !aLabel.IsNull() ) { |
89 | aLabels.Append(aLabel); |
90 | aShapeTool->GetSubShapes(aLabel, aLabels); |
91 | } |
92 | else |
93 | { |
94 | TopoDS_Shape aShape= DBRep::Get(argv[2]); |
95 | if ( !aShape.IsNull() ) |
96 | { |
97 | aShapeTool->Search(aShape, aLabel); |
98 | if ( !aLabel.IsNull() ) { |
99 | aLabels.Append(aLabel); |
100 | aShapeTool->GetSubShapes(aLabel, aLabels); |
101 | } |
102 | else |
103 | { |
104 | di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
105 | return 1; |
106 | } |
107 | } |
108 | } |
109 | } |
110 | |
111 | for ( Standard_Integer i=1; i <= aLabels.Length(); i++ ) |
112 | { |
113 | Standard_Boolean flag = Standard_True; |
114 | TDF_LabelSequence aGDTs; |
115 | aDimTolTool->GetRefDimensionLabels(aLabels.Value(i), aGDTs); |
116 | for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ ) |
117 | { |
118 | Handle(XCAFDoc_Dimension) aDimTol; |
119 | if(aGDTs.Value(j).FindAttribute(XCAFDoc_Dimension::GetID(), aDimTol)) |
120 | { |
121 | Handle(XCAFDimTolObjects_DimensionObject) aDimTolObj = aDimTol->GetObject(); |
122 | if(flag) |
123 | { |
124 | TCollection_AsciiString Entry; |
125 | TDF_Tool::Entry(aLabels.Value(i), Entry); |
126 | di << "\n " << Entry; |
127 | flag = Standard_False; |
128 | } |
129 | TCollection_AsciiString Entry; |
130 | TDF_Tool::Entry(aGDTs.Value(j), Entry); |
131 | di << "\n \t " << Entry; |
132 | flag = Standard_False; |
133 | |
134 | di << " Dimension"; |
135 | } |
136 | } |
137 | aGDTs.Clear(); |
138 | aDimTolTool->GetRefGeomToleranceLabels(aLabels.Value(i), aGDTs); |
139 | for ( Standard_Integer j=1; j <= aGDTs.Length(); j++ ) |
140 | { |
141 | Handle(XCAFDoc_GeomTolerance) aDimTol; |
142 | if(aGDTs.Value(j).FindAttribute(XCAFDoc_GeomTolerance::GetID(), aDimTol)) |
143 | { |
144 | Handle(XCAFDimTolObjects_GeomToleranceObject) aDimTolObj = aDimTol->GetObject(); |
145 | if(flag) |
146 | { |
147 | TCollection_AsciiString Entry; |
148 | TDF_Tool::Entry(aLabels.Value(i), Entry); |
149 | di << "\n " << Entry; |
150 | flag = Standard_False; |
151 | } |
152 | TCollection_AsciiString Entry; |
153 | TDF_Tool::Entry(aGDTs.Value(j), Entry); |
154 | di << "\n \t " << Entry; |
155 | flag = Standard_False; |
156 | |
157 | di << " GeomTolerance"; |
158 | Handle(XCAFDoc_GraphNode) aNode; |
159 | if(aGDTs.Value(j).FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode) && aNode->NbChildren() > 0) |
160 | { |
161 | for(Standard_Integer i = 1; i<=aNode->NbChildren(); i++) |
162 | { |
163 | Handle(XCAFDoc_Datum) aDatum; |
164 | if(aNode->GetChild(i)->Label().FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
165 | { |
166 | TCollection_AsciiString Entry; |
167 | TDF_Tool::Entry(aNode->GetChild(i)->Label(), Entry); |
168 | di << "\n \t \t " << Entry; |
169 | di << " Datum"; |
170 | } |
171 | } |
172 | } |
173 | } |
174 | } |
175 | TDF_Label aDatumL; |
176 | if (aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatumL)) |
177 | { |
178 | Handle(XCAFDoc_Datum) aDatum; |
179 | if(aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
180 | { |
181 | if(flag) |
182 | { |
183 | TCollection_AsciiString Entry; |
184 | TDF_Tool::Entry(aLabels.Value(i), Entry); |
185 | di << "\n " << Entry; |
186 | flag = Standard_False; |
187 | } |
188 | TCollection_AsciiString Entry; |
189 | TDF_Tool::Entry(aDatumL, Entry); |
190 | di << "\n \t " << Entry; |
191 | flag = Standard_False; |
192 | |
193 | di << " Datum"; |
194 | } |
195 | } |
196 | } |
197 | return 0; |
198 | } |
199 | |
200 | static Standard_Integer addDim (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
201 | { |
202 | if (argc < 3) { |
203 | di<<"Use: "<<"XAddDimension Doc shape/label [shape/label]\n"; |
204 | return 1; |
205 | } |
206 | Handle(TDocStd_Document) Doc; |
207 | DDocStd::GetDocument(argv[1], Doc); |
208 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
209 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
210 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
211 | |
212 | TDF_Label aLabel; |
213 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
214 | if ( aLabel.IsNull() ) |
215 | { |
216 | TopoDS_Shape aShape= DBRep::Get(argv[2]); |
217 | if ( !aShape.IsNull() ) |
218 | { |
219 | aShapeTool->Search(aShape, aLabel); |
220 | if ( aLabel.IsNull() ) |
221 | { |
222 | di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
223 | return 1; |
224 | } |
225 | } |
226 | } |
227 | TDF_Label aLabel1; |
228 | if(argc == 4) |
229 | { |
230 | TDF_Tool::Label(Doc->GetData(), argv[3], aLabel1); |
231 | if ( aLabel1.IsNull() ) |
232 | { |
233 | TopoDS_Shape aShape= DBRep::Get(argv[3]); |
234 | if ( !aShape.IsNull() ) |
235 | { |
236 | aShapeTool->Search(aShape, aLabel1); |
237 | if ( aLabel1.IsNull() ) |
238 | { |
239 | di<<"Shape "<<argv[3]<<" is absent in "<<argv[1]<<"\n"; |
240 | return 1; |
241 | } |
242 | } |
243 | } |
244 | } |
245 | |
246 | TDF_Label aDimL = aDimTolTool->AddDimension(); |
247 | if(aLabel1.IsNull()) |
248 | aDimTolTool->SetDimension(aLabel, aDimL); |
249 | else |
250 | aDimTolTool->SetDimension(aLabel, aLabel1, aDimL); |
251 | TCollection_AsciiString Entry; |
252 | TDF_Tool::Entry(aDimL, Entry); |
253 | di << Entry; |
254 | return 0; |
255 | } |
256 | |
257 | static Standard_Integer addGTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
258 | { |
259 | if (argc < 3) { |
260 | di<<"Use: "<<"XAddGeomTolerance Doc shape/label\n"; |
261 | return 1; |
262 | } |
263 | Handle(TDocStd_Document) Doc; |
264 | DDocStd::GetDocument(argv[1], Doc); |
265 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
266 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
267 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
268 | |
269 | TDF_Label aLabel; |
270 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
271 | if ( aLabel.IsNull() ) |
272 | { |
273 | TopoDS_Shape aShape= DBRep::Get(argv[2]); |
274 | if ( !aShape.IsNull() ) |
275 | { |
276 | aShapeTool->Search(aShape, aLabel); |
277 | if ( aLabel.IsNull() ) |
278 | { |
279 | di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
280 | return 1; |
281 | } |
282 | } |
283 | } |
284 | |
285 | TDF_Label aTolL = aDimTolTool->AddGeomTolerance(); |
286 | aDimTolTool->SetGeomTolerance(aLabel, aTolL); |
287 | TCollection_AsciiString Entry; |
288 | TDF_Tool::Entry(aTolL, Entry); |
289 | di << Entry; |
290 | return 0; |
291 | } |
292 | |
293 | static Standard_Integer addDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
294 | { |
295 | if (argc < 3) { |
296 | di<<"Use: "<<"XAddDatum Doc shape/label\n"; |
297 | return 1; |
298 | } |
299 | Handle(TDocStd_Document) Doc; |
300 | DDocStd::GetDocument(argv[1], Doc); |
301 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
302 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
303 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
304 | |
305 | TDF_Label aLabel; |
306 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
307 | if ( aLabel.IsNull() ) |
308 | { |
309 | TopoDS_Shape aShape= DBRep::Get(argv[2]); |
310 | if ( !aShape.IsNull() ) |
311 | { |
312 | aShapeTool->Search(aShape, aLabel); |
313 | if ( aLabel.IsNull() ) |
314 | { |
315 | di<<"Shape "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
316 | return 1; |
317 | } |
318 | } |
319 | } |
320 | |
321 | TDF_Label aDatumL = aDimTolTool->AddDatum(); |
322 | aDimTolTool->SetDatum(aLabel, aDatumL); |
323 | TCollection_AsciiString Entry; |
324 | TDF_Tool::Entry(aDatumL, Entry); |
325 | di << Entry; |
326 | return 0; |
327 | } |
328 | |
329 | static Standard_Integer setDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
330 | { |
331 | if (argc < 4) { |
332 | di<<"Use: "<<"XSetDatum Doc Datum_Label GeomTol_Label\n"; |
333 | return 1; |
334 | } |
335 | Handle(TDocStd_Document) Doc; |
336 | DDocStd::GetDocument(argv[1], Doc); |
337 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
338 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
339 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
340 | |
341 | TDF_Label aLabel; |
342 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
343 | if ( aLabel.IsNull() ) |
344 | { |
345 | di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
346 | return 1; |
347 | } |
348 | |
349 | TDF_Label aTol; |
350 | TDF_Tool::Label(Doc->GetData(), argv[3], aTol); |
351 | if ( aTol.IsNull() ) |
352 | { |
353 | di<<"GeomTolerance "<<argv[3]<<" is absent in "<<argv[1]<<"\n"; |
354 | return 1; |
355 | } |
356 | |
357 | aDimTolTool->SetDatumToGeomTol(aLabel, aTol); |
358 | return 0; |
359 | } |
360 | |
361 | static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
362 | { |
363 | if (argc < 3) { |
364 | di<<"Use: "<<"XGetDatum Doc GeomTol_Label/Shape_Label\n"; |
365 | return 1; |
366 | } |
367 | Handle(TDocStd_Document) Doc; |
368 | DDocStd::GetDocument(argv[1], Doc); |
369 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
370 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
371 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
372 | |
373 | TDF_Label aLabel; |
374 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
375 | if ( aLabel.IsNull() ) |
376 | { |
377 | di<<"Label "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
378 | return 1; |
379 | } |
380 | |
381 | TDF_Label aD; |
382 | if(!aDimTolTool->GetRefDatumLabel(aLabel, aD)) |
383 | { |
384 | TDF_LabelSequence aDS; |
385 | if(aDimTolTool->GetDatumOfTolerLabels(aLabel, aDS)) |
386 | { |
387 | for(Standard_Integer i = 1; i<=aDS.Length();i++) |
388 | { |
389 | if(i>1) di<<", "; |
390 | TCollection_AsciiString Entry; |
391 | TDF_Tool::Entry(aDS.Value(i), Entry); |
392 | di<<Entry; |
393 | } |
394 | } |
395 | } |
396 | else |
397 | { |
398 | TCollection_AsciiString Entry; |
399 | TDF_Tool::Entry(aD, Entry); |
400 | di<<Entry; |
401 | } |
402 | return 0; |
403 | } |
404 | |
405 | static Standard_Integer addDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
406 | { |
407 | if (argc < 4) { |
408 | di<<"Use: "<<"XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n"; |
409 | return 1; |
410 | } |
411 | Handle(TDocStd_Document) Doc; |
412 | DDocStd::GetDocument(argv[1], Doc); |
413 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
414 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
415 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
416 | |
417 | TDF_Label aLabel; |
418 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
419 | if ( aLabel.IsNull() ) |
420 | { |
421 | di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
422 | return 1; |
423 | } |
424 | Handle(XCAFDoc_Datum) aDatum; |
425 | if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
426 | { |
427 | for(Standard_Integer i = 3; i < argc; i++) |
428 | { |
429 | if(Draw::Atoi(argv[i]) < 22 && Draw::Atoi(argv[i]) > -1) |
430 | { |
431 | Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject(); |
432 | anObj->AddModifier((XCAFDimTolObjects_DatumSingleModif)Draw::Atoi(argv[i])); |
433 | aDatum->SetObject(anObj); |
434 | } |
435 | } |
436 | } |
437 | return 0; |
438 | } |
439 | |
440 | static Standard_Integer getDatumModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
441 | { |
442 | if (argc < 3) { |
443 | di<<"Use: "<<"XGetDatumModifiers Doc Datum_Label\n"; |
444 | return 1; |
445 | } |
446 | Handle(TDocStd_Document) Doc; |
447 | DDocStd::GetDocument(argv[1], Doc); |
448 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
449 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
450 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
451 | |
452 | TDF_Label aLabel; |
453 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
454 | if ( aLabel.IsNull() ) |
455 | { |
456 | di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
457 | return 1; |
458 | } |
459 | Handle(XCAFDoc_Datum) aDatum; |
460 | if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
461 | { |
462 | XCAFDimTolObjects_DatumModifiersSequence aS = aDatum->GetObject()->GetModifiers(); |
463 | for(Standard_Integer i = 1; i<=aS.Length();i++) |
464 | { |
465 | if (i > 1) di<<", "; |
466 | switch(aS.Value(i)){ |
467 | case 0 : di<<"AnyCrossSection"; break; |
468 | case 1 : di<<"AnyLongitudinalSection"; break; |
469 | case 2 : di<<"Basic"; break; |
470 | case 3 : di<<"ContactingFeature\n"; break; |
471 | case 4 : di<<"DegreeOfFreedomConstraintU"; break; |
472 | case 5 : di<<"DegreeOfFreedomConstraintV"; break; |
473 | case 6 : di<<"DegreeOfFreedomConstraintW"; break; |
474 | case 7 : di<<"DegreeOfFreedomConstraintX"; break; |
475 | case 8 : di<<"DegreeOfFreedomConstraintY"; break; |
476 | case 9 : di<<"DegreeOfFreedomConstraintZ"; break; |
477 | case 10 : di<<"DistanceVariable"; break; |
478 | case 11 : di<<"FreeState"; break; |
479 | case 12 : di<<"LeastMaterialRequirement"; break; |
480 | case 13 : di<<"Line"; break; |
481 | case 14 : di<<"MajorDiameter"; break; |
482 | case 15 : di<<"MaximumMaterialRequirement"; break; |
483 | case 16 : di<<"MinorDiameter"; break; |
484 | case 17 : di<<"Orientation"; break; |
485 | case 18 : di<<"PitchDiameter"; break; |
486 | case 19 : di<<"Plane"; break; |
487 | case 20 : di<<"Point"; break; |
488 | case 21 : di<<"Translation"; break; |
489 | default : break; |
490 | } |
491 | } |
492 | } |
493 | return 0; |
494 | } |
495 | |
496 | static Standard_Integer setDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
497 | { |
498 | if (argc < 4) { |
499 | di<<"Use: "<<"XSetDatumName Doc Datum_Label name\n"; |
500 | return 1; |
501 | } |
502 | Handle(TDocStd_Document) Doc; |
503 | DDocStd::GetDocument(argv[1], Doc); |
504 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
505 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
506 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
507 | |
508 | TDF_Label aLabel; |
509 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
510 | if ( aLabel.IsNull() ) |
511 | { |
512 | di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
513 | return 1; |
514 | } |
515 | Handle(XCAFDoc_Datum) aDatum; |
516 | if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
517 | { |
518 | Handle(XCAFDimTolObjects_DatumObject) anObj = aDatum->GetObject(); |
519 | anObj->SetName(new TCollection_HAsciiString(argv[3])); |
520 | aDatum->SetObject(anObj); |
521 | } |
522 | return 0; |
523 | } |
524 | |
525 | static Standard_Integer getDatumName (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
526 | { |
527 | if (argc < 3) { |
528 | di<<"Use: "<<"XGetDatumName Doc Datum_Label\n"; |
529 | return 1; |
530 | } |
531 | Handle(TDocStd_Document) Doc; |
532 | DDocStd::GetDocument(argv[1], Doc); |
533 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
534 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
535 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
536 | |
537 | TDF_Label aLabel; |
538 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
539 | if ( aLabel.IsNull() ) |
540 | { |
541 | di<<"Datum "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
542 | return 1; |
543 | } |
544 | Handle(XCAFDoc_Datum) aDatum; |
545 | if(aLabel.FindAttribute(XCAFDoc_Datum::GetID(), aDatum)) |
546 | { |
547 | di<<aDatum->GetObject()->GetName()->ToCString(); |
548 | } |
549 | return 0; |
550 | } |
551 | |
552 | static Standard_Integer setTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
553 | { |
554 | if (argc < 4) { |
555 | di<<"Use: "<<"XSetTypeOfTolerance Doc GTol_Label type\n"; |
556 | return 1; |
557 | } |
558 | Handle(TDocStd_Document) Doc; |
559 | DDocStd::GetDocument(argv[1], Doc); |
560 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
561 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
562 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
563 | |
564 | TDF_Label aLabel; |
565 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
566 | if ( aLabel.IsNull() ) |
567 | { |
568 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
569 | return 1; |
570 | } |
571 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
572 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
573 | { |
574 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 16) |
575 | { |
576 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
577 | anObj->SetType((XCAFDimTolObjects_GeomToleranceType)Draw::Atoi(argv[3])); |
578 | aGeomTolerance->SetObject(anObj); |
579 | } |
580 | } |
581 | return 0; |
582 | } |
583 | |
584 | static Standard_Integer getTypeOfTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
585 | { |
586 | if (argc < 3) { |
587 | di<<"Use: "<<"XGetTypeOfTolerance Doc GTol_Label\n"; |
588 | return 1; |
589 | } |
590 | Handle(TDocStd_Document) Doc; |
591 | DDocStd::GetDocument(argv[1], Doc); |
592 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
593 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
594 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
595 | |
596 | TDF_Label aLabel; |
597 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
598 | if ( aLabel.IsNull() ) |
599 | { |
600 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
601 | return 1; |
602 | } |
603 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
604 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
605 | { |
606 | switch(aGeomTolerance->GetObject()->GetType()){ |
607 | case 0 : di<<"type is absent"; break; |
608 | case 1 : di<<"Angularity"; break; |
609 | case 2 : di<<"CircularRunout"; break; |
610 | case 3 : di<<"CircularityOrRoundness"; break; |
611 | case 4 : di<<"Coaxiality"; break; |
612 | case 5 : di<<"Concentricity"; break; |
613 | case 6 : di<<"Cylindricity"; break; |
614 | case 7 : di<<"Flatness"; break; |
615 | case 8 : di<<"Parallelism"; break; |
616 | case 9 : di<<"Perpendicularity"; break; |
617 | case 10 : di<<"Position"; break; |
618 | case 11 : di<<"ProfileOfLine"; break; |
619 | case 12 : di<<"ProfileOfSurface"; break; |
620 | case 13 : di<<"Straightness"; break; |
621 | case 14 : di<<"Symmetry"; break; |
622 | case 15 : di<<"TotalRunout"; break; |
623 | default : break; |
624 | } |
625 | } |
626 | return 0; |
627 | } |
628 | |
629 | static Standard_Integer setTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
630 | { |
631 | if (argc < 4) { |
632 | di<<"Use: "<<"XSetTypeOfToleranceValue Doc GTol_Label type\n"; |
633 | return 1; |
634 | } |
635 | Handle(TDocStd_Document) Doc; |
636 | DDocStd::GetDocument(argv[1], Doc); |
637 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
638 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
639 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
640 | |
641 | TDF_Label aLabel; |
642 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
643 | if ( aLabel.IsNull() ) |
644 | { |
645 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
646 | return 1; |
647 | } |
648 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
649 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
650 | { |
651 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3) |
652 | { |
653 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
654 | anObj->SetTypeOfValue((XCAFDimTolObjects_GeomToleranceTypeValue)Draw::Atoi(argv[3])); |
655 | aGeomTolerance->SetObject(anObj); |
656 | } |
657 | } |
658 | return 0; |
659 | } |
660 | |
661 | static Standard_Integer getTypeOfTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
662 | { |
663 | if (argc < 3) { |
664 | di<<"Use: "<<"XGetTypeOfToleranceValue Doc GTol_Label\n"; |
665 | return 1; |
666 | } |
667 | Handle(TDocStd_Document) Doc; |
668 | DDocStd::GetDocument(argv[1], Doc); |
669 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
670 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
671 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
672 | |
673 | TDF_Label aLabel; |
674 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
675 | if ( aLabel.IsNull() ) |
676 | { |
677 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
678 | return 1; |
679 | } |
680 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
681 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
682 | { |
683 | switch(aGeomTolerance->GetObject()->GetTypeOfValue()){ |
684 | case 0 : di<<"type is absent"; break; |
685 | case 1 : di<<"Diameter"; break; |
686 | case 2 : di<<"SphericalDiameter"; break; |
687 | default : break; |
688 | } |
689 | } |
690 | return 0; |
691 | } |
692 | |
693 | static Standard_Integer setTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
694 | { |
695 | if (argc < 4) { |
696 | di<<"Use: "<<"XSetToleranceValue Doc GTol_Label value\n"; |
697 | return 1; |
698 | } |
699 | Handle(TDocStd_Document) Doc; |
700 | DDocStd::GetDocument(argv[1], Doc); |
701 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
702 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
703 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
704 | |
705 | TDF_Label aLabel; |
706 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
707 | if ( aLabel.IsNull() ) |
708 | { |
709 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
710 | return 1; |
711 | } |
712 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
713 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
714 | { |
715 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
716 | anObj->SetValue(Draw::Atof(argv[3])); |
717 | aGeomTolerance->SetObject(anObj); |
718 | } |
719 | return 0; |
720 | } |
721 | |
722 | static Standard_Integer getTolVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
723 | { |
724 | if (argc < 3) { |
725 | di<<"Use: "<<"XGetToleranceValue Doc GTol_Label\n"; |
726 | return 1; |
727 | } |
728 | Handle(TDocStd_Document) Doc; |
729 | DDocStd::GetDocument(argv[1], Doc); |
730 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
731 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
732 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
733 | |
734 | TDF_Label aLabel; |
735 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
736 | if ( aLabel.IsNull() ) |
737 | { |
738 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
739 | return 1; |
740 | } |
741 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
742 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
743 | { |
744 | di << aGeomTolerance->GetObject()->GetValue(); |
745 | } |
746 | return 0; |
747 | } |
748 | |
749 | static Standard_Integer setMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
750 | { |
751 | if (argc < 4) { |
752 | di<<"Use: "<<"XSetTolMaterialReq Doc GTol_Label mod\n"; |
753 | return 1; |
754 | } |
755 | Handle(TDocStd_Document) Doc; |
756 | DDocStd::GetDocument(argv[1], Doc); |
757 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
758 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
759 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
760 | |
761 | TDF_Label aLabel; |
762 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
763 | if ( aLabel.IsNull() ) |
764 | { |
765 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
766 | return 1; |
767 | } |
768 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
769 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
770 | { |
771 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3) |
772 | { |
773 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
774 | anObj->SetMaterialRequirementModifier((XCAFDimTolObjects_GeomToleranceMatReqModif)Draw::Atoi(argv[3])); |
775 | aGeomTolerance->SetObject(anObj); |
776 | } |
777 | } |
778 | return 0; |
779 | } |
780 | |
781 | static Standard_Integer getMatReq (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
782 | { |
783 | if (argc < 3) { |
784 | di<<"Use: "<<"XGetTolMaterialReq Doc GTol_Label\n"; |
785 | return 1; |
786 | } |
787 | Handle(TDocStd_Document) Doc; |
788 | DDocStd::GetDocument(argv[1], Doc); |
789 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
790 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
791 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
792 | |
793 | TDF_Label aLabel; |
794 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
795 | if ( aLabel.IsNull() ) |
796 | { |
797 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
798 | return 1; |
799 | } |
800 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
801 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
802 | { |
803 | switch(aGeomTolerance->GetObject()->GetMaterialRequirementModifier()){ |
804 | case 0 : di<<"modifier is absent"; break; |
805 | case 1 : di<<"M"; break; |
806 | case 2 : di<<"L"; break; |
807 | default : break; |
808 | } |
809 | } |
810 | return 0; |
811 | } |
812 | |
813 | static Standard_Integer setZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
814 | { |
815 | if (argc < 4) { |
816 | di<<"Use: "<<"XSetTolZoneMod Doc GTol_Label mod\n"; |
817 | return 1; |
818 | } |
819 | Handle(TDocStd_Document) Doc; |
820 | DDocStd::GetDocument(argv[1], Doc); |
821 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
822 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
823 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
824 | |
825 | TDF_Label aLabel; |
826 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
827 | if ( aLabel.IsNull() ) |
828 | { |
829 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
830 | return 1; |
831 | } |
832 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
833 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
834 | { |
835 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 3) |
836 | { |
837 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
838 | anObj->SetZoneModifier((XCAFDimTolObjects_GeomToleranceZoneModif)Draw::Atoi(argv[3])); |
839 | aGeomTolerance->SetObject(anObj); |
840 | } |
841 | } |
842 | return 0; |
843 | } |
844 | |
845 | static Standard_Integer getZoneMod (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
846 | { |
847 | if (argc < 3) { |
848 | di<<"Use: "<<"XGetTolZoneMod Doc GTol_Label\n"; |
849 | return 1; |
850 | } |
851 | Handle(TDocStd_Document) Doc; |
852 | DDocStd::GetDocument(argv[1], Doc); |
853 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
854 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
855 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
856 | |
857 | TDF_Label aLabel; |
858 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
859 | if ( aLabel.IsNull() ) |
860 | { |
861 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
862 | return 1; |
863 | } |
864 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
865 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
866 | { |
867 | switch(aGeomTolerance->GetObject()->GetZoneModifier()){ |
868 | case 0 : di<<"modifier is absent"; break; |
869 | case 1 : di<<"P"; break; |
870 | case 2 : di<<"NonUniform"; break; |
871 | default : break; |
872 | } |
873 | } |
874 | return 0; |
875 | } |
876 | |
877 | static Standard_Integer setZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
878 | { |
879 | if (argc < 4) { |
880 | di<<"Use: "<<"XSetTolZoneModValue Doc GTol_Label val\n"; |
881 | return 1; |
882 | } |
883 | Handle(TDocStd_Document) Doc; |
884 | DDocStd::GetDocument(argv[1], Doc); |
885 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
886 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
887 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
888 | |
889 | TDF_Label aLabel; |
890 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
891 | if ( aLabel.IsNull() ) |
892 | { |
893 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
894 | return 1; |
895 | } |
896 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
897 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
898 | { |
899 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
900 | anObj->SetValueOfZoneModifier(Draw::Atof(argv[3])); |
901 | aGeomTolerance->SetObject(anObj); |
902 | } |
903 | return 0; |
904 | } |
905 | |
906 | static Standard_Integer getZoneModVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
907 | { |
908 | if (argc < 3) { |
909 | di<<"Use: "<<"XGetTolZoneModValue Doc GTol_Label\n"; |
910 | return 1; |
911 | } |
912 | Handle(TDocStd_Document) Doc; |
913 | DDocStd::GetDocument(argv[1], Doc); |
914 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
915 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
916 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
917 | |
918 | TDF_Label aLabel; |
919 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
920 | if ( aLabel.IsNull() ) |
921 | { |
922 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
923 | return 1; |
924 | } |
925 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
926 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
927 | { |
928 | di << aGeomTolerance->GetObject()->GetValueOfZoneModifier(); |
929 | } |
930 | return 0; |
931 | } |
932 | |
933 | static Standard_Integer addTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
934 | { |
935 | if (argc < 4) { |
936 | di<<"Use: "<<"XAddTolModifier Doc Tol_Label mod1 mod2 ...\n"; |
937 | return 1; |
938 | } |
939 | Handle(TDocStd_Document) Doc; |
940 | DDocStd::GetDocument(argv[1], Doc); |
941 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
942 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
943 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
944 | |
945 | TDF_Label aLabel; |
946 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
947 | if ( aLabel.IsNull() ) |
948 | { |
949 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
950 | return 1; |
951 | } |
952 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
953 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
954 | { |
955 | for(Standard_Integer i = 3; i < argc; i++) |
956 | { |
957 | if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 15) |
958 | { |
959 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
960 | anObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)Draw::Atoi(argv[i])); |
961 | aGeomTolerance->SetObject(anObj); |
962 | } |
963 | } |
964 | } |
965 | return 0; |
966 | } |
967 | |
968 | static Standard_Integer getTolModif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
969 | { |
970 | if (argc < 3) { |
971 | di<<"Use: "<<"XGetTolModifiers Doc Tol_Label\n"; |
972 | return 1; |
973 | } |
974 | Handle(TDocStd_Document) Doc; |
975 | DDocStd::GetDocument(argv[1], Doc); |
976 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
977 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
978 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
979 | |
980 | TDF_Label aLabel; |
981 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
982 | if ( aLabel.IsNull() ) |
983 | { |
984 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
985 | return 1; |
986 | } |
987 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
988 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
989 | { |
990 | XCAFDimTolObjects_GeomToleranceModifiersSequence aS = aGeomTolerance->GetObject()->GetModifiers(); |
991 | for(Standard_Integer i = 1; i <= aS.Length(); i++) |
992 | { |
993 | if (i > 1) di<<", "; |
994 | switch(aS.Value(i)){ |
995 | case 0 : di<<"Any_Cross_Section"; break; |
996 | case 1 : di<<"Common_Zone"; break; |
997 | case 2 : di<<"Each_Radial_Element"; break; |
998 | case 3 : di<<"Free_State"; break; |
999 | case 4 : di<<"Least_Material_Requirement"; break; |
1000 | case 5 : di<<"Line_Element"; break; |
1001 | case 6 : di<<"Major_Diameter"; break; |
1002 | case 7 : di<<"Maximum_Material_Requirement"; break; |
1003 | case 8 : di<<"Minor_Diameter"; break; |
1004 | case 9 : di<<"Not_Convex"; break; |
1005 | case 10 : di<<"Pitch_Diameter"; break; |
1006 | case 11 : di<<"Reciprocity_Requirement"; break; |
1007 | case 12 : di<<"Separate_Requirement"; break; |
1008 | case 13 : di<<"Statistical_Tolerance"; break; |
1009 | case 14 : di<<"Tangent_Plane"; break; |
1010 | default : break; |
1011 | } |
1012 | } |
1013 | } |
1014 | return 0; |
1015 | } |
1016 | |
1017 | static Standard_Integer setTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1018 | { |
1019 | if (argc < 4) { |
1020 | di<<"Use: "<<"XSetTolMaxValue Doc Dim_Label val\n"; |
1021 | return 1; |
1022 | } |
1023 | Handle(TDocStd_Document) Doc; |
1024 | DDocStd::GetDocument(argv[1], Doc); |
1025 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1026 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1027 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1028 | |
1029 | TDF_Label aLabel; |
1030 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1031 | if ( aLabel.IsNull() ) |
1032 | { |
1033 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1034 | return 1; |
1035 | } |
1036 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
1037 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
1038 | { |
1039 | Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGeomTolerance->GetObject(); |
1040 | anObj->SetMaxValueModifier(Draw::Atof(argv[3])); |
1041 | aGeomTolerance->SetObject(anObj); |
1042 | } |
1043 | return 0; |
1044 | } |
1045 | |
1046 | static Standard_Integer getTolMaxVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1047 | { |
1048 | if (argc < 3) { |
1049 | di<<"Use: "<<"XGetTolMaxValue Doc Dim_Label\n"; |
1050 | return 1; |
1051 | } |
1052 | Handle(TDocStd_Document) Doc; |
1053 | DDocStd::GetDocument(argv[1], Doc); |
1054 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1055 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1056 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1057 | |
1058 | TDF_Label aLabel; |
1059 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1060 | if ( aLabel.IsNull() ) |
1061 | { |
1062 | di<<"GeomTolerance "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1063 | return 1; |
1064 | } |
1065 | Handle(XCAFDoc_GeomTolerance) aGeomTolerance; |
1066 | if(aLabel.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGeomTolerance)) |
1067 | { |
1068 | di << aGeomTolerance->GetObject()->GetMaxValueModifier(); |
1069 | } |
1070 | return 0; |
1071 | } |
1072 | |
1073 | static Standard_Integer setDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1074 | { |
1075 | if (argc < 4) { |
1076 | di<<"Use: "<<"XSetDimensionType Doc Dim_Label type\n"; |
1077 | return 1; |
1078 | } |
1079 | Handle(TDocStd_Document) Doc; |
1080 | DDocStd::GetDocument(argv[1], Doc); |
1081 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1082 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1083 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1084 | |
1085 | TDF_Label aLabel; |
1086 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1087 | if ( aLabel.IsNull() ) |
1088 | { |
1089 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1090 | return 1; |
1091 | } |
1092 | Handle(XCAFDoc_Dimension) aDimension; |
1093 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1094 | { |
1095 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 30) |
1096 | { |
1097 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1098 | anObj->SetType((XCAFDimTolObjects_DimensionType)Draw::Atoi(argv[3])); |
1099 | aDimension->SetObject(anObj); |
1100 | } |
1101 | } |
1102 | return 0; |
1103 | } |
1104 | |
1105 | static Standard_Integer getDimType (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1106 | { |
1107 | if (argc < 3) { |
1108 | di<<"Use: "<<"XGetDimensionType Doc Dim_Label\n"; |
1109 | return 1; |
1110 | } |
1111 | Handle(TDocStd_Document) Doc; |
1112 | DDocStd::GetDocument(argv[1], Doc); |
1113 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1114 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1115 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1116 | |
1117 | TDF_Label aLabel; |
1118 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1119 | if ( aLabel.IsNull() ) |
1120 | { |
1121 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1122 | return 1; |
1123 | } |
1124 | Handle(XCAFDoc_Dimension) aDimension; |
1125 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1126 | { |
1127 | switch(aDimension->GetObject()->GetType()){ |
1128 | case 0 : di<<"type is absent"; break; |
1129 | case 1 : di<<"Location_CurvedDistance"; break; |
1130 | case 2 : di<<"Location_LinearDistance"; break; |
1131 | case 3 : di<<"Location_LinearDistance_FromCenterToOuter"; break; |
1132 | case 4 : di<<"Location_LinearDistance_FromCenterToInner"; break; |
1133 | case 5 : di<<"Location_LinearDistance_FromOuterToCenter"; break; |
1134 | case 6 : di<<"Location_LinearDistance_FromOuterToOuter"; break; |
1135 | case 7 : di<<"Location_LinearDistance_FromOuterToInner"; break; |
1136 | case 8 : di<<"Location_LinearDistance_FromInnerToCenter"; break; |
1137 | case 9 : di<<"Location_LinearDistance_FromInnerToOuter"; break; |
1138 | case 10 : di<<"Location_LinearDistance_FromInnerToInner"; break; |
1139 | case 11 : di<<"Location_Angular"; break; |
1140 | case 12 : di<<"Location_Oriented"; break; |
1141 | case 13 : di<<"Location_WithPath"; break; |
1142 | case 14 : di<<"Size_CurveLength"; break; |
1143 | case 15 : di<<"Size_Diameter"; break; |
1144 | case 16 : di<<"Size_SphericalDiameter"; break; |
1145 | case 17 : di<<"Size_Radius"; break; |
1146 | case 18 : di<<"Size_SphericalRadius"; break; |
1147 | case 19 : di<<"Size_ToroidalMinorDiameter"; break; |
1148 | case 20 : di<<"Size_ToroidalMajorDiameter"; break; |
1149 | case 21 : di<<"Size_ToroidalMinorRadius"; break; |
1150 | case 22 : di<<"Size_ToroidalMajorRadius"; break; |
1151 | case 23 : di<<"Size_ToroidalHighMajorDiameter"; break; |
1152 | case 24 : di<<"Size_ToroidalLowMajorDiameter"; break; |
1153 | case 25 : di<<"Size_ToroidalHighMajorRadius"; break; |
1154 | case 26 : di<<"Size_ToroidalLowMajorRadius"; break; |
1155 | case 27 : di<<"Size_Thickness"; break; |
1156 | case 28 : di<<"Size_Angular"; break; |
1157 | case 29 : di<<"Size_WithPath"; break; |
1158 | default : break; |
1159 | } |
1160 | } |
1161 | return 0; |
1162 | } |
1163 | |
1164 | static Standard_Integer setDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1165 | { |
1166 | if (argc < 4) { |
1167 | di<<"Use: "<<"XSetDimensionValue Doc Dim_Label val\n"; |
1168 | return 1; |
1169 | } |
1170 | Handle(TDocStd_Document) Doc; |
1171 | DDocStd::GetDocument(argv[1], Doc); |
1172 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1173 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1174 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1175 | |
1176 | TDF_Label aLabel; |
1177 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1178 | if ( aLabel.IsNull() ) |
1179 | { |
1180 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1181 | return 1; |
1182 | } |
1183 | Handle(XCAFDoc_Dimension) aDimension; |
1184 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1185 | { |
1186 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1187 | anObj->SetValue(Draw::Atof(argv[3])); |
1188 | aDimension->SetObject(anObj); |
1189 | } |
1190 | return 0; |
1191 | } |
1192 | |
1193 | static Standard_Integer getDimVal (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1194 | { |
1195 | if (argc < 3) { |
1196 | di<<"Use: "<<"XGetDimensionValue Doc Dim_Label\n"; |
1197 | return 1; |
1198 | } |
1199 | Handle(TDocStd_Document) Doc; |
1200 | DDocStd::GetDocument(argv[1], Doc); |
1201 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1202 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1203 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1204 | |
1205 | TDF_Label aLabel; |
1206 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1207 | if ( aLabel.IsNull() ) |
1208 | { |
1209 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1210 | return 1; |
1211 | } |
1212 | Handle(XCAFDoc_Dimension) aDimension; |
1213 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1214 | { |
1215 | di << aDimension->GetObject()->GetValue(); |
1216 | } |
1217 | return 0; |
1218 | } |
1219 | |
1220 | static Standard_Integer setDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1221 | { |
1222 | if (argc < 4) { |
1223 | di<<"Use: "<<"XSetDimensionQualifier Doc Dim_Label val\n"; |
1224 | return 1; |
1225 | } |
1226 | Handle(TDocStd_Document) Doc; |
1227 | DDocStd::GetDocument(argv[1], Doc); |
1228 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1229 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1230 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1231 | |
1232 | TDF_Label aLabel; |
1233 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1234 | if ( aLabel.IsNull() ) |
1235 | { |
1236 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1237 | return 1; |
1238 | } |
1239 | Handle(XCAFDoc_Dimension) aDimension; |
1240 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1241 | { |
1242 | if(Draw::Atoi(argv[3]) > -1 && Draw::Atoi(argv[3]) < 4) |
1243 | { |
1244 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1245 | anObj->SetQualifier((XCAFDimTolObjects_DimensionQualifier)Draw::Atoi(argv[3])); |
1246 | aDimension->SetObject(anObj); |
1247 | } |
1248 | } |
1249 | return 0; |
1250 | } |
1251 | |
1252 | static Standard_Integer getDimQalif (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1253 | { |
1254 | if (argc < 3) { |
1255 | di<<"Use: "<<"XGetDimensionQualifier Doc Dim_Label\n"; |
1256 | return 1; |
1257 | } |
1258 | Handle(TDocStd_Document) Doc; |
1259 | DDocStd::GetDocument(argv[1], Doc); |
1260 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1261 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1262 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1263 | |
1264 | TDF_Label aLabel; |
1265 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1266 | if ( aLabel.IsNull() ) |
1267 | { |
1268 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1269 | return 1; |
1270 | } |
1271 | Handle(XCAFDoc_Dimension) aDimension; |
1272 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1273 | { |
1274 | |
1275 | switch(aDimension->GetObject()->GetQualifier()){ |
1276 | case 0 : di<<"type is absent"; break; |
1277 | case 1 : di<<"Min"; break; |
1278 | case 2 : di<<"Max"; break; |
1279 | case 3 : di<<"Avg"; break; |
1280 | default : break; |
1281 | } |
1282 | } |
1283 | return 0; |
1284 | } |
1285 | |
1286 | static Standard_Integer setDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1287 | { |
1288 | if (argc < 5) { |
1289 | di<<"Use: "<<"XSetDimensionRange Doc Dim_Label low_val up_val\n"; |
1290 | return 1; |
1291 | } |
1292 | Handle(TDocStd_Document) Doc; |
1293 | DDocStd::GetDocument(argv[1], Doc); |
1294 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1295 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1296 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1297 | |
1298 | TDF_Label aLabel; |
1299 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1300 | if ( aLabel.IsNull() ) |
1301 | { |
1302 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1303 | return 1; |
1304 | } |
1305 | Handle(XCAFDoc_Dimension) aDimension; |
1306 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1307 | { |
1308 | if(Draw::Atof(argv[3]) < Draw::Atof(argv[4])) |
1309 | { |
1310 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1311 | anObj->SetLowerBound(Draw::Atof(argv[3])); |
1312 | anObj->SetUpperBound(Draw::Atof(argv[4])); |
1313 | aDimension->SetObject(anObj); |
1314 | } |
1315 | } |
1316 | return 0; |
1317 | } |
1318 | |
1319 | static Standard_Integer getDimRange (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1320 | { |
1321 | if (argc < 3) { |
1322 | di<<"Use: "<<"XGetDimensionRange Doc Dim_Label\n"; |
1323 | return 1; |
1324 | } |
1325 | Handle(TDocStd_Document) Doc; |
1326 | DDocStd::GetDocument(argv[1], Doc); |
1327 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1328 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1329 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1330 | |
1331 | TDF_Label aLabel; |
1332 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1333 | if ( aLabel.IsNull() ) |
1334 | { |
1335 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1336 | return 1; |
1337 | } |
1338 | Handle(XCAFDoc_Dimension) aDimension; |
1339 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1340 | { |
1341 | di << "lower " << aDimension->GetObject()->GetLowerBound(); |
1342 | di << " upper " << aDimension->GetObject()->GetUpperBound(); |
1343 | } |
1344 | return 0; |
1345 | } |
1346 | |
1347 | static Standard_Integer setDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1348 | { |
1349 | if (argc < 5) { |
1350 | di<<"Use: "<<"XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val\n"; |
1351 | return 1; |
1352 | } |
1353 | Handle(TDocStd_Document) Doc; |
1354 | DDocStd::GetDocument(argv[1], Doc); |
1355 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1356 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1357 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1358 | |
1359 | TDF_Label aLabel; |
1360 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1361 | if ( aLabel.IsNull() ) |
1362 | { |
1363 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1364 | return 1; |
1365 | } |
1366 | Handle(XCAFDoc_Dimension) aDimension; |
1367 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1368 | { |
1369 | if(Draw::Atof(argv[3]) < Draw::Atof(argv[4])) |
1370 | { |
1371 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1372 | anObj->SetLowerTolValue(Draw::Atof(argv[3])); |
1373 | anObj->SetUpperTolValue(Draw::Atof(argv[4])); |
1374 | aDimension->SetObject(anObj); |
1375 | } |
1376 | } |
1377 | return 0; |
1378 | } |
1379 | |
1380 | static Standard_Integer getDimPlusMinusTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1381 | { |
1382 | if (argc < 3) { |
1383 | di<<"Use: "<<"XGetDimensionPlusMinusTol Doc Dim_Label\n"; |
1384 | return 1; |
1385 | } |
1386 | Handle(TDocStd_Document) Doc; |
1387 | DDocStd::GetDocument(argv[1], Doc); |
1388 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1389 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1390 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1391 | |
1392 | TDF_Label aLabel; |
1393 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1394 | if ( aLabel.IsNull() ) |
1395 | { |
1396 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1397 | return 1; |
1398 | } |
1399 | Handle(XCAFDoc_Dimension) aDimension; |
1400 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1401 | { |
1402 | di << "lower " << aDimension->GetObject()->GetLowerTolValue(); |
1403 | di << " upper " << aDimension->GetObject()->GetUpperTolValue(); |
1404 | } |
1405 | return 0; |
1406 | } |
1407 | |
1408 | static Standard_Integer setDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1409 | { |
1410 | if (argc < 6) { |
1411 | di<<"Use: "<<"XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade\n"; |
1412 | return 1; |
1413 | } |
1414 | Handle(TDocStd_Document) Doc; |
1415 | DDocStd::GetDocument(argv[1], Doc); |
1416 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1417 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1418 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1419 | |
1420 | TDF_Label aLabel; |
1421 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1422 | if ( aLabel.IsNull() ) |
1423 | { |
1424 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1425 | return 1; |
1426 | } |
1427 | Handle(XCAFDoc_Dimension) aDimension; |
1428 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1429 | { |
1430 | if(Draw::Atoi(argv[4]) > 0 && Draw::Atoi(argv[4]) < 29 && Draw::Atoi(argv[5]) > -1 && Draw::Atoi(argv[5]) < 20) |
1431 | { |
1432 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1433 | anObj->SetClassOfTolerance((Draw::Atoi(argv[3]) != 0), (XCAFDimTolObjects_DimensionFormVariance)Draw::Atoi(argv[4]), (XCAFDimTolObjects_DimensionGrade)Draw::Atoi(argv[5])); |
1434 | aDimension->SetObject(anObj); |
1435 | } |
1436 | } |
1437 | return 0; |
1438 | } |
1439 | |
1440 | static Standard_Integer getDimClassTol (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1441 | { |
1442 | if (argc < 3) { |
1443 | di<<"Use: "<<"XGetDimensionClassOfTol Doc Dim_Label\n"; |
1444 | return 1; |
1445 | } |
1446 | Handle(TDocStd_Document) Doc; |
1447 | DDocStd::GetDocument(argv[1], Doc); |
1448 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1449 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1450 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1451 | |
1452 | TDF_Label aLabel; |
1453 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1454 | if ( aLabel.IsNull() ) |
1455 | { |
1456 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1457 | return 1; |
1458 | } |
1459 | Handle(XCAFDoc_Dimension) aDimension; |
1460 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1461 | { |
1462 | Standard_Boolean h; |
1463 | XCAFDimTolObjects_DimensionFormVariance f; |
1464 | XCAFDimTolObjects_DimensionGrade g; |
1465 | if(aDimension->GetObject()->GetClassOfTolerance(h ,f, g)) |
1466 | { |
1467 | if(h) |
1468 | { |
1469 | switch(f){ |
1470 | case 1 : di<<"a";break; |
1471 | case 2 : di<<"b";break; |
1472 | case 3 : di<<"c";break; |
1473 | case 4 : di<<"cd";break; |
1474 | case 5 : di<<"d";break; |
1475 | case 6 : di<<"e";break; |
1476 | case 7 : di<<"ef";break; |
1477 | case 8 : di<<"f";break; |
1478 | case 9 : di<<"fg";break; |
1479 | case 10 : di<<"g";break; |
1480 | case 11 : di<<"h";break; |
1481 | case 12 : di<<"js";break; |
1482 | case 13 : di<<"j";break; |
1483 | case 14 : di<<"k";break; |
1484 | case 15 : di<<"m";break; |
1485 | case 16 : di<<"n";break; |
1486 | case 17 : di<<"p";break; |
1487 | case 18 : di<<"r";break; |
1488 | case 19 : di<<"s";break; |
1489 | case 20 : di<<"t";break; |
1490 | case 21 : di<<"u";break; |
1491 | case 22 : di<<"v";break; |
1492 | case 23 : di<<"x";break; |
1493 | case 24 : di<<"y";break; |
1494 | case 25 : di<<"z";break; |
1495 | case 26 : di<<"a";break; |
1496 | case 27 : di<<"zb";break; |
1497 | case 28 : di<<"zc";break; |
1498 | default : break; |
1499 | } |
1500 | } |
1501 | else |
1502 | { |
1503 | switch(f){ |
1504 | case 1 : di<<"A";break; |
1505 | case 2 : di<<"B";break; |
1506 | case 3 : di<<"C";break; |
1507 | case 4 : di<<"CD";break; |
1508 | case 5 : di<<"D";break; |
1509 | case 6 : di<<"E";break; |
1510 | case 7 : di<<"EF";break; |
1511 | case 8 : di<<"F";break; |
1512 | case 9 : di<<"FG";break; |
1513 | case 10 : di<<"G";break; |
1514 | case 11 : di<<"H";break; |
1515 | case 12 : di<<"JS";break; |
1516 | case 13 : di<<"J";break; |
1517 | case 14 : di<<"K";break; |
1518 | case 15 : di<<"M";break; |
1519 | case 16 : di<<"N";break; |
1520 | case 17 : di<<"P";break; |
1521 | case 18 : di<<"R";break; |
1522 | case 19 : di<<"S";break; |
1523 | case 20 : di<<"T";break; |
1524 | case 21 : di<<"U";break; |
1525 | case 22 : di<<"V";break; |
1526 | case 23 : di<<"X";break; |
1527 | case 24 : di<<"Y";break; |
1528 | case 25 : di<<"Z";break; |
1529 | case 26 : di<<"ZA";break; |
1530 | case 27 : di<<"ZB";break; |
1531 | case 28 : di<<"ZC";break; |
1532 | default : break; |
1533 | } |
1534 | } |
1535 | switch(g){ |
1536 | case 0 : di<<"01"; break; |
1537 | case 1 : di<<"0"; break; |
1538 | case 2 : di<<"1"; break; |
1539 | case 3 : di<<"2"; break; |
1540 | case 4 : di<<"3"; break; |
1541 | case 5 : di<<"4"; break; |
1542 | case 6 : di<<"5"; break; |
1543 | case 7 : di<<"6"; break; |
1544 | case 8 : di<<"7"; break; |
1545 | case 9 : di<<"8"; break; |
1546 | case 10 : di<<"9"; break; |
1547 | case 11 : di<<"10"; break; |
1548 | case 12 : di<<"11"; break; |
1549 | case 13 : di<<"12"; break; |
1550 | case 14 : di<<"13"; break; |
1551 | case 15 : di<<"14"; break; |
1552 | case 16 : di<<"15"; break; |
1553 | case 17 : di<<"16"; break; |
1554 | case 18 : di<<"17"; break; |
1555 | case 19 : di<<"18"; break; |
1556 | default : break; |
1557 | } |
1558 | } |
1559 | } |
1560 | return 0; |
1561 | } |
1562 | |
1563 | static Standard_Integer setDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1564 | { |
1565 | if (argc < 5) { |
1566 | di<<"Use: "<<"XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val\n"; |
1567 | return 1; |
1568 | } |
1569 | Handle(TDocStd_Document) Doc; |
1570 | DDocStd::GetDocument(argv[1], Doc); |
1571 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1572 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1573 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
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 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1586 | anObj->SetNbOfDecimalPlaces(Draw::Atoi(argv[3]), Draw::Atoi(argv[4])); |
1587 | aDimension->SetObject(anObj); |
1588 | } |
1589 | return 0; |
1590 | } |
1591 | |
1592 | static Standard_Integer getDimNbOfDecimalPlaces (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1593 | { |
1594 | if (argc < 3) { |
1595 | di<<"Use: "<<"XGetDimensionNbOfDecimalPlaces Doc Dim_Label\n"; |
1596 | return 1; |
1597 | } |
1598 | Handle(TDocStd_Document) Doc; |
1599 | DDocStd::GetDocument(argv[1], Doc); |
1600 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1601 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1602 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1603 | |
1604 | TDF_Label aLabel; |
1605 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1606 | if ( aLabel.IsNull() ) |
1607 | { |
1608 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1609 | return 1; |
1610 | } |
1611 | Handle(XCAFDoc_Dimension) aDimension; |
1612 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1613 | { |
1614 | Standard_Integer l, r; |
1615 | aDimension->GetObject()->GetNbOfDecimalPlaces(l,r); |
1616 | di << l << "." << r; |
1617 | } |
1618 | return 0; |
1619 | } |
1620 | |
1621 | static Standard_Integer addDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1622 | { |
1623 | if (argc < 4) { |
1624 | di<<"Use: "<<"XAddDimensionModifiers Doc Dim_Label mod1 mod2 ...\n"; |
1625 | return 1; |
1626 | } |
1627 | Handle(TDocStd_Document) Doc; |
1628 | DDocStd::GetDocument(argv[1], Doc); |
1629 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1630 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1631 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1632 | |
1633 | TDF_Label aLabel; |
1634 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1635 | if ( aLabel.IsNull() ) |
1636 | { |
1637 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1638 | return 1; |
1639 | } |
1640 | Handle(XCAFDoc_Dimension) aDimension; |
1641 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1642 | { |
1643 | for(Standard_Integer i = 3; i < argc; i++) |
1644 | { |
1645 | if(Draw::Atoi(argv[i]) > -1 && Draw::Atoi(argv[i]) < 24) |
1646 | { |
1647 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1648 | anObj->AddModifier((XCAFDimTolObjects_DimensionModif)Draw::Atoi(argv[i])); |
1649 | aDimension->SetObject(anObj); |
1650 | } |
1651 | } |
1652 | } |
1653 | return 0; |
1654 | } |
1655 | |
1656 | static Standard_Integer getDimModifier (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1657 | { |
1658 | if (argc < 3) { |
1659 | di<<"Use: "<<"XGetDimensionModifiers Doc Dim_Label\n"; |
1660 | return 1; |
1661 | } |
1662 | Handle(TDocStd_Document) Doc; |
1663 | DDocStd::GetDocument(argv[1], Doc); |
1664 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1665 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1666 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
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 | XCAFDimTolObjects_DimensionModifiersSequence aS = aDimension->GetObject()->GetModifiers(); |
1679 | for(Standard_Integer i = 1; i <= aS.Length(); i++) |
1680 | { |
1681 | if (i > 1) di<<", "; |
1682 | switch(aS.Value(i)){ |
1683 | case 0 : di<<"ControlledRadius"; break; |
1684 | case 1 : di<<"Square"; break; |
1685 | case 2 : di<<"StatisticalTolerance"; break; |
1686 | case 3 : di<<"ContinuousFeature"; break; |
1687 | case 4 : di<<"TwoPointSize"; break; |
1688 | case 5 : di<<"LocalSizeDefinedBySphere"; break; |
1689 | case 6 : di<<"LeastSquaresAssociationCriterion"; break; |
1690 | case 7 : di<<"MaximumInscribedAssociation"; break; |
1691 | case 8 : di<<"MinimumCircumscribedAssociation"; break; |
1692 | case 9 : di<<"CircumferenceDiameter"; break; |
1693 | case 10 : di<<"AreaDiameter"; break; |
1694 | case 11 : di<<"VolumeDiameter"; break; |
1695 | case 12 : di<<"MaximumSize"; break; |
1696 | case 13 : di<<"MinimumSize"; break; |
1697 | case 14 : di<<"AverageSize"; break; |
1698 | case 15 : di<<"MedianSize"; break; |
1699 | case 16 : di<<"MidRangeSize"; break; |
1700 | case 17 : di<<"RangeOfSizes"; break; |
1701 | case 18 : di<<"AnyRestrictedPortionOfFeature"; break; |
1702 | case 19 : di<<"AnyCrossSection"; break; |
1703 | case 20 : di<<"SpecificFixedCrossSection"; break; |
1704 | case 21 : di<<"CommonTolerance"; break; |
1705 | case 22 : di<<"FreeStateCondition"; break; |
1706 | case 23 : di<<"Between"; break; |
1707 | default : break; |
1708 | } |
1709 | } |
1710 | } |
1711 | return 0; |
1712 | } |
1713 | |
1714 | static Standard_Integer addDimPath (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1715 | { |
1716 | if (argc < 4) { |
1717 | di<<"Use: "<<"XSetDimensionPath Doc Dim_Label path(edge)\n"; |
1718 | return 1; |
1719 | } |
1720 | Handle(TDocStd_Document) Doc; |
1721 | DDocStd::GetDocument(argv[1], Doc); |
1722 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1723 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1724 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1725 | |
1726 | TDF_Label aLabel; |
1727 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1728 | if ( aLabel.IsNull() ) |
1729 | { |
1730 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1731 | return 1; |
1732 | } |
1733 | Handle(XCAFDoc_Dimension) aDimension; |
1734 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1735 | { |
1736 | TopoDS_Edge aE = TopoDS::Edge(DBRep::Get(argv[3],TopAbs_EDGE)); |
1737 | if(!aE.IsNull()) |
1738 | { |
1739 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1740 | anObj->SetPath(aE); |
1741 | aDimension->SetObject(anObj); |
1742 | } |
1743 | } |
1744 | return 0; |
1745 | } |
1746 | |
1747 | static Standard_Integer addDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1748 | { |
1749 | if (argc < 5) { |
1750 | di<<"Use: "<<"XSetDimensionPoints Doc Dim_Label v1 v2\n"; |
1751 | return 1; |
1752 | } |
1753 | Handle(TDocStd_Document) Doc; |
1754 | DDocStd::GetDocument(argv[1], Doc); |
1755 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1756 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1757 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1758 | |
1759 | TDF_Label aLabel; |
1760 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1761 | if ( aLabel.IsNull() ) |
1762 | { |
1763 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1764 | return 1; |
1765 | } |
1766 | Handle(XCAFDoc_Dimension) aDimension; |
1767 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1768 | { |
1769 | TopoDS_Vertex aV1 = TopoDS::Vertex(DBRep::Get(argv[3],TopAbs_VERTEX)); |
1770 | TopoDS_Vertex aV2 = TopoDS::Vertex(DBRep::Get(argv[4],TopAbs_VERTEX)); |
1771 | if(!aV1.IsNull() && !aV1.IsNull()) |
1772 | { |
1773 | Handle(TColgp_HArray1OfPnt) arr = new TColgp_HArray1OfPnt(1,2); |
1774 | arr->SetValue(1, BRep_Tool::Pnt(aV1)); |
1775 | arr->SetValue(2, BRep_Tool::Pnt(aV2)); |
1776 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1777 | anObj->SetPoints(arr); |
1778 | aDimension->SetObject(anObj); |
1779 | } |
1780 | } |
1781 | return 0; |
1782 | } |
1783 | |
1784 | static Standard_Integer getDimPoints (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1785 | { |
1786 | if (argc < 3) { |
1787 | di<<"Use: "<<"XGetDimensionPoints Doc Dim_Label\n"; |
1788 | return 1; |
1789 | } |
1790 | Handle(TDocStd_Document) Doc; |
1791 | DDocStd::GetDocument(argv[1], Doc); |
1792 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1793 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1794 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1795 | |
1796 | TDF_Label aLabel; |
1797 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1798 | if ( aLabel.IsNull() ) |
1799 | { |
1800 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1801 | return 1; |
1802 | } |
1803 | Handle(XCAFDoc_Dimension) aDimension; |
1804 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1805 | { |
1806 | Handle(TColgp_HArray1OfPnt) pnts = aDimension->GetObject()->GetPoints(); |
1807 | if(!pnts.IsNull() && pnts->Length() == 2) |
1808 | { |
1809 | di << pnts->Value(1).X() << ";" << pnts->Value(1).Y() << ";" << pnts->Value(1).Z() << " "; |
1810 | di << pnts->Value(2).X() << ";" << pnts->Value(2).Y() << ";" << pnts->Value(2).Z(); |
1811 | } |
1812 | } |
1813 | return 0; |
1814 | } |
1815 | |
1816 | static Standard_Integer addDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1817 | { |
1818 | if (argc < 6) { |
1819 | di<<"Use: "<<"XSetDimensionDir Doc Dim_Label x y z\n"; |
1820 | return 1; |
1821 | } |
1822 | Handle(TDocStd_Document) Doc; |
1823 | DDocStd::GetDocument(argv[1], Doc); |
1824 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1825 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1826 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1827 | |
1828 | TDF_Label aLabel; |
1829 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1830 | if ( aLabel.IsNull() ) |
1831 | { |
1832 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1833 | return 1; |
1834 | } |
1835 | Handle(XCAFDoc_Dimension) aDimension; |
1836 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1837 | { |
1838 | Handle(XCAFDimTolObjects_DimensionObject) anObj = aDimension->GetObject(); |
1839 | anObj->SetDirection(gp_Dir(Draw::Atof(argv[3]),Draw::Atof(argv[4]),Draw::Atof(argv[5]))); |
1840 | aDimension->SetObject(anObj); |
1841 | } |
1842 | return 0; |
1843 | } |
1844 | |
1845 | static Standard_Integer getDimDir (Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
1846 | { |
1847 | if (argc < 3) { |
1848 | di<<"Use: "<<"XSetDimensionDir Doc Dim_Label\n"; |
1849 | return 1; |
1850 | } |
1851 | Handle(TDocStd_Document) Doc; |
1852 | DDocStd::GetDocument(argv[1], Doc); |
1853 | if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; } |
1854 | Handle(XCAFDoc_DimTolTool) aDimTolTool = XCAFDoc_DocumentTool::DimTolTool(Doc->Main()); |
1855 | Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); |
1856 | |
1857 | TDF_Label aLabel; |
1858 | TDF_Tool::Label(Doc->GetData(), argv[2], aLabel); |
1859 | if ( aLabel.IsNull() ) |
1860 | { |
1861 | di<<"Dimension "<<argv[2]<<" is absent in "<<argv[1]<<"\n"; |
1862 | return 1; |
1863 | } |
1864 | Handle(XCAFDoc_Dimension) aDimension; |
1865 | if(aLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimension)) |
1866 | { |
1867 | gp_Dir dir; |
1868 | if(aDimension->GetObject()->GetDirection(dir)) |
1869 | { |
1870 | di << dir.X()<< ";"<< dir.Y()<< ";"<<dir.Z(); |
1871 | } |
1872 | } |
1873 | return 0; |
1874 | } |
1875 | |
1876 | //======================================================================= |
1877 | //function : InitCommands |
1878 | //purpose : |
1879 | //======================================================================= |
1880 | |
1881 | void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di) |
1882 | { |
1883 | |
1884 | static Standard_Boolean initactor = Standard_False; |
1885 | if (initactor) return; initactor = Standard_True; |
1886 | |
1887 | |
1888 | Standard_CString g = "XDE G&DTs commands"; |
1889 | |
1890 | di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ", |
1891 | __FILE__, DumpDGTs, g); |
1892 | |
1893 | di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]", |
1894 | __FILE__, addDim, g); |
1895 | |
1896 | di.Add ("XAddGeomTolerance","XAddGeomTolerance Doc shape/label", |
1897 | __FILE__, addGTol, g); |
1898 | |
1899 | di.Add ("XAddDatum","XAddDatum Doc shape/label", |
1900 | __FILE__, addDatum, g); |
1901 | |
1902 | di.Add ("XSetDatum","XSetDatum Doc Datum_Label GeomTol_Label", |
1903 | __FILE__, setDatum, g); |
1904 | |
1905 | di.Add ("XGetDatum","XGetDatum Doc GeomTol_Label/Shape_Label", |
1906 | __FILE__, getDatum, g); |
1907 | |
1908 | di.Add ("XAddDatumModifier","XAddDatumModifier Doc Datum_Label mod1 mod2 ...\n" |
1909 | "Values:" |
1910 | "\n 0 AnyCrossSection" |
1911 | "\n 1 Any_LongitudinalSection" |
1912 | "\n 2 Basic" |
1913 | "\n 3 ContactingFeature" |
1914 | "\n 4 DegreeOfFreedomConstraintU" |
1915 | "\n 5 DegreeOfFreedomConstraintV" |
1916 | "\n 6 DegreeOfFreedomConstraintW" |
1917 | "\n 7 DegreeOfFreedomConstraintX" |
1918 | "\n 8 DegreeOfFreedomConstraintY" |
1919 | "\n 9 DegreeOfFreedomConstraintZ" |
1920 | "\n 10 DistanceVariable" |
1921 | "\n 11 FreeState" |
1922 | "\n 12 LeastMaterialRequirement" |
1923 | "\n 13 Line" |
1924 | "\n 14 MajorDiameter" |
1925 | "\n 15 MaximumMaterialRequirement" |
1926 | "\n 16 MinorDiameter" |
1927 | "\n 17 Orientation" |
1928 | "\n 18 PitchDiameter" |
1929 | "\n 19 Plane" |
1930 | "\n 20 Point" |
1931 | "\n 21 Translation", |
1932 | __FILE__, addDatumModif, g); |
1933 | |
1934 | di.Add ("XGetDatumModifiers","XGetDatumModifiers Doc Datum_Label", |
1935 | __FILE__, getDatumModif, g); |
1936 | |
1937 | di.Add ("XSetDatumName","XSetDatumName Doc Datum_Label name", |
1938 | __FILE__, setDatumName, g); |
1939 | |
1940 | di.Add ("XGetDatumName","XGetDatumName Doc Datum_Label", |
1941 | __FILE__, getDatumName, g); |
1942 | |
1943 | di.Add ("XSetTypeOfTolerance","XSetTypeOfTolerance Doc GTol_Label type" |
1944 | "Values:\n" |
1945 | "\t 0 type is absent\n" |
1946 | "\t 1 Angularity\n" |
1947 | "\t 2 CircularRunout\n" |
1948 | "\t 3 CircularityOrRoundness\n" |
1949 | "\t 4 Coaxiality\n" |
1950 | "\t 5 Concentricity\n" |
1951 | "\t 6 Cylindricity\n" |
1952 | "\t 7 Flatness\n" |
1953 | "\t 8 Parallelism\n" |
1954 | "\t 9 Perpendicularity\n" |
1955 | "\t 10 Position\n" |
1956 | "\t 11 ProfileOfLine\n" |
1957 | "\t 12 ProfileOfSurface\n" |
1958 | "\t 13 Straightness\n" |
1959 | "\t 14 Symmetry\n" |
1960 | "\t 15 TotalRunout\n", |
1961 | __FILE__, setTypeOfTol, g); |
1962 | |
1963 | di.Add ("XGetTypeOfTolerance","XGetTypeOfTolerance Doc GTol_Label", |
1964 | __FILE__, getTypeOfTol, g); |
1965 | |
1966 | di.Add ("XSetTypeOfToleranceValue","XSetTypeOfToleranceValue Doc GTol_Label type" |
1967 | "Values:" |
1968 | "\n 0 none" |
1969 | "\n 1 Diameter" |
1970 | "\n 2 SphericalDiameter", |
1971 | __FILE__, setTypeOfTolVal, g); |
1972 | |
1973 | di.Add ("XGetTypeOfToleranceValue","XGetTypeOfToleranceValue Doc GTol_Label", |
1974 | __FILE__, getTypeOfTolVal, g); |
1975 | |
1976 | di.Add ("XSetToleranceValue","XSetToleranceValue Doc GTol_Label value", |
1977 | __FILE__, setTolVal, g); |
1978 | |
1979 | di.Add ("XGetToleranceValue","XGetToleranceValue Doc GTol_Label", |
1980 | __FILE__, getTolVal, g); |
1981 | |
1982 | di.Add ("XSetTolMaterialReq","XSetTolMaterialReq Doc GTol_Label mod" |
1983 | "Values:" |
1984 | "\n 0 none" |
1985 | "\n 1 M" |
1986 | "\n 2 L", |
1987 | __FILE__, setMatReq, g); |
1988 | |
1989 | di.Add ("XGetTolMaterialReq","XGetTolMaterialReq Doc GTol_Label", |
1990 | __FILE__, getMatReq, g); |
1991 | |
1992 | di.Add ("XSetTolZoneMod","XSetTolZoneMod Doc GTol_Label mod" |
1993 | "Values:" |
1994 | "\n 0 none" |
1995 | "\n 1 P" |
1996 | "\n 2 NonUniform", |
1997 | __FILE__, setZoneMod, g); |
1998 | |
1999 | di.Add ("XGetTolZoneMod","XGetTolZoneMod Doc GTol_Label", |
2000 | __FILE__, getZoneMod, g); |
2001 | |
2002 | di.Add ("XSetTolZoneModValue","XSetTolZoneModValue Doc GTol_Label val", |
2003 | __FILE__, setZoneModVal, g); |
2004 | |
2005 | di.Add ("XGetTolZoneModValue","XGetTolZoneModValue Doc GTol_Label", |
2006 | __FILE__, getZoneModVal, g); |
2007 | |
2008 | di.Add ("XAddTolModifier","XAddTolModifier Doc Tol_Label mod1 mod2 ..." |
2009 | "Values:\n" |
2010 | "\t 0 Any_Cross_Section\n" |
2011 | "\t 1 Common_Zone\n" |
2012 | "\t 2 Each_Radial_Element\n" |
2013 | "\t 3 Free_State\n" |
2014 | "\t 4 Least_Material_Requirement\n" |
2015 | "\t 5 Line_Element\n" |
2016 | "\t 6 Major_Diameter\n" |
2017 | "\t 7 Maximum_Material_Requirement\n" |
2018 | "\t 8 Minor_Diameter\n" |
2019 | "\t 9 Not_Convex\n" |
2020 | "\t 10 Pitch_Diameter\n" |
2021 | "\t 11 Reciprocity_Requirement\n" |
2022 | "\t 12 Separate_Requirement\n" |
2023 | "\t 13 Statistical_Tolerance\n" |
2024 | "\t 14 Tangent_Plane\n", |
2025 | __FILE__, addTolModif, g); |
2026 | |
2027 | di.Add ("XGetTolModifier","XGetTolModifier Doc Tol_Label", |
2028 | __FILE__, getTolModif, g); |
2029 | |
2030 | di.Add ("XSetTolMaxValue","XSetTolMaxValue Doc Dim_Label val", |
2031 | __FILE__, setTolMaxVal, g); |
2032 | |
2033 | di.Add ("XGetTolMaxValue","XGetTolMaxValue Doc Dim_Label val", |
2034 | __FILE__, getTolMaxVal, g); |
2035 | |
2036 | di.Add ("XSetDimensionType","XSetDimensionType Doc Dim_Label type" |
2037 | "Values:" |
2038 | "\t 0 type is absent\n" |
2039 | "\t 1 Location_CurvedDistance\n" |
2040 | "\t 2 Location_LinearDistance\n" |
2041 | "\t 3 Location_LinearDistance_FromCenterToOuter\n" |
2042 | "\t 4 Location_LinearDistance_FromCenterToInner\n" |
2043 | "\t 5 Location_LinearDistance_FromOuterToCenter\n" |
2044 | "\t 6 Location_LinearDistance_FromOuterToOuter\n" |
2045 | "\t 7 Location_LinearDistance_FromOuterToInner\n" |
2046 | "\t 8 Location_LinearDistance_FromInnerToCenter\n" |
2047 | "\t 9 Location_LinearDistance_FromInnerToOuter\n" |
2048 | "\t 10 Location_LinearDistance_FromInnerToInner\n" |
2049 | "\t 11 Location_Angular\n" |
2050 | "\t 12 Location_Oriented\n" |
2051 | "\t 13 Location_WithPath\n" |
2052 | "\t 14 Size_CurveLength\n" |
2053 | "\t 15 Size_Diameter\n" |
2054 | "\t 16 Size_SphericalDiameter\n" |
2055 | "\t 17 Size_Radius\n" |
2056 | "\t 18 Size_SphericalRadius\n" |
2057 | "\t 19 Size_ToroidalMinorDiameter\n" |
2058 | "\t 20 Size_ToroidalMajorDiameter\n" |
2059 | "\t 21 Size_ToroidalMinorRadius\n" |
2060 | "\t 22 Size_ToroidalMajorRadius\n" |
2061 | "\t 23 Size_ToroidalHighMajorDiameter\n" |
2062 | "\t 24 Size_ToroidalLowMajorDiameter\n" |
2063 | "\t 25 Size_ToroidalHighMajorRadius\n" |
2064 | "\t 26 Size_ToroidalLowMajorRadius\n" |
2065 | "\t 27 Size_Thickness\n" |
2066 | "\t 28 Size_Angular\n" |
2067 | "\t 29 Size_WithPath\n", |
2068 | __FILE__, setDimType, g); |
2069 | |
2070 | di.Add ("XGetDimensionType","XGetDimensionType Doc Dim_Label", |
2071 | __FILE__, getDimType, g); |
2072 | |
2073 | di.Add ("XSetDimensionValue","XSetDimensionValue Doc Dim_Label val", |
2074 | __FILE__, setDimVal, g); |
2075 | |
2076 | di.Add ("XGetDimensionValue","XGetDimensionValue Doc Dim_Label", |
2077 | __FILE__, getDimVal, g); |
2078 | |
2079 | di.Add ("XSetDimensionQualifier","XSetDimensionQualifier Doc Dim_Label val" |
2080 | "Values:" |
2081 | "\n 0 none" |
2082 | "\n 1 Min" |
2083 | "\n 2 Max" |
2084 | "\n 3 Avg", |
2085 | __FILE__, setDimQalif, g); |
2086 | |
2087 | di.Add ("XGetDimensionQualifier","XGetDimensionQualifier Doc Dim_Label", |
2088 | __FILE__, getDimQalif, g); |
2089 | |
2090 | di.Add ("XSetDimensionRange","XSetDimensionRange Doc Dim_Label low_val up_val", |
2091 | __FILE__, setDimRange, g); |
2092 | |
2093 | di.Add ("XGetDimensionRange","XGetDimensionRange Doc Dim_Label", |
2094 | __FILE__, getDimRange, g); |
2095 | |
2096 | di.Add ("XSetDimensionPlusMinusTol","XSetDimensionPlusMinusTol Doc Dim_Label low_val up_val", |
2097 | __FILE__, setDimPlusMinusTol, g); |
2098 | |
2099 | di.Add ("XGetDimensionPlusMinusTol","XGetDimensionPlusMinusTol Doc Dim_Label", |
2100 | __FILE__, getDimPlusMinusTol, g); |
2101 | |
2102 | di.Add ("XSetDimensionClassOfTol","XSetDimensionClassOfTol Doc Dim_Label ishole[1/0] formVar grade" |
2103 | "Values of formVar:" |
2104 | "\t 1 a\n" |
2105 | "\t 2 b\n" |
2106 | "\t 3 c\n" |
2107 | "\t 4 cd\n" |
2108 | "\t 5 d\n" |
2109 | "\t 6 e\n" |
2110 | "\t 7 ef\n" |
2111 | "\t 8 f\n" |
2112 | "\t 9 fg\n" |
2113 | "\t10 g\n" |
2114 | "\t11 h\n" |
2115 | "\t12 js\n" |
2116 | "\t13 j\n" |
2117 | "\t14 k\n" |
2118 | "\t15 m\n" |
2119 | "\t16 n\n" |
2120 | "\t17 p\n" |
2121 | "\t18 r\n" |
2122 | "\t19 s\n" |
2123 | "\t20 t\n" |
2124 | "\t21 u\n" |
2125 | "\t22 v\n" |
2126 | "\t23 x\n" |
2127 | "\t24 y\n" |
2128 | "\t25 z\n" |
2129 | "\t26 za\n" |
2130 | "\t27 zb\n" |
2131 | "\t28 zc\n\n" |
2132 | "Values of grade:" |
2133 | "\t 0 01\n" |
2134 | "\t 1 0\n" |
2135 | "\t 2 1\n" |
2136 | "\t 3 2d\n" |
2137 | "\t 4 3\n" |
2138 | "\t 5 4\n" |
2139 | "\t 6 5f\n" |
2140 | "\t 7 76\n" |
2141 | "\t 8 7g\n" |
2142 | "\t 9 8\n" |
2143 | "\t10 9\n" |
2144 | "\t11 10js\n" |
2145 | "\t12 11j\n" |
2146 | "\t13 12k\n" |
2147 | "\t14 13m\n" |
2148 | "\t15 14n\n" |
2149 | "\t16 15p\n" |
2150 | "\t17 16r\n" |
2151 | "\t18 17s\n" |
2152 | "\t19 18t\n", |
2153 | __FILE__, setDimClassTol, g); |
2154 | |
2155 | di.Add ("XGetDimensionClassOfTol","XGetDimensionClassOfTol Doc Dim_Label", |
2156 | __FILE__, getDimClassTol, g); |
2157 | |
2158 | di.Add ("XSetDimensionNbOfDecimalPlaces","XSetDimensionNbOfDecimalPlaces Doc Dim_Label l_val r_val", |
2159 | __FILE__, setDimNbOfDecimalPlaces, g); |
2160 | |
2161 | di.Add ("XGetDimensionNbOfDecimalPlaces","XGetDimensionNbOfDecimalPlaces Doc Dim_Label", |
2162 | __FILE__, getDimNbOfDecimalPlaces, g); |
2163 | |
2164 | di.Add ("XAddDimensionModifiers","XAddDimensionModifiers Doc Dim_Label mod1 mod2 ..." |
2165 | "Values:" |
2166 | "\t 0 ControlledRadius\n" |
2167 | "\t 1 Square\n" |
2168 | "\t 2 StatisticalTolerance\n" |
2169 | "\t 3 ContinuousFeature\n" |
2170 | "\t 4 TwoPointSize\n" |
2171 | "\t 5 LocalSizeDefinedBySphere\n" |
2172 | "\t 6 LeastSquaresAssociationCriterion\n" |
2173 | "\t 7 MaximumInscribedAssociation\n" |
2174 | "\t 8 MinimumCircumscribedAssociation\n" |
2175 | "\t 9 CircumferenceDiameter\n" |
2176 | "\t10 AreaDiameter\n" |
2177 | "\t11 VolumeDiameter\n" |
2178 | "\t12 MaximumSize\n" |
2179 | "\t13 MinimumSize\n" |
2180 | "\t14 AverageSize\n" |
2181 | "\t15 MedianSize\n" |
2182 | "\t16 MidRangeSize\n" |
2183 | "\t17 RangeOfSizes\n" |
2184 | "\t18 AnyRestrictedPortionOfFeature\n" |
2185 | "\t19 AnyCrossSection\n" |
2186 | "\t20 SpecificFixedCrossSection\n" |
2187 | "\t21 CommonTolerance\n" |
2188 | "\t22 FreeStateCondition\n" |
2189 | "\t23 Between\n", |
2190 | __FILE__, addDimModifier, g); |
2191 | |
2192 | di.Add ("XGetDimensionModifiers","XGetDimensionModifiers Doc Dim_Label", |
2193 | __FILE__, getDimModifier, g); |
2194 | |
2195 | di.Add ("XSetDimensionPath","XSetDimensionPath Doc Dim_Label path(edge)", |
2196 | __FILE__, addDimPath, g); |
2197 | |
2198 | di.Add ("XSetDimensionPoints","XSetDimensionPoints Doc Dim_Label v1 v2", |
2199 | __FILE__, addDimPoints, g); |
2200 | |
2201 | di.Add ("XGetDimensionPoints","XGetDimensionPoints Doc Dim_Label", |
2202 | __FILE__, getDimPoints, g); |
2203 | |
2204 | di.Add ("XSetDimensionDir","XSetDimensionDir Doc Dim_Label x y z", |
2205 | __FILE__, addDimDir, g); |
2206 | |
2207 | di.Add ("XGetDimensionDir","XGetDimensionDir Doc Dim_Label", |
2208 | __FILE__, getDimDir, g); |
2209 | } |