b311480e |
1 | // Created on: 2002-04-25 |
2 | // Created by: Michael PONIKAROV |
3 | // Copyright (c) 2002-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | |
22 | #include <QADNaming.hxx> |
23 | #include <TDF_Label.hxx> |
24 | #include <Draw_Interpretor.hxx> |
25 | #include <TNaming_Builder.hxx> |
26 | #include <TopoDS_Shape.hxx> |
27 | #include <DBRep.hxx> |
28 | |
29 | static Standard_Integer BuildNamedShape (Draw_Interpretor& di, |
30 | Standard_Integer nb, |
31 | const char** arg) { |
32 | if (nb > 4) { |
33 | TDF_Label aLabel; |
34 | if (!QADNaming::Entry(arg, aLabel)) return 1; |
35 | char anEvolution = arg[3][0]; |
36 | Standard_Integer a,anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2; |
37 | // if (anEvolution == 'G') |
38 | // for(a=1;arg[3][a]!=0 && arg[3][a]!='\n';a++) if (arg[3][a]=='2') anEvolution = '2'; |
39 | TNaming_Builder aBuilder(aLabel); |
40 | TopoDS_Shape aShape1,aShape2; |
41 | |
42 | for(a = 4;a < nb;a += anInc) { |
43 | aShape1 = DBRep::Get (arg[a]); |
44 | if (anInc == 2) { |
45 | if (a == nb - 1) { |
46 | di<<"For this type of evolution number of shapes must be even"<<"\n"; |
47 | return 1; |
48 | } |
49 | aShape2 = DBRep::Get(arg[a+1]); |
50 | } |
51 | |
52 | switch (anEvolution) { |
53 | case 'P': |
54 | aBuilder.Generated(aShape1); |
55 | break; |
56 | case 'G': |
57 | aBuilder.Generated(aShape1,aShape2); |
58 | break; |
59 | case 'M': |
60 | aBuilder.Modify(aShape1,aShape2); |
61 | break; |
62 | case 'D': |
63 | aBuilder.Delete(aShape1); |
64 | break; |
65 | case 'R': |
66 | aBuilder.Replace(aShape1,aShape2); |
67 | break; |
68 | case 'S': |
69 | aBuilder.Select(aShape1,aShape2); |
70 | break; |
71 | default: |
72 | di<<"Unknown evolution type"<<"\n"; |
73 | return 1; |
74 | } |
75 | } |
76 | |
77 | // if (nb >= 4) { |
78 | // OnlyModif = atoi(arg[3]); |
79 | // } |
80 | } else { |
81 | di<<"Usage: BuildName df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]"<<"\n"; |
82 | return 1; |
83 | } |
84 | return 0; |
85 | } |
86 | |
87 | |
88 | void QADNaming::BuilderCommands(Draw_Interpretor& theCommands) |
89 | { |
90 | static Standard_Boolean done = Standard_False; |
91 | if (done) return; |
92 | done = Standard_True; |
93 | |
94 | const char* g = "Naming builder commands"; |
95 | |
96 | theCommands.Add("BuildNamedShape", |
97 | "BuildNamedShape df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]", |
98 | __FILE__,BuildNamedShape,g); |
99 | } |