0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IGESSelect / IGESSelect_RebuildDrawings.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_RebuildDrawings.ixx>
19#include <IGESSelect_ViewSorter.hxx>
20#include <IFSelect_PacketList.hxx>
21#include <IGESData_IGESEntity.hxx>
22#include <IGESData_HArray1OfIGESEntity.hxx>
23#include <IGESDraw_Drawing.hxx>
24#include <IGESDraw_DrawingWithRotation.hxx>
25#include <IGESDraw_HArray1OfViewKindEntity.hxx>
26#include <IGESData_ViewKindEntity.hxx>
27#include <TColgp_HArray1OfXY.hxx>
28#include <TColStd_HArray1OfReal.hxx>
29#include <gp_XY.hxx>
30#include <gp_Pnt2d.hxx>
31
32#include <Interface_EntityIterator.hxx>
33#include <Interface_Graph.hxx>
34
35#include <TColStd_Array1OfInteger.hxx>
36#include <Interface_Macros.hxx>
37
38#define PourDrawing 404
39
40
b311480e 41IGESSelect_RebuildDrawings::IGESSelect_RebuildDrawings ()
7fd59977 42 : IGESSelect_ModelModifier (Standard_True) { }
43
44
45 void IGESSelect_RebuildDrawings::Performing
46 (IFSelect_ContextModif& ctx,
47 const Handle(IGESData_IGESModel)& target,
48 Interface_CopyTool& TC) const
49{
50// On reconstruit les drawings qui peuvent l etre
51// Pour chaque drawing de l original, on regarde les composants transferes
52// (evt filtres par <ctx>). Pour cela, on s aide d un ViewSorter
53// Pour chaque drawing dont au moins un element a ete transfere :
54// - On passe le Drawing lui-meme, avec ses views, mais pas ses annotations
55// (c-a-d on le reconstruit)
56// - On reconnecte les views aux entites (cf Directory Part)
57
58 DeclareAndCast(IGESData_IGESModel,original,ctx.OriginalModel());
59 Standard_Integer nbo = original->NbEntities();
60 TColStd_Array1OfInteger pris(0,nbo); pris.Init(0);
61
62// Entites a prendre en compte pour la reconstruction
63// NB : Les drawings deja transferes ne sont bien sur pas reconstruits !
64 Handle(IGESSelect_ViewSorter) sorter = new IGESSelect_ViewSorter;
65 sorter->SetModel(original);
66 sorter->Add(original);
67 for (ctx.Start(); ctx.More(); ctx.Next()) {
68 pris.SetValue (original->Number(ctx.ValueOriginal()),1);
69 }
70 sorter->SortDrawings(ctx.OriginalGraph());
71 Handle(IFSelect_PacketList) sets = sorter->Sets(Standard_True);
72// Regarder, pour chaque paquet, si au moins un element a ete copie
73 Standard_Integer nbs = sets->NbPackets();
74 for (Standard_Integer is = 1; is <= nbs; is ++) {
75 Interface_EntityIterator setl = sets->Entities(is);
76 Interface_EntityIterator newset;
77 for (setl.Start(); setl.More(); setl.Next()) {
78 Handle(Standard_Transient) newent;
79 if (TC.Search(setl.Value(),newent)) newset.AddItem(newent);
80 }
81 if (newset.NbEntities() == 0) continue;
82// On en tient un : le transferer (le reconstruire)
83 Handle(IGESData_IGESEntity) item = sorter->SetItem(is,Standard_True);
84 if (item->TypeNumber() != PourDrawing) continue;
85 if (item->IsKind(STANDARD_TYPE(IGESDraw_Drawing))) {
86 DeclareAndCast(IGESDraw_Drawing,draw,item);
87 Standard_Integer nbv = draw->NbViews();
88 Handle(IGESDraw_HArray1OfViewKindEntity) views;
89 if (nbv > 0) views = new IGESDraw_HArray1OfViewKindEntity (1,nbv);
90// Passer ses vues : toutes
91// Aussi les positions des vues
92 Handle(TColgp_HArray1OfXY) origs;
93 if (nbv > 0) origs = new TColgp_HArray1OfXY (1,nbv);
94 for (Standard_Integer iv = 1; iv <= nbv; iv ++) {
95 DeclareAndCast(IGESData_ViewKindEntity,aview,
96 TC.Transferred(draw->ViewItem(iv)));
97 views->SetValue(iv,aview);
98 target->AddEntity(aview);
99 origs->SetValue(iv,draw->ViewOrigin(iv).XY());
100 }
101// Frame : passer ce qui a ete transfere
102 Handle(IGESData_HArray1OfIGESEntity) frame;
103 Standard_Integer nba = draw->NbAnnotations();
104 Interface_EntityIterator framelist;
105 Standard_Integer ia; // svv Jan11 2000 : porting on DEC
106 for (ia = 1; ia <= nba; ia ++) {
107 Handle(Standard_Transient) annot;
108 if (TC.Search(draw->Annotation(ia),annot)) framelist.GetOneItem(annot);
109 }
110 nba = framelist.NbEntities(); ia = 0;
111 if (nba > 0) frame = new IGESData_HArray1OfIGESEntity (1,nba);
112 for (framelist.Start(); framelist.More(); framelist.Next()) {
113 ia ++; frame->SetValue(ia,GetCasted(IGESData_IGESEntity,framelist.Value()));
114 }
115// Cayest, fabriquer le nouveau Drawing et l ajouter
116 Handle(IGESDraw_Drawing) newdraw = new IGESDraw_Drawing;
117 newdraw->Init (views,origs,frame);
118// Reste le nom, + autres ? drawing unit, ...
119
120// Drawing With Rotation : quasiment identique
121 } else if (item->IsKind(STANDARD_TYPE(IGESDraw_DrawingWithRotation))) {
122 DeclareAndCast(IGESDraw_DrawingWithRotation,draw,item);
123 Standard_Integer nbv = draw->NbViews();
124 Handle(IGESDraw_HArray1OfViewKindEntity) views;
125 if (nbv > 0) views = new IGESDraw_HArray1OfViewKindEntity (1,nbv);
126// Passer ses vues : toutes
127// Aussi les positions des vues .. et les rotations
128 Handle(TColgp_HArray1OfXY) origs;
129 if (nbv > 0) origs = new TColgp_HArray1OfXY (1,nbv);
130 Handle(TColStd_HArray1OfReal) rots;
131 if (nbv > 0) { rots = new TColStd_HArray1OfReal (1,nbv); rots->Init(0.0); }
132
133 for (Standard_Integer iv = 1; iv <= nbv; iv ++) {
134 DeclareAndCast(IGESData_ViewKindEntity,aview,
135 TC.Transferred(draw->ViewItem(iv)));
136 views->SetValue(iv,aview);
137 target->AddEntity(aview);
138 rots->SetValue(iv,draw->OrientationAngle(iv));
139 origs->SetValue(iv,draw->ViewOrigin(iv).XY());
140 }
141// Frame : passer ce qui a ete transfere
142 Handle(IGESData_HArray1OfIGESEntity) frame;
143 Standard_Integer nba = draw->NbAnnotations();
144 Interface_EntityIterator framelist;
145 Standard_Integer ia; // svv Jan11 2000 : porting on DEC
146 for (ia = 1; ia <= nba; ia ++) {
147 Handle(Standard_Transient) annot;
148 if (TC.Search(draw->Annotation(ia),annot)) framelist.GetOneItem(annot);
149 }
150 nba = framelist.NbEntities(); ia = 0;
151 if (nba > 0) frame = new IGESData_HArray1OfIGESEntity (1,nba);
152 for (framelist.Start(); framelist.More(); framelist.Next()) {
153 ia ++; frame->SetValue(ia,GetCasted(IGESData_IGESEntity,framelist.Value()));
154 }
155// Cayest, fabriquer le nouveau DrawingWithRotation et l ajouter
156 Handle(IGESDraw_DrawingWithRotation) newdraw = new IGESDraw_DrawingWithRotation;
157 newdraw->Init (views,origs,rots,frame);
158// Reste le nom, + autres ? drawing unit, ...
159 }
160
161// Il faut encore mettre a jour les Views notees en Directory Part
162// Pour cela, considerer <setl>, pour chaque terme, regarder View()
163// si View() transfere, mettre a jour ...
164 for (setl.Start(); setl.More(); setl.Next()) {
165 DeclareAndCast(IGESData_IGESEntity,ent,setl.Value());
166 Handle(IGESData_ViewKindEntity) vieworig, viewnew;
167 vieworig = ent->View();
168 if (vieworig.IsNull()) continue;
169 if (!TC.Search(vieworig,viewnew)) continue;
170 ent->InitView(viewnew);
171 }
172 }
173
174}
175
176 TCollection_AsciiString IGESSelect_RebuildDrawings::Label () const
177{ return TCollection_AsciiString("Rebuild Drawings (with empty views)"); }