b311480e |
1 | // Created on: 2002-04-25 |
2 | // Created by: Michael PONIKAROV |
973c2be1 |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #include <QADNaming.hxx> |
17 | #include <TDF_Label.hxx> |
18 | #include <Draw_Interpretor.hxx> |
19 | #include <TNaming_Builder.hxx> |
20 | #include <TopoDS_Shape.hxx> |
21 | #include <DBRep.hxx> |
22 | |
23 | static Standard_Integer BuildNamedShape (Draw_Interpretor& di, |
24 | Standard_Integer nb, |
25 | const char** arg) { |
6d1e872b |
26 | if (nb >= 4) { |
7fd59977 |
27 | TDF_Label aLabel; |
28 | if (!QADNaming::Entry(arg, aLabel)) return 1; |
29 | char anEvolution = arg[3][0]; |
30 | Standard_Integer a,anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2; |
31 | // if (anEvolution == 'G') |
32 | // for(a=1;arg[3][a]!=0 && arg[3][a]!='\n';a++) if (arg[3][a]=='2') anEvolution = '2'; |
33 | TNaming_Builder aBuilder(aLabel); |
34 | TopoDS_Shape aShape1,aShape2; |
35 | |
36 | for(a = 4;a < nb;a += anInc) { |
37 | aShape1 = DBRep::Get (arg[a]); |
38 | if (anInc == 2) { |
39 | if (a == nb - 1) { |
586db386 |
40 | di<<"For this type of evolution number of shapes must be even\n"; |
7fd59977 |
41 | return 1; |
42 | } |
43 | aShape2 = DBRep::Get(arg[a+1]); |
44 | } |
45 | |
46 | switch (anEvolution) { |
47 | case 'P': |
48 | aBuilder.Generated(aShape1); |
49 | break; |
50 | case 'G': |
51 | aBuilder.Generated(aShape1,aShape2); |
52 | break; |
53 | case 'M': |
54 | aBuilder.Modify(aShape1,aShape2); |
55 | break; |
56 | case 'D': |
57 | aBuilder.Delete(aShape1); |
58 | break; |
59 | case 'R': |
1ec8a59e |
60 | // aBuilder.Replace(aShape1,aShape2); |
61 | aBuilder.Modify(aShape1,aShape2); |
7fd59977 |
62 | break; |
63 | case 'S': |
64 | aBuilder.Select(aShape1,aShape2); |
65 | break; |
66 | default: |
586db386 |
67 | di<<"Unknown evolution type\n"; |
7fd59977 |
68 | return 1; |
69 | } |
70 | } |
71 | |
72 | // if (nb >= 4) { |
91322f44 |
73 | // OnlyModif = Draw::Atoi(arg[3]); |
7fd59977 |
74 | // } |
75 | } else { |
6d1e872b |
76 | di<<"Usage: BuildName df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) [shape1 shape2 ...]\n"; |
7fd59977 |
77 | return 1; |
78 | } |
79 | return 0; |
80 | } |
81 | |
82 | |
83 | void QADNaming::BuilderCommands(Draw_Interpretor& theCommands) |
84 | { |
85 | static Standard_Boolean done = Standard_False; |
86 | if (done) return; |
87 | done = Standard_True; |
88 | |
89 | const char* g = "Naming builder commands"; |
90 | |
91 | theCommands.Add("BuildNamedShape", |
6d1e872b |
92 | "BuildNamedShape df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) [shape1 shape2 ...]", |
7fd59977 |
93 | __FILE__,BuildNamedShape,g); |
94 | } |