Integration of OCCT 6.5.0 from SVN
[occt.git] / src / QADNaming / QADNaming_BuilderCommands.cxx
CommitLineData
7fd59977 1// File: QADNaming_BuilderCommands.cxx
2// Created: Thu Apr 25 08:57:09 2002
3// Author: Michael PONIKAROV
4// <mpv@covox>
5
6
7#include <QADNaming.hxx>
8#include <TDF_Label.hxx>
9#include <Draw_Interpretor.hxx>
10#include <TNaming_Builder.hxx>
11#include <TopoDS_Shape.hxx>
12#include <DBRep.hxx>
13
14static Standard_Integer BuildNamedShape (Draw_Interpretor& di,
15 Standard_Integer nb,
16 const char** arg) {
17 if (nb > 4) {
18 TDF_Label aLabel;
19 if (!QADNaming::Entry(arg, aLabel)) return 1;
20 char anEvolution = arg[3][0];
21 Standard_Integer a,anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2;
22// if (anEvolution == 'G')
23// for(a=1;arg[3][a]!=0 && arg[3][a]!='\n';a++) if (arg[3][a]=='2') anEvolution = '2';
24 TNaming_Builder aBuilder(aLabel);
25 TopoDS_Shape aShape1,aShape2;
26
27 for(a = 4;a < nb;a += anInc) {
28 aShape1 = DBRep::Get (arg[a]);
29 if (anInc == 2) {
30 if (a == nb - 1) {
31 di<<"For this type of evolution number of shapes must be even"<<"\n";
32 return 1;
33 }
34 aShape2 = DBRep::Get(arg[a+1]);
35 }
36
37 switch (anEvolution) {
38 case 'P':
39 aBuilder.Generated(aShape1);
40 break;
41 case 'G':
42 aBuilder.Generated(aShape1,aShape2);
43 break;
44 case 'M':
45 aBuilder.Modify(aShape1,aShape2);
46 break;
47 case 'D':
48 aBuilder.Delete(aShape1);
49 break;
50 case 'R':
51 aBuilder.Replace(aShape1,aShape2);
52 break;
53 case 'S':
54 aBuilder.Select(aShape1,aShape2);
55 break;
56 default:
57 di<<"Unknown evolution type"<<"\n";
58 return 1;
59 }
60 }
61
62// if (nb >= 4) {
63// OnlyModif = atoi(arg[3]);
64// }
65 } else {
66 di<<"Usage: BuildName df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]"<<"\n";
67 return 1;
68 }
69 return 0;
70}
71
72
73void QADNaming::BuilderCommands(Draw_Interpretor& theCommands)
74{
75 static Standard_Boolean done = Standard_False;
76 if (done) return;
77 done = Standard_True;
78
79 const char* g = "Naming builder commands";
80
81 theCommands.Add("BuildNamedShape",
82 "BuildNamedShape df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]",
83 __FILE__,BuildNamedShape,g);
84}