0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IGESSelect / IGESSelect_RebuildGroups.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <IGESSelect_RebuildGroups.ixx>
19#include <IGESData_IGESEntity.hxx>
20#include <IGESData_HArray1OfIGESEntity.hxx>
21#include <IGESBasic_Group.hxx>
22#include <IGESBasic_GroupWithoutBackP.hxx>
23#include <IGESBasic_OrderedGroup.hxx>
24#include <IGESBasic_OrderedGroupWithoutBackP.hxx>
25#include <TColStd_Array1OfInteger.hxx>
26#include <Interface_EntityIterator.hxx>
27#include <Interface_Macros.hxx>
28
29
30
b311480e 31IGESSelect_RebuildGroups::IGESSelect_RebuildGroups ()
7fd59977 32 : IGESSelect_ModelModifier (Standard_True) { }
33
34 void IGESSelect_RebuildGroups::Performing
35 (IFSelect_ContextModif& ctx,
36 const Handle(IGESData_IGESModel)& target,
37 Interface_CopyTool& TC) const
38{
39// On reconstruit les groupes qui peuvent l etre
40// Pour chaque groupe de l original, on regarde les composants transferes
41// (evt filtres par <ctx>)
42// Ensuite, silyena plus d une, on refait un nouveau groupe
43 DeclareAndCast(IGESData_IGESModel,original,ctx.OriginalModel());
44 Standard_Integer nbo = original->NbEntities();
45
46// Entites a prendre en compte pour la reconstruction
47// NB : Les groupes deja transferes ne sont bien sur pas reconstruits !
48 TColStd_Array1OfInteger pris(0,nbo); pris.Init(0);
49 for (ctx.Start(); ctx.More(); ctx.Next()) {
50 pris.SetValue (original->Number(ctx.ValueOriginal()),1);
51 }
52
53 for (Standard_Integer i = 1; i <= nbo; i ++) {
54 Handle(IGESData_IGESEntity) ent = original->Entity(i);
55 if (ent->TypeNumber() != 402) continue;
56 Standard_Integer casenum = 0;
57 Handle(Standard_Transient) newent;
58 Interface_EntityIterator newlist;
59 if (TC.Search(ent,newent)) continue; // deja passe
60 if (ent->IsKind(STANDARD_TYPE(IGESBasic_Group))) {
61 DeclareAndCast(IGESBasic_Group,g,ent);
62 casenum = 1;
63 Standard_Integer nbg = g->NbEntities();
64 for (Standard_Integer ig = 1; ig <= nbg; ig ++) {
65 if (TC.Search(g->Value(i),newent)) newlist.GetOneItem(newent);
66 }
67 }
68 if (ent->IsKind(STANDARD_TYPE(IGESBasic_GroupWithoutBackP))) {
69 DeclareAndCast(IGESBasic_GroupWithoutBackP,g,ent);
70 casenum = 2;
71 Standard_Integer nbg = g->NbEntities();
72 for (Standard_Integer ig = 1; ig <= nbg; ig ++) {
73 if (TC.Search(g->Value(i),newent)) newlist.GetOneItem(newent);
74 }
75 }
76 if (ent->IsKind(STANDARD_TYPE(IGESBasic_OrderedGroup))) {
77 DeclareAndCast(IGESBasic_OrderedGroup,g,ent);
78 casenum = 3;
79 Standard_Integer nbg = g->NbEntities();
80 for (Standard_Integer ig = 1; ig <= nbg; ig ++) {
81 if (TC.Search(g->Value(i),newent)) newlist.GetOneItem(newent);
82 }
83 }
84 if (ent->IsKind(STANDARD_TYPE(IGESBasic_OrderedGroupWithoutBackP))) {
85 DeclareAndCast(IGESBasic_OrderedGroupWithoutBackP,g,ent);
86 casenum = 4;
87 Standard_Integer nbg = g->NbEntities();
88 for (Standard_Integer ig = 1; ig <= nbg; ig ++) {
89 if (TC.Search(g->Value(i),newent)) newlist.GetOneItem(newent);
90 }
91 }
92// A present, reconstruire sil le faut
93 if (newlist.NbEntities() <= 1) continue; // 0 ou 1 : rien a refaire
94 Handle(IGESData_HArray1OfIGESEntity) tab =
95 new IGESData_HArray1OfIGESEntity(1,newlist.NbEntities());
96 Standard_Integer ng = 0;
97 for (newlist.Start(); newlist.More(); newlist.Next()) {
98 ng ++; tab->SetValue(ng,GetCasted(IGESData_IGESEntity,newlist.Value()));
99 }
100 switch (casenum) {
101 case 1 : {
102 Handle(IGESBasic_Group) g = new IGESBasic_Group;
103 g->Init(tab);
104 target->AddEntity(g);
105
106// Q : faut-il transferer le nom silyena un ?
107 }
108 break;
109 case 2 : {
110 Handle(IGESBasic_GroupWithoutBackP) g = new IGESBasic_GroupWithoutBackP;
111 g->Init(tab);
112 target->AddEntity(g);
113 }
114 break;
115 case 3 : {
116 Handle(IGESBasic_OrderedGroup) g = new IGESBasic_OrderedGroup;
117 g->Init(tab);
118 target->AddEntity(g);
119 }
120 break;
121 case 4 : {
122 Handle(IGESBasic_OrderedGroupWithoutBackP) g =
123 new IGESBasic_OrderedGroupWithoutBackP;
124 g->Init(tab);
125 target->AddEntity(g);
126 }
127 break;
128 default : break;
129 }
130 }
131}
132
133 TCollection_AsciiString IGESSelect_RebuildGroups::Label () const
134{ return TCollection_AsciiString("Rebuild Groups"); }